getdataset

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package getdataset offers a command to get the information of specific dataset.

Index

Constants

This section is empty.

Variables

View Source
var (
	Command = &cobra.Command{
		Use:   "getdataset <provider_url> <dataset_id>",
		Short: "Get dataset info from dataspace provider.",
		Long:  "Uses RUN-DSP instance to get dataset information of a dataspace provider",
		Args:  cobra.ExactArgs(2),
		PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
			_, err := url.Parse(args[0])
			if err != nil {
				return fmt.Errorf("argument needs to be a valid URL")
			}
			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			ctx, ok := viper.Get("initCTX").(context.Context)
			if !ok {
				return fmt.Errorf("couldn't fetch initial context")
			}

			provider := args[0]

			client, conn, err := shared.GetRUNDSPClient()
			if err != nil {
				return fmt.Errorf("couldn't initialise gRPC client: %w", err)
			}
			defer conn.Close()

			ui.Info(fmt.Sprintf("Fetching dataset %s from %s", args[1], provider))
			resp, err := client.GetProviderDataset(ctx, &dspv1alpha1.GetProviderDatasetRequest{
				ProviderUrl: provider,
				DatasetId:   args[1],
			})
			if err != nil {
				return fmt.Errorf("could not get dataset %s from %s: %w", args[1], provider, err)
			}
			ui.Info("Catalogue received")
			return shared.PrintDataset(resp.Dataset, printJSON)
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL