diff --git a/cli/cmd/cloud_account.go b/cli/cmd/cloud_account.go index 47927e41a..5952e9b1e 100644 --- a/cli/cmd/cloud_account.go +++ b/cli/cmd/cloud_account.go @@ -301,6 +301,7 @@ func promptCreateCloudAccount() error { "GCP Audit Log PubSub", "Azure Config", "Azure Activity Log", + "Azure Active Directory Activity Log", "OCI Config", }, } @@ -329,6 +330,8 @@ func promptCreateCloudAccount() error { return createAzureConfigIntegration() case "Azure Activity Log": return createAzureActivityLogIntegration() + case "Azure Active Directory Activity Log": + return createAzureAdAlIntegration() case "OCI Config": return createOciConfigIntegration() default: diff --git a/cli/cmd/integration_azure.go b/cli/cmd/integration_azure.go index 7aecebdfb..6fa67c40b 100644 --- a/cli/cmd/integration_azure.go +++ b/cli/cmd/integration_azure.go @@ -140,3 +140,72 @@ func createAzureActivityLogIntegration() error { cli.StopProgress() return err } + +func createAzureAdAlIntegration() error { + questions := []*survey.Question{ + { + Name: "name", + Prompt: &survey.Input{Message: "Name:"}, + Validate: survey.Required, + }, + { + Name: "client_id", + Prompt: &survey.Input{Message: "Client ID:"}, + Validate: survey.Required, + }, + { + Name: "client_secret", + Prompt: &survey.Input{Message: "Client Secret:"}, + Validate: survey.Required, + }, + { + Name: "tenant_id", + Prompt: &survey.Input{Message: "Tenant ID:"}, + Validate: survey.Required, + }, + { + Name: "event_hub_namespace", + Prompt: &survey.Input{Message: "Event Hub Fully Qualified Namespace:"}, + Validate: survey.Required, + }, + { + Name: "event_hub_name", + Prompt: &survey.Input{Message: "Event Hub Name:"}, + Validate: survey.Required, + }, + } + + answers := struct { + Name string + ClientID string `survey:"client_id"` + ClientSecret string `survey:"client_secret"` + TenantID string `survey:"tenant_id"` + EventHubNamespace string `survey:"event_hub_namespace"` + EventHubName string `survey:"event_hub_name"` + }{} + + err := survey.Ask(questions, &answers, + survey.WithIcons(promptIconsFunc), + ) + if err != nil { + return err + } + + azure := api.NewCloudAccount(answers.Name, + api.AzureAdAlCloudAccount, + api.AzureAdAlData{ + TenantID: answers.TenantID, + EventHubNamespace: answers.EventHubNamespace, + EventHubName: answers.EventHubName, + Credentials: api.AzureAdAlCredentials{ + ClientID: answers.ClientID, + ClientSecret: answers.ClientSecret, + }, + }, + ) + + cli.StartProgress(" Creating integration...") + _, err = cli.LwApi.V2.CloudAccounts.Create(azure) + cli.StopProgress() + return err +}