Skip to content

Commit

Permalink
feat: create AzureAD intg from CLI (manual) (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manan-Bhatia-0 authored Mar 22, 2024
1 parent 8fe68d3 commit 0a5ced9
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/cmd/cloud_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ func promptCreateCloudAccount() error {
"GCP Audit Log PubSub",
"Azure Config",
"Azure Activity Log",
"Azure Active Directory Activity Log",
"OCI Config",
},
}
Expand Down Expand Up @@ -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:
Expand Down
69 changes: 69 additions & 0 deletions cli/cmd/integration_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 0a5ced9

Please sign in to comment.