Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GetTriggerCmd = &cobra.Command{ Use: "get <triggerName>", Short: "Display the properties of a trigger by name.", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { var subscriptionId, resourceGroupName, factoryName = GetArgs(cmd, args) var triggerName = args[0] clientFactory, err := GetClientFactory(subscriptionId) if err != nil { log.Fatalf("failed to create client: %v", err) } ctx := context.Background() res, err := clientFactory.NewTriggersClient().Get(ctx, resourceGroupName, factoryName, triggerName, &armdatafactory.TriggersClientGetOptions{IfNoneMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } fmt.Printf("client: received response from server: %v\n", res.Properties) }, }
getCmd represents the get command
View Source
var ListTriggerCmd = &cobra.Command{ Use: "list", Short: "List all triggers in a factory.", Run: func(cmd *cobra.Command, args []string) { var subscriptionId, resourceGroupName, factoryName = GetArgs(cmd, args) clientFactory, err := GetClientFactory(subscriptionId) if err != nil { log.Fatalf("failed to create client: %v", err) } pager := clientFactory.NewTriggersClient().NewListByFactoryPager(resourceGroupName, factoryName, nil) ctx := context.Background() for pager.More() { page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } for _, v := range page.Value { fmt.Println(*v.Name) } } }, }
getCmd represents the get command
View Source
var StartTriggerCmd = &cobra.Command{ Use: "start <triggerName>", Short: "Start a trigger in a data factory.", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { var subscriptionId, resourceGroupName, factoryName = GetArgs(cmd, args) var triggerName = args[0] clientFactory, err := GetClientFactory(subscriptionId) if err != nil { log.Fatalf("failed to create client: %v", err) } ctx := context.Background() log.Printf("starting trigger %q", triggerName) poller, err := clientFactory.NewTriggersClient().BeginStart(ctx, resourceGroupName, factoryName, triggerName, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } log.Printf("trigger %q started successfully", triggerName) }, }
getCmd represents the get command
View Source
var StopTriggerCmd = &cobra.Command{ Use: "stop <triggerName>", Short: "Stop a trigger in a data factory.", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { var subscriptionId, resourceGroupName, factoryName = GetArgs(cmd, args) var triggerName = args[0] clientFactory, err := GetClientFactory(subscriptionId) if err != nil { log.Fatalf("failed to create client: %v", err) } ctx := context.Background() log.Printf("stopping trigger %q", triggerName) poller, err := clientFactory.NewTriggersClient().BeginStop(ctx, resourceGroupName, factoryName, triggerName, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } _, err = poller.PollUntilDone(ctx, nil) if err != nil { log.Fatalf("failed to pull the result: %v", err) } log.Printf("trigger %q stopped successfully", triggerName) }, }
getCmd represents the get command
View Source
var TriggerCmd = &cobra.Command{ Use: "trigger [command]", Run: func(cmd *cobra.Command, args []string) { fmt.Println("trigger needs a subcommand. Available subcommands are:") for _, cmd := range cmd.Commands() { fmt.Printf(" %s\n", cmd.Use) } }, }
triggerCmd represents the trigger command
Functions ¶
func GetArgs ¶
Get the subscriptionId, resourceGroupName, and factoryName from the environment variables or command line flags. If the values are not set, the program will exit.
func GetClientFactory ¶
Create a new client factory with the default Azure credential If the credential cannot be obtained, the program will exit.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.