diff --git a/internal/services/apimanagement/api_management_workspace_logger_resource.go b/internal/services/apimanagement/api_management_workspace_logger_resource.go new file mode 100644 index 000000000000..dad8ecabed4d --- /dev/null +++ b/internal/services/apimanagement/api_management_workspace_logger_resource.go @@ -0,0 +1,435 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package apimanagement + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/schemaz" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type ApiManagementWorkspaceLoggerModel struct { + Name string `tfschema:"name"` + ApiManagementWorkspaceId string `tfschema:"api_management_workspace_id"` + ApplicationInsights []ApplicationInsightsModel `tfschema:"application_insights"` + EventHub []EventHubModel `tfschema:"eventhub"` + BufferingEnabled bool `tfschema:"buffering_enabled"` + Description string `tfschema:"description"` + ResourceId string `tfschema:"resource_id"` +} + +type ApplicationInsightsModel struct { + InstrumentationKey string `tfschema:"instrumentation_key"` + ConnectionString string `tfschema:"connection_string"` +} + +type EventHubModel struct { + Name string `tfschema:"name"` + ConnectionString string `tfschema:"connection_string"` + EndpointUri string `tfschema:"endpoint_uri"` + UserAssignedIdentityClientId string `tfschema:"user_assigned_identity_client_id"` +} + +type ApiManagementWorkspaceLoggerResource struct{} + +var _ sdk.ResourceWithUpdate = ApiManagementWorkspaceLoggerResource{} + +func (r ApiManagementWorkspaceLoggerResource) ResourceType() string { + return "azurerm_api_management_workspace_logger" +} + +func (r ApiManagementWorkspaceLoggerResource) ModelObject() interface{} { + return &ApiManagementWorkspaceLoggerModel{} +} + +func (r ApiManagementWorkspaceLoggerResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return logger.ValidateWorkspaceLoggerID +} + +func (r ApiManagementWorkspaceLoggerResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": schemaz.SchemaApiManagementChildName(), + + "api_management_workspace_id": commonschema.ResourceIDReferenceRequiredForceNew(&logger.WorkspaceId{}), + + "application_insights": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + ForceNew: true, + ExactlyOneOf: []string{"application_insights", "eventhub"}, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "connection_string": { + Type: pluginsdk.TypeString, + Optional: true, + Sensitive: true, + ExactlyOneOf: []string{"application_insights.0.connection_string", "application_insights.0.instrumentation_key"}, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "instrumentation_key": { + Type: pluginsdk.TypeString, + Optional: true, + Sensitive: true, + ExactlyOneOf: []string{"application_insights.0.connection_string", "application_insights.0.instrumentation_key"}, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + + "buffering_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "eventhub": { + Type: pluginsdk.TypeList, + MaxItems: 1, + Optional: true, + ForceNew: true, + ExactlyOneOf: []string{"application_insights", "eventhub"}, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validate.ValidateEventHubName(), + }, + + "connection_string": { + Type: pluginsdk.TypeString, + Optional: true, + Sensitive: true, + ExactlyOneOf: []string{ + "eventhub.0.connection_string", + "eventhub.0.endpoint_uri", + }, + ConflictsWith: []string{ + "eventhub.0.user_assigned_identity_client_id", + }, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "endpoint_uri": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + ExactlyOneOf: []string{ + "eventhub.0.connection_string", + "eventhub.0.endpoint_uri", + }, + }, + + "user_assigned_identity_client_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.IsUUID, + ConflictsWith: []string{ + "eventhub.0.connection_string", + }, + }, + }, + }, + }, + + "resource_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceID, + }, + } +} + +func (r ApiManagementWorkspaceLoggerResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r ApiManagementWorkspaceLoggerResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.ApiManagement.LoggerClient_v2024_05_01 + + var model ApiManagementWorkspaceLoggerModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + workspaceId, err := logger.ParseWorkspaceID(model.ApiManagementWorkspaceId) + if err != nil { + return err + } + + id := logger.NewWorkspaceLoggerID(workspaceId.SubscriptionId, workspaceId.ResourceGroupName, workspaceId.ServiceName, workspaceId.WorkspaceId, model.Name) + existing, err := client.WorkspaceLoggerGet(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + parameters := logger.LoggerContract{ + Properties: &logger.LoggerContractProperties{ + IsBuffered: pointer.To(model.BufferingEnabled), + }, + } + + if len(model.ApplicationInsights) > 0 { + parameters.Properties.LoggerType = logger.LoggerTypeApplicationInsights + parameters.Properties.Credentials = expandApiManagementWorkspaceLoggerApplicationInsights(model.ApplicationInsights) + } + + if len(model.EventHub) > 0 { + parameters.Properties.LoggerType = logger.LoggerTypeAzureEventHub + parameters.Properties.Credentials = expandApiManagementWorkspaceLoggerEventHub(model.EventHub) + } + + if model.Description != "" { + parameters.Properties.Description = pointer.To(model.Description) + } + + if model.ResourceId != "" { + parameters.Properties.ResourceId = pointer.To(model.ResourceId) + } + + if _, err := client.WorkspaceLoggerCreateOrUpdate(ctx, id, parameters, logger.WorkspaceLoggerCreateOrUpdateOperationOptions{}); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r ApiManagementWorkspaceLoggerResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.ApiManagement.LoggerClient_v2024_05_01 + + id, err := logger.ParseWorkspaceLoggerID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.WorkspaceLoggerGet(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(*id) + } + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + model := ApiManagementWorkspaceLoggerModel{ + Name: id.LoggerId, + ApiManagementWorkspaceId: logger.NewWorkspaceID(id.SubscriptionId, id.ResourceGroupName, id.ServiceName, id.WorkspaceId).ID(), + } + + if respModel := resp.Model; respModel != nil { + if props := respModel.Properties; props != nil { + model.BufferingEnabled = pointer.From(props.IsBuffered) + model.Description = pointer.From(props.Description) + model.ResourceId = pointer.From(props.ResourceId) + + if credentials := props.Credentials; credentials != nil { + var config ApiManagementWorkspaceLoggerModel + if err := metadata.Decode(&config); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + switch props.LoggerType { + case logger.LoggerTypeApplicationInsights: + // The `application_insights.0.instrumentation_key` and `application_insights.0.connection_string` returned by the Azure API is intentionally masked + // (e.g. "{{Logger-Credentials--}}") and does not match the original value provided during creation/update. + // This is by design to prevent exposing sensitive credentials in API responses. + // Therefore, the `application_insights` is sourced from the state. + model.ApplicationInsights = config.ApplicationInsights + case logger.LoggerTypeAzureEventHub: + model.EventHub = flattenApiManagementWorkspaceLoggerEventHub(config, props) + } + } + } + } + + return metadata.Encode(&model) + }, + } +} + +func (r ApiManagementWorkspaceLoggerResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.ApiManagement.LoggerClient_v2024_05_01 + + var model ApiManagementWorkspaceLoggerModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + id, err := logger.ParseWorkspaceLoggerID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.WorkspaceLoggerGet(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + if resp.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", *id) + } + + if resp.Model.Properties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", *id) + } + + payload := resp.Model + if len(model.ApplicationInsights) > 0 { + // `application_insights.0,instrumentation_key` and `application_insights.0.connection_string` read from config since the API masks `instrumentationKey ` and `connectionString`. + payload.Properties.Credentials = expandApiManagementWorkspaceLoggerApplicationInsights(model.ApplicationInsights) + } + + if len(model.EventHub) > 0 { + if metadata.ResourceData.HasChange("eventhub") { + payload.Properties.Credentials = expandApiManagementWorkspaceLoggerEventHub(model.EventHub) + } + } + + if metadata.ResourceData.HasChange("buffering_enabled") { + payload.Properties.IsBuffered = pointer.To(model.BufferingEnabled) + } + + if metadata.ResourceData.HasChange("description") { + payload.Properties.Description = pointer.To(model.Description) + } + + if metadata.ResourceData.HasChange("resource_id") { + payload.Properties.ResourceId = pointer.To(model.ResourceId) + } + + if _, err := client.WorkspaceLoggerCreateOrUpdate(ctx, *id, *payload, logger.WorkspaceLoggerCreateOrUpdateOperationOptions{}); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r ApiManagementWorkspaceLoggerResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.ApiManagement.LoggerClient_v2024_05_01 + + id, err := logger.ParseWorkspaceLoggerID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if _, err := client.WorkspaceLoggerDelete(ctx, *id, logger.WorkspaceLoggerDeleteOperationOptions{}); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func expandApiManagementWorkspaceLoggerApplicationInsights(inputs []ApplicationInsightsModel) *map[string]string { + if len(inputs) == 0 { + return nil + } + + input := &inputs[0] + result := make(map[string]string) + if input.InstrumentationKey != "" { + result["instrumentationKey"] = input.InstrumentationKey + } + if input.ConnectionString != "" { + result["connectionString"] = input.ConnectionString + } + return &result +} + +func expandApiManagementWorkspaceLoggerEventHub(inputs []EventHubModel) *map[string]string { + if len(inputs) == 0 { + return nil + } + + input := inputs[0] + result := make(map[string]string) + result["name"] = input.Name + if len(input.ConnectionString) > 0 { + result["connectionString"] = input.ConnectionString + } else if len(input.EndpointUri) > 0 { + result["endpointAddress"] = input.EndpointUri + // This field is required by the API and only accepts either a valid UUID or `SystemAssigned` as a value, so we default this to `SystemAssigned` in the creation/update if the field is omitted/removed + result["identityClientId"] = "SystemAssigned" + if input.UserAssignedIdentityClientId != "" { + result["identityClientId"] = input.UserAssignedIdentityClientId + } + } + + return &result +} + +func flattenApiManagementWorkspaceLoggerEventHub(model ApiManagementWorkspaceLoggerModel, input *logger.LoggerContractProperties) []EventHubModel { + outputList := make([]EventHubModel, 0) + if input == nil || input.Credentials == nil { + return outputList + } + + output := EventHubModel{} + + if name, ok := (*input.Credentials)["name"]; ok { + output.Name = name + } + + if endpoint, ok := (*input.Credentials)["endpointAddress"]; ok { + output.EndpointUri = endpoint + } + + if eventhub := model.EventHub; len(eventhub) > 0 { + // The `eventhub.0.connection_string` returned by the Azure API is intentionally masked + // (e.g. "{{Logger-Credentials--}}") and does not match the original value provided during creation/update. + // This is by design to prevent exposing sensitive credentials in API responses. + // Therefore, the `connection_string` is sourced from the state. + output.ConnectionString = eventhub[0].ConnectionString + + // The API return `user_assigned_identity_client_id` as an internal identifier (e.g., hex string), + // not the original AAD `client_id` (UUID). Therefore, we read `user_assigned_identity_client_id` from config. + if clientId := eventhub[0].UserAssignedIdentityClientId; clientId != "SystemAssigned" { + output.UserAssignedIdentityClientId = clientId + } + } + outputList = append(outputList, output) + + return outputList +} diff --git a/internal/services/apimanagement/api_management_workspace_logger_resource_test.go b/internal/services/apimanagement/api_management_workspace_logger_resource_test.go new file mode 100644 index 000000000000..d29fb7ff3e53 --- /dev/null +++ b/internal/services/apimanagement/api_management_workspace_logger_resource_test.go @@ -0,0 +1,607 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package apimanagement_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type ApiManagementWorkspaceLoggerTestResource struct{} + +func TestAccApiManagementWorkspaceLogger_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("application_insights.#", "application_insights.0.connection_string", "application_insights.0.instrumentation_key", "application_insights.0.%"), + }) +} + +func TestAccApiManagementWorkspaceLogger_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccApiManagementWorkspaceLogger_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("application_insights.#", "application_insights.0.connection_string", "application_insights.0.instrumentation_key", "application_insights.0.%"), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("application_insights.#", "application_insights.0.connection_string", "application_insights.0.instrumentation_key", "application_insights.0.%"), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("application_insights.#", "application_insights.0.connection_string", "application_insights.0.instrumentation_key", "application_insights.0.%"), + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("application_insights.#", "application_insights.0.connection_string", "application_insights.0.instrumentation_key", "application_insights.0.%"), + }) +} + +func TestAccApiManagementWorkspaceLogger_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("application_insights.#", "application_insights.0.connection_string", "application_insights.0.instrumentation_key", "application_insights.0.%"), + }) +} + +func TestAccApiManagementWorkspaceLogger_basicEventhub(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basicEventhub(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.connection_string"), + }) +} + +func TestAccApiManagementWorkspaceLogger_systemAssignedIdentityEventHub(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.systemAssignedIdentityEventhub(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.user_assigned_identity_client_id"), + { + Config: r.systemAssignedIdentityEventhubUpdate(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.user_assigned_identity_client_id"), + { + Config: r.systemAssignedIdentityEventhub(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.user_assigned_identity_client_id"), + }) +} + +func TestAccApiManagementWorkspaceLogger_managedIdentityEventHub(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_api_management_workspace_logger", "test") + r := ApiManagementWorkspaceLoggerTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.managedIdentityEventhub(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.user_assigned_identity_client_id"), + { + Config: r.managedIdentityEventhubUpdate(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.user_assigned_identity_client_id"), + { + Config: r.managedIdentityEventhub(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("eventhub.0.user_assigned_identity_client_id"), + }) +} + +func (ApiManagementWorkspaceLoggerTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := logger.ParseWorkspaceLoggerID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.ApiManagement.LoggerClient_v2024_05_01.WorkspaceLoggerGet(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + + return pointer.To(resp.Model != nil), nil +} + +func (r ApiManagementWorkspaceLoggerTestResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features { + application_insights { + disable_generated_rule = true + } + } +} + +%[1]s + +resource "azurerm_application_insights" "test" { + name = "acctestappinsights-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_type = "other" +} + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + + application_insights { + connection_string = azurerm_application_insights.test.connection_string + } +} +`, r.template(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features { + application_insights { + disable_generated_rule = true + } + } +} + +%[1]s + +resource "azurerm_application_insights" "test" { + name = "acctestappinsights-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_type = "other" +} + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + description = "Logger from Terraform test" + buffering_enabled = false + resource_id = azurerm_application_insights.test.id + + application_insights { + instrumentation_key = azurerm_application_insights.test.instrumentation_key + } +} +`, r.template(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features { + application_insights { + disable_generated_rule = true + } + } +} + +%[1]s + +resource "azurerm_application_insights" "test" { + name = "acctestappinsights-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_type = "other" +} + +resource "azurerm_application_insights" "test2" { + name = "acctestappinsights2-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_type = "other" +} + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + buffering_enabled = true + description = "Logger from Terraform test update" + resource_id = azurerm_application_insights.test2.id + + application_insights { + instrumentation_key = azurerm_application_insights.test2.instrumentation_key + } +} +`, r.template(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) basicEventhub(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%[1]s + +resource "azurerm_eventhub_namespace" "test" { + name = "acctesteventhubnamespace-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_eventhub" "test" { + name = "acctestEventHub-%[2]d" + namespace_name = azurerm_eventhub_namespace.test.name + resource_group_name = azurerm_resource_group.test.name + partition_count = 2 + message_retention = 1 +} + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + + eventhub { + name = azurerm_eventhub.test.name + connection_string = azurerm_eventhub_namespace.test.default_primary_connection_string + } +} +`, r.template(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) managedIdentityEventhub(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%[1]s + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + + eventhub { + name = azurerm_eventhub.test.name + endpoint_uri = "${azurerm_eventhub_namespace.test.name}.servicebus.windows.net" + user_assigned_identity_client_id = azurerm_user_assigned_identity.test.client_id + } + depends_on = [azurerm_role_assignment.test] +} +`, r.templateWithManagedIdentity(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) managedIdentityEventhubUpdate(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%[1]s + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + + eventhub { + name = azurerm_eventhub.test2.name + endpoint_uri = "${azurerm_eventhub_namespace.test2.name}.servicebus.windows.net" + user_assigned_identity_client_id = azurerm_user_assigned_identity.test2.client_id + } + depends_on = [azurerm_role_assignment.test2] +} +`, r.templateWithManagedIdentity(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) systemAssignedIdentityEventhub(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%[1]s + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + + eventhub { + name = azurerm_eventhub.test.name + endpoint_uri = "${azurerm_eventhub_namespace.test.name}.servicebus.windows.net" + } + depends_on = [azurerm_role_assignment.test] +} +`, r.templateWithSystemAssignedIdentity(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) systemAssignedIdentityEventhubUpdate(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%[1]s + +resource "azurerm_api_management_workspace_logger" "test" { + name = "acctestapimlogger-%[2]d" + api_management_workspace_id = azurerm_api_management_workspace.test.id + + eventhub { + name = azurerm_eventhub.test2.name + endpoint_uri = "${azurerm_eventhub_namespace.test2.name}.servicebus.windows.net" + } + depends_on = [azurerm_role_assignment.test2] +} +`, r.templateWithSystemAssignedIdentity(data), data.RandomInteger) +} + +func (r ApiManagementWorkspaceLoggerTestResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_api_management_workspace_logger" "import" { + name = azurerm_api_management_workspace_logger.test.name + api_management_workspace_id = azurerm_api_management_workspace_logger.test.api_management_workspace_id + + application_insights { + connection_string = azurerm_application_insights.test.connection_string + } +} +`, r.basic(data)) +} + +func (r ApiManagementWorkspaceLoggerTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-apim-%[1]d" + location = "%[2]s" +} + +resource "azurerm_api_management" "test" { + name = "acctestAM-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + publisher_name = "pub1" + publisher_email = "pub1@email.com" + sku_name = "Premium_1" +} + +resource "azurerm_api_management_workspace" "test" { + name = "acctestAMWS-%[1]d" + api_management_id = azurerm_api_management.test.id + display_name = "Test Workspace" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r ApiManagementWorkspaceLoggerTestResource) templateWithManagedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-apim-%[1]d" + location = "%[2]s" +} + +resource "azurerm_eventhub_namespace" "test" { + name = "acctesteventhubnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_eventhub" "test" { + name = "acctesteventhub-%[1]d" + namespace_name = azurerm_eventhub_namespace.test.name + resource_group_name = azurerm_resource_group.test.name + partition_count = 2 + message_retention = 1 +} + +resource "azurerm_user_assigned_identity" "test" { + name = "uai-acctestapimnglogger-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_eventhub_namespace" "test2" { + name = "acctesteventhubnamespace2-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_eventhub" "test2" { + name = "acctesteventhub2-%[1]d" + namespace_name = azurerm_eventhub_namespace.test2.name + resource_group_name = azurerm_resource_group.test.name + partition_count = 2 + message_retention = 1 +} + +resource "azurerm_user_assigned_identity" "test2" { + name = "uai-acctestapimnglogger2-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_role_assignment" "test" { + scope = azurerm_eventhub.test.id + role_definition_name = "Azure Event Hubs Data Sender" + principal_id = azurerm_user_assigned_identity.test.principal_id +} + +resource "azurerm_role_assignment" "test2" { + scope = azurerm_eventhub.test2.id + role_definition_name = "Azure Event Hubs Data Sender" + principal_id = azurerm_user_assigned_identity.test2.principal_id +} + +resource "azurerm_api_management" "test" { + name = "acctestAM-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + publisher_name = "pub1" + publisher_email = "pub1@email.com" + sku_name = "Premium_1" + + identity { + type = "UserAssigned" + identity_ids = [ + azurerm_user_assigned_identity.test.id, + azurerm_user_assigned_identity.test2.id + ] + } +} + +resource "azurerm_api_management_workspace" "test" { + name = "acctestAMWS-%[1]d" + api_management_id = azurerm_api_management.test.id + display_name = "Test Workspace" +} + +`, data.RandomInteger, data.Locations.Primary) +} + +func (r ApiManagementWorkspaceLoggerTestResource) templateWithSystemAssignedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-apim-%[1]d" + location = "%[2]s" +} + +resource "azurerm_eventhub_namespace" "test" { + name = "acctesteventhubnamespace-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_eventhub" "test" { + name = "acctesteventhub-%[1]d" + namespace_name = azurerm_eventhub_namespace.test.name + resource_group_name = azurerm_resource_group.test.name + partition_count = 2 + message_retention = 1 +} + +resource "azurerm_eventhub_namespace" "test2" { + name = "acctesteventhubnamespace2-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Basic" +} + +resource "azurerm_eventhub" "test2" { + name = "acctesteventhub2-%[1]d" + namespace_name = azurerm_eventhub_namespace.test2.name + resource_group_name = azurerm_resource_group.test.name + partition_count = 2 + message_retention = 1 +} + +resource "azurerm_api_management" "test" { + name = "acctestAM-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + publisher_name = "pub1" + publisher_email = "pub1@email.com" + sku_name = "Premium_1" + + identity { + type = "SystemAssigned" + } +} + +resource "azurerm_api_management_workspace" "test" { + name = "acctestAMWS-%[1]d" + api_management_id = azurerm_api_management.test.id + display_name = "Test Workspace" +} + +resource "azurerm_role_assignment" "test" { + scope = azurerm_eventhub.test.id + role_definition_name = "Azure Event Hubs Data Sender" + principal_id = azurerm_api_management.test.identity[0].principal_id +} + +resource "azurerm_role_assignment" "test2" { + scope = azurerm_eventhub.test2.id + role_definition_name = "Azure Event Hubs Data Sender" + principal_id = azurerm_api_management.test.identity[0].principal_id +} +`, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/apimanagement/client/client.go b/internal/services/apimanagement/client/client.go index 87d56235b5b2..c347bfea91c8 100644 --- a/internal/services/apimanagement/client/client.go +++ b/internal/services/apimanagement/client/client.go @@ -54,6 +54,7 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/apigateway" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/apimanagementservice" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/backend" + logger_v2024_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger" policyfragment_v2024_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/policyfragment" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/workspace" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/workspacepolicy" @@ -91,6 +92,7 @@ type Client struct { GroupUsersClient *groupuser.GroupUserClient IdentityProviderClient *identityprovider.IdentityProviderClient LoggerClient *logger.LoggerClient + LoggerClient_v2024_05_01 *logger_v2024_05_01.LoggerClient NamedValueClient *namedvalue.NamedValueClient NotificationRecipientEmailClient *notificationrecipientemail.NotificationRecipientEmailClient NotificationRecipientUserClient *notificationrecipientuser.NotificationRecipientUserClient @@ -313,6 +315,12 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(loggerClient.Client, o.Authorizers.ResourceManager) + loggerClient_v2024_05_01, err := logger_v2024_05_01.NewLoggerClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Logger client: %+v", err) + } + o.Configure(loggerClient_v2024_05_01.Client, o.Authorizers.ResourceManager) + openIdConnectClient, err := openidconnectprovider.NewOpenidConnectProviderClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building OpenId Connect client: %+v", err) @@ -452,6 +460,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { GroupUsersClient: groupUsersClient, IdentityProviderClient: identityProviderClient, LoggerClient: loggerClient, + LoggerClient_v2024_05_01: loggerClient_v2024_05_01, NamedValueClient: namedValueClient, NotificationRecipientEmailClient: notificationRecipientEmailClient, NotificationRecipientUserClient: notificationRecipientUserClient, diff --git a/internal/services/apimanagement/registration.go b/internal/services/apimanagement/registration.go index 241bf6df3f61..a69190725b02 100644 --- a/internal/services/apimanagement/registration.go +++ b/internal/services/apimanagement/registration.go @@ -110,6 +110,7 @@ func (r Registration) Resources() []sdk.Resource { ApiManagementWorkspaceResource{}, ApiManagementWorkspacePolicyResource{}, ApiManagementStandaloneGatewayResource{}, + ApiManagementWorkspaceLoggerResource{}, ApiManagementWorkspacePolicyFragmentResource{}, } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/README.md new file mode 100644 index 000000000000..d67ca4eb4958 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/README.md @@ -0,0 +1,234 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger` Documentation + +The `logger` SDK allows for interaction with Azure Resource Manager `apimanagement` (API Version `2024-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger" +``` + + +### Client Initialization + +```go +client := logger.NewLoggerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LoggerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := logger.NewLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "loggerId") + +payload := logger.LoggerContract{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, logger.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.Delete` + +```go +ctx := context.TODO() +id := logger.NewLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "loggerId") + +read, err := client.Delete(ctx, id, logger.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.Get` + +```go +ctx := context.TODO() +id := logger.NewLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "loggerId") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.GetEntityTag` + +```go +ctx := context.TODO() +id := logger.NewLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "loggerId") + +read, err := client.GetEntityTag(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.ListByService` + +```go +ctx := context.TODO() +id := logger.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName") + +// alternatively `client.ListByService(ctx, id, logger.DefaultListByServiceOperationOptions())` can be used to do batched pagination +items, err := client.ListByServiceComplete(ctx, id, logger.DefaultListByServiceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoggerClient.Update` + +```go +ctx := context.TODO() +id := logger.NewLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "loggerId") + +payload := logger.LoggerUpdateContract{ + // ... +} + + +read, err := client.Update(ctx, id, payload, logger.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.WorkspaceLoggerCreateOrUpdate` + +```go +ctx := context.TODO() +id := logger.NewWorkspaceLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "workspaceId", "loggerId") + +payload := logger.LoggerContract{ + // ... +} + + +read, err := client.WorkspaceLoggerCreateOrUpdate(ctx, id, payload, logger.DefaultWorkspaceLoggerCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.WorkspaceLoggerDelete` + +```go +ctx := context.TODO() +id := logger.NewWorkspaceLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "workspaceId", "loggerId") + +read, err := client.WorkspaceLoggerDelete(ctx, id, logger.DefaultWorkspaceLoggerDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.WorkspaceLoggerGet` + +```go +ctx := context.TODO() +id := logger.NewWorkspaceLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "workspaceId", "loggerId") + +read, err := client.WorkspaceLoggerGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.WorkspaceLoggerGetEntityTag` + +```go +ctx := context.TODO() +id := logger.NewWorkspaceLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "workspaceId", "loggerId") + +read, err := client.WorkspaceLoggerGetEntityTag(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoggerClient.WorkspaceLoggerListByWorkspace` + +```go +ctx := context.TODO() +id := logger.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "workspaceId") + +// alternatively `client.WorkspaceLoggerListByWorkspace(ctx, id, logger.DefaultWorkspaceLoggerListByWorkspaceOperationOptions())` can be used to do batched pagination +items, err := client.WorkspaceLoggerListByWorkspaceComplete(ctx, id, logger.DefaultWorkspaceLoggerListByWorkspaceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoggerClient.WorkspaceLoggerUpdate` + +```go +ctx := context.TODO() +id := logger.NewWorkspaceLoggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceName", "workspaceId", "loggerId") + +payload := logger.LoggerUpdateContract{ + // ... +} + + +read, err := client.WorkspaceLoggerUpdate(ctx, id, payload, logger.DefaultWorkspaceLoggerUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/client.go new file mode 100644 index 000000000000..2ecf8e827204 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/client.go @@ -0,0 +1,26 @@ +package logger + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerClient struct { + Client *resourcemanager.Client +} + +func NewLoggerClientWithBaseURI(sdkApi sdkEnv.Api) (*LoggerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "logger", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LoggerClient: %+v", err) + } + + return &LoggerClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/constants.go new file mode 100644 index 000000000000..0aa7cb68a3e7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/constants.go @@ -0,0 +1,54 @@ +package logger + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerType string + +const ( + LoggerTypeApplicationInsights LoggerType = "applicationInsights" + LoggerTypeAzureEventHub LoggerType = "azureEventHub" + LoggerTypeAzureMonitor LoggerType = "azureMonitor" +) + +func PossibleValuesForLoggerType() []string { + return []string{ + string(LoggerTypeApplicationInsights), + string(LoggerTypeAzureEventHub), + string(LoggerTypeAzureMonitor), + } +} + +func (s *LoggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoggerType(input string) (*LoggerType, error) { + vals := map[string]LoggerType{ + "applicationinsights": LoggerTypeApplicationInsights, + "azureeventhub": LoggerTypeAzureEventHub, + "azuremonitor": LoggerTypeAzureMonitor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoggerType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_logger.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_logger.go new file mode 100644 index 000000000000..0a20a5185879 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_logger.go @@ -0,0 +1,139 @@ +package logger + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LoggerId{}) +} + +var _ resourceids.ResourceId = &LoggerId{} + +// LoggerId is a struct representing the Resource ID for a Logger +type LoggerId struct { + SubscriptionId string + ResourceGroupName string + ServiceName string + LoggerId string +} + +// NewLoggerID returns a new LoggerId struct +func NewLoggerID(subscriptionId string, resourceGroupName string, serviceName string, loggerId string) LoggerId { + return LoggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceName: serviceName, + LoggerId: loggerId, + } +} + +// ParseLoggerID parses 'input' into a LoggerId +func ParseLoggerID(input string) (*LoggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLoggerIDInsensitively parses 'input' case-insensitively into a LoggerId +// note: this method should only be used for API response data and not user input +func ParseLoggerIDInsensitively(input string) (*LoggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LoggerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + if id.LoggerId, ok = input.Parsed["loggerId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loggerId", input) + } + + return nil +} + +// ValidateLoggerID checks that 'input' can be parsed as a Logger ID +func ValidateLoggerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLoggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Logger ID +func (id LoggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ApiManagement/service/%s/loggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceName, id.LoggerId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Logger ID +func (id LoggerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApiManagement", "Microsoft.ApiManagement", "Microsoft.ApiManagement"), + resourceids.StaticSegment("staticService", "service", "service"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + resourceids.StaticSegment("staticLoggers", "loggers", "loggers"), + resourceids.UserSpecifiedSegment("loggerId", "loggerId"), + } +} + +// String returns a human-readable description of this Logger ID +func (id LoggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + fmt.Sprintf("Logger: %q", id.LoggerId), + } + return fmt.Sprintf("Logger (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_service.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_service.go new file mode 100644 index 000000000000..f8754321eebb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_service.go @@ -0,0 +1,130 @@ +package logger + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ApiManagement/service/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApiManagement", "Microsoft.ApiManagement", "Microsoft.ApiManagement"), + resourceids.StaticSegment("staticService", "service", "service"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_workspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_workspace.go new file mode 100644 index 000000000000..7562e92fc191 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_workspace.go @@ -0,0 +1,139 @@ +package logger + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + ServiceName string + WorkspaceId string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, serviceName string, workspaceId string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceName: serviceName, + WorkspaceId: workspaceId, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + if id.WorkspaceId, ok = input.Parsed["workspaceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceId", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ApiManagement/service/%s/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceName, id.WorkspaceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApiManagement", "Microsoft.ApiManagement", "Microsoft.ApiManagement"), + resourceids.StaticSegment("staticService", "service", "service"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceId", "workspaceId"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + fmt.Sprintf("Workspace: %q", id.WorkspaceId), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_workspacelogger.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_workspacelogger.go new file mode 100644 index 000000000000..7164118ff22b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/id_workspacelogger.go @@ -0,0 +1,148 @@ +package logger + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceLoggerId{}) +} + +var _ resourceids.ResourceId = &WorkspaceLoggerId{} + +// WorkspaceLoggerId is a struct representing the Resource ID for a Workspace Logger +type WorkspaceLoggerId struct { + SubscriptionId string + ResourceGroupName string + ServiceName string + WorkspaceId string + LoggerId string +} + +// NewWorkspaceLoggerID returns a new WorkspaceLoggerId struct +func NewWorkspaceLoggerID(subscriptionId string, resourceGroupName string, serviceName string, workspaceId string, loggerId string) WorkspaceLoggerId { + return WorkspaceLoggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceName: serviceName, + WorkspaceId: workspaceId, + LoggerId: loggerId, + } +} + +// ParseWorkspaceLoggerID parses 'input' into a WorkspaceLoggerId +func ParseWorkspaceLoggerID(input string) (*WorkspaceLoggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceLoggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceLoggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceLoggerIDInsensitively parses 'input' case-insensitively into a WorkspaceLoggerId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceLoggerIDInsensitively(input string) (*WorkspaceLoggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceLoggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceLoggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceLoggerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + if id.WorkspaceId, ok = input.Parsed["workspaceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceId", input) + } + + if id.LoggerId, ok = input.Parsed["loggerId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loggerId", input) + } + + return nil +} + +// ValidateWorkspaceLoggerID checks that 'input' can be parsed as a Workspace Logger ID +func ValidateWorkspaceLoggerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceLoggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace Logger ID +func (id WorkspaceLoggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ApiManagement/service/%s/workspaces/%s/loggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceName, id.WorkspaceId, id.LoggerId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace Logger ID +func (id WorkspaceLoggerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApiManagement", "Microsoft.ApiManagement", "Microsoft.ApiManagement"), + resourceids.StaticSegment("staticService", "service", "service"), + resourceids.UserSpecifiedSegment("serviceName", "serviceName"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceId", "workspaceId"), + resourceids.StaticSegment("staticLoggers", "loggers", "loggers"), + resourceids.UserSpecifiedSegment("loggerId", "loggerId"), + } +} + +// String returns a human-readable description of this Workspace Logger ID +func (id WorkspaceLoggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + fmt.Sprintf("Workspace: %q", id.WorkspaceId), + fmt.Sprintf("Logger: %q", id.LoggerId), + } + return fmt.Sprintf("Workspace Logger (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_createorupdate.go new file mode 100644 index 000000000000..3430cb9dd771 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_createorupdate.go @@ -0,0 +1,88 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c LoggerClient) CreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoggerContract + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_delete.go new file mode 100644 index 000000000000..3465b8ec8298 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_delete.go @@ -0,0 +1,77 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c LoggerClient) Delete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_get.go new file mode 100644 index 000000000000..7a6f1ba10d61 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_get.go @@ -0,0 +1,53 @@ +package logger + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +// Get ... +func (c LoggerClient) Get(ctx context.Context, id LoggerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoggerContract + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_getentitytag.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_getentitytag.go new file mode 100644 index 000000000000..b65f6ac22bdb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_getentitytag.go @@ -0,0 +1,46 @@ +package logger + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c LoggerClient) GetEntityTag(ctx context.Context, id LoggerId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_listbyservice.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_listbyservice.go new file mode 100644 index 000000000000..d930656f2675 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_listbyservice.go @@ -0,0 +1,142 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoggerContract +} + +type ListByServiceCompleteResult struct { + LatestHttpResponse *http.Response + Items []LoggerContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListByServiceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByServiceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByService ... +func (c LoggerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByServiceCustomPager{}, + Path: fmt.Sprintf("%s/loggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoggerContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c LoggerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, LoggerContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoggerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate LoggerContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]LoggerContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_update.go new file mode 100644 index 000000000000..669803305568 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_update.go @@ -0,0 +1,87 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c LoggerClient) Update(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoggerContract + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggercreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggercreateorupdate.go new file mode 100644 index 000000000000..dea691c2e184 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggercreateorupdate.go @@ -0,0 +1,88 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceLoggerCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type WorkspaceLoggerCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultWorkspaceLoggerCreateOrUpdateOperationOptions() WorkspaceLoggerCreateOrUpdateOperationOptions { + return WorkspaceLoggerCreateOrUpdateOperationOptions{} +} + +func (o WorkspaceLoggerCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o WorkspaceLoggerCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o WorkspaceLoggerCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// WorkspaceLoggerCreateOrUpdate ... +func (c LoggerClient) WorkspaceLoggerCreateOrUpdate(ctx context.Context, id WorkspaceLoggerId, input LoggerContract, options WorkspaceLoggerCreateOrUpdateOperationOptions) (result WorkspaceLoggerCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoggerContract + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerdelete.go new file mode 100644 index 000000000000..da999d0b4eb2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerdelete.go @@ -0,0 +1,77 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceLoggerDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type WorkspaceLoggerDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultWorkspaceLoggerDeleteOperationOptions() WorkspaceLoggerDeleteOperationOptions { + return WorkspaceLoggerDeleteOperationOptions{} +} + +func (o WorkspaceLoggerDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o WorkspaceLoggerDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o WorkspaceLoggerDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// WorkspaceLoggerDelete ... +func (c LoggerClient) WorkspaceLoggerDelete(ctx context.Context, id WorkspaceLoggerId, options WorkspaceLoggerDeleteOperationOptions) (result WorkspaceLoggerDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerget.go new file mode 100644 index 000000000000..72a7d01a50f7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerget.go @@ -0,0 +1,53 @@ +package logger + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceLoggerGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +// WorkspaceLoggerGet ... +func (c LoggerClient) WorkspaceLoggerGet(ctx context.Context, id WorkspaceLoggerId) (result WorkspaceLoggerGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoggerContract + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggergetentitytag.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggergetentitytag.go new file mode 100644 index 000000000000..92850b0479ad --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggergetentitytag.go @@ -0,0 +1,46 @@ +package logger + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceLoggerGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// WorkspaceLoggerGetEntityTag ... +func (c LoggerClient) WorkspaceLoggerGetEntityTag(ctx context.Context, id WorkspaceLoggerId) (result WorkspaceLoggerGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerlistbyworkspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerlistbyworkspace.go new file mode 100644 index 000000000000..2915ee0a4be7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerlistbyworkspace.go @@ -0,0 +1,142 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceLoggerListByWorkspaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoggerContract +} + +type WorkspaceLoggerListByWorkspaceCompleteResult struct { + LatestHttpResponse *http.Response + Items []LoggerContract +} + +type WorkspaceLoggerListByWorkspaceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultWorkspaceLoggerListByWorkspaceOperationOptions() WorkspaceLoggerListByWorkspaceOperationOptions { + return WorkspaceLoggerListByWorkspaceOperationOptions{} +} + +func (o WorkspaceLoggerListByWorkspaceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o WorkspaceLoggerListByWorkspaceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o WorkspaceLoggerListByWorkspaceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type WorkspaceLoggerListByWorkspaceCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkspaceLoggerListByWorkspaceCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkspaceLoggerListByWorkspace ... +func (c LoggerClient) WorkspaceLoggerListByWorkspace(ctx context.Context, id WorkspaceId, options WorkspaceLoggerListByWorkspaceOperationOptions) (result WorkspaceLoggerListByWorkspaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &WorkspaceLoggerListByWorkspaceCustomPager{}, + Path: fmt.Sprintf("%s/loggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoggerContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkspaceLoggerListByWorkspaceComplete retrieves all the results into a single object +func (c LoggerClient) WorkspaceLoggerListByWorkspaceComplete(ctx context.Context, id WorkspaceId, options WorkspaceLoggerListByWorkspaceOperationOptions) (WorkspaceLoggerListByWorkspaceCompleteResult, error) { + return c.WorkspaceLoggerListByWorkspaceCompleteMatchingPredicate(ctx, id, options, LoggerContractOperationPredicate{}) +} + +// WorkspaceLoggerListByWorkspaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoggerClient) WorkspaceLoggerListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options WorkspaceLoggerListByWorkspaceOperationOptions, predicate LoggerContractOperationPredicate) (result WorkspaceLoggerListByWorkspaceCompleteResult, err error) { + items := make([]LoggerContract, 0) + + resp, err := c.WorkspaceLoggerListByWorkspace(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = WorkspaceLoggerListByWorkspaceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerupdate.go new file mode 100644 index 000000000000..b5b6237b7cfb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/method_workspaceloggerupdate.go @@ -0,0 +1,87 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceLoggerUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type WorkspaceLoggerUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultWorkspaceLoggerUpdateOperationOptions() WorkspaceLoggerUpdateOperationOptions { + return WorkspaceLoggerUpdateOperationOptions{} +} + +func (o WorkspaceLoggerUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o WorkspaceLoggerUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o WorkspaceLoggerUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// WorkspaceLoggerUpdate ... +func (c LoggerClient) WorkspaceLoggerUpdate(ctx context.Context, id WorkspaceLoggerId, input LoggerUpdateContract, options WorkspaceLoggerUpdateOperationOptions) (result WorkspaceLoggerUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoggerContract + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggercontract.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggercontract.go new file mode 100644 index 000000000000..972cc05b227c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggercontract.go @@ -0,0 +1,11 @@ +package logger + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerContract struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LoggerContractProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggercontractproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggercontractproperties.go new file mode 100644 index 000000000000..d70cd7607e35 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggercontractproperties.go @@ -0,0 +1,12 @@ +package logger + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerContractProperties struct { + Credentials *map[string]string `json:"credentials,omitempty"` + Description *string `json:"description,omitempty"` + IsBuffered *bool `json:"isBuffered,omitempty"` + LoggerType LoggerType `json:"loggerType"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggerupdatecontract.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggerupdatecontract.go new file mode 100644 index 000000000000..35373cca5cf2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggerupdatecontract.go @@ -0,0 +1,8 @@ +package logger + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerUpdateContract struct { + Properties *LoggerUpdateParameters `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggerupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggerupdateparameters.go new file mode 100644 index 000000000000..4a4958deaf5c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/model_loggerupdateparameters.go @@ -0,0 +1,11 @@ +package logger + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerUpdateParameters struct { + Credentials *map[string]string `json:"credentials,omitempty"` + Description *string `json:"description,omitempty"` + IsBuffered *bool `json:"isBuffered,omitempty"` + LoggerType *LoggerType `json:"loggerType,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/predicates.go new file mode 100644 index 000000000000..9dfff89de122 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/predicates.go @@ -0,0 +1,27 @@ +package logger + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoggerContractOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p LoggerContractOperationPredicate) Matches(input LoggerContract) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/version.go new file mode 100644 index 000000000000..9f9d15330a52 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger/version.go @@ -0,0 +1,10 @@ +package logger + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-05-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/logger/2024-05-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index b65edf61d723..3e4b1607a55b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -225,6 +225,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2022-08-01/user github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/apigateway github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/apimanagementservice github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/backend +github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/logger github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/policyfragment github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/workspace github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2024-05-01/workspacepolicy diff --git a/website/docs/r/api_management_workspace_logger.html.markdown b/website/docs/r/api_management_workspace_logger.html.markdown new file mode 100644 index 000000000000..5df83a1b04cc --- /dev/null +++ b/website/docs/r/api_management_workspace_logger.html.markdown @@ -0,0 +1,132 @@ +--- +subcategory: "API Management" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_api_management_workspace_logger" +description: |- + Manages a Logger within an API Management Workspace. +--- + +# azurerm_api_management_workspace_logger + +Manages a Logger within an API Management Workspace. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_api_management" "example" { + name = "example-apim" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + publisher_name = "My Company" + publisher_email = "company@terraform.io" + + sku_name = "Premium_1" +} + +resource "azurerm_api_management_workspace" "example" { + name = "example-workspace" + api_management_id = azurerm_api_management.example.id + display_name = "Example Workspace" +} + +resource "azurerm_application_insights" "example" { + name = "example-appinsights" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + application_type = "web" +} + +resource "azurerm_api_management_workspace_logger" "example" { + name = "example-logger" + api_management_workspace_id = azurerm_api_management_workspace.example.id + description = "Example logger for workspace" + + application_insights { + instrumentation_key = azurerm_application_insights.example.instrumentation_key + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the API Management Workspace Logger. Changing this forces a new resource to be created. + +* `api_management_workspace_id` - (Required) Specifies the ID of the API Management Workspace. Changing this forces a new resource to be created. + +--- + +* `application_insights` - (Optional) Specifies the application insights of the API Management Workspace Logger. Changing this forces a new resource to be created. + +* `buffering_enabled` - (Optional) Specifies whether records should be buffered in the API Management Workspace Logger prior to publishing. Defaults to `true`. + +* `description` - (Optional) Specifies a description of the API Management Workspace Logger. + +* `eventhub` - (Optional) Specifies the eventhub of the API Management Workspace Logger. Changing this forces a new resource to be created. + +-> **Note:** Exactly one of `application_insights` or `eventhub` must be specified. + +* `resource_id` - (Optional) Specifies the target resource ID of the API Management Workspace Logger, which can be either an Azure Event Hub or an application insights resource. + +--- + +An `application_insights` block supports the following: + +* `connection_string` - (Optional) Specifies the connection string of application insights. + +* `instrumentation_key` - (Optional) Specifies the instrumentation key of the application insights. + +-> **Note:** Exactly one of `connection_string` or `instrumentation_key` must be specified. + +--- + +An `eventhub` block supports the following: + +* `name` - (Required) Specifies the name of the Event Hub. + +* `connection_string` - (Optional) Specifies the connection string of the Event Hub namespace. + +* `endpoint_uri` - (Optional) Specifies the endpoint address of an Event Hub namespace. + +-> **Note:** Exactly one of `connection_string` or `endpoint_uri` must be specified. + +* `user_assigned_identity_client_id` - (Optional) Specifies the client ID of user-assigned identity that has the "Azure Event Hubs Data Sender" role on the target Event Hub namespace. + +-> **Note:** * If this is omitted, the `SystemAssigned` will be used. + +--- + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the API Management Workspace Logger. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the API Management Workspace Logger. +* `read` - (Defaults to 5 minutes) Used when retrieving the API Management Workspace Logger. +* `update` - (Defaults to 30 minutes) Used when updating the API Management Workspace Logger. +* `delete` - (Defaults to 30 minutes) Used when deleting the API Management Workspace Logger. + +## Import + +API Management Workspace Loggers can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_api_management_workspace_logger.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/instance1/workspaces/workspace1/loggers/logger1 +``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.ApiManagement` - 2024-05-01