diff --git a/internal/services/servicebus/client/client.go b/internal/services/servicebus/client/client.go index 056875696dac..e82bcbd8961c 100644 --- a/internal/services/servicebus/client/client.go +++ b/internal/services/servicebus/client/client.go @@ -1,44 +1,67 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - QueuesClient *servicebus.QueuesClient - DisasterRecoveryConfigsClient *servicebus.DisasterRecoveryConfigsClient - NamespacesClient *servicebus.NamespacesClient - TopicsClient *servicebus.TopicsClient - SubscriptionsClient *servicebus.SubscriptionsClient - SubscriptionRulesClient *servicebus.RulesClient + DisasterRecoveryConfigsClient *disasterrecoveryconfigs.DisasterRecoveryConfigsClient + NamespacesAuthClient *namespacesauthorizationrule.NamespacesAuthorizationRuleClient + NamespacesClient *namespaces.NamespacesClient + QueuesAuthClient *queuesauthorizationrule.QueuesAuthorizationRuleClient + QueuesClient *queues.QueuesClient + SubscriptionsClient *subscriptions.SubscriptionsClient + SubscriptionRulesClient *rules.RulesClient + TopicsAuthClient *topicsauthorizationrule.TopicsAuthorizationRuleClient + TopicsClient *topics.TopicsClient } func NewClient(o *common.ClientOptions) *Client { - QueuesClient := servicebus.NewQueuesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&QueuesClient.Client, o.ResourceManagerAuthorizer) - - DisasterRecoveryConfigsClient := servicebus.NewDisasterRecoveryConfigsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + DisasterRecoveryConfigsClient := disasterrecoveryconfigs.NewDisasterRecoveryConfigsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&DisasterRecoveryConfigsClient.Client, o.ResourceManagerAuthorizer) - NamespacesClient := servicebus.NewNamespacesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + NamespacesAuthClient := namespacesauthorizationrule.NewNamespacesAuthorizationRuleClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&NamespacesAuthClient.Client, o.ResourceManagerAuthorizer) + + NamespacesClient := namespaces.NewNamespacesClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&NamespacesClient.Client, o.ResourceManagerAuthorizer) - TopicsClient := servicebus.NewTopicsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&TopicsClient.Client, o.ResourceManagerAuthorizer) + QueuesAuthClient := queuesauthorizationrule.NewQueuesAuthorizationRuleClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&QueuesAuthClient.Client, o.ResourceManagerAuthorizer) - SubscriptionsClient := servicebus.NewSubscriptionsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + QueuesClient := queues.NewQueuesClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&QueuesClient.Client, o.ResourceManagerAuthorizer) + + SubscriptionsClient := subscriptions.NewSubscriptionsClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&SubscriptionsClient.Client, o.ResourceManagerAuthorizer) - SubscriptionRulesClient := servicebus.NewRulesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + SubscriptionRulesClient := rules.NewRulesClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&SubscriptionRulesClient.Client, o.ResourceManagerAuthorizer) + TopicsAuthClient := topicsauthorizationrule.NewTopicsAuthorizationRuleClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&TopicsAuthClient.Client, o.ResourceManagerAuthorizer) + + TopicsClient := topics.NewTopicsClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&TopicsClient.Client, o.ResourceManagerAuthorizer) + return &Client{ - QueuesClient: &QueuesClient, DisasterRecoveryConfigsClient: &DisasterRecoveryConfigsClient, + NamespacesAuthClient: &NamespacesAuthClient, NamespacesClient: &NamespacesClient, - TopicsClient: &TopicsClient, + QueuesAuthClient: &QueuesAuthClient, + QueuesClient: &QueuesClient, SubscriptionsClient: &SubscriptionsClient, SubscriptionRulesClient: &SubscriptionRulesClient, + TopicsAuthClient: &TopicsAuthClient, + TopicsClient: &TopicsClient, } } diff --git a/internal/services/servicebus/internal.go b/internal/services/servicebus/internal.go index 22e15c42067f..f60d399a0553 100644 --- a/internal/services/servicebus/internal.go +++ b/internal/services/servicebus/internal.go @@ -7,40 +7,42 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) -func expandAuthorizationRuleRights(d *pluginsdk.ResourceData) *[]servicebus.AccessRights { - rights := make([]servicebus.AccessRights, 0) +func expandAuthorizationRuleRights(d *pluginsdk.ResourceData) *[]namespacesauthorizationrule.AccessRights { + rights := make([]namespacesauthorizationrule.AccessRights, 0) if d.Get("listen").(bool) { - rights = append(rights, servicebus.AccessRightsListen) + rights = append(rights, namespacesauthorizationrule.AccessRightsListen) } if d.Get("send").(bool) { - rights = append(rights, servicebus.AccessRightsSend) + rights = append(rights, namespacesauthorizationrule.AccessRightsSend) } if d.Get("manage").(bool) { - rights = append(rights, servicebus.AccessRightsManage) + rights = append(rights, namespacesauthorizationrule.AccessRightsManage) } return &rights } -func flattenAuthorizationRuleRights(rights *[]servicebus.AccessRights) (listen, send, manage bool) { +func flattenAuthorizationRuleRights(rights *[]namespacesauthorizationrule.AccessRights) (listen, send, manage bool) { // zero (initial) value for a bool in go is false if rights != nil { for _, right := range *rights { switch right { - case servicebus.AccessRightsListen: + case namespacesauthorizationrule.AccessRightsListen: listen = true - case servicebus.AccessRightsSend: + case namespacesauthorizationrule.AccessRightsSend: send = true - case servicebus.AccessRightsManage: + case namespacesauthorizationrule.AccessRightsManage: manage = true default: log.Printf("[DEBUG] Unknown Authorization Rule Right '%s'", right) @@ -116,45 +118,51 @@ func authorizationRuleCustomizeDiff(ctx context.Context, d *pluginsdk.ResourceDi return nil } -func waitForPairedNamespaceReplication(ctx context.Context, meta interface{}, resourceGroup, namespaceName string, timeout time.Duration) error { +func waitForPairedNamespaceReplication(ctx context.Context, meta interface{}, id namespaces.NamespaceId, timeout time.Duration) error { namespaceClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespaceClient.Get(ctx, resourceGroup, namespaceName) + resp, err := namespaceClient.Get(ctx, id) - if !strings.EqualFold(string(namespace.Sku.Name), "Premium") { - return err + if model := resp.Model; model != nil { + if !strings.EqualFold(string(model.Sku.Name), "Premium") { + return err + } } disasterRecoveryClient := meta.(*clients.Client).ServiceBus.DisasterRecoveryConfigsClient - disasterRecoveryResponse, err := disasterRecoveryClient.List(ctx, resourceGroup, namespaceName) - if disasterRecoveryResponse.Values() == nil { + disasterRecoveryNamespaceId := disasterrecoveryconfigs.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + disasterRecoveryResponse, err := disasterRecoveryClient.List(ctx, disasterRecoveryNamespaceId) + + if disasterRecoveryResponse.Model == nil { return err } - if len(disasterRecoveryResponse.Values()) != 1 { + if len(*disasterRecoveryResponse.Model) != 1 { return err } - aliasName := *disasterRecoveryResponse.Values()[0].Name + aliasName := (*disasterRecoveryResponse.Model)[0].Name + + disasterRecoveryConfigId := disasterrecoveryconfigs.NewDisasterRecoveryConfigID(disasterRecoveryNamespaceId.SubscriptionId, disasterRecoveryNamespaceId.ResourceGroupName, disasterRecoveryNamespaceId.NamespaceName, *aliasName) stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{string(servicebus.ProvisioningStateDRAccepted)}, - Target: []string{string(servicebus.ProvisioningStateDRSucceeded)}, + Pending: []string{string(disasterrecoveryconfigs.ProvisioningStateDRAccepted)}, + Target: []string{string(disasterrecoveryconfigs.ProvisioningStateDRSucceeded)}, MinTimeout: 30 * time.Second, Timeout: timeout, Refresh: func() (interface{}, string, error) { - read, err := disasterRecoveryClient.Get(ctx, resourceGroup, namespaceName, aliasName) + resp, err := disasterRecoveryClient.Get(ctx, disasterRecoveryConfigId) if err != nil { - return nil, "error", fmt.Errorf("wait read Service Bus Namespace Disaster Recovery Configs %q (Namespace %q / Resource Group %q): %v", aliasName, namespaceName, resourceGroup, err) + return nil, "error", fmt.Errorf("wait read for %s: %v", disasterRecoveryConfigId, err) } - if props := read.ArmDisasterRecoveryProperties; props != nil { - if props.ProvisioningState == servicebus.ProvisioningStateDRFailed { - return read, "failed", fmt.Errorf("replication for Service Bus Namespace Disaster Recovery Configs %q (Namespace %q / Resource Group %q) failed", aliasName, namespaceName, resourceGroup) + if model := resp.Model; model != nil { + if *model.Properties.ProvisioningState == disasterrecoveryconfigs.ProvisioningStateDRFailed { + return resp, "failed", fmt.Errorf("replication for %s failed", disasterRecoveryConfigId) } - return read, string(props.ProvisioningState), nil + return resp, string(*model.Properties.ProvisioningState), nil } - return read, "nil", fmt.Errorf("waiting for replication error Service Bus Namespace Disaster Recovery Configs %q (Namespace %q / Resource Group %q): provisioning state is nil", aliasName, namespaceName, resourceGroup) + return resp, "nil", fmt.Errorf("waiting for replication error for %s: provisioning state is nil", disasterRecoveryConfigId) }, } diff --git a/internal/services/servicebus/migration/namespace_network_rule_set.go b/internal/services/servicebus/migration/namespace_network_rule_set.go index 47cd705c7cb2..6985a1d00674 100644 --- a/internal/services/servicebus/migration/namespace_network_rule_set.go +++ b/internal/services/servicebus/migration/namespace_network_rule_set.go @@ -4,7 +4,7 @@ import ( "context" "strings" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -70,7 +70,7 @@ func (NamespaceNetworkRuleSetV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { oldId = strings.TrimSuffix(oldId, "/networkrulesets/default") } - id, err := parse.NamespaceID(oldId) + id, err := namespaces.ParseNamespaceID(oldId) if err != nil { return nil, err } diff --git a/internal/services/servicebus/migration/subscription.go b/internal/services/servicebus/migration/subscription.go index 3ef85891f0e3..2931abf633a5 100644 --- a/internal/services/servicebus/migration/subscription.go +++ b/internal/services/servicebus/migration/subscription.go @@ -3,7 +3,7 @@ package migration import ( "context" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -91,7 +91,7 @@ func (ServiceBusSubscriptionV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { oldId := rawState["id"].(string) - id, err := parse.SubscriptionID(oldId) + id, err := subscriptions.ParseSubscriptions2ID(oldId) if err != nil { return nil, err } diff --git a/internal/services/servicebus/parse/namespace.go b/internal/services/servicebus/parse/namespace.go deleted file mode 100644 index 45005b2d4784..000000000000 --- a/internal/services/servicebus/parse/namespace.go +++ /dev/null @@ -1,69 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NamespaceId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewNamespaceID(subscriptionId, resourceGroup, name string) NamespaceId { - return NamespaceId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id NamespaceId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Namespace", segmentsStr) -} - -func (id NamespaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// NamespaceID parses a Namespace ID into an NamespaceId struct -func NamespaceID(input string) (*NamespaceId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := NamespaceId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/namespace_authorization_rule.go b/internal/services/servicebus/parse/namespace_authorization_rule.go deleted file mode 100644 index 325f8b070588..000000000000 --- a/internal/services/servicebus/parse/namespace_authorization_rule.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NamespaceAuthorizationRuleId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - AuthorizationRuleName string -} - -func NewNamespaceAuthorizationRuleID(subscriptionId, resourceGroup, namespaceName, authorizationRuleName string) NamespaceAuthorizationRuleId { - return NamespaceAuthorizationRuleId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - AuthorizationRuleName: authorizationRuleName, - } -} - -func (id NamespaceAuthorizationRuleId) String() string { - segments := []string{ - fmt.Sprintf("Authorization Rule Name %q", id.AuthorizationRuleName), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Namespace Authorization Rule", segmentsStr) -} - -func (id NamespaceAuthorizationRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/AuthorizationRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName) -} - -// NamespaceAuthorizationRuleID parses a NamespaceAuthorizationRule ID into an NamespaceAuthorizationRuleId struct -func NamespaceAuthorizationRuleID(input string) (*NamespaceAuthorizationRuleId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := NamespaceAuthorizationRuleId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.AuthorizationRuleName, err = id.PopSegment("AuthorizationRules"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/namespace_authorization_rule_test.go b/internal/services/servicebus/parse/namespace_authorization_rule_test.go deleted file mode 100644 index 32d21008cb62..000000000000 --- a/internal/services/servicebus/parse/namespace_authorization_rule_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NamespaceAuthorizationRuleId{} - -func TestNamespaceAuthorizationRuleIDFormatter(t *testing.T) { - actual := NewNamespaceAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "authorizationRule1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/AuthorizationRules/authorizationRule1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNamespaceAuthorizationRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NamespaceAuthorizationRuleId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/AuthorizationRules/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/AuthorizationRules/authorizationRule1", - Expected: &NamespaceAuthorizationRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - AuthorizationRuleName: "authorizationRule1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/AUTHORIZATIONRULES/AUTHORIZATIONRULE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NamespaceAuthorizationRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.AuthorizationRuleName != v.Expected.AuthorizationRuleName { - t.Fatalf("Expected %q but got %q for AuthorizationRuleName", v.Expected.AuthorizationRuleName, actual.AuthorizationRuleName) - } - } -} diff --git a/internal/services/servicebus/parse/namespace_disaster_recovery_config.go b/internal/services/servicebus/parse/namespace_disaster_recovery_config.go deleted file mode 100644 index a59b73a345c1..000000000000 --- a/internal/services/servicebus/parse/namespace_disaster_recovery_config.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NamespaceDisasterRecoveryConfigId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - DisasterRecoveryConfigName string -} - -func NewNamespaceDisasterRecoveryConfigID(subscriptionId, resourceGroup, namespaceName, disasterRecoveryConfigName string) NamespaceDisasterRecoveryConfigId { - return NamespaceDisasterRecoveryConfigId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - DisasterRecoveryConfigName: disasterRecoveryConfigName, - } -} - -func (id NamespaceDisasterRecoveryConfigId) String() string { - segments := []string{ - fmt.Sprintf("Disaster Recovery Config Name %q", id.DisasterRecoveryConfigName), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Namespace Disaster Recovery Config", segmentsStr) -} - -func (id NamespaceDisasterRecoveryConfigId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/disasterRecoveryConfigs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) -} - -// NamespaceDisasterRecoveryConfigID parses a NamespaceDisasterRecoveryConfig ID into an NamespaceDisasterRecoveryConfigId struct -func NamespaceDisasterRecoveryConfigID(input string) (*NamespaceDisasterRecoveryConfigId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := NamespaceDisasterRecoveryConfigId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.DisasterRecoveryConfigName, err = id.PopSegment("disasterRecoveryConfigs"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/namespace_disaster_recovery_config_test.go b/internal/services/servicebus/parse/namespace_disaster_recovery_config_test.go deleted file mode 100644 index 758acce562d2..000000000000 --- a/internal/services/servicebus/parse/namespace_disaster_recovery_config_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NamespaceDisasterRecoveryConfigId{} - -func TestNamespaceDisasterRecoveryConfigIDFormatter(t *testing.T) { - actual := NewNamespaceDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "aliasName1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/disasterRecoveryConfigs/aliasName1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNamespaceDisasterRecoveryConfigID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NamespaceDisasterRecoveryConfigId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing DisasterRecoveryConfigName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for DisasterRecoveryConfigName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/disasterRecoveryConfigs/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/disasterRecoveryConfigs/aliasName1", - Expected: &NamespaceDisasterRecoveryConfigId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - DisasterRecoveryConfigName: "aliasName1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/DISASTERRECOVERYCONFIGS/ALIASNAME1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NamespaceDisasterRecoveryConfigID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.DisasterRecoveryConfigName != v.Expected.DisasterRecoveryConfigName { - t.Fatalf("Expected %q but got %q for DisasterRecoveryConfigName", v.Expected.DisasterRecoveryConfigName, actual.DisasterRecoveryConfigName) - } - } -} diff --git a/internal/services/servicebus/parse/namespace_test.go b/internal/services/servicebus/parse/namespace_test.go deleted file mode 100644 index 13c9924c88ce..000000000000 --- a/internal/services/servicebus/parse/namespace_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NamespaceId{} - -func TestNamespaceIDFormatter(t *testing.T) { - actual := NewNamespaceID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNamespaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NamespaceId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1", - Expected: &NamespaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "namespace1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NamespaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/servicebus/parse/queue.go b/internal/services/servicebus/parse/queue.go deleted file mode 100644 index 9fa84b5d2c12..000000000000 --- a/internal/services/servicebus/parse/queue.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type QueueId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - Name string -} - -func NewQueueID(subscriptionId, resourceGroup, namespaceName, name string) QueueId { - return QueueId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - Name: name, - } -} - -func (id QueueId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Queue", segmentsStr) -} - -func (id QueueId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/queues/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.Name) -} - -// QueueID parses a Queue ID into an QueueId struct -func QueueID(input string) (*QueueId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := QueueId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("queues"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/queue_authorization_rule.go b/internal/services/servicebus/parse/queue_authorization_rule.go deleted file mode 100644 index ca370ef9a9b0..000000000000 --- a/internal/services/servicebus/parse/queue_authorization_rule.go +++ /dev/null @@ -1,81 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type QueueAuthorizationRuleId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - QueueName string - AuthorizationRuleName string -} - -func NewQueueAuthorizationRuleID(subscriptionId, resourceGroup, namespaceName, queueName, authorizationRuleName string) QueueAuthorizationRuleId { - return QueueAuthorizationRuleId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - QueueName: queueName, - AuthorizationRuleName: authorizationRuleName, - } -} - -func (id QueueAuthorizationRuleId) String() string { - segments := []string{ - fmt.Sprintf("Authorization Rule Name %q", id.AuthorizationRuleName), - fmt.Sprintf("Queue Name %q", id.QueueName), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Queue Authorization Rule", segmentsStr) -} - -func (id QueueAuthorizationRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/queues/%s/authorizationRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) -} - -// QueueAuthorizationRuleID parses a QueueAuthorizationRule ID into an QueueAuthorizationRuleId struct -func QueueAuthorizationRuleID(input string) (*QueueAuthorizationRuleId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := QueueAuthorizationRuleId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.QueueName, err = id.PopSegment("queues"); err != nil { - return nil, err - } - if resourceId.AuthorizationRuleName, err = id.PopSegment("authorizationRules"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/queue_authorization_rule_test.go b/internal/services/servicebus/parse/queue_authorization_rule_test.go deleted file mode 100644 index 45adfc80c163..000000000000 --- a/internal/services/servicebus/parse/queue_authorization_rule_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = QueueAuthorizationRuleId{} - -func TestQueueAuthorizationRuleIDFormatter(t *testing.T) { - actual := NewQueueAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "queue1", "authorizationRule1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/authorizationRule1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestQueueAuthorizationRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *QueueAuthorizationRuleId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing QueueName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for QueueName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/", - Error: true, - }, - - { - // missing AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/", - Error: true, - }, - - { - // missing value for AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/authorizationRule1", - Expected: &QueueAuthorizationRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - QueueName: "queue1", - AuthorizationRuleName: "authorizationRule1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/QUEUES/QUEUE1/AUTHORIZATIONRULES/AUTHORIZATIONRULE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := QueueAuthorizationRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.QueueName != v.Expected.QueueName { - t.Fatalf("Expected %q but got %q for QueueName", v.Expected.QueueName, actual.QueueName) - } - if actual.AuthorizationRuleName != v.Expected.AuthorizationRuleName { - t.Fatalf("Expected %q but got %q for AuthorizationRuleName", v.Expected.AuthorizationRuleName, actual.AuthorizationRuleName) - } - } -} diff --git a/internal/services/servicebus/parse/queue_test.go b/internal/services/servicebus/parse/queue_test.go deleted file mode 100644 index dc7b6ca3a8e2..000000000000 --- a/internal/services/servicebus/parse/queue_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = QueueId{} - -func TestQueueIDFormatter(t *testing.T) { - actual := NewQueueID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "queue1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestQueueID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *QueueId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1", - Expected: &QueueId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - Name: "queue1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/QUEUES/QUEUE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := QueueID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/servicebus/parse/subscription.go b/internal/services/servicebus/parse/subscription.go deleted file mode 100644 index 702bfa8eb2f2..000000000000 --- a/internal/services/servicebus/parse/subscription.go +++ /dev/null @@ -1,81 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SubscriptionId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - TopicName string - Name string -} - -func NewSubscriptionID(subscriptionId, resourceGroup, namespaceName, topicName, name string) SubscriptionId { - return SubscriptionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - TopicName: topicName, - Name: name, - } -} - -func (id SubscriptionId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Topic Name %q", id.TopicName), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Subscription", segmentsStr) -} - -func (id SubscriptionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/subscriptions/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.TopicName, id.Name) -} - -// SubscriptionID parses a Subscription ID into an SubscriptionId struct -func SubscriptionID(input string) (*SubscriptionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := SubscriptionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.TopicName, err = id.PopSegment("topics"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("subscriptions"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/subscription_rule.go b/internal/services/servicebus/parse/subscription_rule.go deleted file mode 100644 index b7efb103f4da..000000000000 --- a/internal/services/servicebus/parse/subscription_rule.go +++ /dev/null @@ -1,87 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SubscriptionRuleId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - TopicName string - SubscriptionName string - RuleName string -} - -func NewSubscriptionRuleID(subscriptionId, resourceGroup, namespaceName, topicName, subscriptionName, ruleName string) SubscriptionRuleId { - return SubscriptionRuleId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - TopicName: topicName, - SubscriptionName: subscriptionName, - RuleName: ruleName, - } -} - -func (id SubscriptionRuleId) String() string { - segments := []string{ - fmt.Sprintf("Rule Name %q", id.RuleName), - fmt.Sprintf("Subscription Name %q", id.SubscriptionName), - fmt.Sprintf("Topic Name %q", id.TopicName), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Subscription Rule", segmentsStr) -} - -func (id SubscriptionRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/subscriptions/%s/rules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.TopicName, id.SubscriptionName, id.RuleName) -} - -// SubscriptionRuleID parses a SubscriptionRule ID into an SubscriptionRuleId struct -func SubscriptionRuleID(input string) (*SubscriptionRuleId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := SubscriptionRuleId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.TopicName, err = id.PopSegment("topics"); err != nil { - return nil, err - } - if resourceId.SubscriptionName, err = id.PopSegment("subscriptions"); err != nil { - return nil, err - } - if resourceId.RuleName, err = id.PopSegment("rules"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/subscription_rule_test.go b/internal/services/servicebus/parse/subscription_rule_test.go deleted file mode 100644 index 8c2decf81422..000000000000 --- a/internal/services/servicebus/parse/subscription_rule_test.go +++ /dev/null @@ -1,160 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SubscriptionRuleId{} - -func TestSubscriptionRuleIDFormatter(t *testing.T) { - actual := NewSubscriptionRuleID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "topic1", "subscription1", "rule1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/rules/rule1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSubscriptionRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SubscriptionRuleId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Error: true, - }, - - { - // missing SubscriptionName - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/", - Error: true, - }, - - { - // missing RuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/", - Error: true, - }, - - { - // missing value for RuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/rules/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/rules/rule1", - Expected: &SubscriptionRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - TopicName: "topic1", - SubscriptionName: "subscription1", - RuleName: "rule1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1/SUBSCRIPTIONS/SUBSCRIPTION1/RULES/RULE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SubscriptionRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.TopicName != v.Expected.TopicName { - t.Fatalf("Expected %q but got %q for TopicName", v.Expected.TopicName, actual.TopicName) - } - if actual.SubscriptionName != v.Expected.SubscriptionName { - t.Fatalf("Expected %q but got %q for SubscriptionName", v.Expected.SubscriptionName, actual.SubscriptionName) - } - if actual.RuleName != v.Expected.RuleName { - t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) - } - } -} diff --git a/internal/services/servicebus/parse/subscription_test.go b/internal/services/servicebus/parse/subscription_test.go deleted file mode 100644 index b678737d3eae..000000000000 --- a/internal/services/servicebus/parse/subscription_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SubscriptionId{} - -func TestSubscriptionIDFormatter(t *testing.T) { - actual := NewSubscriptionID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "topic1", "subscription1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSubscriptionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SubscriptionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Error: true, - }, - - { - // missing Name - Input: "/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1", - Expected: &SubscriptionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - TopicName: "topic1", - Name: "subscription1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1/SUBSCRIPTIONS/SUBSCRIPTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SubscriptionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.TopicName != v.Expected.TopicName { - t.Fatalf("Expected %q but got %q for TopicName", v.Expected.TopicName, actual.TopicName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/servicebus/parse/topic.go b/internal/services/servicebus/parse/topic.go deleted file mode 100644 index e3a5c82c6e59..000000000000 --- a/internal/services/servicebus/parse/topic.go +++ /dev/null @@ -1,75 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type TopicId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - Name string -} - -func NewTopicID(subscriptionId, resourceGroup, namespaceName, name string) TopicId { - return TopicId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - Name: name, - } -} - -func (id TopicId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Topic", segmentsStr) -} - -func (id TopicId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.Name) -} - -// TopicID parses a Topic ID into an TopicId struct -func TopicID(input string) (*TopicId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := TopicId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("topics"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/topic_authorization_rule.go b/internal/services/servicebus/parse/topic_authorization_rule.go deleted file mode 100644 index acfae9a687fd..000000000000 --- a/internal/services/servicebus/parse/topic_authorization_rule.go +++ /dev/null @@ -1,81 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type TopicAuthorizationRuleId struct { - SubscriptionId string - ResourceGroup string - NamespaceName string - TopicName string - AuthorizationRuleName string -} - -func NewTopicAuthorizationRuleID(subscriptionId, resourceGroup, namespaceName, topicName, authorizationRuleName string) TopicAuthorizationRuleId { - return TopicAuthorizationRuleId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - NamespaceName: namespaceName, - TopicName: topicName, - AuthorizationRuleName: authorizationRuleName, - } -} - -func (id TopicAuthorizationRuleId) String() string { - segments := []string{ - fmt.Sprintf("Authorization Rule Name %q", id.AuthorizationRuleName), - fmt.Sprintf("Topic Name %q", id.TopicName), - fmt.Sprintf("Namespace Name %q", id.NamespaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Topic Authorization Rule", segmentsStr) -} - -func (id TopicAuthorizationRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/authorizationRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) -} - -// TopicAuthorizationRuleID parses a TopicAuthorizationRule ID into an TopicAuthorizationRuleId struct -func TopicAuthorizationRuleID(input string) (*TopicAuthorizationRuleId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := TopicAuthorizationRuleId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.NamespaceName, err = id.PopSegment("namespaces"); err != nil { - return nil, err - } - if resourceId.TopicName, err = id.PopSegment("topics"); err != nil { - return nil, err - } - if resourceId.AuthorizationRuleName, err = id.PopSegment("authorizationRules"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/servicebus/parse/topic_authorization_rule_test.go b/internal/services/servicebus/parse/topic_authorization_rule_test.go deleted file mode 100644 index 9ea7d5ac2ec1..000000000000 --- a/internal/services/servicebus/parse/topic_authorization_rule_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = TopicAuthorizationRuleId{} - -func TestTopicAuthorizationRuleIDFormatter(t *testing.T) { - actual := NewTopicAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "topic1", "authorizationRule1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/authorizationRules/authorizationRule1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestTopicAuthorizationRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *TopicAuthorizationRuleId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Error: true, - }, - - { - // missing AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/", - Error: true, - }, - - { - // missing value for AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/authorizationRules/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/authorizationRules/authorizationRule1", - Expected: &TopicAuthorizationRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - TopicName: "topic1", - AuthorizationRuleName: "authorizationRule1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1/AUTHORIZATIONRULES/AUTHORIZATIONRULE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := TopicAuthorizationRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.TopicName != v.Expected.TopicName { - t.Fatalf("Expected %q but got %q for TopicName", v.Expected.TopicName, actual.TopicName) - } - if actual.AuthorizationRuleName != v.Expected.AuthorizationRuleName { - t.Fatalf("Expected %q but got %q for AuthorizationRuleName", v.Expected.AuthorizationRuleName, actual.AuthorizationRuleName) - } - } -} diff --git a/internal/services/servicebus/parse/topic_test.go b/internal/services/servicebus/parse/topic_test.go deleted file mode 100644 index 140bdffea5c1..000000000000 --- a/internal/services/servicebus/parse/topic_test.go +++ /dev/null @@ -1,128 +0,0 @@ -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = TopicId{} - -func TestTopicIDFormatter(t *testing.T) { - actual := NewTopicID("12345678-1234-9876-4563-123456789012", "resGroup1", "namespace1", "topic1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestTopicID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *TopicId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Error: true, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1", - Expected: &TopicId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - NamespaceName: "namespace1", - Name: "topic1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := TopicID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.NamespaceName != v.Expected.NamespaceName { - t.Fatalf("Expected %q but got %q for NamespaceName", v.Expected.NamespaceName, actual.NamespaceName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/servicebus/resourceids.go b/internal/services/servicebus/resourceids.go deleted file mode 100644 index 42deadafb285..000000000000 --- a/internal/services/servicebus/resourceids.go +++ /dev/null @@ -1,11 +0,0 @@ -package servicebus - -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Queue -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=QueueAuthorizationRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/authorizationRule1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NamespaceDisasterRecoveryConfig -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/disasterRecoveryConfigs/aliasName1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Namespace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NamespaceAuthorizationRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/AuthorizationRules/authorizationRule1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Subscription -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SubscriptionRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/rules/rule1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Topic -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=TopicAuthorizationRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/authorizationRules/authorizationRule1 diff --git a/internal/services/servicebus/servicebus_namespace_authorization_rule_data_source.go b/internal/services/servicebus/servicebus_namespace_authorization_rule_data_source.go index cb9b9c90b8d1..fafe01287535 100644 --- a/internal/services/servicebus/servicebus_namespace_authorization_rule_data_source.go +++ b/internal/services/servicebus/servicebus_namespace_authorization_rule_data_source.go @@ -4,13 +4,14 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusNamespaceAuthorizationRule() *pluginsdk.Resource { @@ -30,7 +31,7 @@ func dataSourceServiceBusNamespaceAuthorizationRule() *pluginsdk.Resource { "namespace_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"}, }, @@ -88,7 +89,7 @@ func dataSourceServiceBusNamespaceAuthorizationRule() *pluginsdk.Resource { } func dataSourceServiceBusNamespaceAuthorizationRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.NamespacesClient + client := meta.(*clients.Client).ServiceBus.NamespacesAuthClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -96,40 +97,42 @@ func dataSourceServiceBusNamespaceAuthorizationRuleRead(d *pluginsdk.ResourceDat var resourceGroup string var namespaceName string if v, ok := d.Get("namespace_id").(string); ok && v != "" { - namespaceId, err := parse.NamespaceID(v) + namespaceId, err := namespacesauthorizationrule.ParseNamespaceID(v) if err != nil { - return fmt.Errorf("parsing topic ID %q: %+v", v, err) + return err } - resourceGroup = namespaceId.ResourceGroup - namespaceName = namespaceId.Name + resourceGroup = namespaceId.ResourceGroupName + namespaceName = namespaceId.NamespaceName } else { resourceGroup = d.Get("resource_group_name").(string) namespaceName = d.Get("namespace_name").(string) } - name := d.Get("name").(string) - id := parse.NewNamespaceAuthorizationRuleID(subscriptionId, resourceGroup, namespaceName, name) + id := namespacesauthorizationrule.NewAuthorizationRuleID(subscriptionId, resourceGroup, namespaceName, d.Get("name").(string)) - resp, err := client.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName) + resp, err := client.NamespacesGetAuthorizationRule(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } - keysResp, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName) + keysResp, err := client.NamespacesListKeys(ctx, id) if err != nil { return fmt.Errorf("listing keys for %s: %+v", id, err) } + if model := keysResp.Model; model != nil { + d.Set("primary_key", model.PrimaryKey) + d.Set("primary_connection_string", model.PrimaryConnectionString) + d.Set("secondary_key", model.SecondaryKey) + d.Set("secondary_connection_string", model.SecondaryConnectionString) + d.Set("primary_connection_string_alias", model.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", model.AliasSecondaryConnectionString) + } + d.SetId(id.ID()) - d.Set("primary_key", keysResp.PrimaryKey) - d.Set("primary_connection_string", keysResp.PrimaryConnectionString) - d.Set("secondary_key", keysResp.SecondaryKey) - d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) - d.Set("primary_connection_string_alias", keysResp.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keysResp.AliasSecondaryConnectionString) return nil } diff --git a/internal/services/servicebus/servicebus_namespace_authorization_rule_resource.go b/internal/services/servicebus/servicebus_namespace_authorization_rule_resource.go index 974716bd9706..3696264ad25d 100644 --- a/internal/services/servicebus/servicebus_namespace_authorization_rule_resource.go +++ b/internal/services/servicebus/servicebus_namespace_authorization_rule_resource.go @@ -2,13 +2,13 @@ package servicebus import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -23,7 +23,7 @@ func resourceServiceBusNamespaceAuthorizationRule() *pluginsdk.Resource { Delete: resourceServiceBusNamespaceAuthorizationRuleDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.NamespaceAuthorizationRuleID(id) + _, err := namespacesauthorizationrule.ParseAuthorizationRuleID(id) return err }), @@ -54,117 +54,122 @@ func resourceServiceBusNamespaceAuthorizationRuleSchema() map[string]*pluginsdk. Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, }, }) } func resourceServiceBusNamespaceAuthorizationRuleCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.NamespacesClient + client := meta.(*clients.Client).ServiceBus.NamespacesAuthClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for ServiceBus Namespace Authorization Rule create/update.") - - var resourceId parse.NamespaceAuthorizationRuleId - if namespaceIdLit := d.Get("namespace_id").(string); namespaceIdLit != "" { - namespaceId, _ := parse.NamespaceID(namespaceIdLit) - resourceId = parse.NewNamespaceAuthorizationRuleID(namespaceId.SubscriptionId, namespaceId.ResourceGroup, namespaceId.Name, d.Get("name").(string)) + namespaceAuthId, err := namespacesauthorizationrule.ParseNamespaceID(d.Get("namespace_id").(string)) + if err != nil { + return err } + id := namespacesauthorizationrule.NewAuthorizationRuleID(namespaceAuthId.SubscriptionId, namespaceAuthId.ResourceGroupName, namespaceAuthId.NamespaceName, d.Get("name").(string)) + if d.IsNewResource() { - existing, err := client.GetAuthorizationRule(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.AuthorizationRuleName) + existing, err := client.NamespacesGetAuthorizationRule(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_namespace_authorization_rule", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_namespace_authorization_rule", id.ID()) } } - parameters := servicebus.SBAuthorizationRule{ - Name: utils.String(resourceId.AuthorizationRuleName), - SBAuthorizationRuleProperties: &servicebus.SBAuthorizationRuleProperties{ - Rights: expandAuthorizationRuleRights(d), + parameters := namespacesauthorizationrule.SBAuthorizationRule{ + Name: utils.String(id.AuthorizationRuleName), + Properties: &namespacesauthorizationrule.SBAuthorizationRuleProperties{ + Rights: *expandAuthorizationRuleRights(d), }, } - if _, err := client.CreateOrUpdateAuthorizationRule(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.AuthorizationRuleName, parameters); err != nil { - return fmt.Errorf("creating/updating %s: %+v", resourceId, err) + if _, err := client.NamespacesCreateOrUpdateAuthorizationRule(ctx, id, parameters); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - if err := waitForPairedNamespaceReplication(ctx, meta, resourceId.ResourceGroup, resourceId.NamespaceName, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { - return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", resourceId.NamespaceName, resourceId.ResourceGroup, err) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + if err := waitForPairedNamespaceReplication(ctx, meta, namespaceId, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { + return fmt.Errorf("waiting for replication to complete for %s: %+v", id, err) } return resourceServiceBusNamespaceAuthorizationRuleRead(d, meta) } func resourceServiceBusNamespaceAuthorizationRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.NamespacesClient + client := meta.(*clients.Client).ServiceBus.NamespacesAuthClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceAuthorizationRuleID(d.Id()) + id, err := namespacesauthorizationrule.ParseAuthorizationRuleID(d.Id()) if err != nil { return err } - resp, err := client.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName) + resp, err := client.NamespacesGetAuthorizationRule(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - keysResp, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName) + d.Set("name", id.AuthorizationRuleName) + d.Set("namespace_id", namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName).ID()) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + listen, send, manage := flattenAuthorizationRuleRights(&props.Rights) + d.Set("manage", manage) + d.Set("listen", listen) + d.Set("send", send) + } + } + + keysResp, err := client.NamespacesListKeys(ctx, *id) if err != nil { return fmt.Errorf("listing keys for %s: %+v", id, err) } - d.Set("name", id.AuthorizationRuleName) - d.Set("namespace_id", parse.NewNamespaceID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName).ID()) - - if properties := resp.SBAuthorizationRuleProperties; properties != nil { - listen, send, manage := flattenAuthorizationRuleRights(properties.Rights) - d.Set("manage", manage) - d.Set("listen", listen) - d.Set("send", send) + if keysModel := keysResp.Model; keysModel != nil { + d.Set("primary_key", keysModel.PrimaryKey) + d.Set("primary_connection_string", keysModel.PrimaryConnectionString) + d.Set("secondary_key", keysModel.SecondaryKey) + d.Set("secondary_connection_string", keysModel.SecondaryConnectionString) + d.Set("primary_connection_string_alias", keysModel.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", keysModel.AliasSecondaryConnectionString) } - d.Set("primary_key", keysResp.PrimaryKey) - d.Set("primary_connection_string", keysResp.PrimaryConnectionString) - d.Set("secondary_key", keysResp.SecondaryKey) - d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) - d.Set("primary_connection_string_alias", keysResp.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keysResp.AliasSecondaryConnectionString) - return nil } func resourceServiceBusNamespaceAuthorizationRuleDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.NamespacesClient + client := meta.(*clients.Client).ServiceBus.NamespacesAuthClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceAuthorizationRuleID(d.Id()) + id, err := namespacesauthorizationrule.ParseAuthorizationRuleID(d.Id()) if err != nil { return err } - if _, err = client.DeleteAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName); err != nil { + if _, err = client.NamespacesDeleteAuthorizationRule(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) } - if err := waitForPairedNamespaceReplication(ctx, meta, id.ResourceGroup, id.NamespaceName, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { - return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", id.NamespaceName, id.ResourceGroup, err) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + if err := waitForPairedNamespaceReplication(ctx, meta, namespaceId, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { + return fmt.Errorf("waiting for replication to complete for %s: %+v", *id, err) } return nil diff --git a/internal/services/servicebus/servicebus_namespace_authorization_rule_resource_test.go b/internal/services/servicebus/servicebus_namespace_authorization_rule_resource_test.go index 0ae55a0204b0..8e328afcb565 100644 --- a/internal/services/servicebus/servicebus_namespace_authorization_rule_resource_test.go +++ b/internal/services/servicebus/servicebus_namespace_authorization_rule_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -103,17 +103,17 @@ func TestAccServiceBusNamespaceAuthorizationRule_requiresImport(t *testing.T) { } func (t ServiceBusNamespaceAuthorizationRuleResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.NamespaceAuthorizationRuleID(state.ID) + id, err := namespacesauthorizationrule.ParseAuthorizationRuleID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.NamespacesClient.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.AuthorizationRuleName) + resp, err := clients.ServiceBus.NamespacesAuthClient.NamespacesGetAuthorizationRule(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus Name Space Authorization Rule (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusNamespaceAuthorizationRuleResource) base(data acceptance.TestData, listen, send, manage bool) string { diff --git a/internal/services/servicebus/servicebus_namespace_data_source.go b/internal/services/servicebus/servicebus_namespace_data_source.go index 78d7af144721..115a53377a9e 100644 --- a/internal/services/servicebus/servicebus_namespace_data_source.go +++ b/internal/services/servicebus/servicebus_namespace_data_source.go @@ -5,14 +5,15 @@ import ( "log" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusNamespace() *pluginsdk.Resource { @@ -82,15 +83,15 @@ func dataSourceServiceBusNamespace() *pluginsdk.Resource { func dataSourceServiceBusNamespaceRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).ServiceBus.NamespacesClient - clientStable := meta.(*clients.Client).ServiceBus.NamespacesClient + namespaceAuthClient := meta.(*clients.Client).ServiceBus.NamespacesAuthClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewNamespaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + id := namespaces.NewNamespaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } @@ -98,25 +99,31 @@ func dataSourceServiceBusNamespaceRead(d *pluginsdk.ResourceData, meta interface } d.SetId(id.ID()) - d.Set("location", location.NormalizeNilable(resp.Location)) + if model := resp.Model; model != nil { + d.Set("location", location.Normalize(model.Location)) - if sku := resp.Sku; sku != nil { - d.Set("sku", string(sku.Name)) - d.Set("capacity", sku.Capacity) - } + if sku := model.Sku; sku != nil { + d.Set("sku", string(sku.Name)) + d.Set("capacity", sku.Capacity) + } - if properties := resp.SBNamespaceProperties; properties != nil { - d.Set("zone_redundant", properties.ZoneRedundant) + if props := model.Properties; props != nil { + d.Set("zone_redundant", props.ZoneRedundant) + } } - keys, err := clientStable.ListKeys(ctx, id.ResourceGroup, id.Name, serviceBusNamespaceDefaultAuthorizationRule) + authRuleId := namespacesauthorizationrule.NewAuthorizationRuleID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, serviceBusNamespaceDefaultAuthorizationRule) + + keys, err := namespaceAuthClient.NamespacesListKeys(ctx, authRuleId) if err != nil { log.Printf("[WARN] listing default keys for %s: %+v", id, err) } else { - d.Set("default_primary_connection_string", keys.PrimaryConnectionString) - d.Set("default_secondary_connection_string", keys.SecondaryConnectionString) - d.Set("default_primary_key", keys.PrimaryKey) - d.Set("default_secondary_key", keys.SecondaryKey) + if keysModel := keys.Model; keysModel != nil { + d.Set("default_primary_connection_string", keysModel.PrimaryConnectionString) + d.Set("default_secondary_connection_string", keysModel.SecondaryConnectionString) + d.Set("default_primary_key", keysModel.PrimaryKey) + d.Set("default_secondary_key", keysModel.SecondaryKey) + } } return nil diff --git a/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_data_source.go b/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_data_source.go index 3f2ffb0f38c8..0f1c0d071c3f 100644 --- a/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_data_source.go +++ b/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_data_source.go @@ -5,13 +5,14 @@ import ( "log" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusNamespaceDisasterRecoveryConfig() *pluginsdk.Resource { @@ -31,7 +32,7 @@ func dataSourceServiceBusNamespaceDisasterRecoveryConfig() *pluginsdk.Resource { "namespace_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"}, }, @@ -90,42 +91,50 @@ func dataSourceServiceBusNamespaceDisasterRecoveryConfigRead(d *pluginsdk.Resour var resourceGroup string var namespaceName string if v, ok := d.Get("namespace_id").(string); ok && v != "" { - namespaceId, err := parse.NamespaceID(v) + namespaceId, err := disasterrecoveryconfigs.ParseNamespaceID(v) if err != nil { return fmt.Errorf("parsing topic ID %q: %+v", v, err) } - resourceGroup = namespaceId.ResourceGroup - namespaceName = namespaceId.Name + resourceGroup = namespaceId.ResourceGroupName + namespaceName = namespaceId.NamespaceName } else { resourceGroup = d.Get("resource_group_name").(string) namespaceName = d.Get("namespace_name").(string) } - name := d.Get("name").(string) - id := parse.NewNamespaceDisasterRecoveryConfigID(subscriptionId, resourceGroup, namespaceName, name) - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID(subscriptionId, resourceGroup, namespaceName, d.Get("name").(string)) + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.DisasterRecoveryConfigName) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("name", id.Alias) + d.Set("resource_group_name", id.ResourceGroupName) d.Set("namespace_name", id.NamespaceName) - d.Set("partner_namespace_id", resp.ArmDisasterRecoveryProperties.PartnerNamespace) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("partner_namespace_id", props.PartnerNamespace) + } + } + d.SetId(id.ID()) - keys, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName, serviceBusNamespaceDefaultAuthorizationRule) + authRuleId := disasterrecoveryconfigs.NewAuthorizationRuleID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, d.Get("name").(string)) + keys, err := client.ListKeys(ctx, authRuleId) if err != nil { log.Printf("[WARN] listing default keys for %s: %+v", id, err) } else { - d.Set("primary_connection_string_alias", keys.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keys.AliasSecondaryConnectionString) - d.Set("default_primary_key", keys.PrimaryKey) - d.Set("default_secondary_key", keys.SecondaryKey) + if keysModel := keys.Model; keysModel != nil { + d.Set("primary_connection_string_alias", keysModel.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", keysModel.AliasSecondaryConnectionString) + d.Set("default_primary_key", keysModel.PrimaryKey) + d.Set("default_secondary_key", keysModel.SecondaryKey) + } } return nil } diff --git a/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_resource.go b/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_resource.go index 2982366c816d..2593ce4314f3 100644 --- a/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_resource.go +++ b/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_resource.go @@ -8,12 +8,12 @@ import ( "strconv" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -29,7 +29,7 @@ func resourceServiceBusNamespaceDisasterRecoveryConfig() *pluginsdk.Resource { Delete: resourceServiceBusNamespaceDisasterRecoveryConfigDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.NamespaceDisasterRecoveryConfigID(id) + _, err := disasterrecoveryconfigs.ParseDisasterRecoveryConfigID(id) return err }), @@ -91,34 +91,34 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigCreate(d *pluginsdk.Resour ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - namespaceId, err := parse.NamespaceID(d.Get("primary_namespace_id").(string)) + namespaceId, err := disasterrecoveryconfigs.ParseNamespaceID(d.Get("primary_namespace_id").(string)) if err != nil { return err } partnerNamespaceId := d.Get("partner_namespace_id").(string) - id := parse.NewNamespaceDisasterRecoveryConfigID(namespaceId.SubscriptionId, namespaceId.ResourceGroup, namespaceId.Name, d.Get("name").(string)) + id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID(namespaceId.SubscriptionId, namespaceId.ResourceGroupName, namespaceId.NamespaceName, d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_servicebus_namespace_disaster_recovery_config", id.ID()) } } - parameters := servicebus.ArmDisasterRecovery{ - ArmDisasterRecoveryProperties: &servicebus.ArmDisasterRecoveryProperties{ + parameters := disasterrecoveryconfigs.ArmDisasterRecovery{ + Properties: &disasterrecoveryconfigs.ArmDisasterRecoveryProperties{ PartnerNamespace: utils.String(partnerNamespaceId), }, } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName, parameters); err != nil { + if _, err := client.CreateOrUpdate(ctx, id, parameters); err != nil { return fmt.Errorf("creating/updating %s: %+v", id, err) } @@ -135,7 +135,7 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigUpdate(d *pluginsdk.Resour ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceDisasterRecoveryConfigID(d.State().ID) + id, err := disasterrecoveryconfigs.ParseDisasterRecoveryConfigID(d.State().ID) if err != nil { return err } @@ -144,7 +144,7 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigUpdate(d *pluginsdk.Resour defer locks.UnlockByName(id.NamespaceName, serviceBusNamespaceResourceName) if d.HasChange("partner_namespace_id") { - if _, err := client.BreakPairing(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName); err != nil { + if _, err := client.BreakPairing(ctx, *id); err != nil { return fmt.Errorf("breaking the pairing for %s: %+v", *id, err) } if err := resourceServiceBusNamespaceDisasterRecoveryConfigWaitForState(ctx, client, *id); err != nil { @@ -152,13 +152,13 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigUpdate(d *pluginsdk.Resour } } - parameters := servicebus.ArmDisasterRecovery{ - ArmDisasterRecoveryProperties: &servicebus.ArmDisasterRecoveryProperties{ + parameters := disasterrecoveryconfigs.ArmDisasterRecovery{ + Properties: &disasterrecoveryconfigs.ArmDisasterRecoveryProperties{ PartnerNamespace: utils.String(d.Get("partner_namespace_id").(string)), }, } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName, parameters); err != nil { + if _, err := client.CreateOrUpdate(ctx, *id, parameters); err != nil { return fmt.Errorf("creating/updating %s: %+v", *id, err) } if err := resourceServiceBusNamespaceDisasterRecoveryConfigWaitForState(ctx, client, *id); err != nil { @@ -173,38 +173,44 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigRead(d *pluginsdk.Resource ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceDisasterRecoveryConfigID(d.Id()) + id, err := disasterrecoveryconfigs.ParseDisasterRecoveryConfigID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - primaryId := parse.NewNamespaceID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName) + primaryId := disasterrecoveryconfigs.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) - d.Set("name", id.DisasterRecoveryConfigName) + d.Set("name", id.Alias) d.Set("primary_namespace_id", primaryId.ID()) - if props := resp.ArmDisasterRecoveryProperties; props != nil { - d.Set("partner_namespace_id", props.PartnerNamespace) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("partner_namespace_id", props.PartnerNamespace) + } } - keys, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName, serviceBusNamespaceDefaultAuthorizationRule) + authRuleId := disasterrecoveryconfigs.NewAuthorizationRuleID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.Alias) + + keys, err := client.ListKeys(ctx, authRuleId) if err != nil { log.Printf("[WARN] listing default keys for %s: %+v", id, err) } else { - d.Set("primary_connection_string_alias", keys.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keys.AliasSecondaryConnectionString) - d.Set("default_primary_key", keys.PrimaryKey) - d.Set("default_secondary_key", keys.SecondaryKey) + if keysModel := keys.Model; keysModel != nil { + d.Set("primary_connection_string_alias", keysModel.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", keysModel.AliasSecondaryConnectionString) + d.Set("default_primary_key", keysModel.PrimaryKey) + d.Set("default_secondary_key", keysModel.SecondaryKey) + } } return nil @@ -215,17 +221,17 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigDelete(d *pluginsdk.Resour ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceDisasterRecoveryConfigID(d.Id()) + id, err := disasterrecoveryconfigs.ParseDisasterRecoveryConfigID(d.Id()) if err != nil { return err } - breakPair, err := client.BreakPairing(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + breakPair, err := client.BreakPairing(ctx, *id) if err != nil { return fmt.Errorf("breaking pairing %s: %+v", id, err) } - if breakPair.StatusCode != http.StatusOK { + if breakPair.HttpResponse.StatusCode != http.StatusOK { return fmt.Errorf("breaking pairing for %s: %+v", *id, err) } @@ -233,7 +239,7 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigDelete(d *pluginsdk.Resour return fmt.Errorf("waiting for the pairing to break for %s: %+v", *id, err) } - if _, err := client.Delete(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName); err != nil { + if _, err := client.Delete(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } @@ -244,15 +250,15 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigDelete(d *pluginsdk.Resour MinTimeout: 30 * time.Second, Timeout: d.Timeout(pluginsdk.TimeoutDelete), Refresh: func() (interface{}, string, error) { - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return resp, strconv.Itoa(resp.StatusCode), nil + if response.WasNotFound(resp.HttpResponse) { + return resp, strconv.Itoa(resp.HttpResponse.StatusCode), nil } return nil, "nil", fmt.Errorf("retrieving %s: %+v", *id, err) } - return resp, strconv.Itoa(resp.StatusCode), nil + return resp, strconv.Itoa(resp.HttpResponse.StatusCode), nil }, } @@ -260,6 +266,7 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigDelete(d *pluginsdk.Resour return fmt.Errorf("waiting the deletion of %s: %v", *id, err) } + namespaceId := disasterrecoveryconfigs.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) // it can take some time for the name to become available again // this is mainly here to enable updating the resource in place nameFreeWait := &pluginsdk.StateChangeConf{ @@ -268,12 +275,18 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigDelete(d *pluginsdk.Resour MinTimeout: 30 * time.Second, Timeout: d.Timeout(pluginsdk.TimeoutDelete), Refresh: func() (interface{}, string, error) { - resp, err := client.CheckNameAvailabilityMethod(ctx, id.ResourceGroup, id.NamespaceName, servicebus.CheckNameAvailability{Name: utils.String(id.DisasterRecoveryConfigName)}) + resp, err := client.CheckNameAvailability(ctx, namespaceId, disasterrecoveryconfigs.CheckNameAvailability{Name: id.Alias}) if err != nil { return resp, "Error", fmt.Errorf("checking for the status of %s: %+v", *id, err) } - return resp, string(resp.Reason), nil + reason := "" + if model := resp.Model; model != nil { + if v := model.Reason; v != nil { + reason = string(*v) + } + } + return resp, reason, nil }, } @@ -284,30 +297,32 @@ func resourceServiceBusNamespaceDisasterRecoveryConfigDelete(d *pluginsdk.Resour return nil } -func resourceServiceBusNamespaceDisasterRecoveryConfigWaitForState(ctx context.Context, client *servicebus.DisasterRecoveryConfigsClient, id parse.NamespaceDisasterRecoveryConfigId) error { +func resourceServiceBusNamespaceDisasterRecoveryConfigWaitForState(ctx context.Context, client *disasterrecoveryconfigs.DisasterRecoveryConfigsClient, id disasterrecoveryconfigs.DisasterRecoveryConfigId) error { deadline, ok := ctx.Deadline() if !ok { return fmt.Errorf("context had no deadline") } stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{string(servicebus.ProvisioningStateDRAccepted)}, - Target: []string{string(servicebus.ProvisioningStateDRSucceeded)}, + Pending: []string{string(disasterrecoveryconfigs.ProvisioningStateDRAccepted)}, + Target: []string{string(disasterrecoveryconfigs.ProvisioningStateDRSucceeded)}, MinTimeout: 30 * time.Second, Timeout: time.Until(deadline), Refresh: func() (interface{}, string, error) { - read, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + resp, err := client.Get(ctx, id) if err != nil { return nil, "error", fmt.Errorf("retrieving %s: %+v", id, err) } - if props := read.ArmDisasterRecoveryProperties; props != nil { - if props.ProvisioningState == servicebus.ProvisioningStateDRFailed { - return read, "failed", fmt.Errorf("replication Failed for %s: %+v", id, err) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + if *props.ProvisioningState == disasterrecoveryconfigs.ProvisioningStateDRFailed { + return resp, "failed", fmt.Errorf("replication Failed for %s: %+v", id, err) + } + return resp, string(*props.ProvisioningState), nil } - return read, string(props.ProvisioningState), nil } - return read, "nil", fmt.Errorf("waiting on replication of %s: %+v", id, err) + return resp, "nil", fmt.Errorf("waiting on replication of %s: %+v", id, err) }, } diff --git a/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_test.go b/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_test.go index 48f4503b2586..5953ef7781ea 100644 --- a/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_test.go +++ b/internal/services/servicebus/servicebus_namespace_disaster_recovery_config_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -30,17 +30,17 @@ func TestAccAzureRMServiceBusNamespacePairing_basic(t *testing.T) { } func (t ServiceBusNamespaceDisasterRecoveryConfigResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.NamespaceDisasterRecoveryConfigID(state.ID) + id, err := disasterrecoveryconfigs.ParseDisasterRecoveryConfigID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.DisasterRecoveryConfigsClient.Get(ctx, id.ResourceGroup, id.NamespaceName, id.DisasterRecoveryConfigName) + resp, err := clients.ServiceBus.DisasterRecoveryConfigsClient.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus NameSpace (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusNamespaceDisasterRecoveryConfigResource) basic(data acceptance.TestData) string { diff --git a/internal/services/servicebus/servicebus_namespace_network_rule_set_resource.go b/internal/services/servicebus/servicebus_namespace_network_rule_set_resource.go index 110d31510532..6e6c19d481a5 100644 --- a/internal/services/servicebus/servicebus_namespace_network_rule_set_resource.go +++ b/internal/services/servicebus/servicebus_namespace_network_rule_set_resource.go @@ -6,13 +6,12 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" validateNetwork "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/set" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -29,7 +28,7 @@ func resourceServiceBusNamespaceNetworkRuleSet() *pluginsdk.Resource { Delete: resourceServiceBusNamespaceNetworkRuleSetDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.NamespaceID(id) + _, err := namespaces.ParseNamespaceID(id) return err }), @@ -56,16 +55,16 @@ func resourceServicebusNamespaceNetworkRuleSetSchema() map[string]*pluginsdk.Sch Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, }, "default_action": { Type: pluginsdk.TypeString, Optional: true, - Default: string(servicebus.DefaultActionAllow), + Default: string(namespaces.DefaultActionAllow), ValidateFunc: validation.StringInSlice([]string{ - string(servicebus.DefaultActionAllow), - string(servicebus.DefaultActionDeny), + string(namespaces.DefaultActionAllow), + string(namespaces.DefaultActionDeny), }, false), }, @@ -118,27 +117,29 @@ func resourceServiceBusNamespaceNetworkRuleSetCreateUpdate(d *pluginsdk.Resource ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceID(d.Get("namespace_id").(string)) + id, err := namespaces.ParseNamespaceID(d.Get("namespace_id").(string)) if err != nil { return err } if d.IsNewResource() { - existing, err := client.GetNetworkRuleSet(ctx, id.ResourceGroup, id.Name) + existing, err := client.GetNetworkRuleSet(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for the presence of existing %s: %+v", id, err) } } // This resource is unique to the corresponding service bus namespace. // It will be created automatically along with the namespace, therefore we check whether this resource is identical to a "deleted" one - if !CheckNetworkRuleNullified(existing) { - return tf.ImportAsExistsError("azurerm_servicebus_namespace_network_rule_set", id.ID()) + if model := existing.Model; model != nil { + if !CheckNetworkRuleNullified(*model) { + return tf.ImportAsExistsError("azurerm_servicebus_namespace_network_rule_set", id.ID()) + } } } - defaultAction := servicebus.DefaultAction(d.Get("default_action").(string)) + defaultAction := namespaces.DefaultAction(d.Get("default_action").(string)) vnetRule := expandServiceBusNamespaceVirtualNetworkRules(d.Get("network_rules").(*pluginsdk.Set).List()) ipRule := expandServiceBusNamespaceIPRules(d.Get("ip_rules").(*pluginsdk.Set).List()) publicNetworkAcc := "Disabled" @@ -147,21 +148,23 @@ func resourceServiceBusNamespaceNetworkRuleSetCreateUpdate(d *pluginsdk.Resource } // API doesn't accept "Deny" to be set for "default_action" if no "ip_rules" or "network_rules" is defined and returns no error message to the user - if defaultAction == servicebus.DefaultActionDeny && vnetRule == nil && ipRule == nil { + if defaultAction == namespaces.DefaultActionDeny && vnetRule == nil && ipRule == nil { return fmt.Errorf(" The default action of %s can only be set to `Allow` if no `ip_rules` or `network_rules` is set", id) } - parameters := servicebus.NetworkRuleSet{ - NetworkRuleSetProperties: &servicebus.NetworkRuleSetProperties{ - DefaultAction: defaultAction, + publicNetworkAccess := namespaces.PublicNetworkAccessFlag(publicNetworkAcc) + + parameters := namespaces.NetworkRuleSet{ + Properties: &namespaces.NetworkRuleSetProperties{ + DefaultAction: &defaultAction, VirtualNetworkRules: vnetRule, - IPRules: ipRule, - PublicNetworkAccess: servicebus.PublicNetworkAccessFlag(publicNetworkAcc), + IpRules: ipRule, + PublicNetworkAccess: &publicNetworkAccess, TrustedServiceAccessEnabled: utils.Bool(d.Get("trusted_services_allowed").(bool)), }, } - if _, err := client.CreateOrUpdateNetworkRuleSet(ctx, id.ResourceGroup, id.Name, parameters); err != nil { + if _, err := client.CreateOrUpdateNetworkRuleSet(ctx, *id, parameters); err != nil { return fmt.Errorf("creating/updating %s: %+v", id, err) } @@ -174,15 +177,15 @@ func resourceServiceBusNamespaceNetworkRuleSetRead(d *pluginsdk.ResourceData, me ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceID(d.Id()) + id, err := namespaces.ParseNamespaceID(d.Id()) if err != nil { return err } - resp, err := client.GetNetworkRuleSet(ctx, id.ResourceGroup, id.Name) + resp, err := client.GetNetworkRuleSet(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] Service Bus Namespace Network Rule Set %q does not exist - removing from state", d.Id()) + if response.WasNotFound(resp.HttpResponse) { + log.Printf("%s was not found - removing from state", d.Id()) d.SetId("") return nil } @@ -190,17 +193,28 @@ func resourceServiceBusNamespaceNetworkRuleSetRead(d *pluginsdk.ResourceData, me } d.Set("namespace_id", id.ID()) - if props := resp.NetworkRuleSetProperties; props != nil { - d.Set("default_action", string(props.DefaultAction)) - d.Set("trusted_services_allowed", props.TrustedServiceAccessEnabled) - d.Set("public_network_access_enabled", strings.EqualFold(string(props.PublicNetworkAccess), "Enabled")) - if err := d.Set("network_rules", pluginsdk.NewSet(networkRuleHash, flattenServiceBusNamespaceVirtualNetworkRules(props.VirtualNetworkRules))); err != nil { - return fmt.Errorf("failed to set `network_rules`: %+v", err) - } + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + defaultAction := "" + if v := props.DefaultAction; v != nil { + defaultAction = string(*v) + } + d.Set("default_action", defaultAction) + d.Set("trusted_services_allowed", props.TrustedServiceAccessEnabled) + publicNetworkAccess := "Enabled" + if v := props.PublicNetworkAccess; v != nil { + publicNetworkAccess = string(*v) + } + d.Set("public_network_access_enabled", strings.EqualFold(publicNetworkAccess, "Enabled")) - if err := d.Set("ip_rules", flattenServiceBusNamespaceIPRules(props.IPRules)); err != nil { - return fmt.Errorf("failed to set `ip_rules`: %+v", err) + if err := d.Set("network_rules", pluginsdk.NewSet(networkRuleHash, flattenServiceBusNamespaceVirtualNetworkRules(props.VirtualNetworkRules))); err != nil { + return fmt.Errorf("failed to set `network_rules`: %+v", err) + } + + if err := d.Set("ip_rules", flattenServiceBusNamespaceIPRules(props.IpRules)); err != nil { + return fmt.Errorf("failed to set `ip_rules`: %+v", err) + } } } @@ -212,7 +226,7 @@ func resourceServiceBusNamespaceNetworkRuleSetDelete(d *pluginsdk.ResourceData, ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceID(d.Id()) + id, err := namespaces.ParseNamespaceID(d.Id()) if err != nil { return err } @@ -220,30 +234,31 @@ func resourceServiceBusNamespaceNetworkRuleSetDelete(d *pluginsdk.ResourceData, // A network rule is unique to a namespace, this rule cannot be deleted. // Therefore we here are just disabling it by setting the default_action to allow and remove all its rules and masks - parameters := servicebus.NetworkRuleSet{ - NetworkRuleSetProperties: &servicebus.NetworkRuleSetProperties{ - DefaultAction: servicebus.DefaultActionAllow, + defaultAction := namespaces.DefaultActionAllow + parameters := namespaces.NetworkRuleSet{ + Properties: &namespaces.NetworkRuleSetProperties{ + DefaultAction: &defaultAction, }, } - if _, err := client.CreateOrUpdateNetworkRuleSet(ctx, id.ResourceGroup, id.Name, parameters); err != nil { + if _, err := client.CreateOrUpdateNetworkRuleSet(ctx, *id, parameters); err != nil { return fmt.Errorf("deleting %s: %+v", *id, err) } return nil } -func expandServiceBusNamespaceVirtualNetworkRules(input []interface{}) *[]servicebus.NWRuleSetVirtualNetworkRules { +func expandServiceBusNamespaceVirtualNetworkRules(input []interface{}) *[]namespaces.NWRuleSetVirtualNetworkRules { if len(input) == 0 { return nil } - result := make([]servicebus.NWRuleSetVirtualNetworkRules, 0) + result := make([]namespaces.NWRuleSetVirtualNetworkRules, 0) for _, v := range input { raw := v.(map[string]interface{}) - result = append(result, servicebus.NWRuleSetVirtualNetworkRules{ - Subnet: &servicebus.Subnet{ - ID: utils.String(raw["subnet_id"].(string)), + result = append(result, namespaces.NWRuleSetVirtualNetworkRules{ + Subnet: &namespaces.Subnet{ + Id: raw["subnet_id"].(string), }, IgnoreMissingVnetServiceEndpoint: utils.Bool(raw["ignore_missing_vnet_service_endpoint"].(bool)), }) @@ -252,7 +267,7 @@ func expandServiceBusNamespaceVirtualNetworkRules(input []interface{}) *[]servic return &result } -func flattenServiceBusNamespaceVirtualNetworkRules(input *[]servicebus.NWRuleSetVirtualNetworkRules) []interface{} { +func flattenServiceBusNamespaceVirtualNetworkRules(input *[]namespaces.NWRuleSetVirtualNetworkRules) []interface{} { result := make([]interface{}, 0) if input == nil { return result @@ -260,8 +275,8 @@ func flattenServiceBusNamespaceVirtualNetworkRules(input *[]servicebus.NWRuleSet for _, v := range *input { subnetId := "" - if v.Subnet != nil && v.Subnet.ID != nil { - subnetId = *v.Subnet.ID + if v.Subnet != nil && v.Subnet.Id != "" { + subnetId = v.Subnet.Id } ignore := false @@ -278,31 +293,32 @@ func flattenServiceBusNamespaceVirtualNetworkRules(input *[]servicebus.NWRuleSet return result } -func expandServiceBusNamespaceIPRules(input []interface{}) *[]servicebus.NWRuleSetIPRules { +func expandServiceBusNamespaceIPRules(input []interface{}) *[]namespaces.NWRuleSetIpRules { if len(input) == 0 { return nil } - result := make([]servicebus.NWRuleSetIPRules, 0) + action := namespaces.NetworkRuleIPActionAllow + result := make([]namespaces.NWRuleSetIpRules, 0) for _, v := range input { - result = append(result, servicebus.NWRuleSetIPRules{ - IPMask: utils.String(v.(string)), - Action: servicebus.NetworkRuleIPActionAllow, + result = append(result, namespaces.NWRuleSetIpRules{ + IpMask: utils.String(v.(string)), + Action: &action, }) } return &result } -func flattenServiceBusNamespaceIPRules(input *[]servicebus.NWRuleSetIPRules) []interface{} { +func flattenServiceBusNamespaceIPRules(input *[]namespaces.NWRuleSetIpRules) []interface{} { result := make([]interface{}, 0) if input == nil || len(*input) == 0 { return result } for _, v := range *input { - if v.IPMask != nil { - result = append(result, *v.IPMask) + if v.IpMask != nil { + result = append(result, *v.IpMask) } } @@ -317,21 +333,24 @@ func networkRuleHash(input interface{}) int { return set.HashStringIgnoreCase(v["subnet_id"]) } -func CheckNetworkRuleNullified(resp servicebus.NetworkRuleSet) bool { - if resp.ID == nil || *resp.ID == "" { - return true - } - if resp.NetworkRuleSetProperties == nil { +func CheckNetworkRuleNullified(resp namespaces.NetworkRuleSet) bool { + if resp.Id == nil || *resp.Id == "" { return true } - if resp.DefaultAction != servicebus.DefaultActionAllow { - return false - } - if resp.VirtualNetworkRules != nil && len(*resp.VirtualNetworkRules) > 0 { - return false - } - if resp.IPRules != nil && len(*resp.IPRules) > 0 { - return false + + if props := resp.Properties; props != nil { + if *props.DefaultAction != namespaces.DefaultActionAllow { + return false + } + + if props.VirtualNetworkRules != nil && len(*props.VirtualNetworkRules) > 0 { + return false + } + + if props.IpRules != nil && len(*props.IpRules) > 0 { + return false + } } + return true } diff --git a/internal/services/servicebus/servicebus_namespace_network_rule_set_resource_test.go b/internal/services/servicebus/servicebus_namespace_network_rule_set_resource_test.go index 5a424eb2c481..c4a2226ab3ec 100644 --- a/internal/services/servicebus/servicebus_namespace_network_rule_set_resource_test.go +++ b/internal/services/servicebus/servicebus_namespace_network_rule_set_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -91,17 +91,17 @@ func TestAccServiceBusNamespaceNetworkRule_requiresImport(t *testing.T) { } func (t ServiceBusNamespaceNetworkRuleSetResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.NamespaceID(state.ID) + id, err := namespaces.ParseNamespaceID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.NamespacesClient.GetNetworkRuleSet(ctx, id.ResourceGroup, id.Name) + resp, err := clients.ServiceBus.NamespacesClient.GetNetworkRuleSet(ctx, *id) if err != nil { return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (r ServiceBusNamespaceNetworkRuleSetResource) basic(data acceptance.TestData) string { diff --git a/internal/services/servicebus/servicebus_namespace_resource.go b/internal/services/servicebus/servicebus_namespace_resource.go index 619952454e60..88accc246d96 100644 --- a/internal/services/servicebus/servicebus_namespace_resource.go +++ b/internal/services/servicebus/servicebus_namespace_resource.go @@ -7,19 +7,20 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" keyVaultParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse" keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -43,7 +44,7 @@ func resourceServiceBusNamespace() *pluginsdk.Resource { Delete: resourceServiceBusNamespaceDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.NamespaceID(id) + _, err := namespaces.ParseNamespaceID(id) return err }), @@ -77,9 +78,9 @@ func resourceServiceBusNamespace() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(servicebus.SkuNameBasic), - string(servicebus.SkuNameStandard), - string(servicebus.SkuNamePremium), + string(namespaces.SkuNameBasic), + string(namespaces.SkuNameStandard), + string(namespaces.SkuNamePremium), }, false), }, @@ -164,7 +165,7 @@ func resourceServiceBusNamespace() *pluginsdk.Resource { oldSku, newSku := diff.GetChange("sku") if diff.HasChange("sku") { - if strings.EqualFold(newSku.(string), string(servicebus.SkuNamePremium)) || strings.EqualFold(oldSku.(string), string(servicebus.SkuNamePremium)) { + if strings.EqualFold(newSku.(string), string(namespaces.SkuNamePremium)) || strings.EqualFold(oldSku.(string), string(namespaces.SkuNamePremium)) { log.Printf("[DEBUG] cannot migrate a namespace from or to Premium SKU") diff.ForceNew("sku") } @@ -186,130 +187,134 @@ func resourceServiceBusNamespaceCreateUpdate(d *pluginsdk.ResourceData, meta int sku := d.Get("sku").(string) t := d.Get("tags").(map[string]interface{}) - resourceId := parse.NewNamespaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := namespaces.NewNamespaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, resourceId.ResourceGroup, resourceId.Name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_namespace", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_namespace", id.ID()) } } - identity, err := expandServiceBusNamespaceIdentity(d.Get("identity").([]interface{})) + identity, err := expandSystemAndUserAssignedMap(d.Get("identity").([]interface{})) if err != nil { return fmt.Errorf("expanding `identity`: %+v", err) } - parameters := servicebus.SBNamespace{ - Location: &location, + s := namespaces.SkuTier(sku) + parameters := namespaces.SBNamespace{ + Location: location, Identity: identity, - Sku: &servicebus.SBSku{ - Name: servicebus.SkuName(sku), - Tier: servicebus.SkuTier(sku), + Sku: &namespaces.SBSku{ + Name: namespaces.SkuName(sku), + Tier: &s, }, - SBNamespaceProperties: &servicebus.SBNamespaceProperties{ + Properties: &namespaces.SBNamespaceProperties{ ZoneRedundant: utils.Bool(d.Get("zone_redundant").(bool)), Encryption: expandServiceBusNamespaceEncryption(d.Get("customer_managed_key").([]interface{})), DisableLocalAuth: utils.Bool(!d.Get("local_auth_enabled").(bool)), }, - Tags: tags.Expand(t), + Tags: expandTags(t), } if capacity := d.Get("capacity"); capacity != nil { - if !strings.EqualFold(sku, string(servicebus.SkuNamePremium)) && capacity.(int) > 0 { + if !strings.EqualFold(sku, string(namespaces.SkuNamePremium)) && capacity.(int) > 0 { return fmt.Errorf("Service Bus SKU %q only supports `capacity` of 0", sku) } - if strings.EqualFold(sku, string(servicebus.SkuNamePremium)) && capacity.(int) == 0 { + if strings.EqualFold(sku, string(namespaces.SkuNamePremium)) && capacity.(int) == 0 { return fmt.Errorf("Service Bus SKU %q only supports `capacity` of 1, 2, 4, 8 or 16", sku) } - parameters.Sku.Capacity = utils.Int32(int32(capacity.(int))) + parameters.Sku.Capacity = utils.Int64(int64(capacity.(int))) } - future, err := client.CreateOrUpdate(ctx, resourceId.ResourceGroup, resourceId.Name, parameters) - if err != nil { - return fmt.Errorf("creating/updating %s: %+v", resourceId, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for create/update of %s: %+v", resourceId, err) + if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceServiceBusNamespaceRead(d, meta) } func resourceServiceBusNamespaceRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).ServiceBus.NamespacesClient - clientStable := meta.(*clients.Client).ServiceBus.NamespacesClient + namespaceAuthClient := meta.(*clients.Client).ServiceBus.NamespacesAuthClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceID(d.Id()) + id, err := namespaces.ParseNamespaceID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("location", location.NormalizeNilable(resp.Location)) + d.Set("name", id.NamespaceName) + d.Set("resource_group_name", id.ResourceGroupName) - identity, err := flattenServiceBusNamespaceIdentity(resp.Identity) - if err != nil { - return fmt.Errorf("flattening `identity`: %+v", err) - } - if err := d.Set("identity", identity); err != nil { - return fmt.Errorf("setting `identity`: %+v", err) - } + if model := resp.Model; model != nil { + d.Set("location", location.Normalize(model.Location)) - if sku := resp.Sku; sku != nil { - skuName := "" - // the Azure API is inconsistent here, so rewrite this into the casing we expect - for _, v := range servicebus.PossibleSkuNameValues() { - if strings.EqualFold(string(v), string(sku.Name)) { - skuName = string(v) - } + d.Set("tags", flattenTags(model.Tags)) + + identity, err := identity.FlattenSystemAndUserAssignedMap(model.Identity) + if err != nil { + return fmt.Errorf("flattening `identity`: %+v", err) + } + if err := d.Set("identity", identity); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) } - d.Set("sku", skuName) - d.Set("capacity", sku.Capacity) - } - if properties := resp.SBNamespaceProperties; properties != nil { - d.Set("zone_redundant", properties.ZoneRedundant) - if customerManagedKey, err := flattenServiceBusNamespaceEncryption(properties.Encryption); err == nil { - d.Set("customer_managed_key", customerManagedKey) + if sku := model.Sku; sku != nil { + skuName := "" + // the Azure API is inconsistent here, so rewrite this into the casing we expect + for _, v := range namespaces.PossibleValuesForSkuName() { + if strings.EqualFold(v, string(sku.Name)) { + skuName = v + } + } + d.Set("sku", skuName) + d.Set("capacity", sku.Capacity) } - localAuthEnabled := true - if properties.DisableLocalAuth != nil { - localAuthEnabled = !*properties.DisableLocalAuth + + if props := model.Properties; model != nil { + d.Set("zone_redundant", props.ZoneRedundant) + if customerManagedKey, err := flattenServiceBusNamespaceEncryption(props.Encryption); err == nil { + d.Set("customer_managed_key", customerManagedKey) + } + localAuthEnabled := true + if props.DisableLocalAuth != nil { + localAuthEnabled = !*props.DisableLocalAuth + } + d.Set("local_auth_enabled", localAuthEnabled) } - d.Set("local_auth_enabled", localAuthEnabled) } - keys, err := clientStable.ListKeys(ctx, id.ResourceGroup, id.Name, serviceBusNamespaceDefaultAuthorizationRule) + authRuleId := namespacesauthorizationrule.NewAuthorizationRuleID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, serviceBusNamespaceDefaultAuthorizationRule) + + keys, err := namespaceAuthClient.NamespacesListKeys(ctx, authRuleId) if err != nil { log.Printf("[WARN] listing default keys for %s: %+v", id, err) } else { - d.Set("default_primary_connection_string", keys.PrimaryConnectionString) - d.Set("default_secondary_connection_string", keys.SecondaryConnectionString) - d.Set("default_primary_key", keys.PrimaryKey) - d.Set("default_secondary_key", keys.SecondaryKey) + if keysModel := keys.Model; keysModel != nil { + d.Set("default_primary_connection_string", keysModel.PrimaryConnectionString) + d.Set("default_secondary_connection_string", keysModel.SecondaryConnectionString) + d.Set("default_primary_key", keysModel.PrimaryKey) + d.Set("default_secondary_key", keysModel.SecondaryKey) + } } - - return tags.FlattenAndSet(d, resp.Tags) + return nil } func resourceServiceBusNamespaceDelete(d *pluginsdk.ResourceData, meta interface{}) error { @@ -317,94 +322,42 @@ func resourceServiceBusNamespaceDelete(d *pluginsdk.ResourceData, meta interface ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.NamespaceID(d.Id()) + id, err := namespaces.ParseNamespaceID(d.Id()) if err != nil { return err } - future, err := client.Delete(ctx, id.ResourceGroup, id.Name) - if err != nil { + if err := client.DeleteThenPoll(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("waiting for deletion of %s: %+v", id, err) - } - } - return nil } -func expandServiceBusNamespaceIdentity(input []interface{}) (*servicebus.Identity, error) { - expanded, err := identity.ExpandSystemAndUserAssignedMap(input) - if err != nil { - return nil, err - } - - out := servicebus.Identity{ - Type: servicebus.ManagedServiceIdentityType(string(expanded.Type)), - } - - if len(expanded.IdentityIds) > 0 { - out.UserAssignedIdentities = map[string]*servicebus.UserAssignedIdentity{} - for id := range expanded.IdentityIds { - out.UserAssignedIdentities[id] = &servicebus.UserAssignedIdentity{ - // intentionally empty - } - } - } - return &out, nil -} - -func expandServiceBusNamespaceEncryption(input []interface{}) *servicebus.Encryption { +func expandServiceBusNamespaceEncryption(input []interface{}) *namespaces.Encryption { if len(input) == 0 || input[0] == nil { return nil } v := input[0].(map[string]interface{}) keyId, _ := keyVaultParse.ParseOptionallyVersionedNestedItemID(v["key_vault_key_id"].(string)) - return &servicebus.Encryption{ - KeyVaultProperties: &[]servicebus.KeyVaultProperties{ + keySource := namespaces.KeySourceMicrosoftPointKeyVault + return &namespaces.Encryption{ + KeyVaultProperties: &[]namespaces.KeyVaultProperties{ { KeyName: utils.String(keyId.Name), KeyVersion: utils.String(keyId.Version), - KeyVaultURI: utils.String(keyId.KeyVaultBaseUrl), - Identity: &servicebus.UserAssignedIdentityProperties{ + KeyVaultUri: utils.String(keyId.KeyVaultBaseUrl), + Identity: &namespaces.UserAssignedIdentityProperties{ UserAssignedIdentity: utils.String(v["identity_id"].(string)), }, }, }, - KeySource: servicebus.KeySourceMicrosoftKeyVault, + KeySource: &keySource, RequireInfrastructureEncryption: utils.Bool(v["infrastructure_encryption_enabled"].(bool)), } } -func flattenServiceBusNamespaceIdentity(input *servicebus.Identity) (*[]interface{}, error) { - var transform *identity.SystemAndUserAssignedMap - - if input != nil { - transform = &identity.SystemAndUserAssignedMap{ - Type: identity.Type(string(input.Type)), - IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), - } - if input.PrincipalID != nil { - transform.PrincipalId = *input.PrincipalID - } - if input.TenantID != nil { - transform.TenantId = *input.TenantID - } - for k, v := range input.UserAssignedIdentities { - transform.IdentityIds[k] = identity.UserAssignedIdentityDetails{ - ClientId: v.ClientID, - PrincipalId: v.PrincipalID, - } - } - } - - return identity.FlattenSystemAndUserAssignedMap(transform) -} - -func flattenServiceBusNamespaceEncryption(encryption *servicebus.Encryption) ([]interface{}, error) { +func flattenServiceBusNamespaceEncryption(encryption *namespaces.Encryption) ([]interface{}, error) { if encryption == nil { return []interface{}{}, nil } @@ -413,7 +366,7 @@ func flattenServiceBusNamespaceEncryption(encryption *servicebus.Encryption) ([] var identityId string if keyVaultProperties := encryption.KeyVaultProperties; keyVaultProperties != nil && len(*keyVaultProperties) != 0 { props := (*keyVaultProperties)[0] - keyVaultKeyId, err := keyVaultParse.NewNestedItemID(*props.KeyVaultURI, "keys", *props.KeyName, *props.KeyVersion) + keyVaultKeyId, err := keyVaultParse.NewNestedItemID(*props.KeyVaultUri, "keys", *props.KeyName, *props.KeyVersion) if err != nil { return nil, fmt.Errorf("parsing `key_vault_key_id`: %+v", err) } @@ -431,3 +384,44 @@ func flattenServiceBusNamespaceEncryption(encryption *servicebus.Encryption) ([] }, }, nil } + +func expandSystemAndUserAssignedMap(input []interface{}) (*identity.SystemAndUserAssignedMap, error) { + identityType := identity.TypeNone + identityIds := make(map[string]identity.UserAssignedIdentityDetails, 0) + + if len(input) > 0 { + raw := input[0].(map[string]interface{}) + typeRaw := raw["type"].(string) + if typeRaw == string(identity.TypeSystemAssigned) { + identityType = identity.TypeSystemAssigned + } + if typeRaw == string(identity.TypeSystemAssignedUserAssigned) { + identityType = identity.TypeSystemAssignedUserAssigned + } + if typeRaw == string(identity.TypeUserAssigned) { + identityType = identity.TypeUserAssigned + } + + identityIdsRaw := raw["identity_ids"].(*schema.Set).List() + for _, v := range identityIdsRaw { + identityIds[v.(string)] = identity.UserAssignedIdentityDetails{ + // intentionally empty since the expand shouldn't send these values + } + } + } + + if len(identityIds) > 0 && (identityType != identity.TypeSystemAssignedUserAssigned && identityType != identity.TypeUserAssigned) { + return nil, fmt.Errorf("`identity_ids` can only be specified when `type` is set to %q or %q", string(identity.TypeSystemAssignedUserAssigned), string(identity.TypeUserAssigned)) + } + + if len(identityIds) == 0 { + return &identity.SystemAndUserAssignedMap{ + Type: identityType, + }, nil + } + + return &identity.SystemAndUserAssignedMap{ + Type: identityType, + IdentityIds: identityIds, + }, nil +} diff --git a/internal/services/servicebus/servicebus_namespace_resource_test.go b/internal/services/servicebus/servicebus_namespace_resource_test.go index e4255698ad5f..6b910a30931d 100644 --- a/internal/services/servicebus/servicebus_namespace_resource_test.go +++ b/internal/services/servicebus/servicebus_namespace_resource_test.go @@ -6,10 +6,10 @@ import ( "regexp" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -207,17 +207,17 @@ func TestAccAzureRMServiceBusNamespace_customerManagedKey(t *testing.T) { } func (t ServiceBusNamespaceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.NamespaceID(state.ID) + id, err := namespaces.ParseNamespaceID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.NamespacesClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.ServiceBus.NamespacesClient.Get(ctx, *id) if err != nil { return nil, fmt.Errorf("reading Service Bus NameSpace (%s): %+v", id.String(), err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusNamespaceResource) basic(data acceptance.TestData) string { diff --git a/internal/services/servicebus/servicebus_queue_authorization_rule_data_source.go b/internal/services/servicebus/servicebus_queue_authorization_rule_data_source.go index 6fc593cda8c0..31cb5bfeca97 100644 --- a/internal/services/servicebus/servicebus_queue_authorization_rule_data_source.go +++ b/internal/services/servicebus/servicebus_queue_authorization_rule_data_source.go @@ -4,13 +4,14 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusQueueAuthorizationRule() *pluginsdk.Resource { @@ -31,7 +32,7 @@ func dataSourceServiceBusQueueAuthorizationRule() *pluginsdk.Resource { "queue_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.QueueID, + ValidateFunc: queues.ValidateQueueID, AtLeastOneOf: []string{"queue_id", "resource_group_name", "namespace_name", "queue_name"}, }, @@ -111,7 +112,7 @@ func dataSourceServiceBusQueueAuthorizationRule() *pluginsdk.Resource { } func dataSourceServiceBusQueueAuthorizationRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.QueuesClient + client := meta.(*clients.Client).ServiceBus.QueuesAuthClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -120,53 +121,57 @@ func dataSourceServiceBusQueueAuthorizationRuleRead(d *pluginsdk.ResourceData, m var nsName string var queueName string if v, ok := d.Get("queue_id").(string); ok && v != "" { - queueId, err := parse.QueueID(v) + queueId, err := queuesauthorizationrule.ParseQueueID(v) if err != nil { return fmt.Errorf("parsing topic ID %q: %+v", v, err) } - rgName = queueId.ResourceGroup + rgName = queueId.ResourceGroupName nsName = queueId.NamespaceName - queueName = queueId.Name + queueName = queueId.QueueName } else { rgName = d.Get("resource_group_name").(string) nsName = d.Get("namespace_name").(string) queueName = d.Get("queue_name").(string) } - id := parse.NewQueueAuthorizationRuleID(subscriptionId, rgName, nsName, queueName, d.Get("name").(string)) - resp, err := client.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) + id := queuesauthorizationrule.NewQueueAuthorizationRuleID(subscriptionId, rgName, nsName, queueName, d.Get("name").(string)) + resp, err := client.QueuesGetAuthorizationRule(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } - keysResp, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) - if err != nil { - return fmt.Errorf("listing keys for %s: %+v", id, err) - } - d.SetId(id.ID()) d.Set("name", id.AuthorizationRuleName) d.Set("queue_name", id.QueueName) d.Set("namespace_name", id.NamespaceName) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("queue_id", parse.NewQueueID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.QueueName).ID()) - - if properties := resp.SBAuthorizationRuleProperties; properties != nil { - listen, send, manage := flattenAuthorizationRuleRights(properties.Rights) - d.Set("listen", listen) - d.Set("send", send) - d.Set("manage", manage) + d.Set("resource_group_name", id.ResourceGroupName) + d.Set("queue_id", queuesauthorizationrule.NewQueueID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.QueueName).ID()) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + listen, send, manage := flattenQueueAuthorizationRuleRights(&props.Rights) + d.Set("manage", manage) + d.Set("listen", listen) + d.Set("send", send) + } } - d.Set("primary_key", keysResp.PrimaryKey) - d.Set("primary_connection_string", keysResp.PrimaryConnectionString) - d.Set("secondary_key", keysResp.SecondaryKey) - d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) - d.Set("primary_connection_string_alias", keysResp.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keysResp.AliasSecondaryConnectionString) + keysResp, err := client.QueuesListKeys(ctx, id) + if err != nil { + return fmt.Errorf("listing keys for %s: %+v", id, err) + } + + if keysModel := keysResp.Model; keysModel != nil { + d.Set("primary_key", keysModel.PrimaryKey) + d.Set("primary_connection_string", keysModel.PrimaryConnectionString) + d.Set("secondary_key", keysModel.SecondaryKey) + d.Set("secondary_connection_string", keysModel.SecondaryConnectionString) + d.Set("primary_connection_string_alias", keysModel.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", keysModel.AliasSecondaryConnectionString) + } return nil } diff --git a/internal/services/servicebus/servicebus_queue_authorization_rule_resource.go b/internal/services/servicebus/servicebus_queue_authorization_rule_resource.go index 9004ea433a48..f8291ea0ca10 100644 --- a/internal/services/servicebus/servicebus_queue_authorization_rule_resource.go +++ b/internal/services/servicebus/servicebus_queue_authorization_rule_resource.go @@ -5,10 +5,12 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -23,7 +25,7 @@ func resourceServiceBusQueueAuthorizationRule() *pluginsdk.Resource { Delete: resourceServiceBusQueueAuthorizationRuleDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.QueueAuthorizationRuleID(id) + _, err := queuesauthorizationrule.ParseQueueAuthorizationRuleID(id) return err }), @@ -54,70 +56,69 @@ func resourceServiceBusqueueAuthorizationRuleSchema() map[string]*pluginsdk.Sche Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.QueueID, + ValidateFunc: queues.ValidateQueueID, }, }) } func resourceServiceBusQueueAuthorizationRuleCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.QueuesClient + client := meta.(*clients.Client).ServiceBus.QueuesAuthClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for ServiceBus Queue Authorization Rule creation.") - - var resourceId parse.QueueAuthorizationRuleId - if queueIdLit := d.Get("queue_id").(string); queueIdLit != "" { - queueId, _ := parse.QueueID(queueIdLit) - resourceId = parse.NewQueueAuthorizationRuleID(queueId.SubscriptionId, queueId.ResourceGroup, queueId.NamespaceName, queueId.Name, d.Get("name").(string)) + queueId, err := queuesauthorizationrule.ParseQueueID(d.Get("queue_id").(string)) + if err != nil { + return err } + id := queuesauthorizationrule.NewQueueAuthorizationRuleID(queueId.SubscriptionId, queueId.ResourceGroupName, queueId.NamespaceName, queueId.QueueName, d.Get("name").(string)) + if d.IsNewResource() { - existing, err := client.GetAuthorizationRule(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.QueueName, resourceId.AuthorizationRuleName) + existing, err := client.QueuesGetAuthorizationRule(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_queue_authorization_rule", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_queue_authorization_rule", id.ID()) } } - parameters := servicebus.SBAuthorizationRule{ - Name: utils.String(resourceId.AuthorizationRuleName), - SBAuthorizationRuleProperties: &servicebus.SBAuthorizationRuleProperties{ - Rights: expandAuthorizationRuleRights(d), + parameters := queuesauthorizationrule.SBAuthorizationRule{ + Name: utils.String(id.AuthorizationRuleName), + Properties: &queuesauthorizationrule.SBAuthorizationRuleProperties{ + Rights: *expandQueueAuthorizationRuleRights(d), }, } - if _, err := client.CreateOrUpdateAuthorizationRule(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.QueueName, resourceId.AuthorizationRuleName, parameters); err != nil { - return fmt.Errorf("creating/updating %s: %+v", resourceId, err) + if _, err := client.QueuesCreateOrUpdateAuthorizationRule(ctx, id, parameters); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) - - if err := waitForPairedNamespaceReplication(ctx, meta, resourceId.ResourceGroup, resourceId.NamespaceName, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { - return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", resourceId.NamespaceName, resourceId.ResourceGroup, err) + d.SetId(id.ID()) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + if err := waitForPairedNamespaceReplication(ctx, meta, namespaceId, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { + return fmt.Errorf("waiting for replication to complete for %s: %+v", id, err) } return resourceServiceBusQueueAuthorizationRuleRead(d, meta) } func resourceServiceBusQueueAuthorizationRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.QueuesClient + client := meta.(*clients.Client).ServiceBus.QueuesAuthClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.QueueAuthorizationRuleID(d.Id()) + id, err := queuesauthorizationrule.ParseQueueAuthorizationRuleID(d.Id()) if err != nil { return err } - resp, err := client.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) + resp, err := client.QueuesGetAuthorizationRule(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } @@ -125,48 +126,92 @@ func resourceServiceBusQueueAuthorizationRuleRead(d *pluginsdk.ResourceData, met return fmt.Errorf("retrieving %s: %+v", id, err) } - keysResp, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) + d.Set("name", id.AuthorizationRuleName) + d.Set("queue_id", queuesauthorizationrule.NewQueueID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.QueueName).ID()) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + listen, send, manage := flattenQueueAuthorizationRuleRights(&props.Rights) + d.Set("manage", manage) + d.Set("listen", listen) + d.Set("send", send) + } + } + + keysResp, err := client.QueuesListKeys(ctx, *id) if err != nil { return fmt.Errorf("listing keys for %s: %+v", id, err) } - d.Set("name", id.AuthorizationRuleName) - d.Set("queue_id", parse.NewQueueID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.QueueName).ID()) - - if properties := resp.SBAuthorizationRuleProperties; properties != nil { - listen, send, manage := flattenAuthorizationRuleRights(properties.Rights) - d.Set("manage", manage) - d.Set("listen", listen) - d.Set("send", send) + if keysModel := keysResp.Model; keysModel != nil { + d.Set("primary_key", keysModel.PrimaryKey) + d.Set("primary_connection_string", keysModel.PrimaryConnectionString) + d.Set("secondary_key", keysModel.SecondaryKey) + d.Set("secondary_connection_string", keysModel.SecondaryConnectionString) + d.Set("primary_connection_string_alias", keysModel.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", keysModel.AliasSecondaryConnectionString) } - d.Set("primary_key", keysResp.PrimaryKey) - d.Set("primary_connection_string", keysResp.PrimaryConnectionString) - d.Set("secondary_key", keysResp.SecondaryKey) - d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) - d.Set("primary_connection_string_alias", keysResp.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keysResp.AliasSecondaryConnectionString) - return nil } func resourceServiceBusQueueAuthorizationRuleDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.QueuesClient + client := meta.(*clients.Client).ServiceBus.QueuesAuthClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.QueueAuthorizationRuleID(d.Id()) + id, err := queuesauthorizationrule.ParseQueueAuthorizationRuleID(d.Id()) if err != nil { return err } - if _, err = client.DeleteAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName); err != nil { + if _, err = client.QueuesDeleteAuthorizationRule(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) } - if err := waitForPairedNamespaceReplication(ctx, meta, id.ResourceGroup, id.NamespaceName, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { - return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", id.NamespaceName, id.ResourceGroup, err) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + if err := waitForPairedNamespaceReplication(ctx, meta, namespaceId, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { + return fmt.Errorf("waiting for replication to complete for %s: %+v", *id, err) } return nil } + +func expandQueueAuthorizationRuleRights(d *pluginsdk.ResourceData) *[]queuesauthorizationrule.AccessRights { + rights := make([]queuesauthorizationrule.AccessRights, 0) + + if d.Get("listen").(bool) { + rights = append(rights, queuesauthorizationrule.AccessRightsListen) + } + + if d.Get("send").(bool) { + rights = append(rights, queuesauthorizationrule.AccessRightsSend) + } + + if d.Get("manage").(bool) { + rights = append(rights, queuesauthorizationrule.AccessRightsManage) + } + + return &rights +} + +func flattenQueueAuthorizationRuleRights(rights *[]queuesauthorizationrule.AccessRights) (listen, send, manage bool) { + // zero (initial) value for a bool in go is false + + if rights != nil { + for _, right := range *rights { + switch right { + case queuesauthorizationrule.AccessRightsListen: + listen = true + case queuesauthorizationrule.AccessRightsSend: + send = true + case queuesauthorizationrule.AccessRightsManage: + manage = true + default: + log.Printf("[DEBUG] Unknown Authorization Rule Right '%s'", right) + } + } + } + + return listen, send, manage +} diff --git a/internal/services/servicebus/servicebus_queue_authorization_rule_resource_test.go b/internal/services/servicebus/servicebus_queue_authorization_rule_resource_test.go index 3f3b4e22ec31..3bccc722d906 100644 --- a/internal/services/servicebus/servicebus_queue_authorization_rule_resource_test.go +++ b/internal/services/servicebus/servicebus_queue_authorization_rule_resource_test.go @@ -6,10 +6,10 @@ import ( "strconv" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -135,17 +135,17 @@ func TestAccServiceBusQueueAuthorizationRule_withAliasConnectionString(t *testin } func (t ServiceBusQueueAuthorizationRuleResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.QueueAuthorizationRuleID(state.ID) + id, err := queuesauthorizationrule.ParseQueueAuthorizationRuleID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.QueuesClient.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) + resp, err := clients.ServiceBus.QueuesAuthClient.QueuesGetAuthorizationRule(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus NameSpace Queue Authorization Rule (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusQueueAuthorizationRuleResource) base(data acceptance.TestData, listen, send, manage bool) string { diff --git a/internal/services/servicebus/servicebus_queue_data_source.go b/internal/services/servicebus/servicebus_queue_data_source.go index d8f1fe6ab298..1372bce0ce03 100644 --- a/internal/services/servicebus/servicebus_queue_data_source.go +++ b/internal/services/servicebus/servicebus_queue_data_source.go @@ -4,15 +4,15 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" azValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusQueue() *pluginsdk.Resource { @@ -33,7 +33,7 @@ func dataSourceServiceBusQueue() *pluginsdk.Resource { "namespace_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"}, }, @@ -135,71 +135,62 @@ func dataSourceServiceBusQueue() *pluginsdk.Resource { func dataSourceServiceBusQueueRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).ServiceBus.QueuesClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() - name := d.Get("name").(string) - - var resourceGroup string - var namespaceName string - if v, ok := d.Get("namespace_id").(string); ok && v != "" { - namespaceId, err := parse.NamespaceID(v) - if err != nil { - return fmt.Errorf("parsing topic ID %q: %+v", v, err) - } - resourceGroup = namespaceId.ResourceGroup - namespaceName = namespaceId.Name - } else { - resourceGroup = d.Get("resource_group_name").(string) - namespaceName = d.Get("namespace_name").(string) + namespaceId, err := namespaces.ParseNamespaceID(d.Get("namespace_id").(string)) + if err != nil { + return err } - id := parse.NewQueueID(subscriptionId, resourceGroup, namespaceName, name) - resp, err := client.Get(ctx, resourceGroup, namespaceName, name) + id := queues.NewQueueID(namespaceId.SubscriptionId, namespaceId.ResourceGroupName, namespaceId.NamespaceName, d.Get("name").(string)) + + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Service Bus Queue %q was not found in Resource Group %q Namespace %q", name, resourceGroup, namespaceName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("making Read request on Azure Service Bus Queue %q in Resource Group %q Namespace %q: %v", name, resourceGroup, namespaceName, err) + return fmt.Errorf("retrieving %s: %v", id, err) } d.SetId(id.ID()) - if props := resp.SBQueueProperties; props != nil { - d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) - d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) - d.Set("default_message_ttl", props.DefaultMessageTimeToLive) - d.Set("duplicate_detection_history_time_window", props.DuplicateDetectionHistoryTimeWindow) - d.Set("enable_batched_operations", props.EnableBatchedOperations) - d.Set("enable_express", props.EnableExpress) - d.Set("enable_partitioning", props.EnablePartitioning) - d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) - d.Set("forward_to", props.ForwardTo) - d.Set("lock_duration", props.LockDuration) - d.Set("max_delivery_count", props.MaxDeliveryCount) - d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) - d.Set("requires_session", props.RequiresSession) - d.Set("status", props.Status) - - if apiMaxSizeInMegabytes := props.MaxSizeInMegabytes; apiMaxSizeInMegabytes != nil { - maxSizeInMegabytes := int(*apiMaxSizeInMegabytes) - - // If the queue is NOT in a premium namespace (ie. it is Basic or Standard) and partitioning is enabled - // then the max size returned by the API will be 16 times greater than the value set. - if *props.EnablePartitioning { - namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespacesClient.Get(ctx, resourceGroup, namespaceName) - if err != nil { - return err + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) + d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) + d.Set("default_message_ttl", props.DefaultMessageTimeToLive) + d.Set("duplicate_detection_history_time_window", props.DuplicateDetectionHistoryTimeWindow) + d.Set("enable_batched_operations", props.EnableBatchedOperations) + d.Set("enable_express", props.EnableExpress) + d.Set("enable_partitioning", props.EnablePartitioning) + d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) + d.Set("forward_to", props.ForwardTo) + d.Set("lock_duration", props.LockDuration) + d.Set("max_delivery_count", props.MaxDeliveryCount) + d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) + d.Set("requires_session", props.RequiresSession) + d.Set("status", props.Status) + + if apiMaxSizeInMegabytes := props.MaxSizeInMegabytes; apiMaxSizeInMegabytes != nil { + maxSizeInMegabytes := int(*apiMaxSizeInMegabytes) + + // If the queue is NOT in a premium namespace (ie. it is Basic or Standard) and partitioning is enabled + // then the max size returned by the API will be 16 times greater than the value set. + if *props.EnablePartitioning { + namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient + namespace, err := namespacesClient.Get(ctx, *namespaceId) + if err != nil { + return err + } + + if nsModel := namespace.Model; nsModel != nil && nsModel.Sku.Name != namespaces.SkuNamePremium { + const partitionCount = 16 + maxSizeInMegabytes = int(*apiMaxSizeInMegabytes / partitionCount) + } } - if namespace.Sku.Name != servicebus.SkuNamePremium { - const partitionCount = 16 - maxSizeInMegabytes = int(*apiMaxSizeInMegabytes / partitionCount) - } + d.Set("max_size_in_megabytes", maxSizeInMegabytes) } - - d.Set("max_size_in_megabytes", maxSizeInMegabytes) } } diff --git a/internal/services/servicebus/servicebus_queue_resource.go b/internal/services/servicebus/servicebus_queue_resource.go index 7b27ca1f2c91..a64a94ada41b 100644 --- a/internal/services/servicebus/servicebus_queue_resource.go +++ b/internal/services/servicebus/servicebus_queue_resource.go @@ -2,14 +2,14 @@ package servicebus import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" azValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -25,7 +25,7 @@ func resourceServiceBusQueue() *pluginsdk.Resource { Delete: resourceServiceBusQueueDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.QueueID(id) + _, err := queues.ParseQueueID(id) return err }), @@ -54,7 +54,7 @@ func resourceServicebusQueueSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: azValidate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, }, // Optional @@ -163,16 +163,16 @@ func resourceServicebusQueueSchema() map[string]*pluginsdk.Schema { "status": { Type: pluginsdk.TypeString, Optional: true, - Default: string(servicebus.EntityStatusActive), + Default: string(queues.EntityStatusActive), ValidateFunc: validation.StringInSlice([]string{ - string(servicebus.EntityStatusActive), - string(servicebus.EntityStatusCreating), - string(servicebus.EntityStatusDeleting), - string(servicebus.EntityStatusDisabled), - string(servicebus.EntityStatusReceiveDisabled), - string(servicebus.EntityStatusRenaming), - string(servicebus.EntityStatusSendDisabled), - string(servicebus.EntityStatusUnknown), + string(queues.EntityStatusActive), + string(queues.EntityStatusCreating), + string(queues.EntityStatusDeleting), + string(queues.EntityStatusDisabled), + string(queues.EntityStatusReceiveDisabled), + string(queues.EntityStatusRenaming), + string(queues.EntityStatusSendDisabled), + string(queues.EntityStatusUnknown), }, false), }, } @@ -182,120 +182,120 @@ func resourceServiceBusQueueCreateUpdate(d *pluginsdk.ResourceData, meta interfa client := meta.(*clients.Client).ServiceBus.QueuesClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for ServiceBus Queue creation/update.") - var resourceId parse.QueueId - if namespaceIdLit := d.Get("namespace_id").(string); namespaceIdLit != "" { - namespaceId, _ := parse.NamespaceID(namespaceIdLit) - resourceId = parse.NewQueueID(namespaceId.SubscriptionId, namespaceId.ResourceGroup, namespaceId.Name, d.Get("name").(string)) + namespaceId, err := namespaces.ParseNamespaceID(d.Get("namespace_id").(string)) + if err != nil { + return err } - deadLetteringOnMessageExpiration := d.Get("dead_lettering_on_message_expiration").(bool) - enableBatchedOperations := d.Get("enable_batched_operations").(bool) - enableExpress := d.Get("enable_express").(bool) + id := queues.NewQueueID(namespaceId.SubscriptionId, namespaceId.ResourceGroupName, namespaceId.NamespaceName, d.Get("name").(string)) + isPartitioningEnabled := false if d.HasChange("enable_partitioning") { - existingQueue, err := client.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.Name) + existingQueue, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existingQueue.Response) { - return fmt.Errorf("retrieving ServiceBus Namespace Queue %q (Resource Group %q): %+v", resourceId.Name, resourceId.ResourceGroup, err) + if !response.WasNotFound(existingQueue.HttpResponse) { + return fmt.Errorf("retrieving %s: %+v", id, err) } } - if existingQueue.ID != nil && existingQueue.EnablePartitioning != nil && *existingQueue.EnablePartitioning { - isPartitioningEnabled = true + if model := existingQueue.Model; model != nil { + if props := model.Properties; props != nil { + if model.Id != nil && props.EnablePartitioning != nil && *props.EnablePartitioning { + isPartitioningEnabled = true + } + } } } - enablePartitioning := d.Get("enable_partitioning").(bool) - maxDeliveryCount := int32(d.Get("max_delivery_count").(int)) - maxSizeInMegabytes := int32(d.Get("max_size_in_megabytes").(int)) - requiresDuplicateDetection := d.Get("requires_duplicate_detection").(bool) - requiresSession := d.Get("requires_session").(bool) - status := servicebus.EntityStatus(d.Get("status").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.Name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_queue", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_queue", id.ID()) } } - parameters := servicebus.SBQueue{ - Name: utils.String(resourceId.Name), - SBQueueProperties: &servicebus.SBQueueProperties{ - DeadLetteringOnMessageExpiration: &deadLetteringOnMessageExpiration, - EnableBatchedOperations: &enableBatchedOperations, - EnableExpress: &enableExpress, - EnablePartitioning: &enablePartitioning, - MaxDeliveryCount: &maxDeliveryCount, - MaxSizeInMegabytes: &maxSizeInMegabytes, - RequiresDuplicateDetection: &requiresDuplicateDetection, - RequiresSession: &requiresSession, - Status: status, + status := queues.EntityStatus(d.Get("status").(string)) + parameters := queues.SBQueue{ + Name: utils.String(id.QueueName), + Properties: &queues.SBQueueProperties{ + DeadLetteringOnMessageExpiration: utils.Bool(d.Get("dead_lettering_on_message_expiration").(bool)), + EnableBatchedOperations: utils.Bool(d.Get("enable_batched_operations").(bool)), + EnableExpress: utils.Bool(d.Get("enable_express").(bool)), + EnablePartitioning: utils.Bool(d.Get("enable_partitioning").(bool)), + MaxDeliveryCount: utils.Int64(int64(d.Get("max_delivery_count").(int))), + MaxSizeInMegabytes: utils.Int64(int64(d.Get("max_size_in_megabytes").(int))), + RequiresDuplicateDetection: utils.Bool(d.Get("requires_duplicate_detection").(bool)), + RequiresSession: utils.Bool(d.Get("requires_session").(bool)), + Status: &status, }, } if autoDeleteOnIdle := d.Get("auto_delete_on_idle").(string); autoDeleteOnIdle != "" { - parameters.SBQueueProperties.AutoDeleteOnIdle = &autoDeleteOnIdle + parameters.Properties.AutoDeleteOnIdle = &autoDeleteOnIdle } if defaultMessageTTL := d.Get("default_message_ttl").(string); defaultMessageTTL != "" { - parameters.SBQueueProperties.DefaultMessageTimeToLive = &defaultMessageTTL + parameters.Properties.DefaultMessageTimeToLive = &defaultMessageTTL } if duplicateDetectionHistoryTimeWindow := d.Get("duplicate_detection_history_time_window").(string); duplicateDetectionHistoryTimeWindow != "" { - parameters.SBQueueProperties.DuplicateDetectionHistoryTimeWindow = &duplicateDetectionHistoryTimeWindow + parameters.Properties.DuplicateDetectionHistoryTimeWindow = &duplicateDetectionHistoryTimeWindow } if forwardDeadLetteredMessagesTo := d.Get("forward_dead_lettered_messages_to").(string); forwardDeadLetteredMessagesTo != "" { - parameters.SBQueueProperties.ForwardDeadLetteredMessagesTo = &forwardDeadLetteredMessagesTo + parameters.Properties.ForwardDeadLetteredMessagesTo = &forwardDeadLetteredMessagesTo } if forwardTo := d.Get("forward_to").(string); forwardTo != "" { - parameters.SBQueueProperties.ForwardTo = &forwardTo + parameters.Properties.ForwardTo = &forwardTo } if lockDuration := d.Get("lock_duration").(string); lockDuration != "" { - parameters.SBQueueProperties.LockDuration = &lockDuration + parameters.Properties.LockDuration = &lockDuration } // We need to retrieve the namespace because Premium namespace works differently from Basic and Standard, // so it needs different rules applied to it. namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespacesClient.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName) + namespace, err := namespacesClient.Get(ctx, *namespaceId) if err != nil { - return fmt.Errorf("retrieving ServiceBus Namespace %q (Resource Group %q): %+v", resourceId.NamespaceName, resourceId.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", *namespaceId, err) } + var sku namespaces.SkuName + if nsModel := namespace.Model; nsModel != nil { + sku = nsModel.Sku.Name + } // Enforce Premium namespace to have Express Entities disabled in Terraform since they are not supported for // Premium SKU. - if namespace.Sku.Name == servicebus.SkuNamePremium && d.Get("enable_express").(bool) { - return fmt.Errorf("ServiceBus Queue %q does not support Express Entities in Premium SKU and must be disabled", resourceId.Name) + if sku == namespaces.SkuNamePremium && d.Get("enable_express").(bool) { + return fmt.Errorf("%s does not support Express Entities in Premium SKU and must be disabled", id) } - if namespace.Sku.Name == servicebus.SkuNamePremium && d.Get("enable_partitioning").(bool) && !isPartitioningEnabled { - return fmt.Errorf("Partitioning Entities is not supported in Premium SKU and must be disabled") + if sku == namespaces.SkuNamePremium && d.Get("enable_partitioning").(bool) && !isPartitioningEnabled { + return fmt.Errorf("partitioning Entities is not supported in Premium SKU and must be disabled") } // output of `max_message_size_in_kilobytes` is also set in non-Premium namespaces, with a value of 256 if v, ok := d.GetOk("max_message_size_in_kilobytes"); ok && v.(int) != 256 { - if namespace.Sku.Name != servicebus.SkuNamePremium { - return fmt.Errorf("ServiceBus Queue %q does not support input on `max_message_size_in_kilobytes` in %s SKU and should be removed", resourceId.Name, namespace.Sku.Name) + if sku != namespaces.SkuNamePremium { + return fmt.Errorf("%s does not support input on `max_message_size_in_kilobytes` in %s SKU and should be removed", id, sku) } - parameters.SBQueueProperties.MaxMessageSizeInKilobytes = utils.Int64(int64(v.(int))) + parameters.Properties.MaxMessageSizeInKilobytes = utils.Int64(int64(v.(int))) } - if _, err = client.CreateOrUpdate(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.Name, parameters); err != nil { + if _, err = client.CreateOrUpdate(ctx, id, parameters); err != nil { return err } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceServiceBusQueueRead(d, meta) } @@ -304,62 +304,65 @@ func resourceServiceBusQueueRead(d *pluginsdk.ResourceData, meta interface{}) er ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.QueueID(d.Id()) + id, err := queues.ParseQueueID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("namespace_id", parse.NewNamespaceID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName).ID()) - - if props := resp.SBQueueProperties; props != nil { - d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) - d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) - d.Set("default_message_ttl", props.DefaultMessageTimeToLive) - d.Set("duplicate_detection_history_time_window", props.DuplicateDetectionHistoryTimeWindow) - d.Set("enable_batched_operations", props.EnableBatchedOperations) - d.Set("enable_express", props.EnableExpress) - d.Set("enable_partitioning", props.EnablePartitioning) - d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) - d.Set("forward_to", props.ForwardTo) - d.Set("lock_duration", props.LockDuration) - d.Set("max_delivery_count", props.MaxDeliveryCount) - d.Set("max_message_size_in_kilobytes", props.MaxMessageSizeInKilobytes) - d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) - d.Set("requires_session", props.RequiresSession) - d.Set("status", props.Status) - - if apiMaxSizeInMegabytes := props.MaxSizeInMegabytes; apiMaxSizeInMegabytes != nil { - maxSizeInMegabytes := int(*apiMaxSizeInMegabytes) - - // If the queue is NOT in a premium namespace (ie. it is Basic or Standard) and partitioning is enabled - // then the max size returned by the API will be 16 times greater than the value set. - if *props.EnablePartitioning { - namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespacesClient.Get(ctx, id.ResourceGroup, id.NamespaceName) - if err != nil { - return err + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + + d.Set("name", id.QueueName) + d.Set("namespace_id", namespaceId.ID()) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) + d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) + d.Set("default_message_ttl", props.DefaultMessageTimeToLive) + d.Set("duplicate_detection_history_time_window", props.DuplicateDetectionHistoryTimeWindow) + d.Set("enable_batched_operations", props.EnableBatchedOperations) + d.Set("enable_express", props.EnableExpress) + d.Set("enable_partitioning", props.EnablePartitioning) + d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) + d.Set("forward_to", props.ForwardTo) + d.Set("lock_duration", props.LockDuration) + d.Set("max_delivery_count", props.MaxDeliveryCount) + d.Set("max_message_size_in_kilobytes", props.MaxMessageSizeInKilobytes) + d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) + d.Set("requires_session", props.RequiresSession) + d.Set("status", props.Status) + + if apiMaxSizeInMegabytes := props.MaxSizeInMegabytes; apiMaxSizeInMegabytes != nil { + maxSizeInMegabytes := int(*apiMaxSizeInMegabytes) + + // If the queue is NOT in a premium namespace (ie. it is Basic or Standard) and partitioning is enabled + // then the max size returned by the API will be 16 times greater than the value set. + if *props.EnablePartitioning { + namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient + namespace, err := namespacesClient.Get(ctx, namespaceId) + if err != nil { + return err + } + + if nsModel := namespace.Model; nsModel != nil && nsModel.Sku.Name != namespaces.SkuNamePremium { + const partitionCount = 16 + maxSizeInMegabytes = int(*apiMaxSizeInMegabytes / partitionCount) + } } - if namespace.Sku.Name != servicebus.SkuNamePremium { - const partitionCount = 16 - maxSizeInMegabytes = int(*apiMaxSizeInMegabytes / partitionCount) - } + d.Set("max_size_in_megabytes", maxSizeInMegabytes) } - - d.Set("max_size_in_megabytes", maxSizeInMegabytes) } } - return nil } @@ -368,14 +371,14 @@ func resourceServiceBusQueueDelete(d *pluginsdk.ResourceData, meta interface{}) ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.QueueID(d.Id()) + id, err := queues.ParseQueueID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.NamespaceName, id.Name) + resp, err := client.Delete(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(resp) { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("deleting %s: %+v", id, err) } } diff --git a/internal/services/servicebus/servicebus_queue_resource_test.go b/internal/services/servicebus/servicebus_queue_resource_test.go index 6d45896f459b..c8ea871c522f 100644 --- a/internal/services/servicebus/servicebus_queue_resource_test.go +++ b/internal/services/servicebus/servicebus_queue_resource_test.go @@ -6,10 +6,10 @@ import ( "regexp" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -60,6 +60,7 @@ func TestAccServiceBusQueue_update(t *testing.T) { check.That(data.ResourceName).Key("enable_batched_operations").HasValue("true"), ), }, + data.ImportStep(), { Config: r.update(data), Check: acceptance.ComposeTestCheckFunc( @@ -130,7 +131,7 @@ func TestAccServiceBusQueue_enablePartitioningForPremiumError(t *testing.T) { data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.enablePartitioningForPremiumError(data), - ExpectError: regexp.MustCompile("Partitioning Entities is not supported in Premium SKU and must be disabled"), + ExpectError: regexp.MustCompile("partitioning Entities is not supported in Premium SKU and must be disabled"), }, }) } @@ -366,17 +367,17 @@ func TestAccServiceBusQueue_status(t *testing.T) { } func (t ServiceBusQueueResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.QueueID(state.ID) + id, err := queues.ParseQueueID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.QueuesClient.Get(ctx, id.ResourceGroup, id.NamespaceName, id.Name) + resp, err := clients.ServiceBus.QueuesClient.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus NameSpace Queue (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusQueueResource) basic(data acceptance.TestData) string { diff --git a/internal/services/servicebus/servicebus_subscription_data_source.go b/internal/services/servicebus/servicebus_subscription_data_source.go index 9fc5667917bc..a0cd61b0236b 100644 --- a/internal/services/servicebus/servicebus_subscription_data_source.go +++ b/internal/services/servicebus/servicebus_subscription_data_source.go @@ -4,13 +4,14 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusSubscription() *pluginsdk.Resource { @@ -30,7 +31,7 @@ func dataSourceServiceBusSubscription() *pluginsdk.Resource { "topic_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.TopicID, + ValidateFunc: topics.ValidateTopicID, AtLeastOneOf: []string{"topic_id", "resource_group_name", "namespace_name", "topic_name"}, }, @@ -119,23 +120,23 @@ func dataSourceServiceBusSubscriptionRead(d *pluginsdk.ResourceData, meta interf var nsName string var topicName string if v, ok := d.Get("topic_id").(string); ok && v != "" { - topicId, err := parse.TopicID(v) + topicId, err := subscriptions.ParseTopicID(v) if err != nil { return fmt.Errorf("parsing topic ID %q: %+v", v, err) } - rgName = topicId.ResourceGroup + rgName = topicId.ResourceGroupName nsName = topicId.NamespaceName - topicName = topicId.Name + topicName = topicId.TopicName } else { rgName = d.Get("resource_group_name").(string) nsName = d.Get("namespace_name").(string) topicName = d.Get("topic_name").(string) } - id := parse.NewSubscriptionID(subscriptionId, rgName, nsName, topicName, d.Get("name").(string)) - existing, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.Name) + id := subscriptions.NewSubscriptions2ID(subscriptionId, rgName, nsName, topicName, d.Get("name").(string)) + existing, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(existing.Response) { + if response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("%s was not found", id) } @@ -144,23 +145,25 @@ func dataSourceServiceBusSubscriptionRead(d *pluginsdk.ResourceData, meta interf d.SetId(id.ID()) - if props := existing.SBSubscriptionProperties; props != nil { - d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) - d.Set("default_message_ttl", props.DefaultMessageTimeToLive) - d.Set("lock_duration", props.LockDuration) - d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) - d.Set("dead_lettering_on_filter_evaluation_error", props.DeadLetteringOnFilterEvaluationExceptions) - d.Set("enable_batched_operations", props.EnableBatchedOperations) - d.Set("requires_session", props.RequiresSession) - d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) - d.Set("forward_to", props.ForwardTo) - - maxDeliveryCount := 0 - if props.MaxDeliveryCount != nil { - maxDeliveryCount = int(*props.MaxDeliveryCount) + if model := existing.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) + d.Set("default_message_ttl", props.DefaultMessageTimeToLive) + d.Set("lock_duration", props.LockDuration) + d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) + d.Set("dead_lettering_on_filter_evaluation_error", props.DeadLetteringOnFilterEvaluationExceptions) + d.Set("enable_batched_operations", props.EnableBatchedOperations) + d.Set("requires_session", props.RequiresSession) + d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) + d.Set("forward_to", props.ForwardTo) + + maxDeliveryCount := 0 + if props.MaxDeliveryCount != nil { + maxDeliveryCount = int(*props.MaxDeliveryCount) + } + + d.Set("max_delivery_count", maxDeliveryCount) } - - d.Set("max_delivery_count", maxDeliveryCount) } return nil diff --git a/internal/services/servicebus/servicebus_subscription_resource.go b/internal/services/servicebus/servicebus_subscription_resource.go index ed1f7cba05f7..1bdbf1504d6e 100644 --- a/internal/services/servicebus/servicebus_subscription_resource.go +++ b/internal/services/servicebus/servicebus_subscription_resource.go @@ -5,11 +5,12 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -30,7 +31,7 @@ func resourceServiceBusSubscription() *pluginsdk.Resource { }), Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SubscriptionID(id) + _, err := subscriptions.ParseSubscriptions2ID(id) return err }), @@ -59,7 +60,7 @@ func resourceServicebusSubscriptionSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.TopicID, + ValidateFunc: topics.ValidateTopicID, }, "auto_delete_on_idle": { @@ -122,11 +123,11 @@ func resourceServicebusSubscriptionSchema() map[string]*pluginsdk.Schema { "status": { Type: pluginsdk.TypeString, Optional: true, - Default: string(servicebus.EntityStatusActive), + Default: string(subscriptions.EntityStatusActive), ValidateFunc: validation.StringInSlice([]string{ - string(servicebus.EntityStatusActive), - string(servicebus.EntityStatusDisabled), - string(servicebus.EntityStatusReceiveDisabled), + string(subscriptions.EntityStatusActive), + string(subscriptions.EntityStatusDisabled), + string(subscriptions.EntityStatusReceiveDisabled), }, false), }, } @@ -138,61 +139,62 @@ func resourceServiceBusSubscriptionCreateUpdate(d *pluginsdk.ResourceData, meta defer cancel() log.Printf("[INFO] preparing arguments for ServiceBus Subscription creation.") - var resourceId parse.SubscriptionId + var id subscriptions.Subscriptions2Id if topicIdLit := d.Get("topic_id").(string); topicIdLit != "" { - topicId, _ := parse.TopicID(topicIdLit) - resourceId = parse.NewSubscriptionID(topicId.SubscriptionId, topicId.ResourceGroup, topicId.NamespaceName, topicId.Name, d.Get("name").(string)) + topicId, _ := subscriptions.ParseTopicID(topicIdLit) + id = subscriptions.NewSubscriptions2ID(topicId.SubscriptionId, topicId.ResourceGroupName, topicId.NamespaceName, topicId.TopicName, d.Get("name").(string)) } if d.IsNewResource() { - existing, err := client.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.TopicName, resourceId.Name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_subscription", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_subscription", id.ID()) } } - parameters := servicebus.SBSubscription{ - SBSubscriptionProperties: &servicebus.SBSubscriptionProperties{ + status := subscriptions.EntityStatus(d.Get("status").(string)) + parameters := subscriptions.SBSubscription{ + Properties: &subscriptions.SBSubscriptionProperties{ DeadLetteringOnMessageExpiration: utils.Bool(d.Get("dead_lettering_on_message_expiration").(bool)), DeadLetteringOnFilterEvaluationExceptions: utils.Bool(d.Get("dead_lettering_on_filter_evaluation_error").(bool)), EnableBatchedOperations: utils.Bool(d.Get("enable_batched_operations").(bool)), - MaxDeliveryCount: utils.Int32(int32(d.Get("max_delivery_count").(int))), + MaxDeliveryCount: utils.Int64(int64(d.Get("max_delivery_count").(int))), RequiresSession: utils.Bool(d.Get("requires_session").(bool)), - Status: servicebus.EntityStatus(d.Get("status").(string)), + Status: &status, }, } if autoDeleteOnIdle := d.Get("auto_delete_on_idle").(string); autoDeleteOnIdle != "" { - parameters.SBSubscriptionProperties.AutoDeleteOnIdle = &autoDeleteOnIdle + parameters.Properties.AutoDeleteOnIdle = &autoDeleteOnIdle } if lockDuration := d.Get("lock_duration").(string); lockDuration != "" { - parameters.SBSubscriptionProperties.LockDuration = &lockDuration + parameters.Properties.LockDuration = &lockDuration } if forwardTo := d.Get("forward_to").(string); forwardTo != "" { - parameters.SBSubscriptionProperties.ForwardTo = &forwardTo + parameters.Properties.ForwardTo = &forwardTo } if forwardDeadLetteredMessagesTo := d.Get("forward_dead_lettered_messages_to").(string); forwardDeadLetteredMessagesTo != "" { - parameters.SBSubscriptionProperties.ForwardDeadLetteredMessagesTo = &forwardDeadLetteredMessagesTo + parameters.Properties.ForwardDeadLetteredMessagesTo = &forwardDeadLetteredMessagesTo } if defaultMessageTtl := d.Get("default_message_ttl").(string); defaultMessageTtl != "" { - parameters.DefaultMessageTimeToLive = &defaultMessageTtl + parameters.Properties.DefaultMessageTimeToLive = &defaultMessageTtl } - if _, err := client.CreateOrUpdate(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.TopicName, resourceId.Name, parameters); err != nil { - return fmt.Errorf("creating/updating %s: %v", resourceId, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters); err != nil { + return fmt.Errorf("creating/updating %s: %v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceServiceBusSubscriptionRead(d, meta) } @@ -201,37 +203,39 @@ func resourceServiceBusSubscriptionRead(d *pluginsdk.ResourceData, meta interfac ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SubscriptionID(d.Id()) + id, err := subscriptions.ParseSubscriptions2ID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("topic_id", parse.NewTopicID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.TopicName).ID()) - - if props := resp.SBSubscriptionProperties; props != nil { - d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) - d.Set("default_message_ttl", props.DefaultMessageTimeToLive) - d.Set("lock_duration", props.LockDuration) - d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) - d.Set("dead_lettering_on_filter_evaluation_error", props.DeadLetteringOnFilterEvaluationExceptions) - d.Set("enable_batched_operations", props.EnableBatchedOperations) - d.Set("requires_session", props.RequiresSession) - d.Set("forward_to", props.ForwardTo) - d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) - d.Set("status", utils.String(string(props.Status))) - - if count := props.MaxDeliveryCount; count != nil { - d.Set("max_delivery_count", int(*count)) + d.Set("name", id.SubscriptionName) + d.Set("topic_id", subscriptions.NewTopicID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName).ID()) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) + d.Set("default_message_ttl", props.DefaultMessageTimeToLive) + d.Set("lock_duration", props.LockDuration) + d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration) + d.Set("dead_lettering_on_filter_evaluation_error", props.DeadLetteringOnFilterEvaluationExceptions) + d.Set("enable_batched_operations", props.EnableBatchedOperations) + d.Set("requires_session", props.RequiresSession) + d.Set("forward_to", props.ForwardTo) + d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo) + d.Set("status", utils.String(string(*props.Status))) + + if count := props.MaxDeliveryCount; count != nil { + d.Set("max_delivery_count", int(*count)) + } } } @@ -243,12 +247,12 @@ func resourceServiceBusSubscriptionDelete(d *pluginsdk.ResourceData, meta interf ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SubscriptionID(d.Id()) + id, err := subscriptions.ParseSubscriptions2ID(d.Id()) if err != nil { return err } - if _, err = client.Delete(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.Name); err != nil { + if _, err = client.Delete(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) } diff --git a/internal/services/servicebus/servicebus_subscription_resource_test.go b/internal/services/servicebus/servicebus_subscription_resource_test.go index 56f4a6e7bf7d..1128d776389a 100644 --- a/internal/services/servicebus/servicebus_subscription_resource_test.go +++ b/internal/services/servicebus/servicebus_subscription_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -219,17 +219,17 @@ func TestAccServiceBusSubscription_status(t *testing.T) { } func (t ServiceBusSubscriptionResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SubscriptionID(state.ID) + id, err := subscriptions.ParseSubscriptions2ID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.SubscriptionsClient.Get(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.Name) + resp, err := clients.ServiceBus.SubscriptionsClient.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus NameSpace Subscription (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } const testAccServiceBusSubscription_tfTemplate = ` diff --git a/internal/services/servicebus/servicebus_subscription_rule_resource.go b/internal/services/servicebus/servicebus_subscription_rule_resource.go index 24835ba35e04..129527787491 100644 --- a/internal/services/servicebus/servicebus_subscription_rule_resource.go +++ b/internal/services/servicebus/servicebus_subscription_rule_resource.go @@ -5,11 +5,11 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -26,7 +26,7 @@ func resourceServiceBusSubscriptionRule() *pluginsdk.Resource { Delete: resourceServiceBusSubscriptionRuleDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.SubscriptionRuleID(id) + _, err := rules.ParseRuleID(id) return err }), @@ -55,7 +55,7 @@ func resourceServicebusSubscriptionRuleSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.SubscriptionID, + ValidateFunc: subscriptions.ValidateSubscriptions2ID, DiffSuppressFunc: suppress.CaseDifference, }, @@ -63,8 +63,8 @@ func resourceServicebusSubscriptionRuleSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(servicebus.FilterTypeSQLFilter), - string(servicebus.FilterTypeCorrelationFilter), + string(subscriptions.FilterTypeSqlFilter), + string(subscriptions.FilterTypeCorrelationFilter), }, false), }, @@ -178,108 +178,117 @@ func resourceServicebusSubscriptionRuleSchema() map[string]*pluginsdk.Schema { func resourceServiceBusSubscriptionRuleCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).ServiceBus.SubscriptionRulesClient + subscriptionClient := meta.(*clients.Client).ServiceBus.SubscriptionsClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() log.Printf("[INFO] preparing arguments for Azure Service Bus Subscription Rule creation.") filterType := d.Get("filter_type").(string) - var resourceId parse.SubscriptionRuleId + var id subscriptions.RuleId if subscriptionIdLit := d.Get("subscription_id").(string); subscriptionIdLit != "" { - subscriptionId, _ := parse.SubscriptionID(subscriptionIdLit) - resourceId = parse.NewSubscriptionRuleID(subscriptionId.SubscriptionId, - subscriptionId.ResourceGroup, + subscriptionId, _ := rules.ParseSubscriptions2ID(subscriptionIdLit) + id = subscriptions.NewRuleID(subscriptionId.SubscriptionId, + subscriptionId.ResourceGroupName, subscriptionId.NamespaceName, subscriptionId.TopicName, - subscriptionId.Name, + subscriptionId.SubscriptionName, d.Get("name").(string), ) } if d.IsNewResource() { - existing, err := client.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.TopicName, resourceId.SubscriptionName, resourceId.RuleName) + existing, err := subscriptionClient.RulesGet(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_subscription_rule", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_subscription_rule", id.ID()) } } - rule := servicebus.Rule{ - Ruleproperties: &servicebus.Ruleproperties{ - FilterType: servicebus.FilterType(filterType), + filter := rules.FilterType(filterType) + rule := rules.Rule{ + Properties: &rules.Ruleproperties{ + FilterType: &filter, }, } if action := d.Get("action").(string); action != "" { - rule.Ruleproperties.Action = &servicebus.Action{ - SQLExpression: &action, + rule.Properties.Action = &rules.Action{ + SqlExpression: &action, } } - if rule.Ruleproperties.FilterType == servicebus.FilterTypeCorrelationFilter { + if *rule.Properties.FilterType == rules.FilterTypeCorrelationFilter { correlationFilter, err := expandAzureRmServiceBusCorrelationFilter(d) if err != nil { return fmt.Errorf("expanding `correlation_filter`: %+v", err) } - rule.Ruleproperties.CorrelationFilter = correlationFilter + rule.Properties.CorrelationFilter = correlationFilter } - if rule.Ruleproperties.FilterType == servicebus.FilterTypeSQLFilter { + if *rule.Properties.FilterType == rules.FilterTypeSqlFilter { sqlFilter := d.Get("sql_filter").(string) - rule.Ruleproperties.SQLFilter = &servicebus.SQLFilter{ - SQLExpression: &sqlFilter, + rule.Properties.SqlFilter = &rules.SqlFilter{ + SqlExpression: &sqlFilter, } } - if _, err := client.CreateOrUpdate(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.TopicName, resourceId.SubscriptionName, resourceId.RuleName, rule); err != nil { - return fmt.Errorf("creating/updating %s: %+v", resourceId, err) + // switch this around so that the rule id from subscription is generated for the get method + ruleId, err := rules.ParseRuleID(id.ID()) + if err != nil { + return err + } + if _, err := client.CreateOrUpdate(ctx, *ruleId, rule); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceServiceBusSubscriptionRuleRead(d, meta) } func resourceServiceBusSubscriptionRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.SubscriptionRulesClient + client := meta.(*clients.Client).ServiceBus.SubscriptionsClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SubscriptionRuleID(d.Id()) + id, err := subscriptions.ParseRuleID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.SubscriptionName, id.RuleName) + resp, err := client.RulesGet(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("subscription_id", parse.NewSubscriptionID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.TopicName, id.SubscriptionName).ID()) + d.Set("subscription_id", subscriptions.NewSubscriptions2ID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName, id.SubscriptionName).ID()) d.Set("name", id.RuleName) - if properties := resp.Ruleproperties; properties != nil { - d.Set("filter_type", properties.FilterType) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("filter_type", props.FilterType) - if properties.Action != nil { - d.Set("action", properties.Action.SQLExpression) - } + if props.Action != nil { + d.Set("action", props.Action.SqlExpression) + } - if properties.SQLFilter != nil { - d.Set("sql_filter", properties.SQLFilter.SQLExpression) - } + if props.SqlFilter != nil { + d.Set("sql_filter", props.SqlFilter.SqlExpression) + } - if err := d.Set("correlation_filter", flattenAzureRmServiceBusCorrelationFilter(properties.CorrelationFilter)); err != nil { - return fmt.Errorf("setting `correlation_filter`: %+v", err) + if err := d.Set("correlation_filter", flattenAzureRmServiceBusCorrelationFilter(props.CorrelationFilter)); err != nil { + return fmt.Errorf("setting `correlation_filter`: %+v", err) + } } } @@ -291,14 +300,14 @@ func resourceServiceBusSubscriptionRuleDelete(d *pluginsdk.ResourceData, meta in ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.SubscriptionRuleID(d.Id()) + id, err := rules.ParseRuleID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.SubscriptionName, id.RuleName) + resp, err := client.Delete(ctx, *id) if err != nil { - if !response.WasNotFound(resp.Response) { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("deleting %s: %+v", id, err) } } @@ -306,7 +315,7 @@ func resourceServiceBusSubscriptionRuleDelete(d *pluginsdk.ResourceData, meta in return nil } -func expandAzureRmServiceBusCorrelationFilter(d *pluginsdk.ResourceData) (*servicebus.CorrelationFilter, error) { +func expandAzureRmServiceBusCorrelationFilter(d *pluginsdk.ResourceData) (*rules.CorrelationFilter, error) { configs := d.Get("correlation_filter").([]interface{}) if len(configs) == 0 { return nil, fmt.Errorf("`correlation_filter` is required when `filter_type` is set to `CorrelationFilter`") @@ -322,20 +331,21 @@ func expandAzureRmServiceBusCorrelationFilter(d *pluginsdk.ResourceData) (*servi replyToSessionID := config["reply_to_session_id"].(string) sessionID := config["session_id"].(string) to := config["to"].(string) - properties := utils.ExpandMapStringPtrString(config["properties"].(map[string]interface{})) - if contentType == "" && correlationID == "" && label == "" && messageID == "" && replyTo == "" && replyToSessionID == "" && sessionID == "" && to == "" && len(properties) == 0 { - return nil, fmt.Errorf("At least one property must be set in the `correlation_filter` block") + properties := expandProperties(config["properties"].(map[string]interface{})) + + if contentType == "" && correlationID == "" && label == "" && messageID == "" && replyTo == "" && replyToSessionID == "" && sessionID == "" && to == "" && len(*properties) == 0 { + return nil, fmt.Errorf("at least one property must be set in the `correlation_filter` block") } - correlationFilter := servicebus.CorrelationFilter{} + correlationFilter := rules.CorrelationFilter{} if correlationID != "" { - correlationFilter.CorrelationID = utils.String(correlationID) + correlationFilter.CorrelationId = utils.String(correlationID) } if messageID != "" { - correlationFilter.MessageID = utils.String(messageID) + correlationFilter.MessageId = utils.String(messageID) } if to != "" { @@ -351,37 +361,37 @@ func expandAzureRmServiceBusCorrelationFilter(d *pluginsdk.ResourceData) (*servi } if sessionID != "" { - correlationFilter.SessionID = utils.String(sessionID) + correlationFilter.SessionId = utils.String(sessionID) } if replyToSessionID != "" { - correlationFilter.ReplyToSessionID = utils.String(replyToSessionID) + correlationFilter.ReplyToSessionId = utils.String(replyToSessionID) } if contentType != "" { correlationFilter.ContentType = utils.String(contentType) } - if len(properties) > 0 { + if len(*properties) > 0 { correlationFilter.Properties = properties } return &correlationFilter, nil } -func flattenAzureRmServiceBusCorrelationFilter(input *servicebus.CorrelationFilter) []interface{} { +func flattenAzureRmServiceBusCorrelationFilter(input *subscriptions.CorrelationFilter) []interface{} { if input == nil { return []interface{}{} } filter := make(map[string]interface{}) - if input.CorrelationID != nil { - filter["correlation_id"] = *input.CorrelationID + if input.CorrelationId != nil { + filter["correlation_id"] = *input.CorrelationId } - if input.MessageID != nil { - filter["message_id"] = *input.MessageID + if input.MessageId != nil { + filter["message_id"] = *input.MessageId } if input.To != nil { @@ -396,12 +406,12 @@ func flattenAzureRmServiceBusCorrelationFilter(input *servicebus.CorrelationFilt filter["label"] = *input.Label } - if input.SessionID != nil { - filter["session_id"] = *input.SessionID + if input.SessionId != nil { + filter["session_id"] = *input.SessionId } - if input.ReplyToSessionID != nil { - filter["reply_to_session_id"] = *input.ReplyToSessionID + if input.ReplyToSessionId != nil { + filter["reply_to_session_id"] = *input.ReplyToSessionId } if input.ContentType != nil { @@ -409,8 +419,28 @@ func flattenAzureRmServiceBusCorrelationFilter(input *servicebus.CorrelationFilt } if input.Properties != nil { - filter["properties"] = utils.FlattenMapStringPtrString(input.Properties) + filter["properties"] = flattenProperties(input.Properties) } return []interface{}{filter} } + +func expandProperties(input map[string]interface{}) *map[string]string { + output := make(map[string]string) + for k, v := range input { + output[k] = v.(string) + } + return &output +} + +func flattenProperties(input *map[string]string) map[string]*string { + output := make(map[string]*string) + + if input != nil { + for k, v := range *input { + output[k] = utils.String(v) + } + } + + return output +} diff --git a/internal/services/servicebus/servicebus_subscription_rule_resource_test.go b/internal/services/servicebus/servicebus_subscription_rule_resource_test.go index 644466858b6a..d2ac989b31f8 100644 --- a/internal/services/servicebus/servicebus_subscription_rule_resource_test.go +++ b/internal/services/servicebus/servicebus_subscription_rule_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -153,17 +153,17 @@ func TestAccServiceBusSubscriptionRule_updateSqlFilterToCorrelationFilter(t *tes } func (t ServiceBusSubscriptionRuleResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.SubscriptionRuleID(state.ID) + id, err := subscriptions.ParseRuleID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.SubscriptionRulesClient.Get(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.SubscriptionName, id.RuleName) + resp, err := clients.ServiceBus.SubscriptionsClient.RulesGet(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus NameSpace Subscription Rule (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (r ServiceBusSubscriptionRuleResource) basicSqlFilter(data acceptance.TestData) string { diff --git a/internal/services/servicebus/servicebus_topic_authorization_rule_data_source.go b/internal/services/servicebus/servicebus_topic_authorization_rule_data_source.go index 3236af7a4ffa..584094358a5c 100644 --- a/internal/services/servicebus/servicebus_topic_authorization_rule_data_source.go +++ b/internal/services/servicebus/servicebus_topic_authorization_rule_data_source.go @@ -4,13 +4,15 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusTopicAuthorizationRule() *pluginsdk.Resource { @@ -31,7 +33,7 @@ func dataSourceServiceBusTopicAuthorizationRule() *pluginsdk.Resource { "topic_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.TopicID, + ValidateFunc: topics.ValidateTopicID, AtLeastOneOf: []string{"topic_id", "resource_group_name", "namespace_name", "queue_name"}, }, @@ -118,7 +120,7 @@ func dataSourceServiceBusTopicAuthorizationRule() *pluginsdk.Resource { } func dataSourceServiceBusTopicAuthorizationRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.TopicsClient + client := meta.(*clients.Client).ServiceBus.TopicsAuthClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -127,29 +129,29 @@ func dataSourceServiceBusTopicAuthorizationRuleRead(d *pluginsdk.ResourceData, m var nsName string var topicName string if v, ok := d.Get("topic_id").(string); ok && v != "" { - topicId, err := parse.TopicID(v) + topicId, err := topicsauthorizationrule.ParseTopicID(v) if err != nil { return fmt.Errorf("parsing topic ID %q: %+v", v, err) } - rgName = topicId.ResourceGroup + rgName = topicId.ResourceGroupName nsName = topicId.NamespaceName - topicName = topicId.Name + topicName = topicId.TopicName } else { rgName = d.Get("resource_group_name").(string) nsName = d.Get("namespace_name").(string) topicName = d.Get("topic_name").(string) } - id := parse.NewTopicAuthorizationRuleID(subscriptionId, rgName, nsName, topicName, d.Get("name").(string)) - resp, err := client.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) + id := topicsauthorizationrule.NewTopicAuthorizationRuleID(subscriptionId, rgName, nsName, topicName, d.Get("name").(string)) + resp, err := client.TopicsGetAuthorizationRule(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) } - keysResp, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) + keysResp, err := client.TopicsListKeys(ctx, id) if err != nil { return fmt.Errorf("listing keys for %s: %+v", id, err) } @@ -158,21 +160,25 @@ func dataSourceServiceBusTopicAuthorizationRuleRead(d *pluginsdk.ResourceData, m d.Set("name", id.AuthorizationRuleName) d.Set("topic_name", id.TopicName) d.Set("namespace_name", id.NamespaceName) - d.Set("resource_group_name", id.ResourceGroup) - - if properties := resp.SBAuthorizationRuleProperties; properties != nil { - listen, send, manage := flattenAuthorizationRuleRights(properties.Rights) - d.Set("listen", listen) - d.Set("send", send) - d.Set("manage", manage) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + listen, send, manage := flattenTopicAuthorizationRuleRights(&props.Rights) + d.Set("listen", listen) + d.Set("send", send) + d.Set("manage", manage) + } } - d.Set("primary_key", keysResp.PrimaryKey) - d.Set("primary_connection_string", keysResp.PrimaryConnectionString) - d.Set("secondary_key", keysResp.SecondaryKey) - d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) - d.Set("primary_connection_string_alias", keysResp.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keysResp.AliasSecondaryConnectionString) + if model := keysResp.Model; model != nil { + d.Set("primary_key", model.PrimaryKey) + d.Set("primary_connection_string", model.PrimaryConnectionString) + d.Set("secondary_key", model.SecondaryKey) + d.Set("secondary_connection_string", model.SecondaryConnectionString) + d.Set("primary_connection_string_alias", model.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", model.AliasSecondaryConnectionString) + } return nil } diff --git a/internal/services/servicebus/servicebus_topic_authorization_rule_resource.go b/internal/services/servicebus/servicebus_topic_authorization_rule_resource.go index 0b246eb5a342..bd66957eaa06 100644 --- a/internal/services/servicebus/servicebus_topic_authorization_rule_resource.go +++ b/internal/services/servicebus/servicebus_topic_authorization_rule_resource.go @@ -5,10 +5,12 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -23,7 +25,7 @@ func resourceServiceBusTopicAuthorizationRule() *pluginsdk.Resource { Delete: resourceServiceBusTopicAuthorizationRuleDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.TopicAuthorizationRuleID(id) + _, err := topicsauthorizationrule.ParseTopicAuthorizationRuleID(id) return err }), @@ -54,69 +56,73 @@ func resourceServiceBusTopicAuthorizationRuleSchema() map[string]*pluginsdk.Sche Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.TopicID, + ValidateFunc: topics.ValidateTopicID, }, } } func resourceServiceBusTopicAuthorizationRuleCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.TopicsClient + client := meta.(*clients.Client).ServiceBus.TopicsAuthClient ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() log.Printf("[INFO] preparing arguments for AzureRM ServiceBus Topic Authorization Rule creation.") - var resourceId parse.TopicAuthorizationRuleId + var id topicsauthorizationrule.TopicAuthorizationRuleId if topicIdLit := d.Get("topic_id").(string); topicIdLit != "" { - topicId, _ := parse.TopicID(topicIdLit) - resourceId = parse.NewTopicAuthorizationRuleID(topicId.SubscriptionId, topicId.ResourceGroup, topicId.NamespaceName, topicId.Name, d.Get("name").(string)) + topicId, err := topicsauthorizationrule.ParseTopicID(topicIdLit) + if err != nil { + return err + } + id = topicsauthorizationrule.NewTopicAuthorizationRuleID(topicId.SubscriptionId, topicId.ResourceGroupName, topicId.NamespaceName, topicId.TopicName, d.Get("name").(string)) } if d.IsNewResource() { - existing, err := client.GetAuthorizationRule(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.TopicName, resourceId.AuthorizationRuleName) + existing, err := client.TopicsGetAuthorizationRule(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_servicebus_topic_authorization_rule", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_servicebus_topic_authorization_rule", id.ID()) } } - parameters := servicebus.SBAuthorizationRule{ - Name: utils.String(resourceId.AuthorizationRuleName), - SBAuthorizationRuleProperties: &servicebus.SBAuthorizationRuleProperties{ - Rights: expandAuthorizationRuleRights(d), + parameters := topicsauthorizationrule.SBAuthorizationRule{ + Name: utils.String(id.AuthorizationRuleName), + Properties: &topicsauthorizationrule.SBAuthorizationRuleProperties{ + Rights: *expandTopicAuthorizationRuleRights(d), }, } - if _, err := client.CreateOrUpdateAuthorizationRule(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.TopicName, resourceId.AuthorizationRuleName, parameters); err != nil { - return fmt.Errorf("creating/updating %s: %+v", resourceId, err) + if _, err := client.TopicsCreateOrUpdateAuthorizationRule(ctx, id, parameters); err != nil { + return fmt.Errorf("creating/updating %s: %+v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) - if err := waitForPairedNamespaceReplication(ctx, meta, resourceId.ResourceGroup, resourceId.NamespaceName, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { - return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", resourceId.NamespaceName, resourceId.ResourceGroup, err) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + if err := waitForPairedNamespaceReplication(ctx, meta, namespaceId, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { + return fmt.Errorf("waiting for replication to complete for %s: %+v", id, err) } return resourceServiceBusTopicAuthorizationRuleRead(d, meta) } func resourceServiceBusTopicAuthorizationRuleRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.TopicsClient + client := meta.(*clients.Client).ServiceBus.TopicsAuthClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TopicAuthorizationRuleID(d.Id()) + id, err := topicsauthorizationrule.ParseTopicAuthorizationRuleID(d.Id()) if err != nil { return err } - resp, err := client.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) + resp, err := client.TopicsGetAuthorizationRule(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } @@ -124,47 +130,90 @@ func resourceServiceBusTopicAuthorizationRuleRead(d *pluginsdk.ResourceData, met } d.Set("name", id.AuthorizationRuleName) - d.Set("topic_id", parse.NewTopicID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName, id.TopicName).ID()) - - if properties := resp.SBAuthorizationRuleProperties; properties != nil { - listen, send, manage := flattenAuthorizationRuleRights(properties.Rights) - d.Set("listen", listen) - d.Set("send", send) - d.Set("manage", manage) + d.Set("topic_id", topicsauthorizationrule.NewTopicID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName).ID()) + + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + listen, send, manage := flattenTopicAuthorizationRuleRights(&props.Rights) + d.Set("listen", listen) + d.Set("send", send) + d.Set("manage", manage) + } } - keysResp, err := client.ListKeys(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) + keysResp, err := client.TopicsListKeys(ctx, *id) if err != nil { return fmt.Errorf("listing keys for %s: %+v", id, err) } - d.Set("primary_key", keysResp.PrimaryKey) - d.Set("primary_connection_string", keysResp.PrimaryConnectionString) - d.Set("secondary_key", keysResp.SecondaryKey) - d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) - d.Set("primary_connection_string_alias", keysResp.AliasPrimaryConnectionString) - d.Set("secondary_connection_string_alias", keysResp.AliasSecondaryConnectionString) + if model := keysResp.Model; model != nil { + d.Set("primary_key", model.PrimaryKey) + d.Set("primary_connection_string", model.PrimaryConnectionString) + d.Set("secondary_key", model.SecondaryKey) + d.Set("secondary_connection_string", model.SecondaryConnectionString) + d.Set("primary_connection_string_alias", model.AliasPrimaryConnectionString) + d.Set("secondary_connection_string_alias", model.AliasSecondaryConnectionString) + } return nil } func resourceServiceBusTopicAuthorizationRuleDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ServiceBus.TopicsClient + client := meta.(*clients.Client).ServiceBus.TopicsAuthClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TopicAuthorizationRuleID(d.Id()) + id, err := topicsauthorizationrule.ParseTopicAuthorizationRuleID(d.Id()) if err != nil { return err } - if _, err = client.DeleteAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName); err != nil { + if _, err = client.TopicsDeleteAuthorizationRule(ctx, *id); err != nil { return fmt.Errorf("deleting %s: %+v", id, err) } - if err := waitForPairedNamespaceReplication(ctx, meta, id.ResourceGroup, id.NamespaceName, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { - return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", id.NamespaceName, id.ResourceGroup, err) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + + if err := waitForPairedNamespaceReplication(ctx, meta, namespaceId, d.Timeout(pluginsdk.TimeoutUpdate)); err != nil { + return fmt.Errorf("waiting for replication to complete for Service Bus Namespace Disaster Recovery Configs (Namespace %q / Resource Group %q): %s", id.NamespaceName, id.ResourceGroupName, err) } return nil } + +func expandTopicAuthorizationRuleRights(d *pluginsdk.ResourceData) *[]topicsauthorizationrule.AccessRights { + rights := make([]topicsauthorizationrule.AccessRights, 0) + + if d.Get("listen").(bool) { + rights = append(rights, topicsauthorizationrule.AccessRightsListen) + } + + if d.Get("send").(bool) { + rights = append(rights, topicsauthorizationrule.AccessRightsSend) + } + + if d.Get("manage").(bool) { + rights = append(rights, topicsauthorizationrule.AccessRightsManage) + } + + return &rights +} + +func flattenTopicAuthorizationRuleRights(rights *[]topicsauthorizationrule.AccessRights) (listen, send, manage bool) { + if rights != nil { + for _, right := range *rights { + switch right { + case topicsauthorizationrule.AccessRightsListen: + listen = true + case topicsauthorizationrule.AccessRightsSend: + send = true + case topicsauthorizationrule.AccessRightsManage: + manage = true + default: + log.Printf("[DEBUG] Unknown Authorization Rule Right '%s'", right) + } + } + } + + return listen, send, manage +} diff --git a/internal/services/servicebus/servicebus_topic_authorization_rule_resource_test.go b/internal/services/servicebus/servicebus_topic_authorization_rule_resource_test.go index 6242d47d1a7b..cc95707037d1 100644 --- a/internal/services/servicebus/servicebus_topic_authorization_rule_resource_test.go +++ b/internal/services/servicebus/servicebus_topic_authorization_rule_resource_test.go @@ -6,10 +6,10 @@ import ( "strconv" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -137,17 +137,17 @@ func TestAccServiceBusTopicAuthorizationRule_withAliasConnectionString(t *testin } func (t ServiceBusTopicAuthorizationRuleResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.TopicAuthorizationRuleID(state.ID) + id, err := topicsauthorizationrule.ParseTopicAuthorizationRuleID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.TopicsClient.GetAuthorizationRule(ctx, id.ResourceGroup, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) + resp, err := clients.ServiceBus.TopicsAuthClient.TopicsGetAuthorizationRule(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus Topic Authorization Rule (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusTopicAuthorizationRuleResource) base(data acceptance.TestData, listen, send, manage bool) string { diff --git a/internal/services/servicebus/servicebus_topic_data_source.go b/internal/services/servicebus/servicebus_topic_data_source.go index 72ccf8f18d14..192214d1248d 100644 --- a/internal/services/servicebus/servicebus_topic_data_source.go +++ b/internal/services/servicebus/servicebus_topic_data_source.go @@ -4,15 +4,15 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" azValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceServiceBusTopic() *pluginsdk.Resource { @@ -33,7 +33,7 @@ func dataSourceServiceBusTopic() *pluginsdk.Resource { "namespace_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"}, }, @@ -113,67 +113,75 @@ func dataSourceServiceBusTopicRead(d *pluginsdk.ResourceData, meta interface{}) subscriptionId := meta.(*clients.Client).Account.SubscriptionId defer cancel() - name := d.Get("name").(string) - var resourceGroup string var namespaceName string if v, ok := d.Get("namespace_id").(string); ok && v != "" { - namespaceId, err := parse.NamespaceID(v) + namespaceId, err := topics.ParseNamespaceID(v) if err != nil { - return fmt.Errorf("parsing topic ID %q: %+v", v, err) + return err } - resourceGroup = namespaceId.ResourceGroup - namespaceName = namespaceId.Name + resourceGroup = namespaceId.ResourceGroupName + namespaceName = namespaceId.NamespaceName } else { resourceGroup = d.Get("resource_group_name").(string) namespaceName = d.Get("namespace_name").(string) } - id := parse.NewTopicID(subscriptionId, resourceGroup, namespaceName, name) - resp, err := client.Get(ctx, resourceGroup, namespaceName, name) + id := topics.NewTopicID(subscriptionId, resourceGroup, namespaceName, d.Get("name").(string)) + + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Service Bus Topic %q was not found in Resource Group %q Namespace %q", name, resourceGroup, namespaceName) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("making Read request on Azure Service Bus Topic %q in Resource Group %q Namespace %q: %v", name, resourceGroup, namespaceName, err) + return fmt.Errorf("retrieving %s: %v", id, err) } d.SetId(id.ID()) - if props := resp.SBTopicProperties; props != nil { - d.Set("status", string(props.Status)) - d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) - d.Set("default_message_ttl", props.DefaultMessageTimeToLive) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + status := "" + if v := props.Status; v != nil { + status = string(*v) + } + d.Set("status", status) + d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) + d.Set("default_message_ttl", props.DefaultMessageTimeToLive) - if window := props.DuplicateDetectionHistoryTimeWindow; window != nil && *window != "" { - d.Set("duplicate_detection_history_time_window", window) - } + if window := props.DuplicateDetectionHistoryTimeWindow; window != nil && *window != "" { + d.Set("duplicate_detection_history_time_window", window) + } - d.Set("enable_batched_operations", props.EnableBatchedOperations) - d.Set("enable_express", props.EnableExpress) - d.Set("enable_partitioning", props.EnablePartitioning) - d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) - d.Set("support_ordering", props.SupportOrdering) - - if maxSizeMB := props.MaxSizeInMegabytes; maxSizeMB != nil { - maxSize := int(*props.MaxSizeInMegabytes) - - // if the topic is in a premium namespace and partitioning is enabled then the - // max size returned by the API will be 16 times greater than the value set - if partitioning := props.EnablePartitioning; partitioning != nil && *partitioning { - namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespacesClient.Get(ctx, resourceGroup, namespaceName) - if err != nil { - return err + d.Set("enable_batched_operations", props.EnableBatchedOperations) + d.Set("enable_express", props.EnableExpress) + d.Set("enable_partitioning", props.EnablePartitioning) + d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) + d.Set("support_ordering", props.SupportOrdering) + + if maxSizeMB := props.MaxSizeInMegabytes; maxSizeMB != nil { + maxSize := int(*props.MaxSizeInMegabytes) + + // if the topic is in a premium namespace and partitioning is enabled then the + // max size returned by the API will be 16 times greater than the value set + if partitioning := props.EnablePartitioning; partitioning != nil && *partitioning { + namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + namespace, err := namespacesClient.Get(ctx, namespaceId) + if err != nil { + return err + } + + if namespaceModel := namespace.Model; namespaceModel != nil { + if namespaceModel.Sku.Name != namespaces.SkuNamePremium { + const partitionCount = 16 + maxSize = int(*props.MaxSizeInMegabytes / partitionCount) + } + } } - if namespace.Sku.Name != servicebus.SkuNamePremium { - const partitionCount = 16 - maxSize = int(*props.MaxSizeInMegabytes / partitionCount) - } + d.Set("max_size_in_megabytes", maxSize) } - - d.Set("max_size_in_megabytes", maxSize) } } diff --git a/internal/services/servicebus/servicebus_topic_resource.go b/internal/services/servicebus/servicebus_topic_resource.go index 8421c276c9bf..26b74ad2cb17 100644 --- a/internal/services/servicebus/servicebus_topic_resource.go +++ b/internal/services/servicebus/servicebus_topic_resource.go @@ -5,11 +5,12 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" azValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -25,7 +26,7 @@ func resourceServiceBusTopic() *pluginsdk.Resource { Delete: resourceServiceBusTopicDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.TopicID(id) + _, err := topics.ParseTopicID(id) return err }), @@ -54,16 +55,16 @@ func resourceServiceBusTopicSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: azValidate.NamespaceID, + ValidateFunc: namespaces.ValidateNamespaceID, }, "status": { Type: pluginsdk.TypeString, Optional: true, - Default: string(servicebus.EntityStatusActive), + Default: string(topics.EntityStatusActive), ValidateFunc: validation.StringInSlice([]string{ - string(servicebus.EntityStatusActive), - string(servicebus.EntityStatusDisabled), + string(topics.EntityStatusActive), + string(topics.EntityStatusDisabled), }, false), }, @@ -140,79 +141,78 @@ func resourceServiceBusTopicCreateUpdate(d *pluginsdk.ResourceData, meta interfa defer cancel() log.Printf("[INFO] preparing arguments for Azure ServiceBus Topic creation.") - status := d.Get("status").(string) - - enableBatchedOps := d.Get("enable_batched_operations").(bool) - enableExpress := d.Get("enable_express").(bool) - enablePartitioning := d.Get("enable_partitioning").(bool) - maxSize := int32(d.Get("max_size_in_megabytes").(int)) - requiresDuplicateDetection := d.Get("requires_duplicate_detection").(bool) - supportOrdering := d.Get("support_ordering").(bool) - - var resourceId parse.TopicId + var id topics.TopicId if namespaceIdLit := d.Get("namespace_id").(string); namespaceIdLit != "" { - namespaceId, _ := parse.NamespaceID(namespaceIdLit) - resourceId = parse.NewTopicID(namespaceId.SubscriptionId, namespaceId.ResourceGroup, namespaceId.Name, d.Get("name").(string)) + namespaceId, err := topics.ParseNamespaceID(namespaceIdLit) + if err != nil { + return err + } + id = topics.NewTopicID(namespaceId.SubscriptionId, namespaceId.ResourceGroupName, namespaceId.NamespaceName, d.Get("name").(string)) } if d.IsNewResource() { - existing, err := client.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.Name) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", resourceId, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_service_fabric_cluster", resourceId.ID()) + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_service_fabric_cluster", id.ID()) } } - parameters := servicebus.SBTopic{ - Name: utils.String(resourceId.Name), - SBTopicProperties: &servicebus.SBTopicProperties{ - Status: servicebus.EntityStatus(status), - EnableBatchedOperations: utils.Bool(enableBatchedOps), - EnableExpress: utils.Bool(enableExpress), - EnablePartitioning: utils.Bool(enablePartitioning), - MaxSizeInMegabytes: utils.Int32(maxSize), - RequiresDuplicateDetection: utils.Bool(requiresDuplicateDetection), - SupportOrdering: utils.Bool(supportOrdering), + status := topics.EntityStatus(d.Get("status").(string)) + parameters := topics.SBTopic{ + Name: utils.String(id.TopicName), + Properties: &topics.SBTopicProperties{ + Status: &status, + EnableBatchedOperations: utils.Bool(d.Get("enable_batched_operations").(bool)), + EnableExpress: utils.Bool(d.Get("enable_express").(bool)), + EnablePartitioning: utils.Bool(d.Get("enable_partitioning").(bool)), + MaxSizeInMegabytes: utils.Int64(int64(d.Get("max_size_in_megabytes").(int))), + RequiresDuplicateDetection: utils.Bool(d.Get("requires_duplicate_detection").(bool)), + SupportOrdering: utils.Bool(d.Get("support_ordering").(bool)), }, } if autoDeleteOnIdle := d.Get("auto_delete_on_idle").(string); autoDeleteOnIdle != "" { - parameters.SBTopicProperties.AutoDeleteOnIdle = utils.String(autoDeleteOnIdle) + parameters.Properties.AutoDeleteOnIdle = utils.String(autoDeleteOnIdle) } if defaultTTL := d.Get("default_message_ttl").(string); defaultTTL != "" { - parameters.SBTopicProperties.DefaultMessageTimeToLive = utils.String(defaultTTL) + parameters.Properties.DefaultMessageTimeToLive = utils.String(defaultTTL) } if duplicateWindow := d.Get("duplicate_detection_history_time_window").(string); duplicateWindow != "" { - parameters.SBTopicProperties.DuplicateDetectionHistoryTimeWindow = utils.String(duplicateWindow) + parameters.Properties.DuplicateDetectionHistoryTimeWindow = utils.String(duplicateWindow) } // We need to retrieve the namespace because Premium namespace works differently from Basic and Standard namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespacesClient.Get(ctx, resourceId.ResourceGroup, resourceId.NamespaceName) + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + resp, err := namespacesClient.Get(ctx, namespaceId) if err != nil { - return fmt.Errorf("retrieving ServiceBus Namespace %q (Resource Group %q): %+v", resourceId.NamespaceName, resourceId.ResourceGroup, err) + return fmt.Errorf("retrieving ServiceBus Namespace %q (Resource Group %q): %+v", id.NamespaceName, id.ResourceGroupName, err) } // output of `max_message_size_in_kilobytes` is also set in non-Premium namespaces, with a value of 256 if v, ok := d.GetOk("max_message_size_in_kilobytes"); ok && v.(int) != 256 { - if namespace.Sku.Name != servicebus.SkuNamePremium { - return fmt.Errorf("ServiceBus Topic %q does not support input on `max_message_size_in_kilobytes` in %s SKU and should be removed", resourceId.Name, namespace.Sku.Name) + if model := resp.Model; model != nil { + if model.Sku.Name != namespaces.SkuNamePremium { + return fmt.Errorf("%s does not support input on `max_message_size_in_kilobytes` in %s SKU and should be removed", id, model.Sku.Name) + } + parameters.Properties.MaxMessageSizeInKilobytes = utils.Int64(int64(v.(int))) } - parameters.SBTopicProperties.MaxMessageSizeInKilobytes = utils.Int64(int64(v.(int))) + } - if _, err := client.CreateOrUpdate(ctx, resourceId.ResourceGroup, resourceId.NamespaceName, resourceId.Name, parameters); err != nil { - return fmt.Errorf("creating/updating %s: %v", resourceId, err) + if _, err := client.CreateOrUpdate(ctx, id, parameters); err != nil { + return fmt.Errorf("creating/updating %s: %v", id, err) } - d.SetId(resourceId.ID()) + d.SetId(id.ID()) return resourceServiceBusTopicRead(d, meta) } @@ -221,58 +221,67 @@ func resourceServiceBusTopicRead(d *pluginsdk.ResourceData, meta interface{}) er ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TopicID(d.Id()) + id, err := topics.ParseTopicID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.NamespaceName, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", id.Name) - d.Set("namespace_id", parse.NewNamespaceID(id.SubscriptionId, id.ResourceGroup, id.NamespaceName).ID()) + d.Set("name", id.TopicName) + d.Set("namespace_id", topics.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName).ID()) - if props := resp.SBTopicProperties; props != nil { - d.Set("status", string(props.Status)) - d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) - d.Set("default_message_ttl", props.DefaultMessageTimeToLive) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + status := "" + if v := props.Status; v != nil { + status = string(*v) + } + d.Set("status", status) + d.Set("auto_delete_on_idle", props.AutoDeleteOnIdle) + d.Set("default_message_ttl", props.DefaultMessageTimeToLive) - if window := props.DuplicateDetectionHistoryTimeWindow; window != nil && *window != "" { - d.Set("duplicate_detection_history_time_window", window) - } + if window := props.DuplicateDetectionHistoryTimeWindow; window != nil && *window != "" { + d.Set("duplicate_detection_history_time_window", window) + } - d.Set("enable_batched_operations", props.EnableBatchedOperations) - d.Set("enable_express", props.EnableExpress) - d.Set("enable_partitioning", props.EnablePartitioning) - d.Set("max_message_size_in_kilobytes", props.MaxMessageSizeInKilobytes) - d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) - d.Set("support_ordering", props.SupportOrdering) - - if maxSizeMB := props.MaxSizeInMegabytes; maxSizeMB != nil { - maxSize := int(*props.MaxSizeInMegabytes) - - // if the topic is in a premium namespace and partitioning is enabled then the - // max size returned by the API will be 16 times greater than the value set - if partitioning := props.EnablePartitioning; partitioning != nil && *partitioning { - namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient - namespace, err := namespacesClient.Get(ctx, id.ResourceGroup, id.NamespaceName) - if err != nil { - return err + d.Set("enable_batched_operations", props.EnableBatchedOperations) + d.Set("enable_express", props.EnableExpress) + d.Set("enable_partitioning", props.EnablePartitioning) + d.Set("max_message_size_in_kilobytes", props.MaxMessageSizeInKilobytes) + d.Set("requires_duplicate_detection", props.RequiresDuplicateDetection) + d.Set("support_ordering", props.SupportOrdering) + + if maxSizeMB := props.MaxSizeInMegabytes; maxSizeMB != nil { + maxSize := int(*props.MaxSizeInMegabytes) + + // if the topic is in a premium namespace and partitioning is enabled then the + // max size returned by the API will be 16 times greater than the value set + if partitioning := props.EnablePartitioning; partitioning != nil && *partitioning { + namespacesClient := meta.(*clients.Client).ServiceBus.NamespacesClient + namespaceId := namespaces.NewNamespaceID(id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) + namespaceResp, err := namespacesClient.Get(ctx, namespaceId) + if err != nil { + return err + } + + if namespaceModel := namespaceResp.Model; namespaceModel != nil { + if namespaceModel.Sku.Name != namespaces.SkuNamePremium { + const partitionCount = 16 + maxSize = int(*props.MaxSizeInMegabytes / partitionCount) + } + } } - if namespace.Sku.Name != servicebus.SkuNamePremium { - const partitionCount = 16 - maxSize = int(*props.MaxSizeInMegabytes / partitionCount) - } + d.Set("max_size_in_megabytes", maxSize) } - - d.Set("max_size_in_megabytes", maxSize) } } @@ -284,14 +293,14 @@ func resourceServiceBusTopicDelete(d *pluginsdk.ResourceData, meta interface{}) ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.TopicID(d.Id()) + id, err := topics.ParseTopicID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ResourceGroup, id.NamespaceName, id.Name) + resp, err := client.Delete(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(resp) { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("deleting %s: %+v", id, err) } } diff --git a/internal/services/servicebus/servicebus_topic_resource_test.go b/internal/services/servicebus/servicebus_topic_resource_test.go index d5b718978705..8eac17ea09ce 100644 --- a/internal/services/servicebus/servicebus_topic_resource_test.go +++ b/internal/services/servicebus/servicebus_topic_resource_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics" "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/services/servicebus/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -226,17 +226,17 @@ func TestAccServiceBusTopic_isoTimeSpanAttributes(t *testing.T) { } func (t ServiceBusTopicResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.TopicID(state.ID) + id, err := topics.ParseTopicID(state.ID) if err != nil { return nil, err } - resp, err := clients.ServiceBus.TopicsClient.Get(ctx, id.ResourceGroup, id.NamespaceName, id.Name) + resp, err := clients.ServiceBus.TopicsClient.Get(ctx, *id) if err != nil { - return nil, fmt.Errorf("reading Service Bus Topic (%s): %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return utils.Bool(resp.ID != nil), nil + return utils.Bool(resp.Model != nil), nil } func (ServiceBusTopicResource) basic(data acceptance.TestData) string { diff --git a/internal/services/servicebus/transition.go b/internal/services/servicebus/transition.go new file mode 100644 index 000000000000..449c32f02993 --- /dev/null +++ b/internal/services/servicebus/transition.go @@ -0,0 +1,23 @@ +package servicebus + +import "github.com/hashicorp/terraform-provider-azurerm/utils" + +func expandTags(input map[string]interface{}) *map[string]string { + output := make(map[string]string) + for k, v := range input { + output[k] = v.(string) + } + return &output +} + +func flattenTags(input *map[string]string) map[string]*string { + output := make(map[string]*string) + + if input != nil { + for k, v := range *input { + output[k] = utils.String(v) + } + } + + return output +} diff --git a/internal/services/servicebus/validate/namespace_authorization_rule_id.go b/internal/services/servicebus/validate/namespace_authorization_rule_id.go deleted file mode 100644 index eebbfa60318b..000000000000 --- a/internal/services/servicebus/validate/namespace_authorization_rule_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func NamespaceAuthorizationRuleID(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 := parse.NamespaceAuthorizationRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/namespace_authorization_rule_id_test.go b/internal/services/servicebus/validate/namespace_authorization_rule_id_test.go deleted file mode 100644 index 3f534cb11511..000000000000 --- a/internal/services/servicebus/validate/namespace_authorization_rule_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNamespaceAuthorizationRuleID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/AuthorizationRules/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/AuthorizationRules/authorizationRule1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/AUTHORIZATIONRULES/AUTHORIZATIONRULE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NamespaceAuthorizationRuleID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/namespace_disaster_recovery_config_id.go b/internal/services/servicebus/validate/namespace_disaster_recovery_config_id.go deleted file mode 100644 index f7172936f1c2..000000000000 --- a/internal/services/servicebus/validate/namespace_disaster_recovery_config_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func NamespaceDisasterRecoveryConfigID(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 := parse.NamespaceDisasterRecoveryConfigID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/namespace_disaster_recovery_config_id_test.go b/internal/services/servicebus/validate/namespace_disaster_recovery_config_id_test.go deleted file mode 100644 index 3cfe79782170..000000000000 --- a/internal/services/servicebus/validate/namespace_disaster_recovery_config_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNamespaceDisasterRecoveryConfigID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing DisasterRecoveryConfigName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for DisasterRecoveryConfigName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/disasterRecoveryConfigs/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/disasterRecoveryConfigs/aliasName1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/DISASTERRECOVERYCONFIGS/ALIASNAME1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NamespaceDisasterRecoveryConfigID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/namespace_id.go b/internal/services/servicebus/validate/namespace_id.go deleted file mode 100644 index 3f659acb776d..000000000000 --- a/internal/services/servicebus/validate/namespace_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func NamespaceID(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 := parse.NamespaceID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/namespace_id_test.go b/internal/services/servicebus/validate/namespace_id_test.go deleted file mode 100644 index a2e216ed0f6b..000000000000 --- a/internal/services/servicebus/validate/namespace_id_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNamespaceID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NamespaceID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/queue_authorization_rule_id.go b/internal/services/servicebus/validate/queue_authorization_rule_id.go deleted file mode 100644 index 1b353fa468c1..000000000000 --- a/internal/services/servicebus/validate/queue_authorization_rule_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func QueueAuthorizationRuleID(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 := parse.QueueAuthorizationRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/queue_authorization_rule_id_test.go b/internal/services/servicebus/validate/queue_authorization_rule_id_test.go deleted file mode 100644 index 3f22f53443b3..000000000000 --- a/internal/services/servicebus/validate/queue_authorization_rule_id_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestQueueAuthorizationRuleID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing QueueName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for QueueName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/", - Valid: false, - }, - - { - // missing AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/", - Valid: false, - }, - - { - // missing value for AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/authorizationRule1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/QUEUES/QUEUE1/AUTHORIZATIONRULES/AUTHORIZATIONRULE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := QueueAuthorizationRuleID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/queue_id.go b/internal/services/servicebus/validate/queue_id.go deleted file mode 100644 index 4e2296d7e49e..000000000000 --- a/internal/services/servicebus/validate/queue_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func QueueID(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 := parse.QueueID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/queue_id_test.go b/internal/services/servicebus/validate/queue_id_test.go deleted file mode 100644 index 2ec5822cee89..000000000000 --- a/internal/services/servicebus/validate/queue_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestQueueID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/QUEUES/QUEUE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := QueueID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/subscription_id.go b/internal/services/servicebus/validate/subscription_id.go deleted file mode 100644 index 2b4c61e583d8..000000000000 --- a/internal/services/servicebus/validate/subscription_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func SubscriptionID(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 := parse.SubscriptionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/subscription_id_test.go b/internal/services/servicebus/validate/subscription_id_test.go deleted file mode 100644 index a64caf635d23..000000000000 --- a/internal/services/servicebus/validate/subscription_id_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSubscriptionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Valid: false, - }, - - { - // missing Name - Input: "/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1/SUBSCRIPTIONS/SUBSCRIPTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SubscriptionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/subscription_rule_id.go b/internal/services/servicebus/validate/subscription_rule_id.go deleted file mode 100644 index d175f3d5547a..000000000000 --- a/internal/services/servicebus/validate/subscription_rule_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func SubscriptionRuleID(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 := parse.SubscriptionRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/subscription_rule_id_test.go b/internal/services/servicebus/validate/subscription_rule_id_test.go deleted file mode 100644 index b8f236dea44b..000000000000 --- a/internal/services/servicebus/validate/subscription_rule_id_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSubscriptionRuleID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Valid: false, - }, - - { - // missing SubscriptionName - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/", - Valid: false, - }, - - { - // missing RuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/", - Valid: false, - }, - - { - // missing value for RuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/rules/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/subscriptions/subscription1/rules/rule1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1/SUBSCRIPTIONS/SUBSCRIPTION1/RULES/RULE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SubscriptionRuleID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/topic_authorization_rule_id.go b/internal/services/servicebus/validate/topic_authorization_rule_id.go deleted file mode 100644 index ecf764e68529..000000000000 --- a/internal/services/servicebus/validate/topic_authorization_rule_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func TopicAuthorizationRuleID(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 := parse.TopicAuthorizationRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/topic_authorization_rule_id_test.go b/internal/services/servicebus/validate/topic_authorization_rule_id_test.go deleted file mode 100644 index ccf3d40fe39e..000000000000 --- a/internal/services/servicebus/validate/topic_authorization_rule_id_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestTopicAuthorizationRuleID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for TopicName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Valid: false, - }, - - { - // missing AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/", - Valid: false, - }, - - { - // missing value for AuthorizationRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/authorizationRules/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1/authorizationRules/authorizationRule1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1/AUTHORIZATIONRULES/AUTHORIZATIONRULE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := TopicAuthorizationRuleID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/servicebus/validate/topic_id.go b/internal/services/servicebus/validate/topic_id.go deleted file mode 100644 index 76d8988c4305..000000000000 --- a/internal/services/servicebus/validate/topic_id.go +++ /dev/null @@ -1,23 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/parse" -) - -func TopicID(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 := parse.TopicID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/servicebus/validate/topic_id_test.go b/internal/services/servicebus/validate/topic_id_test.go deleted file mode 100644 index 2e110d1166df..000000000000 --- a/internal/services/servicebus/validate/topic_id_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestTopicID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/", - Valid: false, - }, - - { - // missing value for NamespaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.ServiceBus/namespaces/namespace1/topics/topic1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.SERVICEBUS/NAMESPACES/NAMESPACE1/TOPICS/TOPIC1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := TopicID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/CHANGELOG.md deleted file mode 100644 index 52911e4cc5e4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -# Change History - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/_meta.json deleted file mode 100644 index 48dcf3c45aac..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "af463c3f9502d353b8a009685177f13335adb8cd", - "readme": "/_/azure-rest-api-specs/specification/servicebus/resource-manager/readme.md", - "tag": "package-2021-06-preview", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-06-preview --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/servicebus/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/client.go deleted file mode 100644 index 149da60ad477..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/client.go +++ /dev/null @@ -1,41 +0,0 @@ -// Package servicebus implements the Azure ARM Servicebus service API version 2021-06-01-preview. -// -// -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( - // DefaultBaseURI is the default URI used for the service Servicebus - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Servicebus. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with -// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/disasterrecoveryconfigs.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/disasterrecoveryconfigs.go deleted file mode 100644 index e9857e1e57f8..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/disasterrecoveryconfigs.go +++ /dev/null @@ -1,1040 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// DisasterRecoveryConfigsClient is the client for the DisasterRecoveryConfigs methods of the Servicebus service. -type DisasterRecoveryConfigsClient struct { - BaseClient -} - -// NewDisasterRecoveryConfigsClient creates an instance of the DisasterRecoveryConfigsClient client. -func NewDisasterRecoveryConfigsClient(subscriptionID string) DisasterRecoveryConfigsClient { - return NewDisasterRecoveryConfigsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewDisasterRecoveryConfigsClientWithBaseURI creates an instance of the DisasterRecoveryConfigsClient client using a -// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, -// Azure stack). -func NewDisasterRecoveryConfigsClientWithBaseURI(baseURI string, subscriptionID string) DisasterRecoveryConfigsClient { - return DisasterRecoveryConfigsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// BreakPairing this operation disables the Disaster Recovery and stops replicating changes from primary to secondary -// namespaces -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -func (client DisasterRecoveryConfigsClient) BreakPairing(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.BreakPairing") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "BreakPairing", err.Error()) - } - - req, err := client.BreakPairingPreparer(ctx, resourceGroupName, namespaceName, alias) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "BreakPairing", nil, "Failure preparing request") - return - } - - resp, err := client.BreakPairingSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "BreakPairing", resp, "Failure sending request") - return - } - - result, err = client.BreakPairingResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "BreakPairing", resp, "Failure responding to request") - return - } - - return -} - -// BreakPairingPreparer prepares the BreakPairing request. -func (client DisasterRecoveryConfigsClient) BreakPairingPreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// BreakPairingSender sends the BreakPairing request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) BreakPairingSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// BreakPairingResponder handles the response to the BreakPairing request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) BreakPairingResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// CheckNameAvailabilityMethod check the give namespace name availability. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// parameters - parameters to check availability of the given namespace name -func (client DisasterRecoveryConfigsClient) CheckNameAvailabilityMethod(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckNameAvailability) (result CheckNameAvailabilityResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.CheckNameAvailabilityMethod") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "CheckNameAvailabilityMethod", err.Error()) - } - - req, err := client.CheckNameAvailabilityMethodPreparer(ctx, resourceGroupName, namespaceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "CheckNameAvailabilityMethod", nil, "Failure preparing request") - return - } - - resp, err := client.CheckNameAvailabilityMethodSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "CheckNameAvailabilityMethod", resp, "Failure sending request") - return - } - - result, err = client.CheckNameAvailabilityMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "CheckNameAvailabilityMethod", resp, "Failure responding to request") - return - } - - return -} - -// CheckNameAvailabilityMethodPreparer prepares the CheckNameAvailabilityMethod request. -func (client DisasterRecoveryConfigsClient) CheckNameAvailabilityMethodPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckNameAvailability) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckNameAvailabilityMethodSender sends the CheckNameAvailabilityMethod request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) CheckNameAvailabilityMethodSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CheckNameAvailabilityMethodResponder handles the response to the CheckNameAvailabilityMethod request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) CheckNameAvailabilityMethodResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdate creates or updates a new Alias(Disaster Recovery configuration) -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -// parameters - parameters required to create an Alias(Disaster Recovery configuration) -func (client DisasterRecoveryConfigsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, alias string, parameters ArmDisasterRecovery) (result ArmDisasterRecovery, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, alias, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client DisasterRecoveryConfigsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string, parameters ArmDisasterRecovery) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) CreateOrUpdateResponder(resp *http.Response) (result ArmDisasterRecovery, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes an Alias(Disaster Recovery configuration) -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -func (client DisasterRecoveryConfigsClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, alias) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client DisasterRecoveryConfigsClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// FailOver invokes GEO DR failover and reconfigure the alias to point to the secondary namespace -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -// parameters - parameters required to create an Alias(Disaster Recovery configuration) -func (client DisasterRecoveryConfigsClient) FailOver(ctx context.Context, resourceGroupName string, namespaceName string, alias string, parameters *FailoverProperties) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.FailOver") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "FailOver", err.Error()) - } - - req, err := client.FailOverPreparer(ctx, resourceGroupName, namespaceName, alias, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "FailOver", nil, "Failure preparing request") - return - } - - resp, err := client.FailOverSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "FailOver", resp, "Failure sending request") - return - } - - result, err = client.FailOverResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "FailOver", resp, "Failure responding to request") - return - } - - return -} - -// FailOverPreparer prepares the FailOver request. -func (client DisasterRecoveryConfigsClient) FailOverPreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string, parameters *FailoverProperties) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if parameters != nil { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithJSON(parameters)) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// FailOverSender sends the FailOver request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) FailOverSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// FailOverResponder handles the response to the FailOver request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) FailOverResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -func (client DisasterRecoveryConfigsClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (result ArmDisasterRecovery, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, alias) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client DisasterRecoveryConfigsClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) GetResponder(resp *http.Response) (result ArmDisasterRecovery, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAuthorizationRule gets an authorization rule for a namespace by rule name. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -// authorizationRuleName - the authorization rule name. -func (client DisasterRecoveryConfigsClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, alias string, authorizationRuleName string) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.GetAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "GetAuthorizationRule", err.Error()) - } - - req, err := client.GetAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, alias, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.GetAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "GetAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.GetAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "GetAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request. -func (client DisasterRecoveryConfigsClient) GetAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) GetAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets all Alias(Disaster Recovery configurations) -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client DisasterRecoveryConfigsClient) List(ctx context.Context, resourceGroupName string, namespaceName string) (result ArmDisasterRecoveryListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.List") - defer func() { - sc := -1 - if result.adrlr.Response.Response != nil { - sc = result.adrlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.adrlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "List", resp, "Failure sending request") - return - } - - result.adrlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "List", resp, "Failure responding to request") - return - } - if result.adrlr.hasNextLink() && result.adrlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client DisasterRecoveryConfigsClient) ListPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) ListResponder(resp *http.Response) (result ArmDisasterRecoveryListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client DisasterRecoveryConfigsClient) listNextResults(ctx context.Context, lastResults ArmDisasterRecoveryListResult) (result ArmDisasterRecoveryListResult, err error) { - req, err := lastResults.armDisasterRecoveryListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client DisasterRecoveryConfigsClient) ListComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result ArmDisasterRecoveryListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, namespaceName) - return -} - -// ListAuthorizationRules gets the authorization rules for a namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -func (client DisasterRecoveryConfigsClient) ListAuthorizationRules(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (result SBAuthorizationRuleListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.sarlr.Response.Response != nil { - sc = result.sarlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "ListAuthorizationRules", err.Error()) - } - - result.fn = client.listAuthorizationRulesNextResults - req, err := client.ListAuthorizationRulesPreparer(ctx, resourceGroupName, namespaceName, alias) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.sarlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "ListAuthorizationRules", resp, "Failure sending request") - return - } - - result.sarlr, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "ListAuthorizationRules", resp, "Failure responding to request") - return - } - if result.sarlr.hasNextLink() && result.sarlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. -func (client DisasterRecoveryConfigsClient) ListAuthorizationRulesPreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) ListAuthorizationRulesResponder(resp *http.Response) (result SBAuthorizationRuleListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAuthorizationRulesNextResults retrieves the next set of results, if any. -func (client DisasterRecoveryConfigsClient) listAuthorizationRulesNextResults(ctx context.Context, lastResults SBAuthorizationRuleListResult) (result SBAuthorizationRuleListResult, err error) { - req, err := lastResults.sBAuthorizationRuleListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "listAuthorizationRulesNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "listAuthorizationRulesNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "listAuthorizationRulesNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAuthorizationRulesComplete enumerates all values, automatically crossing page boundaries as required. -func (client DisasterRecoveryConfigsClient) ListAuthorizationRulesComplete(ctx context.Context, resourceGroupName string, namespaceName string, alias string) (result SBAuthorizationRuleListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListAuthorizationRules(ctx, resourceGroupName, namespaceName, alias) - return -} - -// ListKeys gets the primary and secondary connection strings for the namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// alias - the Disaster Recovery configuration name -// authorizationRuleName - the authorization rule name. -func (client DisasterRecoveryConfigsClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, alias string, authorizationRuleName string) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DisasterRecoveryConfigsClient.ListKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: alias, - Constraints: []validation.Constraint{{Target: "alias", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "alias", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.DisasterRecoveryConfigsClient", "ListKeys", err.Error()) - } - - req, err := client.ListKeysPreparer(ctx, resourceGroupName, namespaceName, alias, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp, err := client.ListKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "ListKeys", resp, "Failure sending request") - return - } - - result, err = client.ListKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.DisasterRecoveryConfigsClient", "ListKeys", resp, "Failure responding to request") - return - } - - return -} - -// ListKeysPreparer prepares the ListKeys request. -func (client DisasterRecoveryConfigsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, alias string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "alias": autorest.Encode("path", alias), - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/authorizationRules/{authorizationRuleName}/listKeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListKeysSender sends the ListKeys request. The method will close the -// http.Response Body if it receives an error. -func (client DisasterRecoveryConfigsClient) ListKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListKeysResponder handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (client DisasterRecoveryConfigsClient) ListKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/enums.go deleted file mode 100644 index 52ad60d6ba50..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/enums.go +++ /dev/null @@ -1,310 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// AccessRights enumerates the values for access rights. -type AccessRights string - -const ( - // AccessRightsListen ... - AccessRightsListen AccessRights = "Listen" - // AccessRightsManage ... - AccessRightsManage AccessRights = "Manage" - // AccessRightsSend ... - AccessRightsSend AccessRights = "Send" -) - -// PossibleAccessRightsValues returns an array of possible values for the AccessRights const type. -func PossibleAccessRightsValues() []AccessRights { - return []AccessRights{AccessRightsListen, AccessRightsManage, AccessRightsSend} -} - -// CreatedByType enumerates the values for created by type. -type CreatedByType string - -const ( - // CreatedByTypeApplication ... - CreatedByTypeApplication CreatedByType = "Application" - // CreatedByTypeKey ... - CreatedByTypeKey CreatedByType = "Key" - // CreatedByTypeManagedIdentity ... - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - // CreatedByTypeUser ... - CreatedByTypeUser CreatedByType = "User" -) - -// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. -func PossibleCreatedByTypeValues() []CreatedByType { - return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} -} - -// DefaultAction enumerates the values for default action. -type DefaultAction string - -const ( - // DefaultActionAllow ... - DefaultActionAllow DefaultAction = "Allow" - // DefaultActionDeny ... - DefaultActionDeny DefaultAction = "Deny" -) - -// PossibleDefaultActionValues returns an array of possible values for the DefaultAction const type. -func PossibleDefaultActionValues() []DefaultAction { - return []DefaultAction{DefaultActionAllow, DefaultActionDeny} -} - -// EndPointProvisioningState enumerates the values for end point provisioning state. -type EndPointProvisioningState string - -const ( - // EndPointProvisioningStateCanceled ... - EndPointProvisioningStateCanceled EndPointProvisioningState = "Canceled" - // EndPointProvisioningStateCreating ... - EndPointProvisioningStateCreating EndPointProvisioningState = "Creating" - // EndPointProvisioningStateDeleting ... - EndPointProvisioningStateDeleting EndPointProvisioningState = "Deleting" - // EndPointProvisioningStateFailed ... - EndPointProvisioningStateFailed EndPointProvisioningState = "Failed" - // EndPointProvisioningStateSucceeded ... - EndPointProvisioningStateSucceeded EndPointProvisioningState = "Succeeded" - // EndPointProvisioningStateUpdating ... - EndPointProvisioningStateUpdating EndPointProvisioningState = "Updating" -) - -// PossibleEndPointProvisioningStateValues returns an array of possible values for the EndPointProvisioningState const type. -func PossibleEndPointProvisioningStateValues() []EndPointProvisioningState { - return []EndPointProvisioningState{EndPointProvisioningStateCanceled, EndPointProvisioningStateCreating, EndPointProvisioningStateDeleting, EndPointProvisioningStateFailed, EndPointProvisioningStateSucceeded, EndPointProvisioningStateUpdating} -} - -// EntityStatus enumerates the values for entity status. -type EntityStatus string - -const ( - // EntityStatusActive ... - EntityStatusActive EntityStatus = "Active" - // EntityStatusCreating ... - EntityStatusCreating EntityStatus = "Creating" - // EntityStatusDeleting ... - EntityStatusDeleting EntityStatus = "Deleting" - // EntityStatusDisabled ... - EntityStatusDisabled EntityStatus = "Disabled" - // EntityStatusReceiveDisabled ... - EntityStatusReceiveDisabled EntityStatus = "ReceiveDisabled" - // EntityStatusRenaming ... - EntityStatusRenaming EntityStatus = "Renaming" - // EntityStatusRestoring ... - EntityStatusRestoring EntityStatus = "Restoring" - // EntityStatusSendDisabled ... - EntityStatusSendDisabled EntityStatus = "SendDisabled" - // EntityStatusUnknown ... - EntityStatusUnknown EntityStatus = "Unknown" -) - -// PossibleEntityStatusValues returns an array of possible values for the EntityStatus const type. -func PossibleEntityStatusValues() []EntityStatus { - return []EntityStatus{EntityStatusActive, EntityStatusCreating, EntityStatusDeleting, EntityStatusDisabled, EntityStatusReceiveDisabled, EntityStatusRenaming, EntityStatusRestoring, EntityStatusSendDisabled, EntityStatusUnknown} -} - -// FilterType enumerates the values for filter type. -type FilterType string - -const ( - // FilterTypeCorrelationFilter ... - FilterTypeCorrelationFilter FilterType = "CorrelationFilter" - // FilterTypeSQLFilter ... - FilterTypeSQLFilter FilterType = "SqlFilter" -) - -// PossibleFilterTypeValues returns an array of possible values for the FilterType const type. -func PossibleFilterTypeValues() []FilterType { - return []FilterType{FilterTypeCorrelationFilter, FilterTypeSQLFilter} -} - -// KeySource enumerates the values for key source. -type KeySource string - -const ( - // KeySourceMicrosoftKeyVault ... - KeySourceMicrosoftKeyVault KeySource = "Microsoft.KeyVault" -) - -// PossibleKeySourceValues returns an array of possible values for the KeySource const type. -func PossibleKeySourceValues() []KeySource { - return []KeySource{KeySourceMicrosoftKeyVault} -} - -// KeyType enumerates the values for key type. -type KeyType string - -const ( - // KeyTypePrimaryKey ... - KeyTypePrimaryKey KeyType = "PrimaryKey" - // KeyTypeSecondaryKey ... - KeyTypeSecondaryKey KeyType = "SecondaryKey" -) - -// PossibleKeyTypeValues returns an array of possible values for the KeyType const type. -func PossibleKeyTypeValues() []KeyType { - return []KeyType{KeyTypePrimaryKey, KeyTypeSecondaryKey} -} - -// ManagedServiceIdentityType enumerates the values for managed service identity type. -type ManagedServiceIdentityType string - -const ( - // ManagedServiceIdentityTypeNone ... - ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" - // ManagedServiceIdentityTypeSystemAssigned ... - ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" - // ManagedServiceIdentityTypeSystemAssignedUserAssigned ... - ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned, UserAssigned" - // ManagedServiceIdentityTypeUserAssigned ... - ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" -) - -// PossibleManagedServiceIdentityTypeValues returns an array of possible values for the ManagedServiceIdentityType const type. -func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { - return []ManagedServiceIdentityType{ManagedServiceIdentityTypeNone, ManagedServiceIdentityTypeSystemAssigned, ManagedServiceIdentityTypeSystemAssignedUserAssigned, ManagedServiceIdentityTypeUserAssigned} -} - -// NetworkRuleIPAction enumerates the values for network rule ip action. -type NetworkRuleIPAction string - -const ( - // NetworkRuleIPActionAllow ... - NetworkRuleIPActionAllow NetworkRuleIPAction = "Allow" -) - -// PossibleNetworkRuleIPActionValues returns an array of possible values for the NetworkRuleIPAction const type. -func PossibleNetworkRuleIPActionValues() []NetworkRuleIPAction { - return []NetworkRuleIPAction{NetworkRuleIPActionAllow} -} - -// PrivateLinkConnectionStatus enumerates the values for private link connection status. -type PrivateLinkConnectionStatus string - -const ( - // PrivateLinkConnectionStatusApproved ... - PrivateLinkConnectionStatusApproved PrivateLinkConnectionStatus = "Approved" - // PrivateLinkConnectionStatusDisconnected ... - PrivateLinkConnectionStatusDisconnected PrivateLinkConnectionStatus = "Disconnected" - // PrivateLinkConnectionStatusPending ... - PrivateLinkConnectionStatusPending PrivateLinkConnectionStatus = "Pending" - // PrivateLinkConnectionStatusRejected ... - PrivateLinkConnectionStatusRejected PrivateLinkConnectionStatus = "Rejected" -) - -// PossiblePrivateLinkConnectionStatusValues returns an array of possible values for the PrivateLinkConnectionStatus const type. -func PossiblePrivateLinkConnectionStatusValues() []PrivateLinkConnectionStatus { - return []PrivateLinkConnectionStatus{PrivateLinkConnectionStatusApproved, PrivateLinkConnectionStatusDisconnected, PrivateLinkConnectionStatusPending, PrivateLinkConnectionStatusRejected} -} - -// ProvisioningStateDR enumerates the values for provisioning state dr. -type ProvisioningStateDR string - -const ( - // ProvisioningStateDRAccepted ... - ProvisioningStateDRAccepted ProvisioningStateDR = "Accepted" - // ProvisioningStateDRFailed ... - ProvisioningStateDRFailed ProvisioningStateDR = "Failed" - // ProvisioningStateDRSucceeded ... - ProvisioningStateDRSucceeded ProvisioningStateDR = "Succeeded" -) - -// PossibleProvisioningStateDRValues returns an array of possible values for the ProvisioningStateDR const type. -func PossibleProvisioningStateDRValues() []ProvisioningStateDR { - return []ProvisioningStateDR{ProvisioningStateDRAccepted, ProvisioningStateDRFailed, ProvisioningStateDRSucceeded} -} - -// PublicNetworkAccessFlag enumerates the values for public network access flag. -type PublicNetworkAccessFlag string - -const ( - // PublicNetworkAccessFlagDisabled ... - PublicNetworkAccessFlagDisabled PublicNetworkAccessFlag = "Disabled" - // PublicNetworkAccessFlagEnabled ... - PublicNetworkAccessFlagEnabled PublicNetworkAccessFlag = "Enabled" -) - -// PossiblePublicNetworkAccessFlagValues returns an array of possible values for the PublicNetworkAccessFlag const type. -func PossiblePublicNetworkAccessFlagValues() []PublicNetworkAccessFlag { - return []PublicNetworkAccessFlag{PublicNetworkAccessFlagDisabled, PublicNetworkAccessFlagEnabled} -} - -// RoleDisasterRecovery enumerates the values for role disaster recovery. -type RoleDisasterRecovery string - -const ( - // RoleDisasterRecoveryPrimary ... - RoleDisasterRecoveryPrimary RoleDisasterRecovery = "Primary" - // RoleDisasterRecoveryPrimaryNotReplicating ... - RoleDisasterRecoveryPrimaryNotReplicating RoleDisasterRecovery = "PrimaryNotReplicating" - // RoleDisasterRecoverySecondary ... - RoleDisasterRecoverySecondary RoleDisasterRecovery = "Secondary" -) - -// PossibleRoleDisasterRecoveryValues returns an array of possible values for the RoleDisasterRecovery const type. -func PossibleRoleDisasterRecoveryValues() []RoleDisasterRecovery { - return []RoleDisasterRecovery{RoleDisasterRecoveryPrimary, RoleDisasterRecoveryPrimaryNotReplicating, RoleDisasterRecoverySecondary} -} - -// SkuName enumerates the values for sku name. -type SkuName string - -const ( - // SkuNameBasic ... - SkuNameBasic SkuName = "Basic" - // SkuNamePremium ... - SkuNamePremium SkuName = "Premium" - // SkuNameStandard ... - SkuNameStandard SkuName = "Standard" -) - -// PossibleSkuNameValues returns an array of possible values for the SkuName const type. -func PossibleSkuNameValues() []SkuName { - return []SkuName{SkuNameBasic, SkuNamePremium, SkuNameStandard} -} - -// SkuTier enumerates the values for sku tier. -type SkuTier string - -const ( - // SkuTierBasic ... - SkuTierBasic SkuTier = "Basic" - // SkuTierPremium ... - SkuTierPremium SkuTier = "Premium" - // SkuTierStandard ... - SkuTierStandard SkuTier = "Standard" -) - -// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. -func PossibleSkuTierValues() []SkuTier { - return []SkuTier{SkuTierBasic, SkuTierPremium, SkuTierStandard} -} - -// UnavailableReason enumerates the values for unavailable reason. -type UnavailableReason string - -const ( - // UnavailableReasonInvalidName ... - UnavailableReasonInvalidName UnavailableReason = "InvalidName" - // UnavailableReasonNameInLockdown ... - UnavailableReasonNameInLockdown UnavailableReason = "NameInLockdown" - // UnavailableReasonNameInUse ... - UnavailableReasonNameInUse UnavailableReason = "NameInUse" - // UnavailableReasonNone ... - UnavailableReasonNone UnavailableReason = "None" - // UnavailableReasonSubscriptionIsDisabled ... - UnavailableReasonSubscriptionIsDisabled UnavailableReason = "SubscriptionIsDisabled" - // UnavailableReasonTooManyNamespaceInCurrentSubscription ... - UnavailableReasonTooManyNamespaceInCurrentSubscription UnavailableReason = "TooManyNamespaceInCurrentSubscription" -) - -// PossibleUnavailableReasonValues returns an array of possible values for the UnavailableReason const type. -func PossibleUnavailableReasonValues() []UnavailableReason { - return []UnavailableReason{UnavailableReasonInvalidName, UnavailableReasonNameInLockdown, UnavailableReasonNameInUse, UnavailableReasonNone, UnavailableReasonSubscriptionIsDisabled, UnavailableReasonTooManyNamespaceInCurrentSubscription} -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/migrationconfigs.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/migrationconfigs.go deleted file mode 100644 index 4157d2940a9c..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/migrationconfigs.go +++ /dev/null @@ -1,608 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// MigrationConfigsClient is the client for the MigrationConfigs methods of the Servicebus service. -type MigrationConfigsClient struct { - BaseClient -} - -// NewMigrationConfigsClient creates an instance of the MigrationConfigsClient client. -func NewMigrationConfigsClient(subscriptionID string) MigrationConfigsClient { - return NewMigrationConfigsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewMigrationConfigsClientWithBaseURI creates an instance of the MigrationConfigsClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewMigrationConfigsClientWithBaseURI(baseURI string, subscriptionID string) MigrationConfigsClient { - return MigrationConfigsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CompleteMigration this operation Completes Migration of entities by pointing the connection strings to Premium -// namespace and any entities created after the operation will be under Premium Namespace. CompleteMigration operation -// will fail when entity migration is in-progress. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client MigrationConfigsClient) CompleteMigration(ctx context.Context, resourceGroupName string, namespaceName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.CompleteMigration") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.MigrationConfigsClient", "CompleteMigration", err.Error()) - } - - req, err := client.CompleteMigrationPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "CompleteMigration", nil, "Failure preparing request") - return - } - - resp, err := client.CompleteMigrationSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "CompleteMigration", resp, "Failure sending request") - return - } - - result, err = client.CompleteMigrationResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "CompleteMigration", resp, "Failure responding to request") - return - } - - return -} - -// CompleteMigrationPreparer prepares the CompleteMigration request. -func (client MigrationConfigsClient) CompleteMigrationPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "configName": autorest.Encode("path", "$default"), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/upgrade", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CompleteMigrationSender sends the CompleteMigration request. The method will close the -// http.Response Body if it receives an error. -func (client MigrationConfigsClient) CompleteMigrationSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CompleteMigrationResponder handles the response to the CompleteMigration request. The method always -// closes the http.Response Body. -func (client MigrationConfigsClient) CompleteMigrationResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// CreateAndStartMigration creates Migration configuration and starts migration of entities from Standard to Premium -// namespace -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// parameters - parameters required to create Migration Configuration -func (client MigrationConfigsClient) CreateAndStartMigration(ctx context.Context, resourceGroupName string, namespaceName string, parameters MigrationConfigProperties) (result MigrationConfigsCreateAndStartMigrationFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.CreateAndStartMigration") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.MigrationConfigPropertiesProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.MigrationConfigPropertiesProperties.TargetNamespace", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.MigrationConfigPropertiesProperties.PostMigrationName", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("servicebus.MigrationConfigsClient", "CreateAndStartMigration", err.Error()) - } - - req, err := client.CreateAndStartMigrationPreparer(ctx, resourceGroupName, namespaceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "CreateAndStartMigration", nil, "Failure preparing request") - return - } - - result, err = client.CreateAndStartMigrationSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "CreateAndStartMigration", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateAndStartMigrationPreparer prepares the CreateAndStartMigration request. -func (client MigrationConfigsClient) CreateAndStartMigrationPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters MigrationConfigProperties) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "configName": autorest.Encode("path", "$default"), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateAndStartMigrationSender sends the CreateAndStartMigration request. The method will close the -// http.Response Body if it receives an error. -func (client MigrationConfigsClient) CreateAndStartMigrationSender(req *http.Request) (future MigrationConfigsCreateAndStartMigrationFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateAndStartMigrationResponder handles the response to the CreateAndStartMigration request. The method always -// closes the http.Response Body. -func (client MigrationConfigsClient) CreateAndStartMigrationResponder(resp *http.Response) (result MigrationConfigProperties, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a MigrationConfiguration -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client MigrationConfigsClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.MigrationConfigsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client MigrationConfigsClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "configName": autorest.Encode("path", "$default"), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client MigrationConfigsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client MigrationConfigsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get retrieves Migration Config -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client MigrationConfigsClient) Get(ctx context.Context, resourceGroupName string, namespaceName string) (result MigrationConfigProperties, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.MigrationConfigsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client MigrationConfigsClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "configName": autorest.Encode("path", "$default"), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client MigrationConfigsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client MigrationConfigsClient) GetResponder(resp *http.Response) (result MigrationConfigProperties, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets all migrationConfigurations -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client MigrationConfigsClient) List(ctx context.Context, resourceGroupName string, namespaceName string) (result MigrationConfigListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.List") - defer func() { - sc := -1 - if result.mclr.Response.Response != nil { - sc = result.mclr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.MigrationConfigsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.mclr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "List", resp, "Failure sending request") - return - } - - result.mclr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "List", resp, "Failure responding to request") - return - } - if result.mclr.hasNextLink() && result.mclr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client MigrationConfigsClient) ListPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client MigrationConfigsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client MigrationConfigsClient) ListResponder(resp *http.Response) (result MigrationConfigListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client MigrationConfigsClient) listNextResults(ctx context.Context, lastResults MigrationConfigListResult) (result MigrationConfigListResult, err error) { - req, err := lastResults.migrationConfigListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client MigrationConfigsClient) ListComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result MigrationConfigListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, namespaceName) - return -} - -// Revert this operation reverts Migration -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client MigrationConfigsClient) Revert(ctx context.Context, resourceGroupName string, namespaceName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigsClient.Revert") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.MigrationConfigsClient", "Revert", err.Error()) - } - - req, err := client.RevertPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Revert", nil, "Failure preparing request") - return - } - - resp, err := client.RevertSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Revert", resp, "Failure sending request") - return - } - - result, err = client.RevertResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsClient", "Revert", resp, "Failure responding to request") - return - } - - return -} - -// RevertPreparer prepares the Revert request. -func (client MigrationConfigsClient) RevertPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "configName": autorest.Encode("path", "$default"), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/migrationConfigurations/{configName}/revert", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RevertSender sends the Revert request. The method will close the -// http.Response Body if it receives an error. -func (client MigrationConfigsClient) RevertSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// RevertResponder handles the response to the Revert request. The method always -// closes the http.Response Body. -func (client MigrationConfigsClient) RevertResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/models.go deleted file mode 100644 index 13755feaedd0..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/models.go +++ /dev/null @@ -1,3989 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus" - -// AccessKeys namespace/ServiceBus Connection String -type AccessKeys struct { - autorest.Response `json:"-"` - // PrimaryConnectionString - READ-ONLY; Primary connection string of the created namespace authorization rule. - PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` - // SecondaryConnectionString - READ-ONLY; Secondary connection string of the created namespace authorization rule. - SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` - // AliasPrimaryConnectionString - READ-ONLY; Primary connection string of the alias if GEO DR is enabled - AliasPrimaryConnectionString *string `json:"aliasPrimaryConnectionString,omitempty"` - // AliasSecondaryConnectionString - READ-ONLY; Secondary connection string of the alias if GEO DR is enabled - AliasSecondaryConnectionString *string `json:"aliasSecondaryConnectionString,omitempty"` - // PrimaryKey - READ-ONLY; A base64-encoded 256-bit primary key for signing and validating the SAS token. - PrimaryKey *string `json:"primaryKey,omitempty"` - // SecondaryKey - READ-ONLY; A base64-encoded 256-bit primary key for signing and validating the SAS token. - SecondaryKey *string `json:"secondaryKey,omitempty"` - // KeyName - READ-ONLY; A string that describes the authorization rule. - KeyName *string `json:"keyName,omitempty"` -} - -// MarshalJSON is the custom marshaler for AccessKeys. -func (ak AccessKeys) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// Action represents the filter actions which are allowed for the transformation of a message that have -// been matched by a filter expression. -type Action struct { - // SQLExpression - SQL expression. e.g. MyProperty='ABC' - SQLExpression *string `json:"sqlExpression,omitempty"` - // CompatibilityLevel - This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - CompatibilityLevel *int32 `json:"compatibilityLevel,omitempty"` - // RequiresPreprocessing - Value that indicates whether the rule action requires preprocessing. - RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` -} - -// ArmDisasterRecovery single item in List or Get Alias(Disaster Recovery configuration) operation -type ArmDisasterRecovery struct { - autorest.Response `json:"-"` - // ArmDisasterRecoveryProperties - Properties required to the Create Or Update Alias(Disaster Recovery configurations) - *ArmDisasterRecoveryProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ArmDisasterRecovery. -func (adr ArmDisasterRecovery) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if adr.ArmDisasterRecoveryProperties != nil { - objectMap["properties"] = adr.ArmDisasterRecoveryProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ArmDisasterRecovery struct. -func (adr *ArmDisasterRecovery) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var armDisasterRecoveryProperties ArmDisasterRecoveryProperties - err = json.Unmarshal(*v, &armDisasterRecoveryProperties) - if err != nil { - return err - } - adr.ArmDisasterRecoveryProperties = &armDisasterRecoveryProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - adr.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - adr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - adr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - adr.Type = &typeVar - } - } - } - - return nil -} - -// ArmDisasterRecoveryListResult the result of the List Alias(Disaster Recovery configuration) operation. -type ArmDisasterRecoveryListResult struct { - autorest.Response `json:"-"` - // Value - List of Alias(Disaster Recovery configurations) - Value *[]ArmDisasterRecovery `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to the next set of results. Not empty if Value contains incomplete list of Alias(Disaster Recovery configuration) - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ArmDisasterRecoveryListResult. -func (adrlr ArmDisasterRecoveryListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if adrlr.Value != nil { - objectMap["value"] = adrlr.Value - } - return json.Marshal(objectMap) -} - -// ArmDisasterRecoveryListResultIterator provides access to a complete listing of ArmDisasterRecovery -// values. -type ArmDisasterRecoveryListResultIterator struct { - i int - page ArmDisasterRecoveryListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ArmDisasterRecoveryListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ArmDisasterRecoveryListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ArmDisasterRecoveryListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ArmDisasterRecoveryListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ArmDisasterRecoveryListResultIterator) Response() ArmDisasterRecoveryListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ArmDisasterRecoveryListResultIterator) Value() ArmDisasterRecovery { - if !iter.page.NotDone() { - return ArmDisasterRecovery{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ArmDisasterRecoveryListResultIterator type. -func NewArmDisasterRecoveryListResultIterator(page ArmDisasterRecoveryListResultPage) ArmDisasterRecoveryListResultIterator { - return ArmDisasterRecoveryListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (adrlr ArmDisasterRecoveryListResult) IsEmpty() bool { - return adrlr.Value == nil || len(*adrlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (adrlr ArmDisasterRecoveryListResult) hasNextLink() bool { - return adrlr.NextLink != nil && len(*adrlr.NextLink) != 0 -} - -// armDisasterRecoveryListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (adrlr ArmDisasterRecoveryListResult) armDisasterRecoveryListResultPreparer(ctx context.Context) (*http.Request, error) { - if !adrlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(adrlr.NextLink))) -} - -// ArmDisasterRecoveryListResultPage contains a page of ArmDisasterRecovery values. -type ArmDisasterRecoveryListResultPage struct { - fn func(context.Context, ArmDisasterRecoveryListResult) (ArmDisasterRecoveryListResult, error) - adrlr ArmDisasterRecoveryListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ArmDisasterRecoveryListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ArmDisasterRecoveryListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.adrlr) - if err != nil { - return err - } - page.adrlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ArmDisasterRecoveryListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ArmDisasterRecoveryListResultPage) NotDone() bool { - return !page.adrlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ArmDisasterRecoveryListResultPage) Response() ArmDisasterRecoveryListResult { - return page.adrlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ArmDisasterRecoveryListResultPage) Values() []ArmDisasterRecovery { - if page.adrlr.IsEmpty() { - return nil - } - return *page.adrlr.Value -} - -// Creates a new instance of the ArmDisasterRecoveryListResultPage type. -func NewArmDisasterRecoveryListResultPage(cur ArmDisasterRecoveryListResult, getNextPage func(context.Context, ArmDisasterRecoveryListResult) (ArmDisasterRecoveryListResult, error)) ArmDisasterRecoveryListResultPage { - return ArmDisasterRecoveryListResultPage{ - fn: getNextPage, - adrlr: cur, - } -} - -// ArmDisasterRecoveryProperties properties required to the Create Or Update Alias(Disaster Recovery -// configurations) -type ArmDisasterRecoveryProperties struct { - // ProvisioningState - READ-ONLY; Provisioning state of the Alias(Disaster Recovery configuration) - possible values 'Accepted' or 'Succeeded' or 'Failed'. Possible values include: 'ProvisioningStateDRAccepted', 'ProvisioningStateDRSucceeded', 'ProvisioningStateDRFailed' - ProvisioningState ProvisioningStateDR `json:"provisioningState,omitempty"` - // PendingReplicationOperationsCount - READ-ONLY; Number of entities pending to be replicated. - PendingReplicationOperationsCount *int64 `json:"pendingReplicationOperationsCount,omitempty"` - // PartnerNamespace - ARM Id of the Primary/Secondary eventhub namespace name, which is part of GEO DR pairing - PartnerNamespace *string `json:"partnerNamespace,omitempty"` - // AlternateName - Primary/Secondary eventhub namespace name, which is part of GEO DR pairing - AlternateName *string `json:"alternateName,omitempty"` - // Role - READ-ONLY; role of namespace in GEO DR - possible values 'Primary' or 'PrimaryNotReplicating' or 'Secondary'. Possible values include: 'RoleDisasterRecoveryPrimary', 'RoleDisasterRecoveryPrimaryNotReplicating', 'RoleDisasterRecoverySecondary' - Role RoleDisasterRecovery `json:"role,omitempty"` -} - -// MarshalJSON is the custom marshaler for ArmDisasterRecoveryProperties. -func (adr ArmDisasterRecoveryProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if adr.PartnerNamespace != nil { - objectMap["partnerNamespace"] = adr.PartnerNamespace - } - if adr.AlternateName != nil { - objectMap["alternateName"] = adr.AlternateName - } - return json.Marshal(objectMap) -} - -// CheckNameAvailability description of a Check Name availability request properties. -type CheckNameAvailability struct { - // Name - The Name to check the namespace name availability and The namespace name can contain only letters, numbers, and hyphens. The namespace must start with a letter, and it must end with a letter or number. - Name *string `json:"name,omitempty"` -} - -// CheckNameAvailabilityResult description of a Check Name availability request properties. -type CheckNameAvailabilityResult struct { - autorest.Response `json:"-"` - // Message - READ-ONLY; The detailed info regarding the reason associated with the namespace. - Message *string `json:"message,omitempty"` - // NameAvailable - Value indicating namespace is availability, true if the namespace is available; otherwise, false. - NameAvailable *bool `json:"nameAvailable,omitempty"` - // Reason - The reason for unavailability of a namespace. Possible values include: 'UnavailableReasonNone', 'UnavailableReasonInvalidName', 'UnavailableReasonSubscriptionIsDisabled', 'UnavailableReasonNameInUse', 'UnavailableReasonNameInLockdown', 'UnavailableReasonTooManyNamespaceInCurrentSubscription' - Reason UnavailableReason `json:"reason,omitempty"` -} - -// MarshalJSON is the custom marshaler for CheckNameAvailabilityResult. -func (cnar CheckNameAvailabilityResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cnar.NameAvailable != nil { - objectMap["nameAvailable"] = cnar.NameAvailable - } - if cnar.Reason != "" { - objectMap["reason"] = cnar.Reason - } - return json.Marshal(objectMap) -} - -// ConnectionState connectionState information. -type ConnectionState struct { - // Status - Status of the connection. Possible values include: 'PrivateLinkConnectionStatusPending', 'PrivateLinkConnectionStatusApproved', 'PrivateLinkConnectionStatusRejected', 'PrivateLinkConnectionStatusDisconnected' - Status PrivateLinkConnectionStatus `json:"status,omitempty"` - // Description - Description of the connection state. - Description *string `json:"description,omitempty"` -} - -// CorrelationFilter represents the correlation filter expression. -type CorrelationFilter struct { - // Properties - dictionary object for custom filters - Properties map[string]*string `json:"properties"` - // CorrelationID - Identifier of the correlation. - CorrelationID *string `json:"correlationId,omitempty"` - // MessageID - Identifier of the message. - MessageID *string `json:"messageId,omitempty"` - // To - Address to send to. - To *string `json:"to,omitempty"` - // ReplyTo - Address of the queue to reply to. - ReplyTo *string `json:"replyTo,omitempty"` - // Label - Application specific label. - Label *string `json:"label,omitempty"` - // SessionID - Session identifier. - SessionID *string `json:"sessionId,omitempty"` - // ReplyToSessionID - Session identifier to reply to. - ReplyToSessionID *string `json:"replyToSessionId,omitempty"` - // ContentType - Content type of the message. - ContentType *string `json:"contentType,omitempty"` - // RequiresPreprocessing - Value that indicates whether the rule action requires preprocessing. - RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` -} - -// MarshalJSON is the custom marshaler for CorrelationFilter. -func (cf CorrelationFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cf.Properties != nil { - objectMap["properties"] = cf.Properties - } - if cf.CorrelationID != nil { - objectMap["correlationId"] = cf.CorrelationID - } - if cf.MessageID != nil { - objectMap["messageId"] = cf.MessageID - } - if cf.To != nil { - objectMap["to"] = cf.To - } - if cf.ReplyTo != nil { - objectMap["replyTo"] = cf.ReplyTo - } - if cf.Label != nil { - objectMap["label"] = cf.Label - } - if cf.SessionID != nil { - objectMap["sessionId"] = cf.SessionID - } - if cf.ReplyToSessionID != nil { - objectMap["replyToSessionId"] = cf.ReplyToSessionID - } - if cf.ContentType != nil { - objectMap["contentType"] = cf.ContentType - } - if cf.RequiresPreprocessing != nil { - objectMap["requiresPreprocessing"] = cf.RequiresPreprocessing - } - return json.Marshal(objectMap) -} - -// Encryption properties to configure Encryption -type Encryption struct { - // KeyVaultProperties - Properties of KeyVault - KeyVaultProperties *[]KeyVaultProperties `json:"keyVaultProperties,omitempty"` - // KeySource - Enumerates the possible value of keySource for Encryption. Possible values include: 'KeySourceMicrosoftKeyVault' - KeySource KeySource `json:"keySource,omitempty"` - // RequireInfrastructureEncryption - Enable Infrastructure Encryption (Double Encryption) - RequireInfrastructureEncryption *bool `json:"requireInfrastructureEncryption,omitempty"` -} - -// ErrorAdditionalInfo the resource management error additional info. -type ErrorAdditionalInfo struct { - // Type - READ-ONLY; The additional info type. - Type *string `json:"type,omitempty"` - // Info - READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty"` -} - -// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. -func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ErrorResponse the resource management error response. -type ErrorResponse struct { - // Error - The error object. - Error *ErrorResponseError `json:"error,omitempty"` -} - -// ErrorResponseError the error object. -type ErrorResponseError struct { - // Code - READ-ONLY; The error code. - Code *string `json:"code,omitempty"` - // Message - READ-ONLY; The error message. - Message *string `json:"message,omitempty"` - // Target - READ-ONLY; The error target. - Target *string `json:"target,omitempty"` - // Details - READ-ONLY; The error details. - Details *[]ErrorResponse `json:"details,omitempty"` - // AdditionalInfo - READ-ONLY; The error additional info. - AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` -} - -// MarshalJSON is the custom marshaler for ErrorResponseError. -func (er ErrorResponseError) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// FailoverProperties safe failover is to indicate the service should wait for pending replication to -// finish before switching to the secondary. -type FailoverProperties struct { - // FailoverPropertiesProperties - Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - *FailoverPropertiesProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for FailoverProperties. -func (fp FailoverProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if fp.FailoverPropertiesProperties != nil { - objectMap["properties"] = fp.FailoverPropertiesProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for FailoverProperties struct. -func (fp *FailoverProperties) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var failoverPropertiesProperties FailoverPropertiesProperties - err = json.Unmarshal(*v, &failoverPropertiesProperties) - if err != nil { - return err - } - fp.FailoverPropertiesProperties = &failoverPropertiesProperties - } - } - } - - return nil -} - -// FailoverPropertiesProperties safe failover is to indicate the service should wait for pending -// replication to finish before switching to the secondary. -type FailoverPropertiesProperties struct { - // IsSafeFailover - Safe failover is to indicate the service should wait for pending replication to finish before switching to the secondary. - IsSafeFailover *bool `json:"IsSafeFailover,omitempty"` -} - -// Identity properties to configure User Assigned Identities for Bring your Own Keys -type Identity struct { - // PrincipalID - READ-ONLY; ObjectId from the KeyVault - PrincipalID *string `json:"principalId,omitempty"` - // TenantID - READ-ONLY; TenantId from the KeyVault - TenantID *string `json:"tenantId,omitempty"` - // Type - Type of managed service identity. Possible values include: 'ManagedServiceIdentityTypeSystemAssigned', 'ManagedServiceIdentityTypeUserAssigned', 'ManagedServiceIdentityTypeSystemAssignedUserAssigned', 'ManagedServiceIdentityTypeNone' - Type ManagedServiceIdentityType `json:"type,omitempty"` - // UserAssignedIdentities - Properties for User Assigned Identities - UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities"` -} - -// MarshalJSON is the custom marshaler for Identity. -func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if i.Type != "" { - objectMap["type"] = i.Type - } - if i.UserAssignedIdentities != nil { - objectMap["userAssignedIdentities"] = i.UserAssignedIdentities - } - return json.Marshal(objectMap) -} - -// KeyVaultProperties properties to configure keyVault Properties -type KeyVaultProperties struct { - // KeyName - Name of the Key from KeyVault - KeyName *string `json:"keyName,omitempty"` - // KeyVaultURI - Uri of KeyVault - KeyVaultURI *string `json:"keyVaultUri,omitempty"` - // KeyVersion - Version of KeyVault - KeyVersion *string `json:"keyVersion,omitempty"` - Identity *UserAssignedIdentityProperties `json:"identity,omitempty"` -} - -// MessageCountDetails message Count Details. -type MessageCountDetails struct { - // ActiveMessageCount - READ-ONLY; Number of active messages in the queue, topic, or subscription. - ActiveMessageCount *int64 `json:"activeMessageCount,omitempty"` - // DeadLetterMessageCount - READ-ONLY; Number of messages that are dead lettered. - DeadLetterMessageCount *int64 `json:"deadLetterMessageCount,omitempty"` - // ScheduledMessageCount - READ-ONLY; Number of scheduled messages. - ScheduledMessageCount *int64 `json:"scheduledMessageCount,omitempty"` - // TransferMessageCount - READ-ONLY; Number of messages transferred to another queue, topic, or subscription. - TransferMessageCount *int64 `json:"transferMessageCount,omitempty"` - // TransferDeadLetterMessageCount - READ-ONLY; Number of messages transferred into dead letters. - TransferDeadLetterMessageCount *int64 `json:"transferDeadLetterMessageCount,omitempty"` -} - -// MarshalJSON is the custom marshaler for MessageCountDetails. -func (mcd MessageCountDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// MigrationConfigListResult the result of the List migrationConfigurations operation. -type MigrationConfigListResult struct { - autorest.Response `json:"-"` - // Value - List of Migration Configs - Value *[]MigrationConfigProperties `json:"value,omitempty"` - // NextLink - READ-ONLY; Link to the next set of results. Not empty if Value contains incomplete list of migrationConfigurations - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for MigrationConfigListResult. -func (mclr MigrationConfigListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mclr.Value != nil { - objectMap["value"] = mclr.Value - } - return json.Marshal(objectMap) -} - -// MigrationConfigListResultIterator provides access to a complete listing of MigrationConfigProperties -// values. -type MigrationConfigListResultIterator struct { - i int - page MigrationConfigListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *MigrationConfigListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *MigrationConfigListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter MigrationConfigListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter MigrationConfigListResultIterator) Response() MigrationConfigListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter MigrationConfigListResultIterator) Value() MigrationConfigProperties { - if !iter.page.NotDone() { - return MigrationConfigProperties{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the MigrationConfigListResultIterator type. -func NewMigrationConfigListResultIterator(page MigrationConfigListResultPage) MigrationConfigListResultIterator { - return MigrationConfigListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (mclr MigrationConfigListResult) IsEmpty() bool { - return mclr.Value == nil || len(*mclr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (mclr MigrationConfigListResult) hasNextLink() bool { - return mclr.NextLink != nil && len(*mclr.NextLink) != 0 -} - -// migrationConfigListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (mclr MigrationConfigListResult) migrationConfigListResultPreparer(ctx context.Context) (*http.Request, error) { - if !mclr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(mclr.NextLink))) -} - -// MigrationConfigListResultPage contains a page of MigrationConfigProperties values. -type MigrationConfigListResultPage struct { - fn func(context.Context, MigrationConfigListResult) (MigrationConfigListResult, error) - mclr MigrationConfigListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *MigrationConfigListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/MigrationConfigListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.mclr) - if err != nil { - return err - } - page.mclr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *MigrationConfigListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page MigrationConfigListResultPage) NotDone() bool { - return !page.mclr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page MigrationConfigListResultPage) Response() MigrationConfigListResult { - return page.mclr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page MigrationConfigListResultPage) Values() []MigrationConfigProperties { - if page.mclr.IsEmpty() { - return nil - } - return *page.mclr.Value -} - -// Creates a new instance of the MigrationConfigListResultPage type. -func NewMigrationConfigListResultPage(cur MigrationConfigListResult, getNextPage func(context.Context, MigrationConfigListResult) (MigrationConfigListResult, error)) MigrationConfigListResultPage { - return MigrationConfigListResultPage{ - fn: getNextPage, - mclr: cur, - } -} - -// MigrationConfigProperties single item in List or Get Migration Config operation -type MigrationConfigProperties struct { - autorest.Response `json:"-"` - // MigrationConfigPropertiesProperties - Properties required to the Create Migration Configuration - *MigrationConfigPropertiesProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for MigrationConfigProperties. -func (mcp MigrationConfigProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mcp.MigrationConfigPropertiesProperties != nil { - objectMap["properties"] = mcp.MigrationConfigPropertiesProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for MigrationConfigProperties struct. -func (mcp *MigrationConfigProperties) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var migrationConfigPropertiesProperties MigrationConfigPropertiesProperties - err = json.Unmarshal(*v, &migrationConfigPropertiesProperties) - if err != nil { - return err - } - mcp.MigrationConfigPropertiesProperties = &migrationConfigPropertiesProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - mcp.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mcp.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mcp.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mcp.Type = &typeVar - } - } - } - - return nil -} - -// MigrationConfigPropertiesProperties properties required to the Create Migration Configuration -type MigrationConfigPropertiesProperties struct { - // ProvisioningState - READ-ONLY; Provisioning state of Migration Configuration - ProvisioningState *string `json:"provisioningState,omitempty"` - // PendingReplicationOperationsCount - READ-ONLY; Number of entities pending to be replicated. - PendingReplicationOperationsCount *int64 `json:"pendingReplicationOperationsCount,omitempty"` - // TargetNamespace - Existing premium Namespace ARM Id name which has no entities, will be used for migration - TargetNamespace *string `json:"targetNamespace,omitempty"` - // PostMigrationName - Name to access Standard Namespace after migration - PostMigrationName *string `json:"postMigrationName,omitempty"` - // MigrationState - READ-ONLY; State in which Standard to Premium Migration is, possible values : Unknown, Reverting, Completing, Initiating, Syncing, Active - MigrationState *string `json:"migrationState,omitempty"` -} - -// MarshalJSON is the custom marshaler for MigrationConfigPropertiesProperties. -func (mcp MigrationConfigPropertiesProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mcp.TargetNamespace != nil { - objectMap["targetNamespace"] = mcp.TargetNamespace - } - if mcp.PostMigrationName != nil { - objectMap["postMigrationName"] = mcp.PostMigrationName - } - return json.Marshal(objectMap) -} - -// MigrationConfigsCreateAndStartMigrationFuture an abstraction for monitoring and retrieving the results -// of a long-running operation. -type MigrationConfigsCreateAndStartMigrationFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(MigrationConfigsClient) (MigrationConfigProperties, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *MigrationConfigsCreateAndStartMigrationFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for MigrationConfigsCreateAndStartMigrationFuture.Result. -func (future *MigrationConfigsCreateAndStartMigrationFuture) result(client MigrationConfigsClient) (mcp MigrationConfigProperties, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsCreateAndStartMigrationFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - mcp.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("servicebus.MigrationConfigsCreateAndStartMigrationFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if mcp.Response.Response, err = future.GetResult(sender); err == nil && mcp.Response.Response.StatusCode != http.StatusNoContent { - mcp, err = client.CreateAndStartMigrationResponder(mcp.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.MigrationConfigsCreateAndStartMigrationFuture", "Result", mcp.Response.Response, "Failure responding to request") - } - } - return -} - -// NamespacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type NamespacesCreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(NamespacesClient) (SBNamespace, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *NamespacesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for NamespacesCreateOrUpdateFuture.Result. -func (future *NamespacesCreateOrUpdateFuture) result(client NamespacesClient) (sn SBNamespace, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - sn.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("servicebus.NamespacesCreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if sn.Response.Response, err = future.GetResult(sender); err == nil && sn.Response.Response.StatusCode != http.StatusNoContent { - sn, err = client.CreateOrUpdateResponder(sn.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesCreateOrUpdateFuture", "Result", sn.Response.Response, "Failure responding to request") - } - } - return -} - -// NamespacesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type NamespacesDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(NamespacesClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *NamespacesDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for NamespacesDeleteFuture.Result. -func (future *NamespacesDeleteFuture) result(client NamespacesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("servicebus.NamespacesDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// NetworkRuleSet description of NetworkRuleSet resource. -type NetworkRuleSet struct { - autorest.Response `json:"-"` - // NetworkRuleSetProperties - NetworkRuleSet properties - *NetworkRuleSetProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for NetworkRuleSet. -func (nrs NetworkRuleSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if nrs.NetworkRuleSetProperties != nil { - objectMap["properties"] = nrs.NetworkRuleSetProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for NetworkRuleSet struct. -func (nrs *NetworkRuleSet) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var networkRuleSetProperties NetworkRuleSetProperties - err = json.Unmarshal(*v, &networkRuleSetProperties) - if err != nil { - return err - } - nrs.NetworkRuleSetProperties = &networkRuleSetProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - nrs.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - nrs.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - nrs.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - nrs.Type = &typeVar - } - } - } - - return nil -} - -// NetworkRuleSetListResult the response of the List NetworkRuleSet operation. -type NetworkRuleSetListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List NetworkRuleSet operation. - Value *[]NetworkRuleSet `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of NetworkRuleSet. - NextLink *string `json:"nextLink,omitempty"` -} - -// NetworkRuleSetListResultIterator provides access to a complete listing of NetworkRuleSet values. -type NetworkRuleSetListResultIterator struct { - i int - page NetworkRuleSetListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *NetworkRuleSetListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NetworkRuleSetListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *NetworkRuleSetListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter NetworkRuleSetListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter NetworkRuleSetListResultIterator) Response() NetworkRuleSetListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter NetworkRuleSetListResultIterator) Value() NetworkRuleSet { - if !iter.page.NotDone() { - return NetworkRuleSet{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the NetworkRuleSetListResultIterator type. -func NewNetworkRuleSetListResultIterator(page NetworkRuleSetListResultPage) NetworkRuleSetListResultIterator { - return NetworkRuleSetListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (nrslr NetworkRuleSetListResult) IsEmpty() bool { - return nrslr.Value == nil || len(*nrslr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (nrslr NetworkRuleSetListResult) hasNextLink() bool { - return nrslr.NextLink != nil && len(*nrslr.NextLink) != 0 -} - -// networkRuleSetListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (nrslr NetworkRuleSetListResult) networkRuleSetListResultPreparer(ctx context.Context) (*http.Request, error) { - if !nrslr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(nrslr.NextLink))) -} - -// NetworkRuleSetListResultPage contains a page of NetworkRuleSet values. -type NetworkRuleSetListResultPage struct { - fn func(context.Context, NetworkRuleSetListResult) (NetworkRuleSetListResult, error) - nrslr NetworkRuleSetListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *NetworkRuleSetListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NetworkRuleSetListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.nrslr) - if err != nil { - return err - } - page.nrslr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *NetworkRuleSetListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page NetworkRuleSetListResultPage) NotDone() bool { - return !page.nrslr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page NetworkRuleSetListResultPage) Response() NetworkRuleSetListResult { - return page.nrslr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page NetworkRuleSetListResultPage) Values() []NetworkRuleSet { - if page.nrslr.IsEmpty() { - return nil - } - return *page.nrslr.Value -} - -// Creates a new instance of the NetworkRuleSetListResultPage type. -func NewNetworkRuleSetListResultPage(cur NetworkRuleSetListResult, getNextPage func(context.Context, NetworkRuleSetListResult) (NetworkRuleSetListResult, error)) NetworkRuleSetListResultPage { - return NetworkRuleSetListResultPage{ - fn: getNextPage, - nrslr: cur, - } -} - -// NetworkRuleSetProperties networkRuleSet properties -type NetworkRuleSetProperties struct { - // TrustedServiceAccessEnabled - Value that indicates whether Trusted Service Access is Enabled or not. - TrustedServiceAccessEnabled *bool `json:"trustedServiceAccessEnabled,omitempty"` - // DefaultAction - Default Action for Network Rule Set. Possible values include: 'DefaultActionAllow', 'DefaultActionDeny' - DefaultAction DefaultAction `json:"defaultAction,omitempty"` - // VirtualNetworkRules - List VirtualNetwork Rules - VirtualNetworkRules *[]NWRuleSetVirtualNetworkRules `json:"virtualNetworkRules,omitempty"` - // IPRules - List of IpRules - IPRules *[]NWRuleSetIPRules `json:"ipRules,omitempty"` - // PublicNetworkAccess - This determines if traffic is allowed over public network. By default it is enabled. Possible values include: 'PublicNetworkAccessFlagEnabled', 'PublicNetworkAccessFlagDisabled' - PublicNetworkAccess PublicNetworkAccessFlag `json:"publicNetworkAccess,omitempty"` -} - -// NWRuleSetIPRules description of NetWorkRuleSet - IpRules resource. -type NWRuleSetIPRules struct { - // IPMask - IP Mask - IPMask *string `json:"ipMask,omitempty"` - // Action - The IP Filter Action. Possible values include: 'NetworkRuleIPActionAllow' - Action NetworkRuleIPAction `json:"action,omitempty"` -} - -// NWRuleSetVirtualNetworkRules description of VirtualNetworkRules - NetworkRules resource. -type NWRuleSetVirtualNetworkRules struct { - // Subnet - Subnet properties - Subnet *Subnet `json:"subnet,omitempty"` - // IgnoreMissingVnetServiceEndpoint - Value that indicates whether to ignore missing VNet Service Endpoint - IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` -} - -// Operation a ServiceBus REST API operation -type Operation struct { - // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` -} - -// MarshalJSON is the custom marshaler for Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if o.Display != nil { - objectMap["display"] = o.Display - } - return json.Marshal(objectMap) -} - -// OperationDisplay the object that represents the operation. -type OperationDisplay struct { - // Provider - READ-ONLY; Service provider: Microsoft.ServiceBus - Provider *string `json:"provider,omitempty"` - // Resource - READ-ONLY; Resource on which the operation is performed: Invoice, etc. - Resource *string `json:"resource,omitempty"` - // Operation - READ-ONLY; Operation type: Read, write, delete, etc. - Operation *string `json:"operation,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationListResult result of the request to list ServiceBus operations. It contains a list of -// operations and a URL link to get the next set of results. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of ServiceBus operations supported by the Microsoft.ServiceBus resource provider. - Value *[]Operation `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationListResult. -func (olr OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationListResultIterator) Response() OperationListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (olr OperationListResult) hasNextLink() bool { - return olr.NextLink != nil && len(*olr.NextLink) != 0 -} - -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !olr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{ - fn: getNextPage, - olr: cur, - } -} - -// PrivateEndpoint privateEndpoint information. -type PrivateEndpoint struct { - // ID - The ARM identifier for Private Endpoint. - ID *string `json:"id,omitempty"` -} - -// PrivateEndpointConnection properties of the PrivateEndpointConnection. -type PrivateEndpointConnection struct { - autorest.Response `json:"-"` - // PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnection. - *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateEndpointConnection. -func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pec.PrivateEndpointConnectionProperties != nil { - objectMap["properties"] = pec.PrivateEndpointConnectionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. -func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var privateEndpointConnectionProperties PrivateEndpointConnectionProperties - err = json.Unmarshal(*v, &privateEndpointConnectionProperties) - if err != nil { - return err - } - pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - pec.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - pec.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - pec.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - pec.Type = &typeVar - } - } - } - - return nil -} - -// PrivateEndpointConnectionListResult result of the list of all private endpoint connections operation. -type PrivateEndpointConnectionListResult struct { - autorest.Response `json:"-"` - // Value - A collection of private endpoint connection resources. - Value *[]PrivateEndpointConnection `json:"value,omitempty"` - // NextLink - A link for the next page of private endpoint connection resources. - NextLink *string `json:"nextLink,omitempty"` -} - -// PrivateEndpointConnectionListResultIterator provides access to a complete listing of -// PrivateEndpointConnection values. -type PrivateEndpointConnectionListResultIterator struct { - i int - page PrivateEndpointConnectionListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *PrivateEndpointConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *PrivateEndpointConnectionListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter PrivateEndpointConnectionListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter PrivateEndpointConnectionListResultIterator) Response() PrivateEndpointConnectionListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter PrivateEndpointConnectionListResultIterator) Value() PrivateEndpointConnection { - if !iter.page.NotDone() { - return PrivateEndpointConnection{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the PrivateEndpointConnectionListResultIterator type. -func NewPrivateEndpointConnectionListResultIterator(page PrivateEndpointConnectionListResultPage) PrivateEndpointConnectionListResultIterator { - return PrivateEndpointConnectionListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (peclr PrivateEndpointConnectionListResult) IsEmpty() bool { - return peclr.Value == nil || len(*peclr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (peclr PrivateEndpointConnectionListResult) hasNextLink() bool { - return peclr.NextLink != nil && len(*peclr.NextLink) != 0 -} - -// privateEndpointConnectionListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (peclr PrivateEndpointConnectionListResult) privateEndpointConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { - if !peclr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(peclr.NextLink))) -} - -// PrivateEndpointConnectionListResultPage contains a page of PrivateEndpointConnection values. -type PrivateEndpointConnectionListResultPage struct { - fn func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error) - peclr PrivateEndpointConnectionListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *PrivateEndpointConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.peclr) - if err != nil { - return err - } - page.peclr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *PrivateEndpointConnectionListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page PrivateEndpointConnectionListResultPage) NotDone() bool { - return !page.peclr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page PrivateEndpointConnectionListResultPage) Response() PrivateEndpointConnectionListResult { - return page.peclr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page PrivateEndpointConnectionListResultPage) Values() []PrivateEndpointConnection { - if page.peclr.IsEmpty() { - return nil - } - return *page.peclr.Value -} - -// Creates a new instance of the PrivateEndpointConnectionListResultPage type. -func NewPrivateEndpointConnectionListResultPage(cur PrivateEndpointConnectionListResult, getNextPage func(context.Context, PrivateEndpointConnectionListResult) (PrivateEndpointConnectionListResult, error)) PrivateEndpointConnectionListResultPage { - return PrivateEndpointConnectionListResultPage{ - fn: getNextPage, - peclr: cur, - } -} - -// PrivateEndpointConnectionProperties properties of the private endpoint connection resource. -type PrivateEndpointConnectionProperties struct { - // PrivateEndpoint - The Private Endpoint resource for this Connection. - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - // PrivateLinkServiceConnectionState - Details about the state of the connection. - PrivateLinkServiceConnectionState *ConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - // ProvisioningState - Provisioning state of the Private Endpoint Connection. Possible values include: 'EndPointProvisioningStateCreating', 'EndPointProvisioningStateUpdating', 'EndPointProvisioningStateDeleting', 'EndPointProvisioningStateSucceeded', 'EndPointProvisioningStateCanceled', 'EndPointProvisioningStateFailed' - ProvisioningState EndPointProvisioningState `json:"provisioningState,omitempty"` -} - -// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a -// long-running operation. -type PrivateEndpointConnectionsDeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. -func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - ar.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("servicebus.PrivateEndpointConnectionsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// PrivateLinkResource information of the private link resource. -type PrivateLinkResource struct { - // PrivateLinkResourceProperties - Properties of the private link resource. - *PrivateLinkResourceProperties `json:"properties,omitempty"` - // ID - Fully qualified identifier of the resource. - ID *string `json:"id,omitempty"` - // Name - Name of the resource - Name *string `json:"name,omitempty"` - // Type - Type of the resource - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for PrivateLinkResource. -func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if plr.PrivateLinkResourceProperties != nil { - objectMap["properties"] = plr.PrivateLinkResourceProperties - } - if plr.ID != nil { - objectMap["id"] = plr.ID - } - if plr.Name != nil { - objectMap["name"] = plr.Name - } - if plr.Type != nil { - objectMap["type"] = plr.Type - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. -func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var privateLinkResourceProperties PrivateLinkResourceProperties - err = json.Unmarshal(*v, &privateLinkResourceProperties) - if err != nil { - return err - } - plr.PrivateLinkResourceProperties = &privateLinkResourceProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - plr.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - plr.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - plr.Type = &typeVar - } - } - } - - return nil -} - -// PrivateLinkResourceProperties properties of PrivateLinkResource -type PrivateLinkResourceProperties struct { - GroupID *string `json:"groupId,omitempty"` - // RequiredMembers - Required Members - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - // RequiredZoneNames - Required Zone Names - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} - -// PrivateLinkResourcesListResult result of the List private link resources operation. -type PrivateLinkResourcesListResult struct { - autorest.Response `json:"-"` - // Value - A collection of private link resources - Value *[]PrivateLinkResource `json:"value,omitempty"` - // NextLink - A link for the next page of private link resources. - NextLink *string `json:"nextLink,omitempty"` -} - -// RegenerateAccessKeyParameters parameters supplied to the Regenerate Authorization Rule operation, -// specifies which key needs to be reset. -type RegenerateAccessKeyParameters struct { - // KeyType - The access key to regenerate. Possible values include: 'KeyTypePrimaryKey', 'KeyTypeSecondaryKey' - KeyType KeyType `json:"keyType,omitempty"` - // Key - Optional, if the key value provided, is reset for KeyType value or autogenerate Key value set for keyType - Key *string `json:"key,omitempty"` -} - -// Resource the Resource definition for other than namespace. -type Resource struct { - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ResourceNamespacePatch the Resource definition. -type ResourceNamespacePatch struct { - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for ResourceNamespacePatch. -func (rnp ResourceNamespacePatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rnp.Location != nil { - objectMap["location"] = rnp.Location - } - if rnp.Tags != nil { - objectMap["tags"] = rnp.Tags - } - return json.Marshal(objectMap) -} - -// Rule description of Rule Resource. -type Rule struct { - autorest.Response `json:"-"` - // Ruleproperties - Properties of Rule resource - *Ruleproperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Rule. -func (r Rule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.Ruleproperties != nil { - objectMap["properties"] = r.Ruleproperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Rule struct. -func (r *Rule) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var ruleproperties Ruleproperties - err = json.Unmarshal(*v, &ruleproperties) - if err != nil { - return err - } - r.Ruleproperties = &ruleproperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - r.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - r.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - r.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - r.Type = &typeVar - } - } - } - - return nil -} - -// RuleListResult the response of the List rule operation. -type RuleListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List Rules operation. - Value *[]Rule `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of rules - NextLink *string `json:"nextLink,omitempty"` -} - -// RuleListResultIterator provides access to a complete listing of Rule values. -type RuleListResultIterator struct { - i int - page RuleListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *RuleListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RuleListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *RuleListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RuleListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter RuleListResultIterator) Response() RuleListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter RuleListResultIterator) Value() Rule { - if !iter.page.NotDone() { - return Rule{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RuleListResultIterator type. -func NewRuleListResultIterator(page RuleListResultPage) RuleListResultIterator { - return RuleListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rlr RuleListResult) IsEmpty() bool { - return rlr.Value == nil || len(*rlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (rlr RuleListResult) hasNextLink() bool { - return rlr.NextLink != nil && len(*rlr.NextLink) != 0 -} - -// ruleListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rlr RuleListResult) ruleListResultPreparer(ctx context.Context) (*http.Request, error) { - if !rlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rlr.NextLink))) -} - -// RuleListResultPage contains a page of Rule values. -type RuleListResultPage struct { - fn func(context.Context, RuleListResult) (RuleListResult, error) - rlr RuleListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *RuleListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RuleListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.rlr) - if err != nil { - return err - } - page.rlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *RuleListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RuleListResultPage) NotDone() bool { - return !page.rlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RuleListResultPage) Response() RuleListResult { - return page.rlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RuleListResultPage) Values() []Rule { - if page.rlr.IsEmpty() { - return nil - } - return *page.rlr.Value -} - -// Creates a new instance of the RuleListResultPage type. -func NewRuleListResultPage(cur RuleListResult, getNextPage func(context.Context, RuleListResult) (RuleListResult, error)) RuleListResultPage { - return RuleListResultPage{ - fn: getNextPage, - rlr: cur, - } -} - -// Ruleproperties description of Rule Resource. -type Ruleproperties struct { - // Action - Represents the filter actions which are allowed for the transformation of a message that have been matched by a filter expression. - Action *Action `json:"action,omitempty"` - // FilterType - Filter type that is evaluated against a BrokeredMessage. Possible values include: 'FilterTypeSQLFilter', 'FilterTypeCorrelationFilter' - FilterType FilterType `json:"filterType,omitempty"` - // SQLFilter - Properties of sqlFilter - SQLFilter *SQLFilter `json:"sqlFilter,omitempty"` - // CorrelationFilter - Properties of correlationFilter - CorrelationFilter *CorrelationFilter `json:"correlationFilter,omitempty"` -} - -// SBAuthorizationRule description of a namespace authorization rule. -type SBAuthorizationRule struct { - autorest.Response `json:"-"` - // SBAuthorizationRuleProperties - AuthorizationRule properties. - *SBAuthorizationRuleProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBAuthorizationRule. -func (sar SBAuthorizationRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sar.SBAuthorizationRuleProperties != nil { - objectMap["properties"] = sar.SBAuthorizationRuleProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SBAuthorizationRule struct. -func (sar *SBAuthorizationRule) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var sBAuthorizationRuleProperties SBAuthorizationRuleProperties - err = json.Unmarshal(*v, &sBAuthorizationRuleProperties) - if err != nil { - return err - } - sar.SBAuthorizationRuleProperties = &sBAuthorizationRuleProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - sar.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sar.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sar.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sar.Type = &typeVar - } - } - } - - return nil -} - -// SBAuthorizationRuleListResult the response to the List Namespace operation. -type SBAuthorizationRuleListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List Authorization Rules operation. - Value *[]SBAuthorizationRule `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of Authorization Rules. - NextLink *string `json:"nextLink,omitempty"` -} - -// SBAuthorizationRuleListResultIterator provides access to a complete listing of SBAuthorizationRule -// values. -type SBAuthorizationRuleListResultIterator struct { - i int - page SBAuthorizationRuleListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *SBAuthorizationRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBAuthorizationRuleListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *SBAuthorizationRuleListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter SBAuthorizationRuleListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter SBAuthorizationRuleListResultIterator) Response() SBAuthorizationRuleListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter SBAuthorizationRuleListResultIterator) Value() SBAuthorizationRule { - if !iter.page.NotDone() { - return SBAuthorizationRule{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the SBAuthorizationRuleListResultIterator type. -func NewSBAuthorizationRuleListResultIterator(page SBAuthorizationRuleListResultPage) SBAuthorizationRuleListResultIterator { - return SBAuthorizationRuleListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (sarlr SBAuthorizationRuleListResult) IsEmpty() bool { - return sarlr.Value == nil || len(*sarlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (sarlr SBAuthorizationRuleListResult) hasNextLink() bool { - return sarlr.NextLink != nil && len(*sarlr.NextLink) != 0 -} - -// sBAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (sarlr SBAuthorizationRuleListResult) sBAuthorizationRuleListResultPreparer(ctx context.Context) (*http.Request, error) { - if !sarlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(sarlr.NextLink))) -} - -// SBAuthorizationRuleListResultPage contains a page of SBAuthorizationRule values. -type SBAuthorizationRuleListResultPage struct { - fn func(context.Context, SBAuthorizationRuleListResult) (SBAuthorizationRuleListResult, error) - sarlr SBAuthorizationRuleListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *SBAuthorizationRuleListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBAuthorizationRuleListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.sarlr) - if err != nil { - return err - } - page.sarlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *SBAuthorizationRuleListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page SBAuthorizationRuleListResultPage) NotDone() bool { - return !page.sarlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page SBAuthorizationRuleListResultPage) Response() SBAuthorizationRuleListResult { - return page.sarlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page SBAuthorizationRuleListResultPage) Values() []SBAuthorizationRule { - if page.sarlr.IsEmpty() { - return nil - } - return *page.sarlr.Value -} - -// Creates a new instance of the SBAuthorizationRuleListResultPage type. -func NewSBAuthorizationRuleListResultPage(cur SBAuthorizationRuleListResult, getNextPage func(context.Context, SBAuthorizationRuleListResult) (SBAuthorizationRuleListResult, error)) SBAuthorizationRuleListResultPage { - return SBAuthorizationRuleListResultPage{ - fn: getNextPage, - sarlr: cur, - } -} - -// SBAuthorizationRuleProperties authorizationRule properties. -type SBAuthorizationRuleProperties struct { - // Rights - The rights associated with the rule. - Rights *[]AccessRights `json:"rights,omitempty"` -} - -// SBClientAffineProperties properties specific to client affine subscriptions. -type SBClientAffineProperties struct { - // ClientID - Indicates the Client ID of the application that created the client-affine subscription. - ClientID *string `json:"clientId,omitempty"` - // IsDurable - For client-affine subscriptions, this value indicates whether the subscription is durable or not. - IsDurable *bool `json:"isDurable,omitempty"` - // IsShared - For client-affine subscriptions, this value indicates whether the subscription is shared or not. - IsShared *bool `json:"isShared,omitempty"` -} - -// SBNamespace description of a namespace resource. -type SBNamespace struct { - autorest.Response `json:"-"` - // Sku - Properties of SKU - Sku *SBSku `json:"sku,omitempty"` - // Identity - Properties of BYOK Identity description - Identity *Identity `json:"identity,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // SBNamespaceProperties - Properties of the namespace. - *SBNamespaceProperties `json:"properties,omitempty"` - // Location - The Geo-location where the resource lives - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBNamespace. -func (sn SBNamespace) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sn.Sku != nil { - objectMap["sku"] = sn.Sku - } - if sn.Identity != nil { - objectMap["identity"] = sn.Identity - } - if sn.SBNamespaceProperties != nil { - objectMap["properties"] = sn.SBNamespaceProperties - } - if sn.Location != nil { - objectMap["location"] = sn.Location - } - if sn.Tags != nil { - objectMap["tags"] = sn.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SBNamespace struct. -func (sn *SBNamespace) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "sku": - if v != nil { - var sku SBSku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - sn.Sku = &sku - } - case "identity": - if v != nil { - var identity Identity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - sn.Identity = &identity - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - sn.SystemData = &systemData - } - case "properties": - if v != nil { - var sBNamespaceProperties SBNamespaceProperties - err = json.Unmarshal(*v, &sBNamespaceProperties) - if err != nil { - return err - } - sn.SBNamespaceProperties = &sBNamespaceProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - sn.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - sn.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sn.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sn.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sn.Type = &typeVar - } - } - } - - return nil -} - -// SBNamespaceListResult the response of the List Namespace operation. -type SBNamespaceListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List Namespace operation. - Value *[]SBNamespace `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of Namespaces. - NextLink *string `json:"nextLink,omitempty"` -} - -// SBNamespaceListResultIterator provides access to a complete listing of SBNamespace values. -type SBNamespaceListResultIterator struct { - i int - page SBNamespaceListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *SBNamespaceListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBNamespaceListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *SBNamespaceListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter SBNamespaceListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter SBNamespaceListResultIterator) Response() SBNamespaceListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter SBNamespaceListResultIterator) Value() SBNamespace { - if !iter.page.NotDone() { - return SBNamespace{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the SBNamespaceListResultIterator type. -func NewSBNamespaceListResultIterator(page SBNamespaceListResultPage) SBNamespaceListResultIterator { - return SBNamespaceListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (snlr SBNamespaceListResult) IsEmpty() bool { - return snlr.Value == nil || len(*snlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (snlr SBNamespaceListResult) hasNextLink() bool { - return snlr.NextLink != nil && len(*snlr.NextLink) != 0 -} - -// sBNamespaceListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (snlr SBNamespaceListResult) sBNamespaceListResultPreparer(ctx context.Context) (*http.Request, error) { - if !snlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(snlr.NextLink))) -} - -// SBNamespaceListResultPage contains a page of SBNamespace values. -type SBNamespaceListResultPage struct { - fn func(context.Context, SBNamespaceListResult) (SBNamespaceListResult, error) - snlr SBNamespaceListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *SBNamespaceListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBNamespaceListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.snlr) - if err != nil { - return err - } - page.snlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *SBNamespaceListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page SBNamespaceListResultPage) NotDone() bool { - return !page.snlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page SBNamespaceListResultPage) Response() SBNamespaceListResult { - return page.snlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page SBNamespaceListResultPage) Values() []SBNamespace { - if page.snlr.IsEmpty() { - return nil - } - return *page.snlr.Value -} - -// Creates a new instance of the SBNamespaceListResultPage type. -func NewSBNamespaceListResultPage(cur SBNamespaceListResult, getNextPage func(context.Context, SBNamespaceListResult) (SBNamespaceListResult, error)) SBNamespaceListResultPage { - return SBNamespaceListResultPage{ - fn: getNextPage, - snlr: cur, - } -} - -// SBNamespaceProperties properties of the namespace. -type SBNamespaceProperties struct { - // ProvisioningState - READ-ONLY; Provisioning state of the namespace. - ProvisioningState *string `json:"provisioningState,omitempty"` - // Status - READ-ONLY; Status of the namespace. - Status *string `json:"status,omitempty"` - // CreatedAt - READ-ONLY; The time the namespace was created - CreatedAt *date.Time `json:"createdAt,omitempty"` - // UpdatedAt - READ-ONLY; The time the namespace was updated. - UpdatedAt *date.Time `json:"updatedAt,omitempty"` - // ServiceBusEndpoint - READ-ONLY; Endpoint you can use to perform Service Bus operations. - ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` - // MetricID - READ-ONLY; Identifier for Azure Insights metrics - MetricID *string `json:"metricId,omitempty"` - // ZoneRedundant - Enabling this property creates a Premium Service Bus Namespace in regions supported availability zones. - ZoneRedundant *bool `json:"zoneRedundant,omitempty"` - // Encryption - Properties of BYOK Encryption description - Encryption *Encryption `json:"encryption,omitempty"` - // PrivateEndpointConnections - List of private endpoint connections. - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - // DisableLocalAuth - This property disables SAS authentication for the Service Bus namespace. - DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBNamespaceProperties. -func (snp SBNamespaceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if snp.ZoneRedundant != nil { - objectMap["zoneRedundant"] = snp.ZoneRedundant - } - if snp.Encryption != nil { - objectMap["encryption"] = snp.Encryption - } - if snp.PrivateEndpointConnections != nil { - objectMap["privateEndpointConnections"] = snp.PrivateEndpointConnections - } - if snp.DisableLocalAuth != nil { - objectMap["disableLocalAuth"] = snp.DisableLocalAuth - } - return json.Marshal(objectMap) -} - -// SBNamespaceUpdateParameters description of a namespace resource. -type SBNamespaceUpdateParameters struct { - // Sku - Properties of SKU - Sku *SBSku `json:"sku,omitempty"` - // SBNamespaceProperties - Properties of the namespace. - *SBNamespaceProperties `json:"properties,omitempty"` - // Identity - Properties of BYOK Identity description - Identity *Identity `json:"identity,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBNamespaceUpdateParameters. -func (snup SBNamespaceUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if snup.Sku != nil { - objectMap["sku"] = snup.Sku - } - if snup.SBNamespaceProperties != nil { - objectMap["properties"] = snup.SBNamespaceProperties - } - if snup.Identity != nil { - objectMap["identity"] = snup.Identity - } - if snup.Location != nil { - objectMap["location"] = snup.Location - } - if snup.Tags != nil { - objectMap["tags"] = snup.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SBNamespaceUpdateParameters struct. -func (snup *SBNamespaceUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "sku": - if v != nil { - var sku SBSku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - snup.Sku = &sku - } - case "properties": - if v != nil { - var sBNamespaceProperties SBNamespaceProperties - err = json.Unmarshal(*v, &sBNamespaceProperties) - if err != nil { - return err - } - snup.SBNamespaceProperties = &sBNamespaceProperties - } - case "identity": - if v != nil { - var identity Identity - err = json.Unmarshal(*v, &identity) - if err != nil { - return err - } - snup.Identity = &identity - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - snup.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - snup.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - snup.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - snup.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - snup.Type = &typeVar - } - } - } - - return nil -} - -// SBQueue description of queue Resource. -type SBQueue struct { - autorest.Response `json:"-"` - // SBQueueProperties - Queue Properties - *SBQueueProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBQueue. -func (sq SBQueue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sq.SBQueueProperties != nil { - objectMap["properties"] = sq.SBQueueProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SBQueue struct. -func (sq *SBQueue) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var sBQueueProperties SBQueueProperties - err = json.Unmarshal(*v, &sBQueueProperties) - if err != nil { - return err - } - sq.SBQueueProperties = &sBQueueProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - sq.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sq.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sq.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sq.Type = &typeVar - } - } - } - - return nil -} - -// SBQueueListResult the response to the List Queues operation. -type SBQueueListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List Queues operation. - Value *[]SBQueue `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of queues. - NextLink *string `json:"nextLink,omitempty"` -} - -// SBQueueListResultIterator provides access to a complete listing of SBQueue values. -type SBQueueListResultIterator struct { - i int - page SBQueueListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *SBQueueListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBQueueListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *SBQueueListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter SBQueueListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter SBQueueListResultIterator) Response() SBQueueListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter SBQueueListResultIterator) Value() SBQueue { - if !iter.page.NotDone() { - return SBQueue{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the SBQueueListResultIterator type. -func NewSBQueueListResultIterator(page SBQueueListResultPage) SBQueueListResultIterator { - return SBQueueListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (sqlr SBQueueListResult) IsEmpty() bool { - return sqlr.Value == nil || len(*sqlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (sqlr SBQueueListResult) hasNextLink() bool { - return sqlr.NextLink != nil && len(*sqlr.NextLink) != 0 -} - -// sBQueueListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (sqlr SBQueueListResult) sBQueueListResultPreparer(ctx context.Context) (*http.Request, error) { - if !sqlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(sqlr.NextLink))) -} - -// SBQueueListResultPage contains a page of SBQueue values. -type SBQueueListResultPage struct { - fn func(context.Context, SBQueueListResult) (SBQueueListResult, error) - sqlr SBQueueListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *SBQueueListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBQueueListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.sqlr) - if err != nil { - return err - } - page.sqlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *SBQueueListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page SBQueueListResultPage) NotDone() bool { - return !page.sqlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page SBQueueListResultPage) Response() SBQueueListResult { - return page.sqlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page SBQueueListResultPage) Values() []SBQueue { - if page.sqlr.IsEmpty() { - return nil - } - return *page.sqlr.Value -} - -// Creates a new instance of the SBQueueListResultPage type. -func NewSBQueueListResultPage(cur SBQueueListResult, getNextPage func(context.Context, SBQueueListResult) (SBQueueListResult, error)) SBQueueListResultPage { - return SBQueueListResultPage{ - fn: getNextPage, - sqlr: cur, - } -} - -// SBQueueProperties the Queue Properties definition. -type SBQueueProperties struct { - // CountDetails - READ-ONLY; Message Count Details. - CountDetails *MessageCountDetails `json:"countDetails,omitempty"` - // CreatedAt - READ-ONLY; The exact time the message was created. - CreatedAt *date.Time `json:"createdAt,omitempty"` - // UpdatedAt - READ-ONLY; The exact time the message was updated. - UpdatedAt *date.Time `json:"updatedAt,omitempty"` - // AccessedAt - READ-ONLY; Last time a message was sent, or the last time there was a receive request to this queue. - AccessedAt *date.Time `json:"accessedAt,omitempty"` - // SizeInBytes - READ-ONLY; The size of the queue, in bytes. - SizeInBytes *int64 `json:"sizeInBytes,omitempty"` - // MessageCount - READ-ONLY; The number of messages in the queue. - MessageCount *int64 `json:"messageCount,omitempty"` - // LockDuration - ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. The maximum value for LockDuration is 5 minutes; the default value is 1 minute. - LockDuration *string `json:"lockDuration,omitempty"` - // MaxSizeInMegabytes - The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. Default is 1024. - MaxSizeInMegabytes *int32 `json:"maxSizeInMegabytes,omitempty"` - // MaxMessageSizeInKilobytes - Maximum size (in KB) of the message payload that can be accepted by the queue. This property is only used in Premium today and default is 1024. - MaxMessageSizeInKilobytes *int64 `json:"maxMessageSizeInKilobytes,omitempty"` - // RequiresDuplicateDetection - A value indicating if this queue requires duplicate detection. - RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"` - // RequiresSession - A value that indicates whether the queue supports the concept of sessions. - RequiresSession *bool `json:"requiresSession,omitempty"` - // DefaultMessageTimeToLive - ISO 8601 default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself. - DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` - // DeadLetteringOnMessageExpiration - A value that indicates whether this queue has dead letter support when a message expires. - DeadLetteringOnMessageExpiration *bool `json:"deadLetteringOnMessageExpiration,omitempty"` - // DuplicateDetectionHistoryTimeWindow - ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` - // MaxDeliveryCount - The maximum delivery count. A message is automatically deadlettered after this number of deliveries. default value is 10. - MaxDeliveryCount *int32 `json:"maxDeliveryCount,omitempty"` - // Status - Enumerates the possible values for the status of a messaging entity. Possible values include: 'EntityStatusActive', 'EntityStatusDisabled', 'EntityStatusRestoring', 'EntityStatusSendDisabled', 'EntityStatusReceiveDisabled', 'EntityStatusCreating', 'EntityStatusDeleting', 'EntityStatusRenaming', 'EntityStatusUnknown' - Status EntityStatus `json:"status,omitempty"` - // EnableBatchedOperations - Value that indicates whether server-side batched operations are enabled. - EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` - // AutoDeleteOnIdle - ISO 8061 timeSpan idle interval after which the queue is automatically deleted. The minimum duration is 5 minutes. - AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` - // EnablePartitioning - A value that indicates whether the queue is to be partitioned across multiple message brokers. - EnablePartitioning *bool `json:"enablePartitioning,omitempty"` - // EnableExpress - A value that indicates whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing it to persistent storage. - EnableExpress *bool `json:"enableExpress,omitempty"` - // ForwardTo - Queue/Topic name to forward the messages - ForwardTo *string `json:"forwardTo,omitempty"` - // ForwardDeadLetteredMessagesTo - Queue/Topic name to forward the Dead Letter message - ForwardDeadLetteredMessagesTo *string `json:"forwardDeadLetteredMessagesTo,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBQueueProperties. -func (sqp SBQueueProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sqp.LockDuration != nil { - objectMap["lockDuration"] = sqp.LockDuration - } - if sqp.MaxSizeInMegabytes != nil { - objectMap["maxSizeInMegabytes"] = sqp.MaxSizeInMegabytes - } - if sqp.MaxMessageSizeInKilobytes != nil { - objectMap["maxMessageSizeInKilobytes"] = sqp.MaxMessageSizeInKilobytes - } - if sqp.RequiresDuplicateDetection != nil { - objectMap["requiresDuplicateDetection"] = sqp.RequiresDuplicateDetection - } - if sqp.RequiresSession != nil { - objectMap["requiresSession"] = sqp.RequiresSession - } - if sqp.DefaultMessageTimeToLive != nil { - objectMap["defaultMessageTimeToLive"] = sqp.DefaultMessageTimeToLive - } - if sqp.DeadLetteringOnMessageExpiration != nil { - objectMap["deadLetteringOnMessageExpiration"] = sqp.DeadLetteringOnMessageExpiration - } - if sqp.DuplicateDetectionHistoryTimeWindow != nil { - objectMap["duplicateDetectionHistoryTimeWindow"] = sqp.DuplicateDetectionHistoryTimeWindow - } - if sqp.MaxDeliveryCount != nil { - objectMap["maxDeliveryCount"] = sqp.MaxDeliveryCount - } - if sqp.Status != "" { - objectMap["status"] = sqp.Status - } - if sqp.EnableBatchedOperations != nil { - objectMap["enableBatchedOperations"] = sqp.EnableBatchedOperations - } - if sqp.AutoDeleteOnIdle != nil { - objectMap["autoDeleteOnIdle"] = sqp.AutoDeleteOnIdle - } - if sqp.EnablePartitioning != nil { - objectMap["enablePartitioning"] = sqp.EnablePartitioning - } - if sqp.EnableExpress != nil { - objectMap["enableExpress"] = sqp.EnableExpress - } - if sqp.ForwardTo != nil { - objectMap["forwardTo"] = sqp.ForwardTo - } - if sqp.ForwardDeadLetteredMessagesTo != nil { - objectMap["forwardDeadLetteredMessagesTo"] = sqp.ForwardDeadLetteredMessagesTo - } - return json.Marshal(objectMap) -} - -// SBSku SKU of the namespace. -type SBSku struct { - // Name - Name of this SKU. Possible values include: 'SkuNameBasic', 'SkuNameStandard', 'SkuNamePremium' - Name SkuName `json:"name,omitempty"` - // Tier - The billing tier of this particular SKU. Possible values include: 'SkuTierBasic', 'SkuTierStandard', 'SkuTierPremium' - Tier SkuTier `json:"tier,omitempty"` - // Capacity - The specified messaging units for the tier. For Premium tier, capacity are 1,2 and 4. - Capacity *int32 `json:"capacity,omitempty"` -} - -// SBSubscription description of subscription resource. -type SBSubscription struct { - autorest.Response `json:"-"` - // SBSubscriptionProperties - Properties of subscriptions resource. - *SBSubscriptionProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBSubscription. -func (ss SBSubscription) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ss.SBSubscriptionProperties != nil { - objectMap["properties"] = ss.SBSubscriptionProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SBSubscription struct. -func (ss *SBSubscription) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var sBSubscriptionProperties SBSubscriptionProperties - err = json.Unmarshal(*v, &sBSubscriptionProperties) - if err != nil { - return err - } - ss.SBSubscriptionProperties = &sBSubscriptionProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - ss.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ss.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ss.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ss.Type = &typeVar - } - } - } - - return nil -} - -// SBSubscriptionListResult the response to the List Subscriptions operation. -type SBSubscriptionListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List Subscriptions operation. - Value *[]SBSubscription `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of subscriptions. - NextLink *string `json:"nextLink,omitempty"` -} - -// SBSubscriptionListResultIterator provides access to a complete listing of SBSubscription values. -type SBSubscriptionListResultIterator struct { - i int - page SBSubscriptionListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *SBSubscriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBSubscriptionListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *SBSubscriptionListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter SBSubscriptionListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter SBSubscriptionListResultIterator) Response() SBSubscriptionListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter SBSubscriptionListResultIterator) Value() SBSubscription { - if !iter.page.NotDone() { - return SBSubscription{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the SBSubscriptionListResultIterator type. -func NewSBSubscriptionListResultIterator(page SBSubscriptionListResultPage) SBSubscriptionListResultIterator { - return SBSubscriptionListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (sslr SBSubscriptionListResult) IsEmpty() bool { - return sslr.Value == nil || len(*sslr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (sslr SBSubscriptionListResult) hasNextLink() bool { - return sslr.NextLink != nil && len(*sslr.NextLink) != 0 -} - -// sBSubscriptionListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (sslr SBSubscriptionListResult) sBSubscriptionListResultPreparer(ctx context.Context) (*http.Request, error) { - if !sslr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(sslr.NextLink))) -} - -// SBSubscriptionListResultPage contains a page of SBSubscription values. -type SBSubscriptionListResultPage struct { - fn func(context.Context, SBSubscriptionListResult) (SBSubscriptionListResult, error) - sslr SBSubscriptionListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *SBSubscriptionListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBSubscriptionListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.sslr) - if err != nil { - return err - } - page.sslr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *SBSubscriptionListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page SBSubscriptionListResultPage) NotDone() bool { - return !page.sslr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page SBSubscriptionListResultPage) Response() SBSubscriptionListResult { - return page.sslr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page SBSubscriptionListResultPage) Values() []SBSubscription { - if page.sslr.IsEmpty() { - return nil - } - return *page.sslr.Value -} - -// Creates a new instance of the SBSubscriptionListResultPage type. -func NewSBSubscriptionListResultPage(cur SBSubscriptionListResult, getNextPage func(context.Context, SBSubscriptionListResult) (SBSubscriptionListResult, error)) SBSubscriptionListResultPage { - return SBSubscriptionListResultPage{ - fn: getNextPage, - sslr: cur, - } -} - -// SBSubscriptionProperties description of Subscription Resource. -type SBSubscriptionProperties struct { - // MessageCount - READ-ONLY; Number of messages. - MessageCount *int64 `json:"messageCount,omitempty"` - // CreatedAt - READ-ONLY; Exact time the message was created. - CreatedAt *date.Time `json:"createdAt,omitempty"` - // AccessedAt - READ-ONLY; Last time there was a receive request to this subscription. - AccessedAt *date.Time `json:"accessedAt,omitempty"` - // UpdatedAt - READ-ONLY; The exact time the message was updated. - UpdatedAt *date.Time `json:"updatedAt,omitempty"` - // CountDetails - READ-ONLY; Message count details - CountDetails *MessageCountDetails `json:"countDetails,omitempty"` - // LockDuration - ISO 8061 lock duration timespan for the subscription. The default value is 1 minute. - LockDuration *string `json:"lockDuration,omitempty"` - // RequiresSession - Value indicating if a subscription supports the concept of sessions. - RequiresSession *bool `json:"requiresSession,omitempty"` - // DefaultMessageTimeToLive - ISO 8061 Default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself. - DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` - // DeadLetteringOnFilterEvaluationExceptions - Value that indicates whether a subscription has dead letter support on filter evaluation exceptions. - DeadLetteringOnFilterEvaluationExceptions *bool `json:"deadLetteringOnFilterEvaluationExceptions,omitempty"` - // DeadLetteringOnMessageExpiration - Value that indicates whether a subscription has dead letter support when a message expires. - DeadLetteringOnMessageExpiration *bool `json:"deadLetteringOnMessageExpiration,omitempty"` - // DuplicateDetectionHistoryTimeWindow - ISO 8601 timeSpan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` - // MaxDeliveryCount - Number of maximum deliveries. - MaxDeliveryCount *int32 `json:"maxDeliveryCount,omitempty"` - // Status - Enumerates the possible values for the status of a messaging entity. Possible values include: 'EntityStatusActive', 'EntityStatusDisabled', 'EntityStatusRestoring', 'EntityStatusSendDisabled', 'EntityStatusReceiveDisabled', 'EntityStatusCreating', 'EntityStatusDeleting', 'EntityStatusRenaming', 'EntityStatusUnknown' - Status EntityStatus `json:"status,omitempty"` - // EnableBatchedOperations - Value that indicates whether server-side batched operations are enabled. - EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` - // AutoDeleteOnIdle - ISO 8061 timeSpan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` - // ForwardTo - Queue/Topic name to forward the messages - ForwardTo *string `json:"forwardTo,omitempty"` - // ForwardDeadLetteredMessagesTo - Queue/Topic name to forward the Dead Letter message - ForwardDeadLetteredMessagesTo *string `json:"forwardDeadLetteredMessagesTo,omitempty"` - // IsClientAffine - Value that indicates whether the subscription has an affinity to the client id. - IsClientAffine *bool `json:"isClientAffine,omitempty"` - // ClientAffineProperties - Properties specific to client affine subscriptions. - ClientAffineProperties *SBClientAffineProperties `json:"clientAffineProperties,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBSubscriptionProperties. -func (ssp SBSubscriptionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ssp.LockDuration != nil { - objectMap["lockDuration"] = ssp.LockDuration - } - if ssp.RequiresSession != nil { - objectMap["requiresSession"] = ssp.RequiresSession - } - if ssp.DefaultMessageTimeToLive != nil { - objectMap["defaultMessageTimeToLive"] = ssp.DefaultMessageTimeToLive - } - if ssp.DeadLetteringOnFilterEvaluationExceptions != nil { - objectMap["deadLetteringOnFilterEvaluationExceptions"] = ssp.DeadLetteringOnFilterEvaluationExceptions - } - if ssp.DeadLetteringOnMessageExpiration != nil { - objectMap["deadLetteringOnMessageExpiration"] = ssp.DeadLetteringOnMessageExpiration - } - if ssp.DuplicateDetectionHistoryTimeWindow != nil { - objectMap["duplicateDetectionHistoryTimeWindow"] = ssp.DuplicateDetectionHistoryTimeWindow - } - if ssp.MaxDeliveryCount != nil { - objectMap["maxDeliveryCount"] = ssp.MaxDeliveryCount - } - if ssp.Status != "" { - objectMap["status"] = ssp.Status - } - if ssp.EnableBatchedOperations != nil { - objectMap["enableBatchedOperations"] = ssp.EnableBatchedOperations - } - if ssp.AutoDeleteOnIdle != nil { - objectMap["autoDeleteOnIdle"] = ssp.AutoDeleteOnIdle - } - if ssp.ForwardTo != nil { - objectMap["forwardTo"] = ssp.ForwardTo - } - if ssp.ForwardDeadLetteredMessagesTo != nil { - objectMap["forwardDeadLetteredMessagesTo"] = ssp.ForwardDeadLetteredMessagesTo - } - if ssp.IsClientAffine != nil { - objectMap["isClientAffine"] = ssp.IsClientAffine - } - if ssp.ClientAffineProperties != nil { - objectMap["clientAffineProperties"] = ssp.ClientAffineProperties - } - return json.Marshal(objectMap) -} - -// SBTopic description of topic resource. -type SBTopic struct { - autorest.Response `json:"-"` - // SBTopicProperties - Properties of topic resource. - *SBTopicProperties `json:"properties,omitempty"` - // SystemData - READ-ONLY; The system meta data relating to this resource. - SystemData *SystemData `json:"systemData,omitempty"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBTopic. -func (st SBTopic) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if st.SBTopicProperties != nil { - objectMap["properties"] = st.SBTopicProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SBTopic struct. -func (st *SBTopic) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var sBTopicProperties SBTopicProperties - err = json.Unmarshal(*v, &sBTopicProperties) - if err != nil { - return err - } - st.SBTopicProperties = &sBTopicProperties - } - case "systemData": - if v != nil { - var systemData SystemData - err = json.Unmarshal(*v, &systemData) - if err != nil { - return err - } - st.SystemData = &systemData - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - st.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - st.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - st.Type = &typeVar - } - } - } - - return nil -} - -// SBTopicListResult the response to the List Topics operation. -type SBTopicListResult struct { - autorest.Response `json:"-"` - // Value - Result of the List Topics operation. - Value *[]SBTopic `json:"value,omitempty"` - // NextLink - Link to the next set of results. Not empty if Value contains incomplete list of topics. - NextLink *string `json:"nextLink,omitempty"` -} - -// SBTopicListResultIterator provides access to a complete listing of SBTopic values. -type SBTopicListResultIterator struct { - i int - page SBTopicListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *SBTopicListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBTopicListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *SBTopicListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter SBTopicListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter SBTopicListResultIterator) Response() SBTopicListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter SBTopicListResultIterator) Value() SBTopic { - if !iter.page.NotDone() { - return SBTopic{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the SBTopicListResultIterator type. -func NewSBTopicListResultIterator(page SBTopicListResultPage) SBTopicListResultIterator { - return SBTopicListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (stlr SBTopicListResult) IsEmpty() bool { - return stlr.Value == nil || len(*stlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (stlr SBTopicListResult) hasNextLink() bool { - return stlr.NextLink != nil && len(*stlr.NextLink) != 0 -} - -// sBTopicListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (stlr SBTopicListResult) sBTopicListResultPreparer(ctx context.Context) (*http.Request, error) { - if !stlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(stlr.NextLink))) -} - -// SBTopicListResultPage contains a page of SBTopic values. -type SBTopicListResultPage struct { - fn func(context.Context, SBTopicListResult) (SBTopicListResult, error) - stlr SBTopicListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *SBTopicListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SBTopicListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.stlr) - if err != nil { - return err - } - page.stlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *SBTopicListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page SBTopicListResultPage) NotDone() bool { - return !page.stlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page SBTopicListResultPage) Response() SBTopicListResult { - return page.stlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page SBTopicListResultPage) Values() []SBTopic { - if page.stlr.IsEmpty() { - return nil - } - return *page.stlr.Value -} - -// Creates a new instance of the SBTopicListResultPage type. -func NewSBTopicListResultPage(cur SBTopicListResult, getNextPage func(context.Context, SBTopicListResult) (SBTopicListResult, error)) SBTopicListResultPage { - return SBTopicListResultPage{ - fn: getNextPage, - stlr: cur, - } -} - -// SBTopicProperties the Topic Properties definition. -type SBTopicProperties struct { - // SizeInBytes - READ-ONLY; Size of the topic, in bytes. - SizeInBytes *int64 `json:"sizeInBytes,omitempty"` - // CreatedAt - READ-ONLY; Exact time the message was created. - CreatedAt *date.Time `json:"createdAt,omitempty"` - // UpdatedAt - READ-ONLY; The exact time the message was updated. - UpdatedAt *date.Time `json:"updatedAt,omitempty"` - // AccessedAt - READ-ONLY; Last time the message was sent, or a request was received, for this topic. - AccessedAt *date.Time `json:"accessedAt,omitempty"` - // SubscriptionCount - READ-ONLY; Number of subscriptions. - SubscriptionCount *int32 `json:"subscriptionCount,omitempty"` - // CountDetails - READ-ONLY; Message count details - CountDetails *MessageCountDetails `json:"countDetails,omitempty"` - // DefaultMessageTimeToLive - ISO 8601 Default message timespan to live value. This is the duration after which the message expires, starting from when the message is sent to Service Bus. This is the default value used when TimeToLive is not set on a message itself. - DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` - // MaxSizeInMegabytes - Maximum size of the topic in megabytes, which is the size of the memory allocated for the topic. Default is 1024. - MaxSizeInMegabytes *int32 `json:"maxSizeInMegabytes,omitempty"` - // MaxMessageSizeInKilobytes - Maximum size (in KB) of the message payload that can be accepted by the topic. This property is only used in Premium today and default is 1024. - MaxMessageSizeInKilobytes *int64 `json:"maxMessageSizeInKilobytes,omitempty"` - // RequiresDuplicateDetection - Value indicating if this topic requires duplicate detection. - RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"` - // DuplicateDetectionHistoryTimeWindow - ISO8601 timespan structure that defines the duration of the duplicate detection history. The default value is 10 minutes. - DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` - // EnableBatchedOperations - Value that indicates whether server-side batched operations are enabled. - EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` - // Status - Enumerates the possible values for the status of a messaging entity. Possible values include: 'EntityStatusActive', 'EntityStatusDisabled', 'EntityStatusRestoring', 'EntityStatusSendDisabled', 'EntityStatusReceiveDisabled', 'EntityStatusCreating', 'EntityStatusDeleting', 'EntityStatusRenaming', 'EntityStatusUnknown' - Status EntityStatus `json:"status,omitempty"` - // SupportOrdering - Value that indicates whether the topic supports ordering. - SupportOrdering *bool `json:"supportOrdering,omitempty"` - // AutoDeleteOnIdle - ISO 8601 timespan idle interval after which the topic is automatically deleted. The minimum duration is 5 minutes. - AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` - // EnablePartitioning - Value that indicates whether the topic to be partitioned across multiple message brokers is enabled. - EnablePartitioning *bool `json:"enablePartitioning,omitempty"` - // EnableExpress - Value that indicates whether Express Entities are enabled. An express topic holds a message in memory temporarily before writing it to persistent storage. - EnableExpress *bool `json:"enableExpress,omitempty"` -} - -// MarshalJSON is the custom marshaler for SBTopicProperties. -func (stp SBTopicProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if stp.DefaultMessageTimeToLive != nil { - objectMap["defaultMessageTimeToLive"] = stp.DefaultMessageTimeToLive - } - if stp.MaxSizeInMegabytes != nil { - objectMap["maxSizeInMegabytes"] = stp.MaxSizeInMegabytes - } - if stp.MaxMessageSizeInKilobytes != nil { - objectMap["maxMessageSizeInKilobytes"] = stp.MaxMessageSizeInKilobytes - } - if stp.RequiresDuplicateDetection != nil { - objectMap["requiresDuplicateDetection"] = stp.RequiresDuplicateDetection - } - if stp.DuplicateDetectionHistoryTimeWindow != nil { - objectMap["duplicateDetectionHistoryTimeWindow"] = stp.DuplicateDetectionHistoryTimeWindow - } - if stp.EnableBatchedOperations != nil { - objectMap["enableBatchedOperations"] = stp.EnableBatchedOperations - } - if stp.Status != "" { - objectMap["status"] = stp.Status - } - if stp.SupportOrdering != nil { - objectMap["supportOrdering"] = stp.SupportOrdering - } - if stp.AutoDeleteOnIdle != nil { - objectMap["autoDeleteOnIdle"] = stp.AutoDeleteOnIdle - } - if stp.EnablePartitioning != nil { - objectMap["enablePartitioning"] = stp.EnablePartitioning - } - if stp.EnableExpress != nil { - objectMap["enableExpress"] = stp.EnableExpress - } - return json.Marshal(objectMap) -} - -// SQLFilter represents a filter which is a composition of an expression and an action that is executed in -// the pub/sub pipeline. -type SQLFilter struct { - // SQLExpression - The SQL expression. e.g. MyProperty='ABC' - SQLExpression *string `json:"sqlExpression,omitempty"` - // CompatibilityLevel - This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - CompatibilityLevel *int32 `json:"compatibilityLevel,omitempty"` - // RequiresPreprocessing - Value that indicates whether the rule action requires preprocessing. - RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` -} - -// SQLRuleAction represents set of actions written in SQL language-based syntax that is performed against a -// ServiceBus.Messaging.BrokeredMessage -type SQLRuleAction struct { - // SQLExpression - SQL expression. e.g. MyProperty='ABC' - SQLExpression *string `json:"sqlExpression,omitempty"` - // CompatibilityLevel - This property is reserved for future use. An integer value showing the compatibility level, currently hard-coded to 20. - CompatibilityLevel *int32 `json:"compatibilityLevel,omitempty"` - // RequiresPreprocessing - Value that indicates whether the rule action requires preprocessing. - RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` -} - -// Subnet properties supplied for Subnet -type Subnet struct { - // ID - Resource ID of Virtual Network Subnet - ID *string `json:"id,omitempty"` -} - -// SystemData metadata pertaining to creation and last modification of the resource. -type SystemData struct { - // CreatedBy - The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` - // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' - CreatedByType CreatedByType `json:"createdByType,omitempty"` - // CreatedAt - The timestamp of resource creation (UTC). - CreatedAt *date.Time `json:"createdAt,omitempty"` - // LastModifiedBy - The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' - LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` - // LastModifiedAt - The type of identity that last modified the resource. - LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` -} - -// TrackedResource the Resource definition. -type TrackedResource struct { - // Location - The Geo-location where the resource lives - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource Id - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for TrackedResource. -func (tr TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tr.Location != nil { - objectMap["location"] = tr.Location - } - if tr.Tags != nil { - objectMap["tags"] = tr.Tags - } - return json.Marshal(objectMap) -} - -// UserAssignedIdentity recognized Dictionary value. -type UserAssignedIdentity struct { - // PrincipalID - READ-ONLY; Principal Id of user assigned identity - PrincipalID *string `json:"principalId,omitempty"` - // ClientID - READ-ONLY; Client Id of user assigned identity - ClientID *string `json:"clientId,omitempty"` -} - -// MarshalJSON is the custom marshaler for UserAssignedIdentity. -func (uai UserAssignedIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// UserAssignedIdentityProperties ... -type UserAssignedIdentityProperties struct { - // UserAssignedIdentity - ARM ID of user Identity selected for encryption - UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/namespaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/namespaces.go deleted file mode 100644 index 6e34c5da36d8..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/namespaces.go +++ /dev/null @@ -1,1600 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// NamespacesClient is the client for the Namespaces methods of the Servicebus service. -type NamespacesClient struct { - BaseClient -} - -// NewNamespacesClient creates an instance of the NamespacesClient client. -func NewNamespacesClient(subscriptionID string) NamespacesClient { - return NewNamespacesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewNamespacesClientWithBaseURI creates an instance of the NamespacesClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewNamespacesClientWithBaseURI(baseURI string, subscriptionID string) NamespacesClient { - return NamespacesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckNameAvailabilityMethod check the give namespace name availability. -// Parameters: -// parameters - parameters to check availability of the given namespace name -func (client NamespacesClient) CheckNameAvailabilityMethod(ctx context.Context, parameters CheckNameAvailability) (result CheckNameAvailabilityResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.CheckNameAvailabilityMethod") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "CheckNameAvailabilityMethod", err.Error()) - } - - req, err := client.CheckNameAvailabilityMethodPreparer(ctx, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod", nil, "Failure preparing request") - return - } - - resp, err := client.CheckNameAvailabilityMethodSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod", resp, "Failure sending request") - return - } - - result, err = client.CheckNameAvailabilityMethodResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CheckNameAvailabilityMethod", resp, "Failure responding to request") - return - } - - return -} - -// CheckNameAvailabilityMethodPreparer prepares the CheckNameAvailabilityMethod request. -func (client NamespacesClient) CheckNameAvailabilityMethodPreparer(ctx context.Context, parameters CheckNameAvailability) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/CheckNameAvailability", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckNameAvailabilityMethodSender sends the CheckNameAvailabilityMethod request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) CheckNameAvailabilityMethodSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CheckNameAvailabilityMethodResponder handles the response to the CheckNameAvailabilityMethod request. The method always -// closes the http.Response Body. -func (client NamespacesClient) CheckNameAvailabilityMethodResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdate creates or updates a service namespace. Once created, this namespace's resource manifest is -// immutable. This operation is idempotent. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name. -// parameters - parameters supplied to create a namespace resource. -func (client NamespacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, parameters SBNamespace) (result NamespacesCreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client NamespacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters SBNamespace) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) CreateOrUpdateSender(req *http.Request) (future NamespacesCreateOrUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateResponder(resp *http.Response) (result SBNamespace, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateAuthorizationRule creates or updates an authorization rule for a namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// authorizationRuleName - the authorization rule name. -// parameters - the shared access authorization rule. -func (client NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SBAuthorizationRule) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.CreateOrUpdateAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.SBAuthorizationRuleProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.SBAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", err.Error()) - } - - req, err := client.CreateOrUpdateAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, authorizationRuleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request. -func (client NamespacesClient) CreateOrUpdateAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SBAuthorizationRule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateNetworkRuleSet create or update NetworkRuleSet for a Namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// parameters - the Namespace IpFilterRule. -func (client NamespacesClient) CreateOrUpdateNetworkRuleSet(ctx context.Context, resourceGroupName string, namespaceName string, parameters NetworkRuleSet) (result NetworkRuleSet, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.CreateOrUpdateNetworkRuleSet") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "CreateOrUpdateNetworkRuleSet", err.Error()) - } - - req, err := client.CreateOrUpdateNetworkRuleSetPreparer(ctx, resourceGroupName, namespaceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateNetworkRuleSet", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateNetworkRuleSetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateNetworkRuleSet", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateNetworkRuleSetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "CreateOrUpdateNetworkRuleSet", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateNetworkRuleSetPreparer prepares the CreateOrUpdateNetworkRuleSet request. -func (client NamespacesClient) CreateOrUpdateNetworkRuleSetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters NetworkRuleSet) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateNetworkRuleSetSender sends the CreateOrUpdateNetworkRuleSet request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) CreateOrUpdateNetworkRuleSetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateNetworkRuleSetResponder handles the response to the CreateOrUpdateNetworkRuleSet request. The method always -// closes the http.Response Body. -func (client NamespacesClient) CreateOrUpdateNetworkRuleSetResponder(resp *http.Response) (result NetworkRuleSet, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes an existing namespace. This operation also removes all associated resources under the namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client NamespacesClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string) (result NamespacesDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client NamespacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) DeleteSender(req *http.Request) (future NamespacesDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client NamespacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteAuthorizationRule deletes a namespace authorization rule. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// authorizationRuleName - the authorization rule name. -func (client NamespacesClient) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.DeleteAuthorizationRule") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "DeleteAuthorizationRule", err.Error()) - } - - req, err := client.DeleteAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteAuthorizationRuleSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.DeleteAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "DeleteAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request. -func (client NamespacesClient) DeleteAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (client NamespacesClient) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets a description for the specified namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client NamespacesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string) (result SBNamespace, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client NamespacesClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client NamespacesClient) GetResponder(resp *http.Response) (result SBNamespace, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAuthorizationRule gets an authorization rule for a namespace by rule name. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// authorizationRuleName - the authorization rule name. -func (client NamespacesClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.GetAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "GetAuthorizationRule", err.Error()) - } - - req, err := client.GetAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.GetAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.GetAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request. -func (client NamespacesClient) GetAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (client NamespacesClient) GetAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetNetworkRuleSet gets NetworkRuleSet for a Namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client NamespacesClient) GetNetworkRuleSet(ctx context.Context, resourceGroupName string, namespaceName string) (result NetworkRuleSet, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.GetNetworkRuleSet") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "GetNetworkRuleSet", err.Error()) - } - - req, err := client.GetNetworkRuleSetPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetNetworkRuleSet", nil, "Failure preparing request") - return - } - - resp, err := client.GetNetworkRuleSetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetNetworkRuleSet", resp, "Failure sending request") - return - } - - result, err = client.GetNetworkRuleSetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "GetNetworkRuleSet", resp, "Failure responding to request") - return - } - - return -} - -// GetNetworkRuleSetPreparer prepares the GetNetworkRuleSet request. -func (client NamespacesClient) GetNetworkRuleSetPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetNetworkRuleSetSender sends the GetNetworkRuleSet request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) GetNetworkRuleSetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetNetworkRuleSetResponder handles the response to the GetNetworkRuleSet request. The method always -// closes the http.Response Body. -func (client NamespacesClient) GetNetworkRuleSetResponder(resp *http.Response) (result NetworkRuleSet, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets all the available namespaces within the subscription, irrespective of the resource groups. -func (client NamespacesClient) List(ctx context.Context) (result SBNamespaceListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.List") - defer func() { - sc := -1 - if result.snlr.Response.Response != nil { - sc = result.snlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.snlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "List", resp, "Failure sending request") - return - } - - result.snlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "List", resp, "Failure responding to request") - return - } - if result.snlr.hasNextLink() && result.snlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client NamespacesClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceBus/namespaces", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client NamespacesClient) ListResponder(resp *http.Response) (result SBNamespaceListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client NamespacesClient) listNextResults(ctx context.Context, lastResults SBNamespaceListResult) (result SBNamespaceListResult, err error) { - req, err := lastResults.sBNamespaceListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client NamespacesClient) ListComplete(ctx context.Context) (result SBNamespaceListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} - -// ListAuthorizationRules gets the authorization rules for a namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client NamespacesClient) ListAuthorizationRules(ctx context.Context, resourceGroupName string, namespaceName string) (result SBAuthorizationRuleListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.sarlr.Response.Response != nil { - sc = result.sarlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "ListAuthorizationRules", err.Error()) - } - - result.fn = client.listAuthorizationRulesNextResults - req, err := client.ListAuthorizationRulesPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.sarlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", resp, "Failure sending request") - return - } - - result.sarlr, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListAuthorizationRules", resp, "Failure responding to request") - return - } - if result.sarlr.hasNextLink() && result.sarlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. -func (client NamespacesClient) ListAuthorizationRulesPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (client NamespacesClient) ListAuthorizationRulesResponder(resp *http.Response) (result SBAuthorizationRuleListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAuthorizationRulesNextResults retrieves the next set of results, if any. -func (client NamespacesClient) listAuthorizationRulesNextResults(ctx context.Context, lastResults SBAuthorizationRuleListResult) (result SBAuthorizationRuleListResult, err error) { - req, err := lastResults.sBAuthorizationRuleListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listAuthorizationRulesNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listAuthorizationRulesNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listAuthorizationRulesNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAuthorizationRulesComplete enumerates all values, automatically crossing page boundaries as required. -func (client NamespacesClient) ListAuthorizationRulesComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result SBAuthorizationRuleListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListAuthorizationRules(ctx, resourceGroupName, namespaceName) - return -} - -// ListByResourceGroup gets the available namespaces within a resource group. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -func (client NamespacesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result SBNamespaceListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.snlr.Response.Response != nil { - sc = result.snlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "ListByResourceGroup", err.Error()) - } - - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.snlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result.snlr, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListByResourceGroup", resp, "Failure responding to request") - return - } - if result.snlr.hasNextLink() && result.snlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client NamespacesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client NamespacesClient) ListByResourceGroupResponder(resp *http.Response) (result SBNamespaceListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client NamespacesClient) listByResourceGroupNextResults(ctx context.Context, lastResults SBNamespaceListResult) (result SBNamespaceListResult, err error) { - req, err := lastResults.sBNamespaceListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client NamespacesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result SBNamespaceListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) - return -} - -// ListKeys gets the primary and secondary connection strings for the namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// authorizationRuleName - the authorization rule name. -func (client NamespacesClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "ListKeys", err.Error()) - } - - req, err := client.ListKeysPreparer(ctx, resourceGroupName, namespaceName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp, err := client.ListKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", resp, "Failure sending request") - return - } - - result, err = client.ListKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListKeys", resp, "Failure responding to request") - return - } - - return -} - -// ListKeysPreparer prepares the ListKeys request. -func (client NamespacesClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListKeysSender sends the ListKeys request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) ListKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListKeysResponder handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNetworkRuleSets gets list of NetworkRuleSet for a Namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client NamespacesClient) ListNetworkRuleSets(ctx context.Context, resourceGroupName string, namespaceName string) (result NetworkRuleSetListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListNetworkRuleSets") - defer func() { - sc := -1 - if result.nrslr.Response.Response != nil { - sc = result.nrslr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "ListNetworkRuleSets", err.Error()) - } - - result.fn = client.listNetworkRuleSetsNextResults - req, err := client.ListNetworkRuleSetsPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListNetworkRuleSets", nil, "Failure preparing request") - return - } - - resp, err := client.ListNetworkRuleSetsSender(req) - if err != nil { - result.nrslr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListNetworkRuleSets", resp, "Failure sending request") - return - } - - result.nrslr, err = client.ListNetworkRuleSetsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "ListNetworkRuleSets", resp, "Failure responding to request") - return - } - if result.nrslr.hasNextLink() && result.nrslr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListNetworkRuleSetsPreparer prepares the ListNetworkRuleSets request. -func (client NamespacesClient) ListNetworkRuleSetsPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/networkRuleSets", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListNetworkRuleSetsSender sends the ListNetworkRuleSets request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) ListNetworkRuleSetsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListNetworkRuleSetsResponder handles the response to the ListNetworkRuleSets request. The method always -// closes the http.Response Body. -func (client NamespacesClient) ListNetworkRuleSetsResponder(resp *http.Response) (result NetworkRuleSetListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNetworkRuleSetsNextResults retrieves the next set of results, if any. -func (client NamespacesClient) listNetworkRuleSetsNextResults(ctx context.Context, lastResults NetworkRuleSetListResult) (result NetworkRuleSetListResult, err error) { - req, err := lastResults.networkRuleSetListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNetworkRuleSetsNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListNetworkRuleSetsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNetworkRuleSetsNextResults", resp, "Failure sending next results request") - } - result, err = client.ListNetworkRuleSetsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "listNetworkRuleSetsNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListNetworkRuleSetsComplete enumerates all values, automatically crossing page boundaries as required. -func (client NamespacesClient) ListNetworkRuleSetsComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result NetworkRuleSetListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.ListNetworkRuleSets") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListNetworkRuleSets(ctx, resourceGroupName, namespaceName) - return -} - -// RegenerateKeys regenerates the primary or secondary connection strings for the namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// authorizationRuleName - the authorization rule name. -// parameters - parameters supplied to regenerate the authorization rule. -func (client NamespacesClient) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateAccessKeyParameters) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.RegenerateKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "RegenerateKeys", err.Error()) - } - - req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, namespaceName, authorizationRuleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - resp, err := client.RegenerateKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", resp, "Failure sending request") - return - } - - result, err = client.RegenerateKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "RegenerateKeys", resp, "Failure responding to request") - return - } - - return -} - -// RegenerateKeysPreparer prepares the RegenerateKeys request. -func (client NamespacesClient) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters RegenerateAccessKeyParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegenerateKeysSender sends the RegenerateKeys request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (client NamespacesClient) RegenerateKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is -// idempotent. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// parameters - parameters supplied to update a namespace resource. -func (client NamespacesClient) Update(ctx context.Context, resourceGroupName string, namespaceName string, parameters SBNamespaceUpdateParameters) (result SBNamespace, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.Update") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.NamespacesClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, namespaceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.NamespacesClient", "Update", resp, "Failure responding to request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client NamespacesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters SBNamespaceUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client NamespacesClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client NamespacesClient) UpdateResponder(resp *http.Response) (result SBNamespace, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/operations.go deleted file mode 100644 index 9bcd98ac66db..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/operations.go +++ /dev/null @@ -1,140 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// OperationsClient is the client for the Operations methods of the Servicebus service. -type OperationsClient struct { - BaseClient -} - -// NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists all of the available ServiceBus REST API operations. -func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.olr.Response.Response != nil { - sc = result.olr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", resp, "Failure sending request") - return - } - - result.olr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "List", resp, "Failure responding to request") - return - } - if result.olr.hasNextLink() && result.olr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.ServiceBus/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.OperationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.OperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.OperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/privateendpointconnections.go deleted file mode 100644 index d6ea029c1544..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/privateendpointconnections.go +++ /dev/null @@ -1,431 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PrivateEndpointConnectionsClient is the client for the PrivateEndpointConnections methods of the Servicebus service. -type PrivateEndpointConnectionsClient struct { - BaseClient -} - -// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. -func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { - return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client -// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign -// clouds, Azure stack). -func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates PrivateEndpointConnections of service namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// privateEndpointConnectionName - the PrivateEndpointConnection name -// parameters - parameters supplied to update Status of PrivateEndPoint Connection to namespace resource. -func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (result PrivateEndpointConnection, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, privateEndpointConnectionName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes an existing Private Endpoint Connection. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// privateEndpointConnectionName - the PrivateEndpointConnection name -func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.PrivateEndpointConnectionsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, privateEndpointConnectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, privateEndpointConnectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets a description for the specified Private Endpoint Connection. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// privateEndpointConnectionName - the PrivateEndpointConnection name -func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.PrivateEndpointConnectionsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, privateEndpointConnectionName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, privateEndpointConnectionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets the available PrivateEndpointConnections within a namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, namespaceName string) (result PrivateEndpointConnectionListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") - defer func() { - sc := -1 - if result.peclr.Response.Response != nil { - sc = result.peclr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.PrivateEndpointConnectionsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.peclr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") - return - } - - result.peclr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") - return - } - if result.peclr.hasNextLink() && result.peclr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client PrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateEndpointConnections", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client PrivateEndpointConnectionsClient) listNextResults(ctx context.Context, lastResults PrivateEndpointConnectionListResult) (result PrivateEndpointConnectionListResult, err error) { - req, err := lastResults.privateEndpointConnectionListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateEndpointConnectionsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client PrivateEndpointConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result PrivateEndpointConnectionListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, namespaceName) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/privatelinkresources.go deleted file mode 100644 index 456d9a3947bb..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/privatelinkresources.go +++ /dev/null @@ -1,119 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// PrivateLinkResourcesClient is the client for the PrivateLinkResources methods of the Servicebus service. -type PrivateLinkResourcesClient struct { - BaseClient -} - -// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. -func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { - return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Get gets lists of resources that supports Privatelinks. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string) (result PrivateLinkResourcesListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.PrivateLinkResourcesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/privateLinkResources", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResourcesListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/queues.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/queues.go deleted file mode 100644 index 51860ed7400f..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/queues.go +++ /dev/null @@ -1,1069 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// QueuesClient is the client for the Queues methods of the Servicebus service. -type QueuesClient struct { - BaseClient -} - -// NewQueuesClient creates an instance of the QueuesClient client. -func NewQueuesClient(subscriptionID string) QueuesClient { - return NewQueuesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewQueuesClientWithBaseURI creates an instance of the QueuesClient client using a custom endpoint. Use this when -// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewQueuesClientWithBaseURI(baseURI string, subscriptionID string) QueuesClient { - return QueuesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates or updates a Service Bus queue. This operation is idempotent. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -// parameters - parameters supplied to create or update a queue resource. -func (client QueuesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, parameters SBQueue) (result SBQueue, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, queueName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client QueuesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, parameters SBQueue) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client QueuesClient) CreateOrUpdateResponder(resp *http.Response) (result SBQueue, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateAuthorizationRule creates an authorization rule for a queue. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -// authorizationRuleName - the authorization rule name. -// parameters - the shared access authorization rule. -func (client QueuesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string, parameters SBAuthorizationRule) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.CreateOrUpdateAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.SBAuthorizationRuleProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.SBAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", err.Error()) - } - - req, err := client.CreateOrUpdateAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, queueName, authorizationRuleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request. -func (client QueuesClient) CreateOrUpdateAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string, parameters SBAuthorizationRule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (client QueuesClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a queue from the specified namespace in a resource group. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -func (client QueuesClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, queueName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client QueuesClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client QueuesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteAuthorizationRule deletes a queue authorization rule. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -// authorizationRuleName - the authorization rule name. -func (client QueuesClient) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.DeleteAuthorizationRule") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "DeleteAuthorizationRule", err.Error()) - } - - req, err := client.DeleteAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, queueName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteAuthorizationRuleSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.DeleteAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "DeleteAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request. -func (client QueuesClient) DeleteAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (client QueuesClient) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get returns a description for the specified queue. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -func (client QueuesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (result SBQueue, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, queueName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client QueuesClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client QueuesClient) GetResponder(resp *http.Response) (result SBQueue, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAuthorizationRule gets an authorization rule for a queue by rule name. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -// authorizationRuleName - the authorization rule name. -func (client QueuesClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.GetAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "GetAuthorizationRule", err.Error()) - } - - req, err := client.GetAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, queueName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.GetAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.GetAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "GetAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request. -func (client QueuesClient) GetAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (client QueuesClient) GetAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListAuthorizationRules gets all authorization rules for a queue. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -func (client QueuesClient) ListAuthorizationRules(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (result SBAuthorizationRuleListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.sarlr.Response.Response != nil { - sc = result.sarlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "ListAuthorizationRules", err.Error()) - } - - result.fn = client.listAuthorizationRulesNextResults - req, err := client.ListAuthorizationRulesPreparer(ctx, resourceGroupName, namespaceName, queueName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.sarlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", resp, "Failure sending request") - return - } - - result.sarlr, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListAuthorizationRules", resp, "Failure responding to request") - return - } - if result.sarlr.hasNextLink() && result.sarlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. -func (client QueuesClient) ListAuthorizationRulesPreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (client QueuesClient) ListAuthorizationRulesResponder(resp *http.Response) (result SBAuthorizationRuleListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAuthorizationRulesNextResults retrieves the next set of results, if any. -func (client QueuesClient) listAuthorizationRulesNextResults(ctx context.Context, lastResults SBAuthorizationRuleListResult) (result SBAuthorizationRuleListResult, err error) { - req, err := lastResults.sBAuthorizationRuleListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "listAuthorizationRulesNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "listAuthorizationRulesNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "listAuthorizationRulesNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAuthorizationRulesComplete enumerates all values, automatically crossing page boundaries as required. -func (client QueuesClient) ListAuthorizationRulesComplete(ctx context.Context, resourceGroupName string, namespaceName string, queueName string) (result SBAuthorizationRuleListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListAuthorizationRules(ctx, resourceGroupName, namespaceName, queueName) - return -} - -// ListByNamespace gets the queues within a namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// skip - skip is only used if a previous operation returned a partial result. If a previous response contains -// a nextLink element, the value of the nextLink element will include a skip parameter that specifies a -// starting point to use for subsequent calls. -// top - may be used to limit the number of results to the most recent N usageDetails. -func (client QueuesClient) ListByNamespace(ctx context.Context, resourceGroupName string, namespaceName string, skip *int32, top *int32) (result SBQueueListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.ListByNamespace") - defer func() { - sc := -1 - if result.sqlr.Response.Response != nil { - sc = result.sqlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, - }}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "ListByNamespace", err.Error()) - } - - result.fn = client.listByNamespaceNextResults - req, err := client.ListByNamespacePreparer(ctx, resourceGroupName, namespaceName, skip, top) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - resp, err := client.ListByNamespaceSender(req) - if err != nil { - result.sqlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListByNamespace", resp, "Failure sending request") - return - } - - result.sqlr, err = client.ListByNamespaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListByNamespace", resp, "Failure responding to request") - return - } - if result.sqlr.hasNextLink() && result.sqlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByNamespacePreparer prepares the ListByNamespace request. -func (client QueuesClient) ListByNamespacePreparer(ctx context.Context, resourceGroupName string, namespaceName string, skip *int32, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByNamespaceSender sends the ListByNamespace request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) ListByNamespaceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByNamespaceResponder handles the response to the ListByNamespace request. The method always -// closes the http.Response Body. -func (client QueuesClient) ListByNamespaceResponder(resp *http.Response) (result SBQueueListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByNamespaceNextResults retrieves the next set of results, if any. -func (client QueuesClient) listByNamespaceNextResults(ctx context.Context, lastResults SBQueueListResult) (result SBQueueListResult, err error) { - req, err := lastResults.sBQueueListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "listByNamespaceNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByNamespaceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.QueuesClient", "listByNamespaceNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByNamespaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "listByNamespaceNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByNamespaceComplete enumerates all values, automatically crossing page boundaries as required. -func (client QueuesClient) ListByNamespaceComplete(ctx context.Context, resourceGroupName string, namespaceName string, skip *int32, top *int32) (result SBQueueListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.ListByNamespace") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListByNamespace(ctx, resourceGroupName, namespaceName, skip, top) - return -} - -// ListKeys primary and secondary connection strings to the queue. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -// authorizationRuleName - the authorization rule name. -func (client QueuesClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.ListKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "ListKeys", err.Error()) - } - - req, err := client.ListKeysPreparer(ctx, resourceGroupName, namespaceName, queueName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp, err := client.ListKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", resp, "Failure sending request") - return - } - - result, err = client.ListKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "ListKeys", resp, "Failure responding to request") - return - } - - return -} - -// ListKeysPreparer prepares the ListKeys request. -func (client QueuesClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/ListKeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListKeysSender sends the ListKeys request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) ListKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListKeysResponder handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (client QueuesClient) ListKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// RegenerateKeys regenerates the primary or secondary connection strings to the queue. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// queueName - the queue name. -// authorizationRuleName - the authorization rule name. -// parameters - parameters supplied to regenerate the authorization rule. -func (client QueuesClient) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string, parameters RegenerateAccessKeyParameters) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/QueuesClient.RegenerateKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: queueName, - Constraints: []validation.Constraint{{Target: "queueName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.QueuesClient", "RegenerateKeys", err.Error()) - } - - req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, namespaceName, queueName, authorizationRuleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - resp, err := client.RegenerateKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", resp, "Failure sending request") - return - } - - result, err = client.RegenerateKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.QueuesClient", "RegenerateKeys", resp, "Failure responding to request") - return - } - - return -} - -// RegenerateKeysPreparer prepares the RegenerateKeys request. -func (client QueuesClient) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string, parameters RegenerateAccessKeyParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "queueName": autorest.Encode("path", queueName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/queues/{queueName}/authorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegenerateKeysSender sends the RegenerateKeys request. The method will close the -// http.Response Body if it receives an error. -func (client QueuesClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (client QueuesClient) RegenerateKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/rules.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/rules.go deleted file mode 100644 index 9fd10bb35e11..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/rules.go +++ /dev/null @@ -1,492 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// RulesClient is the client for the Rules methods of the Servicebus service. -type RulesClient struct { - BaseClient -} - -// NewRulesClient creates an instance of the RulesClient client. -func NewRulesClient(subscriptionID string) RulesClient { - return NewRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewRulesClientWithBaseURI creates an instance of the RulesClient client using a custom endpoint. Use this when -// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewRulesClientWithBaseURI(baseURI string, subscriptionID string) RulesClient { - return RulesClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates a new rule and updates an existing rule -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -// ruleName - the rule name. -// parameters - parameters supplied to create a rule. -func (client RulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string, parameters Rule) (result Rule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: ruleName, - Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.RulesClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, ruleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client RulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string, parameters Rule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "ruleName": autorest.Encode("path", ruleName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client RulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client RulesClient) CreateOrUpdateResponder(resp *http.Response) (result Rule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes an existing rule. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -// ruleName - the rule name. -func (client RulesClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: ruleName, - Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.RulesClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, ruleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "ruleName": autorest.Encode("path", ruleName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client RulesClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client RulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get retrieves the description for the specified rule. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -// ruleName - the rule name. -func (client RulesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (result Rule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: ruleName, - Constraints: []validation.Constraint{{Target: "ruleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "ruleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.RulesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, ruleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client RulesClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "ruleName": autorest.Encode("path", ruleName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules/{ruleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client RulesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client RulesClient) GetResponder(resp *http.Response) (result Rule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListBySubscriptions list all the rules within given topic-subscription -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -// skip - skip is only used if a previous operation returned a partial result. If a previous response contains -// a nextLink element, the value of the nextLink element will include a skip parameter that specifies a -// starting point to use for subsequent calls. -// top - may be used to limit the number of results to the most recent N usageDetails. -func (client RulesClient) ListBySubscriptions(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, skip *int32, top *int32) (result RuleListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.ListBySubscriptions") - defer func() { - sc := -1 - if result.rlr.Response.Response != nil { - sc = result.rlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, - }}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("servicebus.RulesClient", "ListBySubscriptions", err.Error()) - } - - result.fn = client.listBySubscriptionsNextResults - req, err := client.ListBySubscriptionsPreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, skip, top) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "ListBySubscriptions", nil, "Failure preparing request") - return - } - - resp, err := client.ListBySubscriptionsSender(req) - if err != nil { - result.rlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "ListBySubscriptions", resp, "Failure sending request") - return - } - - result.rlr, err = client.ListBySubscriptionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "ListBySubscriptions", resp, "Failure responding to request") - return - } - if result.rlr.hasNextLink() && result.rlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListBySubscriptionsPreparer prepares the ListBySubscriptions request. -func (client RulesClient) ListBySubscriptionsPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, skip *int32, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}/rules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListBySubscriptionsSender sends the ListBySubscriptions request. The method will close the -// http.Response Body if it receives an error. -func (client RulesClient) ListBySubscriptionsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListBySubscriptionsResponder handles the response to the ListBySubscriptions request. The method always -// closes the http.Response Body. -func (client RulesClient) ListBySubscriptionsResponder(resp *http.Response) (result RuleListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listBySubscriptionsNextResults retrieves the next set of results, if any. -func (client RulesClient) listBySubscriptionsNextResults(ctx context.Context, lastResults RuleListResult) (result RuleListResult, err error) { - req, err := lastResults.ruleListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.RulesClient", "listBySubscriptionsNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListBySubscriptionsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.RulesClient", "listBySubscriptionsNextResults", resp, "Failure sending next results request") - } - result, err = client.ListBySubscriptionsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.RulesClient", "listBySubscriptionsNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListBySubscriptionsComplete enumerates all values, automatically crossing page boundaries as required. -func (client RulesClient) ListBySubscriptionsComplete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, skip *int32, top *int32) (result RuleListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RulesClient.ListBySubscriptions") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListBySubscriptions(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, skip, top) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/subscriptions.go deleted file mode 100644 index 0f78e281c66e..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/subscriptions.go +++ /dev/null @@ -1,472 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// SubscriptionsClient is the client for the Subscriptions methods of the Servicebus service. -type SubscriptionsClient struct { - BaseClient -} - -// NewSubscriptionsClient creates an instance of the SubscriptionsClient client. -func NewSubscriptionsClient(subscriptionID string) SubscriptionsClient { - return NewSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewSubscriptionsClientWithBaseURI creates an instance of the SubscriptionsClient client using a custom endpoint. -// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsClient { - return SubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates a topic subscription. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -// parameters - parameters supplied to create a subscription resource. -func (client SubscriptionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, parameters SBSubscription) (result SBSubscription, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.SubscriptionsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client SubscriptionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, parameters SBSubscription) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) CreateOrUpdateResponder(resp *http.Response) (result SBSubscription, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a subscription from the specified topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -func (client SubscriptionsClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.SubscriptionsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client SubscriptionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get returns a subscription description for the specified topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// subscriptionName - the subscription name. -func (client SubscriptionsClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string) (result SBSubscription, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: subscriptionName, - Constraints: []validation.Constraint{{Target: "subscriptionName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "subscriptionName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.SubscriptionsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, topicName, subscriptionName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client SubscriptionsClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, subscriptionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "subscriptionName": autorest.Encode("path", subscriptionName), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions/{subscriptionName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) GetResponder(resp *http.Response) (result SBSubscription, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByTopic list all the subscriptions under a specified topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// skip - skip is only used if a previous operation returned a partial result. If a previous response contains -// a nextLink element, the value of the nextLink element will include a skip parameter that specifies a -// starting point to use for subsequent calls. -// top - may be used to limit the number of results to the most recent N usageDetails. -func (client SubscriptionsClient) ListByTopic(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, skip *int32, top *int32) (result SBSubscriptionListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByTopic") - defer func() { - sc := -1 - if result.sslr.Response.Response != nil { - sc = result.sslr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, - }}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("servicebus.SubscriptionsClient", "ListByTopic", err.Error()) - } - - result.fn = client.listByTopicNextResults - req, err := client.ListByTopicPreparer(ctx, resourceGroupName, namespaceName, topicName, skip, top) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListByTopic", nil, "Failure preparing request") - return - } - - resp, err := client.ListByTopicSender(req) - if err != nil { - result.sslr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListByTopic", resp, "Failure sending request") - return - } - - result.sslr, err = client.ListByTopicResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "ListByTopic", resp, "Failure responding to request") - return - } - if result.sslr.hasNextLink() && result.sslr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByTopicPreparer prepares the ListByTopic request. -func (client SubscriptionsClient) ListByTopicPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, skip *int32, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/subscriptions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByTopicSender sends the ListByTopic request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) ListByTopicSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByTopicResponder handles the response to the ListByTopic request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) ListByTopicResponder(resp *http.Response) (result SBSubscriptionListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByTopicNextResults retrieves the next set of results, if any. -func (client SubscriptionsClient) listByTopicNextResults(ctx context.Context, lastResults SBSubscriptionListResult) (result SBSubscriptionListResult, err error) { - req, err := lastResults.sBSubscriptionListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "listByTopicNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByTopicSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "listByTopicNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByTopicResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.SubscriptionsClient", "listByTopicNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByTopicComplete enumerates all values, automatically crossing page boundaries as required. -func (client SubscriptionsClient) ListByTopicComplete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, skip *int32, top *int32) (result SBSubscriptionListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByTopic") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListByTopic(ctx, resourceGroupName, namespaceName, topicName, skip, top) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/topics.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/topics.go deleted file mode 100644 index 91462d403a84..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/topics.go +++ /dev/null @@ -1,1069 +0,0 @@ -package servicebus - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// TopicsClient is the client for the Topics methods of the Servicebus service. -type TopicsClient struct { - BaseClient -} - -// NewTopicsClient creates an instance of the TopicsClient client. -func NewTopicsClient(subscriptionID string) TopicsClient { - return NewTopicsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewTopicsClientWithBaseURI creates an instance of the TopicsClient client using a custom endpoint. Use this when -// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewTopicsClientWithBaseURI(baseURI string, subscriptionID string) TopicsClient { - return TopicsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate creates a topic in the specified namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// parameters - parameters supplied to create a topic resource. -func (client TopicsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, parameters SBTopic) (result SBTopic, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, topicName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client TopicsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, parameters SBTopic) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client TopicsClient) CreateOrUpdateResponder(resp *http.Response) (result SBTopic, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateAuthorizationRule creates an authorization rule for the specified topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// authorizationRuleName - the authorization rule name. -// parameters - the shared access authorization rule. -func (client TopicsClient) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string, parameters SBAuthorizationRule) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.CreateOrUpdateAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.SBAuthorizationRuleProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.SBAuthorizationRuleProperties.Rights", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", err.Error()) - } - - req, err := client.CreateOrUpdateAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, topicName, authorizationRuleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request. -func (client TopicsClient) CreateOrUpdateAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string, parameters SBAuthorizationRule) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - parameters.SystemData = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (client TopicsClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes a topic from the specified namespace and resource group. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -func (client TopicsClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, topicName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client TopicsClient) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client TopicsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteAuthorizationRule deletes a topic authorization rule. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// authorizationRuleName - the authorization rule name. -func (client TopicsClient) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.DeleteAuthorizationRule") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "DeleteAuthorizationRule", err.Error()) - } - - req, err := client.DeleteAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, topicName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteAuthorizationRuleSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.DeleteAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "DeleteAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request. -func (client TopicsClient) DeleteAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (client TopicsClient) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get returns a description for the specified topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -func (client TopicsClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (result SBTopic, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, topicName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client TopicsClient) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client TopicsClient) GetResponder(resp *http.Response) (result SBTopic, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetAuthorizationRule returns the specified authorization rule. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// authorizationRuleName - the authorization rule name. -func (client TopicsClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (result SBAuthorizationRule, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.GetAuthorizationRule") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "GetAuthorizationRule", err.Error()) - } - - req, err := client.GetAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, topicName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - resp, err := client.GetAuthorizationRuleSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", resp, "Failure sending request") - return - } - - result, err = client.GetAuthorizationRuleResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "GetAuthorizationRule", resp, "Failure responding to request") - return - } - - return -} - -// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request. -func (client TopicsClient) GetAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (client TopicsClient) GetAuthorizationRuleResponder(resp *http.Response) (result SBAuthorizationRule, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListAuthorizationRules gets authorization rules for a topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -func (client TopicsClient) ListAuthorizationRules(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (result SBAuthorizationRuleListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.sarlr.Response.Response != nil { - sc = result.sarlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "ListAuthorizationRules", err.Error()) - } - - result.fn = client.listAuthorizationRulesNextResults - req, err := client.ListAuthorizationRulesPreparer(ctx, resourceGroupName, namespaceName, topicName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.sarlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", resp, "Failure sending request") - return - } - - result.sarlr, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListAuthorizationRules", resp, "Failure responding to request") - return - } - if result.sarlr.hasNextLink() && result.sarlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. -func (client TopicsClient) ListAuthorizationRulesPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (client TopicsClient) ListAuthorizationRulesResponder(resp *http.Response) (result SBAuthorizationRuleListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listAuthorizationRulesNextResults retrieves the next set of results, if any. -func (client TopicsClient) listAuthorizationRulesNextResults(ctx context.Context, lastResults SBAuthorizationRuleListResult) (result SBAuthorizationRuleListResult, err error) { - req, err := lastResults.sBAuthorizationRuleListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "listAuthorizationRulesNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListAuthorizationRulesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "listAuthorizationRulesNextResults", resp, "Failure sending next results request") - } - result, err = client.ListAuthorizationRulesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "listAuthorizationRulesNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListAuthorizationRulesComplete enumerates all values, automatically crossing page boundaries as required. -func (client TopicsClient) ListAuthorizationRulesComplete(ctx context.Context, resourceGroupName string, namespaceName string, topicName string) (result SBAuthorizationRuleListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListAuthorizationRules") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListAuthorizationRules(ctx, resourceGroupName, namespaceName, topicName) - return -} - -// ListByNamespace gets all the topics in a namespace. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// skip - skip is only used if a previous operation returned a partial result. If a previous response contains -// a nextLink element, the value of the nextLink element will include a skip parameter that specifies a -// starting point to use for subsequent calls. -// top - may be used to limit the number of results to the most recent N usageDetails. -func (client TopicsClient) ListByNamespace(ctx context.Context, resourceGroupName string, namespaceName string, skip *int32, top *int32) (result SBTopicListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListByNamespace") - defer func() { - sc := -1 - if result.stlr.Response.Response != nil { - sc = result.stlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: skip, - Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, - }}}}, - {TargetValue: top, - Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, - {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "ListByNamespace", err.Error()) - } - - result.fn = client.listByNamespaceNextResults - req, err := client.ListByNamespacePreparer(ctx, resourceGroupName, namespaceName, skip, top) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - resp, err := client.ListByNamespaceSender(req) - if err != nil { - result.stlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListByNamespace", resp, "Failure sending request") - return - } - - result.stlr, err = client.ListByNamespaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListByNamespace", resp, "Failure responding to request") - return - } - if result.stlr.hasNextLink() && result.stlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListByNamespacePreparer prepares the ListByNamespace request. -func (client TopicsClient) ListByNamespacePreparer(ctx context.Context, resourceGroupName string, namespaceName string, skip *int32, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByNamespaceSender sends the ListByNamespace request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) ListByNamespaceSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListByNamespaceResponder handles the response to the ListByNamespace request. The method always -// closes the http.Response Body. -func (client TopicsClient) ListByNamespaceResponder(resp *http.Response) (result SBTopicListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByNamespaceNextResults retrieves the next set of results, if any. -func (client TopicsClient) listByNamespaceNextResults(ctx context.Context, lastResults SBTopicListResult) (result SBTopicListResult, err error) { - req, err := lastResults.sBTopicListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "listByNamespaceNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByNamespaceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "servicebus.TopicsClient", "listByNamespaceNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByNamespaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "listByNamespaceNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByNamespaceComplete enumerates all values, automatically crossing page boundaries as required. -func (client TopicsClient) ListByNamespaceComplete(ctx context.Context, resourceGroupName string, namespaceName string, skip *int32, top *int32) (result SBTopicListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListByNamespace") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListByNamespace(ctx, resourceGroupName, namespaceName, skip, top) - return -} - -// ListKeys gets the primary and secondary connection strings for the topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// authorizationRuleName - the authorization rule name. -func (client TopicsClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.ListKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "ListKeys", err.Error()) - } - - req, err := client.ListKeysPreparer(ctx, resourceGroupName, namespaceName, topicName, authorizationRuleName) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp, err := client.ListKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", resp, "Failure sending request") - return - } - - result, err = client.ListKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "ListKeys", resp, "Failure responding to request") - return - } - - return -} - -// ListKeysPreparer prepares the ListKeys request. -func (client TopicsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/ListKeys", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListKeysSender sends the ListKeys request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) ListKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// ListKeysResponder handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (client TopicsClient) ListKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// RegenerateKeys regenerates primary or secondary connection strings for the topic. -// Parameters: -// resourceGroupName - name of the Resource group within the Azure subscription. -// namespaceName - the namespace name -// topicName - the topic name. -// authorizationRuleName - the authorization rule name. -// parameters - parameters supplied to regenerate the authorization rule. -func (client TopicsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string, parameters RegenerateAccessKeyParameters) (result AccessKeys, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/TopicsClient.RegenerateKeys") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: resourceGroupName, - Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, - {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: namespaceName, - Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}, - {TargetValue: topicName, - Constraints: []validation.Constraint{{Target: "topicName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, - {TargetValue: authorizationRuleName, - Constraints: []validation.Constraint{{Target: "authorizationRuleName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "authorizationRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { - return result, validation.NewError("servicebus.TopicsClient", "RegenerateKeys", err.Error()) - } - - req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, namespaceName, topicName, authorizationRuleName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - resp, err := client.RegenerateKeysSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", resp, "Failure sending request") - return - } - - result, err = client.RegenerateKeysResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "servicebus.TopicsClient", "RegenerateKeys", resp, "Failure responding to request") - return - } - - return -} - -// RegenerateKeysPreparer prepares the RegenerateKeys request. -func (client TopicsClient) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string, parameters RegenerateAccessKeyParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "authorizationRuleName": autorest.Encode("path", authorizationRuleName), - "namespaceName": autorest.Encode("path", namespaceName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "topicName": autorest.Encode("path", topicName), - } - - const APIVersion = "2021-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/topics/{topicName}/authorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegenerateKeysSender sends the RegenerateKeys request. The method will close the -// http.Response Body if it receives an error. -func (client TopicsClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (client TopicsClient) RegenerateKeysResponder(resp *http.Response) (result AccessKeys, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/version.go deleted file mode 100644 index 3da1a0663295..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package servicebus - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " servicebus/2021-06-01-preview" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/README.md new file mode 100644 index 000000000000..266cf8709d2e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/README.md @@ -0,0 +1,197 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs` Documentation + +The `disasterrecoveryconfigs` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/disasterrecoveryconfigs" +``` + + +### Client Initialization + +```go +client := disasterrecoveryconfigs.NewDisasterRecoveryConfigsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.BreakPairing` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "aliasValue") + +read, err := client.BreakPairing(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +payload := disasterrecoveryconfigs.CheckNameAvailability{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "aliasValue") + +payload := disasterrecoveryconfigs.ArmDisasterRecovery{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.Delete` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "aliasValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.FailOver` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "aliasValue") + +payload := disasterrecoveryconfigs.FailoverProperties{ + // ... +} + + +read, err := client.FailOver(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.Get` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "aliasValue") + +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: `DisasterRecoveryConfigsClient.GetAuthorizationRule` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +read, err := client.GetAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.List` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.ListAuthorizationRules` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewDisasterRecoveryConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "aliasValue") + +// alternatively `client.ListAuthorizationRules(ctx, id)` can be used to do batched pagination +items, err := client.ListAuthorizationRulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DisasterRecoveryConfigsClient.ListKeys` + +```go +ctx := context.TODO() +id := disasterrecoveryconfigs.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +read, err := client.ListKeys(ctx, id) +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/servicebus/2021-06-01-preview/disasterrecoveryconfigs/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/client.go new file mode 100644 index 000000000000..92bd0f75168c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/client.go @@ -0,0 +1,18 @@ +package disasterrecoveryconfigs + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisasterRecoveryConfigsClient struct { + Client autorest.Client + baseUri string +} + +func NewDisasterRecoveryConfigsClientWithBaseURI(endpoint string) DisasterRecoveryConfigsClient { + return DisasterRecoveryConfigsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/constants.go new file mode 100644 index 000000000000..06c06cd30fc1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/constants.go @@ -0,0 +1,139 @@ +package disasterrecoveryconfigs + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessRights string + +const ( + AccessRightsListen AccessRights = "Listen" + AccessRightsManage AccessRights = "Manage" + AccessRightsSend AccessRights = "Send" +) + +func PossibleValuesForAccessRights() []string { + return []string{ + string(AccessRightsListen), + string(AccessRightsManage), + string(AccessRightsSend), + } +} + +func parseAccessRights(input string) (*AccessRights, error) { + vals := map[string]AccessRights{ + "listen": AccessRightsListen, + "manage": AccessRightsManage, + "send": AccessRightsSend, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessRights(input) + return &out, nil +} + +type ProvisioningStateDR string + +const ( + ProvisioningStateDRAccepted ProvisioningStateDR = "Accepted" + ProvisioningStateDRFailed ProvisioningStateDR = "Failed" + ProvisioningStateDRSucceeded ProvisioningStateDR = "Succeeded" +) + +func PossibleValuesForProvisioningStateDR() []string { + return []string{ + string(ProvisioningStateDRAccepted), + string(ProvisioningStateDRFailed), + string(ProvisioningStateDRSucceeded), + } +} + +func parseProvisioningStateDR(input string) (*ProvisioningStateDR, error) { + vals := map[string]ProvisioningStateDR{ + "accepted": ProvisioningStateDRAccepted, + "failed": ProvisioningStateDRFailed, + "succeeded": ProvisioningStateDRSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateDR(input) + return &out, nil +} + +type RoleDisasterRecovery string + +const ( + RoleDisasterRecoveryPrimary RoleDisasterRecovery = "Primary" + RoleDisasterRecoveryPrimaryNotReplicating RoleDisasterRecovery = "PrimaryNotReplicating" + RoleDisasterRecoverySecondary RoleDisasterRecovery = "Secondary" +) + +func PossibleValuesForRoleDisasterRecovery() []string { + return []string{ + string(RoleDisasterRecoveryPrimary), + string(RoleDisasterRecoveryPrimaryNotReplicating), + string(RoleDisasterRecoverySecondary), + } +} + +func parseRoleDisasterRecovery(input string) (*RoleDisasterRecovery, error) { + vals := map[string]RoleDisasterRecovery{ + "primary": RoleDisasterRecoveryPrimary, + "primarynotreplicating": RoleDisasterRecoveryPrimaryNotReplicating, + "secondary": RoleDisasterRecoverySecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RoleDisasterRecovery(input) + return &out, nil +} + +type UnavailableReason string + +const ( + UnavailableReasonInvalidName UnavailableReason = "InvalidName" + UnavailableReasonNameInLockdown UnavailableReason = "NameInLockdown" + UnavailableReasonNameInUse UnavailableReason = "NameInUse" + UnavailableReasonNone UnavailableReason = "None" + UnavailableReasonSubscriptionIsDisabled UnavailableReason = "SubscriptionIsDisabled" + UnavailableReasonTooManyNamespaceInCurrentSubscription UnavailableReason = "TooManyNamespaceInCurrentSubscription" +) + +func PossibleValuesForUnavailableReason() []string { + return []string{ + string(UnavailableReasonInvalidName), + string(UnavailableReasonNameInLockdown), + string(UnavailableReasonNameInUse), + string(UnavailableReasonNone), + string(UnavailableReasonSubscriptionIsDisabled), + string(UnavailableReasonTooManyNamespaceInCurrentSubscription), + } +} + +func parseUnavailableReason(input string) (*UnavailableReason, error) { + vals := map[string]UnavailableReason{ + "invalidname": UnavailableReasonInvalidName, + "nameinlockdown": UnavailableReasonNameInLockdown, + "nameinuse": UnavailableReasonNameInUse, + "none": UnavailableReasonNone, + "subscriptionisdisabled": UnavailableReasonSubscriptionIsDisabled, + "toomanynamespaceincurrentsubscription": UnavailableReasonTooManyNamespaceInCurrentSubscription, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnavailableReason(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_authorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_authorizationrule.go new file mode 100644 index 000000000000..31f8873ab15d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_authorizationrule.go @@ -0,0 +1,137 @@ +package disasterrecoveryconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = AuthorizationRuleId{} + +// AuthorizationRuleId is a struct representing the Resource ID for a Authorization Rule +type AuthorizationRuleId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + AuthorizationRuleName string +} + +// NewAuthorizationRuleID returns a new AuthorizationRuleId struct +func NewAuthorizationRuleID(subscriptionId string, resourceGroupName string, namespaceName string, authorizationRuleName string) AuthorizationRuleId { + return AuthorizationRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + AuthorizationRuleName: authorizationRuleName, + } +} + +// ParseAuthorizationRuleID parses 'input' into a AuthorizationRuleId +func ParseAuthorizationRuleID(input string) (*AuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(AuthorizationRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseAuthorizationRuleIDInsensitively parses 'input' case-insensitively into a AuthorizationRuleId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationRuleIDInsensitively(input string) (*AuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(AuthorizationRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateAuthorizationRuleID checks that 'input' can be parsed as a Authorization Rule ID +func ValidateAuthorizationRuleID(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 := ParseAuthorizationRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization Rule ID +func (id AuthorizationRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/authorizationRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.AuthorizationRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization Rule ID +func (id AuthorizationRuleId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticAuthorizationRules", "authorizationRules", "authorizationRules"), + resourceids.UserSpecifiedSegment("authorizationRuleName", "authorizationRuleValue"), + } +} + +// String returns a human-readable description of this Authorization Rule ID +func (id AuthorizationRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Authorization Rule Name: %q", id.AuthorizationRuleName), + } + return fmt.Sprintf("Authorization Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_disasterrecoveryconfig.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_disasterrecoveryconfig.go new file mode 100644 index 000000000000..71d68d16ba30 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_disasterrecoveryconfig.go @@ -0,0 +1,137 @@ +package disasterrecoveryconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = DisasterRecoveryConfigId{} + +// DisasterRecoveryConfigId is a struct representing the Resource ID for a Disaster Recovery Config +type DisasterRecoveryConfigId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + Alias string +} + +// NewDisasterRecoveryConfigID returns a new DisasterRecoveryConfigId struct +func NewDisasterRecoveryConfigID(subscriptionId string, resourceGroupName string, namespaceName string, alias string) DisasterRecoveryConfigId { + return DisasterRecoveryConfigId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + Alias: alias, + } +} + +// ParseDisasterRecoveryConfigID parses 'input' into a DisasterRecoveryConfigId +func ParseDisasterRecoveryConfigID(input string) (*DisasterRecoveryConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(DisasterRecoveryConfigId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DisasterRecoveryConfigId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.Alias, ok = parsed.Parsed["alias"]; !ok { + return nil, fmt.Errorf("the segment 'alias' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseDisasterRecoveryConfigIDInsensitively parses 'input' case-insensitively into a DisasterRecoveryConfigId +// note: this method should only be used for API response data and not user input +func ParseDisasterRecoveryConfigIDInsensitively(input string) (*DisasterRecoveryConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(DisasterRecoveryConfigId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DisasterRecoveryConfigId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.Alias, ok = parsed.Parsed["alias"]; !ok { + return nil, fmt.Errorf("the segment 'alias' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateDisasterRecoveryConfigID checks that 'input' can be parsed as a Disaster Recovery Config ID +func ValidateDisasterRecoveryConfigID(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 := ParseDisasterRecoveryConfigID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Disaster Recovery Config ID +func (id DisasterRecoveryConfigId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/disasterRecoveryConfigs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.Alias) +} + +// Segments returns a slice of Resource ID Segments which comprise this Disaster Recovery Config ID +func (id DisasterRecoveryConfigId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticDisasterRecoveryConfigs", "disasterRecoveryConfigs", "disasterRecoveryConfigs"), + resourceids.UserSpecifiedSegment("alias", "aliasValue"), + } +} + +// String returns a human-readable description of this Disaster Recovery Config ID +func (id DisasterRecoveryConfigId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Alias: %q", id.Alias), + } + return fmt.Sprintf("Disaster Recovery Config (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_namespace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_namespace.go new file mode 100644 index 000000000000..2b4c2f953466 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/id_namespace.go @@ -0,0 +1,124 @@ +package disasterrecoveryconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = NamespaceId{} + +// NamespaceId is a struct representing the Resource ID for a Namespace +type NamespaceId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string +} + +// NewNamespaceID returns a new NamespaceId struct +func NewNamespaceID(subscriptionId string, resourceGroupName string, namespaceName string) NamespaceId { + return NamespaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + } +} + +// ParseNamespaceID parses 'input' into a NamespaceId +func ParseNamespaceID(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseNamespaceIDInsensitively parses 'input' case-insensitively into a NamespaceId +// note: this method should only be used for API response data and not user input +func ParseNamespaceIDInsensitively(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateNamespaceID checks that 'input' can be parsed as a Namespace ID +func ValidateNamespaceID(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 := ParseNamespaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Namespace ID +func (id NamespaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Namespace ID +func (id NamespaceId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + } +} + +// String returns a human-readable description of this Namespace ID +func (id NamespaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + } + return fmt.Sprintf("Namespace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_breakpairing_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_breakpairing_autorest.go new file mode 100644 index 000000000000..144131ab3e57 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_breakpairing_autorest.go @@ -0,0 +1,66 @@ +package disasterrecoveryconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BreakPairingOperationResponse struct { + HttpResponse *http.Response +} + +// BreakPairing ... +func (c DisasterRecoveryConfigsClient) BreakPairing(ctx context.Context, id DisasterRecoveryConfigId) (result BreakPairingOperationResponse, err error) { + req, err := c.preparerForBreakPairing(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "BreakPairing", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "BreakPairing", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForBreakPairing(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "BreakPairing", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForBreakPairing prepares the BreakPairing request. +func (c DisasterRecoveryConfigsClient) preparerForBreakPairing(ctx context.Context, id DisasterRecoveryConfigId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/breakPairing", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForBreakPairing handles the response to the BreakPairing request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForBreakPairing(resp *http.Response) (result BreakPairingOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_checknameavailability_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_checknameavailability_autorest.go new file mode 100644 index 000000000000..29d5af69ca5f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_checknameavailability_autorest.go @@ -0,0 +1,69 @@ +package disasterrecoveryconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c DisasterRecoveryConfigsClient) CheckNameAvailability(ctx context.Context, id NamespaceId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { + req, err := c.preparerForCheckNameAvailability(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCheckNameAvailability(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCheckNameAvailability prepares the CheckNameAvailability request. +func (c DisasterRecoveryConfigsClient) preparerForCheckNameAvailability(ctx context.Context, id NamespaceId, input CheckNameAvailability) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/disasterRecoveryConfigs/checkNameAvailability", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_createorupdate_autorest.go new file mode 100644 index 000000000000..f6ed48aef31d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_createorupdate_autorest.go @@ -0,0 +1,68 @@ +package disasterrecoveryconfigs + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *ArmDisasterRecovery +} + +// CreateOrUpdate ... +func (c DisasterRecoveryConfigsClient) CreateOrUpdate(ctx context.Context, id DisasterRecoveryConfigId, input ArmDisasterRecovery) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c DisasterRecoveryConfigsClient) preparerForCreateOrUpdate(ctx context.Context, id DisasterRecoveryConfigId, input ArmDisasterRecovery) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_delete_autorest.go new file mode 100644 index 000000000000..b98d8635ee1e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_delete_autorest.go @@ -0,0 +1,65 @@ +package disasterrecoveryconfigs + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 +} + +// Delete ... +func (c DisasterRecoveryConfigsClient) Delete(ctx context.Context, id DisasterRecoveryConfigId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c DisasterRecoveryConfigsClient) preparerForDelete(ctx context.Context, id DisasterRecoveryConfigId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_failover_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_failover_autorest.go new file mode 100644 index 000000000000..a7a8f71ea7e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_failover_autorest.go @@ -0,0 +1,67 @@ +package disasterrecoveryconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailOverOperationResponse struct { + HttpResponse *http.Response +} + +// FailOver ... +func (c DisasterRecoveryConfigsClient) FailOver(ctx context.Context, id DisasterRecoveryConfigId, input FailoverProperties) (result FailOverOperationResponse, err error) { + req, err := c.preparerForFailOver(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "FailOver", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "FailOver", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForFailOver(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "FailOver", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForFailOver prepares the FailOver request. +func (c DisasterRecoveryConfigsClient) preparerForFailOver(ctx context.Context, id DisasterRecoveryConfigId, input FailoverProperties) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/failover", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForFailOver handles the response to the FailOver request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForFailOver(resp *http.Response) (result FailOverOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_get_autorest.go new file mode 100644 index 000000000000..da5493fb0272 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_get_autorest.go @@ -0,0 +1,67 @@ +package disasterrecoveryconfigs + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *ArmDisasterRecovery +} + +// Get ... +func (c DisasterRecoveryConfigsClient) Get(ctx context.Context, id DisasterRecoveryConfigId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c DisasterRecoveryConfigsClient) preparerForGet(ctx context.Context, id DisasterRecoveryConfigId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_getauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_getauthorizationrule_autorest.go new file mode 100644 index 000000000000..a4eea395979f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_getauthorizationrule_autorest.go @@ -0,0 +1,67 @@ +package disasterrecoveryconfigs + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// GetAuthorizationRule ... +func (c DisasterRecoveryConfigsClient) GetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForGetAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "GetAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. +func (c DisasterRecoveryConfigsClient) preparerForGetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_list_autorest.go new file mode 100644 index 000000000000..abd321a27394 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_list_autorest.go @@ -0,0 +1,186 @@ +package disasterrecoveryconfigs + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ArmDisasterRecovery + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ArmDisasterRecovery +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// List ... +func (c DisasterRecoveryConfigsClient) List(ctx context.Context, id NamespaceId) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c DisasterRecoveryConfigsClient) ListComplete(ctx context.Context, id NamespaceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ArmDisasterRecoveryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c DisasterRecoveryConfigsClient) ListCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate ArmDisasterRecoveryOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ArmDisasterRecovery, 0) + + page, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForList prepares the List request. +func (c DisasterRecoveryConfigsClient) preparerForList(ctx context.Context, id NamespaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/disasterRecoveryConfigs", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c DisasterRecoveryConfigsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ArmDisasterRecovery `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_listauthorizationrules_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_listauthorizationrules_autorest.go new file mode 100644 index 000000000000..e6bdeaccb281 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_listauthorizationrules_autorest.go @@ -0,0 +1,186 @@ +package disasterrecoveryconfigs + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + Model *[]SBAuthorizationRule + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) +} + +type ListAuthorizationRulesCompleteResult struct { + Items []SBAuthorizationRule +} + +func (r ListAuthorizationRulesOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListAuthorizationRules ... +func (c DisasterRecoveryConfigsClient) ListAuthorizationRules(ctx context.Context, id DisasterRecoveryConfigId) (resp ListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForListAuthorizationRules(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListAuthorizationRules", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListAuthorizationRulesComplete retrieves all of the results into a single object +func (c DisasterRecoveryConfigsClient) ListAuthorizationRulesComplete(ctx context.Context, id DisasterRecoveryConfigId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, SBAuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c DisasterRecoveryConfigsClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id DisasterRecoveryConfigId, predicate SBAuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { + items := make([]SBAuthorizationRule, 0) + + page, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListAuthorizationRulesCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. +func (c DisasterRecoveryConfigsClient) preparerForListAuthorizationRules(ctx context.Context, id DisasterRecoveryConfigId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. +func (c DisasterRecoveryConfigsClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { + type page struct { + Values []SBAuthorizationRule `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListAuthorizationRules", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListAuthorizationRules(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_listkeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_listkeys_autorest.go new file mode 100644 index 000000000000..1a26d3f29538 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/method_listkeys_autorest.go @@ -0,0 +1,68 @@ +package disasterrecoveryconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// ListKeys ... +func (c DisasterRecoveryConfigsClient) ListKeys(ctx context.Context, id AuthorizationRuleId) (result ListKeysOperationResponse, err error) { + req, err := c.preparerForListKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "disasterrecoveryconfigs.DisasterRecoveryConfigsClient", "ListKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListKeys prepares the ListKeys request. +func (c DisasterRecoveryConfigsClient) preparerForListKeys(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListKeys handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (c DisasterRecoveryConfigsClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_accesskeys.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_accesskeys.go new file mode 100644 index 000000000000..b3e1e8186bf3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_accesskeys.go @@ -0,0 +1,14 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessKeys struct { + AliasPrimaryConnectionString *string `json:"aliasPrimaryConnectionString,omitempty"` + AliasSecondaryConnectionString *string `json:"aliasSecondaryConnectionString,omitempty"` + KeyName *string `json:"keyName,omitempty"` + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_armdisasterrecovery.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_armdisasterrecovery.go new file mode 100644 index 000000000000..1300a4b02e91 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_armdisasterrecovery.go @@ -0,0 +1,16 @@ +package disasterrecoveryconfigs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmDisasterRecovery struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ArmDisasterRecoveryProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_armdisasterrecoveryproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_armdisasterrecoveryproperties.go new file mode 100644 index 000000000000..233aac5a3e81 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_armdisasterrecoveryproperties.go @@ -0,0 +1,12 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmDisasterRecoveryProperties struct { + AlternateName *string `json:"alternateName,omitempty"` + PartnerNamespace *string `json:"partnerNamespace,omitempty"` + PendingReplicationOperationsCount *int64 `json:"pendingReplicationOperationsCount,omitempty"` + ProvisioningState *ProvisioningStateDR `json:"provisioningState,omitempty"` + Role *RoleDisasterRecovery `json:"role,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_checknameavailability.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_checknameavailability.go new file mode 100644 index 000000000000..ce3efaa22e31 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_checknameavailability.go @@ -0,0 +1,8 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailability struct { + Name string `json:"name"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_checknameavailabilityresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_checknameavailabilityresult.go new file mode 100644 index 000000000000..5704fc33d00d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *UnavailableReason `json:"reason,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_failoverproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_failoverproperties.go new file mode 100644 index 000000000000..b9f9dc735b73 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_failoverproperties.go @@ -0,0 +1,8 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProperties struct { + Properties *FailoverPropertiesProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_failoverpropertiesproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_failoverpropertiesproperties.go new file mode 100644 index 000000000000..1d6aa6a722af --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_failoverpropertiesproperties.go @@ -0,0 +1,8 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverPropertiesProperties struct { + IsSafeFailover *bool `json:"IsSafeFailover,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_sbauthorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_sbauthorizationrule.go new file mode 100644 index 000000000000..71eeb750ccb9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_sbauthorizationrule.go @@ -0,0 +1,16 @@ +package disasterrecoveryconfigs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBAuthorizationRuleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_sbauthorizationruleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_sbauthorizationruleproperties.go new file mode 100644 index 000000000000..eb27b8c1a6cb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/model_sbauthorizationruleproperties.go @@ -0,0 +1,8 @@ +package disasterrecoveryconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRuleProperties struct { + Rights []AccessRights `json:"rights"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/predicates.go new file mode 100644 index 000000000000..b8bdab69f2b7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/predicates.go @@ -0,0 +1,47 @@ +package disasterrecoveryconfigs + +type ArmDisasterRecoveryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ArmDisasterRecoveryOperationPredicate) Matches(input ArmDisasterRecovery) 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 +} + +type SBAuthorizationRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBAuthorizationRuleOperationPredicate) Matches(input SBAuthorizationRule) 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/servicebus/2021-06-01-preview/disasterrecoveryconfigs/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/version.go new file mode 100644 index 000000000000..36f568cd68c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs/version.go @@ -0,0 +1,12 @@ +package disasterrecoveryconfigs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/disasterrecoveryconfigs/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/README.md new file mode 100644 index 000000000000..98b1a661301a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/README.md @@ -0,0 +1,195 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces` Documentation + +The `namespaces` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/namespaces" +``` + + +### Client Initialization + +```go +client := namespaces.NewNamespacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NamespacesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := namespaces.NewSubscriptionID() + +payload := namespaces.CheckNameAvailability{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +payload := namespaces.SBNamespace{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NamespacesClient.CreateOrUpdateNetworkRuleSet` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +payload := namespaces.NetworkRuleSet{ + // ... +} + + +read, err := client.CreateOrUpdateNetworkRuleSet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesClient.Delete` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NamespacesClient.Get` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +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: `NamespacesClient.GetNetworkRuleSet` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +read, err := client.GetNetworkRuleSet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesClient.List` + +```go +ctx := context.TODO() +id := namespaces.NewSubscriptionID() + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NamespacesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := namespaces.NewResourceGroupID() + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NamespacesClient.ListNetworkRuleSets` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +// alternatively `client.ListNetworkRuleSets(ctx, id)` can be used to do batched pagination +items, err := client.ListNetworkRuleSetsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NamespacesClient.Update` + +```go +ctx := context.TODO() +id := namespaces.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +payload := namespaces.SBNamespaceUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +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/servicebus/2021-06-01-preview/namespaces/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/client.go new file mode 100644 index 000000000000..bf25155c4194 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/client.go @@ -0,0 +1,18 @@ +package namespaces + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesClient struct { + Client autorest.Client + baseUri string +} + +func NewNamespacesClientWithBaseURI(endpoint string) NamespacesClient { + return NamespacesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/constants.go new file mode 100644 index 000000000000..20327b00897b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/constants.go @@ -0,0 +1,288 @@ +package namespaces + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type EndPointProvisioningState string + +const ( + EndPointProvisioningStateCanceled EndPointProvisioningState = "Canceled" + EndPointProvisioningStateCreating EndPointProvisioningState = "Creating" + EndPointProvisioningStateDeleting EndPointProvisioningState = "Deleting" + EndPointProvisioningStateFailed EndPointProvisioningState = "Failed" + EndPointProvisioningStateSucceeded EndPointProvisioningState = "Succeeded" + EndPointProvisioningStateUpdating EndPointProvisioningState = "Updating" +) + +func PossibleValuesForEndPointProvisioningState() []string { + return []string{ + string(EndPointProvisioningStateCanceled), + string(EndPointProvisioningStateCreating), + string(EndPointProvisioningStateDeleting), + string(EndPointProvisioningStateFailed), + string(EndPointProvisioningStateSucceeded), + string(EndPointProvisioningStateUpdating), + } +} + +func parseEndPointProvisioningState(input string) (*EndPointProvisioningState, error) { + vals := map[string]EndPointProvisioningState{ + "canceled": EndPointProvisioningStateCanceled, + "creating": EndPointProvisioningStateCreating, + "deleting": EndPointProvisioningStateDeleting, + "failed": EndPointProvisioningStateFailed, + "succeeded": EndPointProvisioningStateSucceeded, + "updating": EndPointProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndPointProvisioningState(input) + return &out, nil +} + +type KeySource string + +const ( + KeySourceMicrosoftPointKeyVault KeySource = "Microsoft.KeyVault" +) + +func PossibleValuesForKeySource() []string { + return []string{ + string(KeySourceMicrosoftPointKeyVault), + } +} + +func parseKeySource(input string) (*KeySource, error) { + vals := map[string]KeySource{ + "microsoft.keyvault": KeySourceMicrosoftPointKeyVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeySource(input) + return &out, nil +} + +type NetworkRuleIPAction string + +const ( + NetworkRuleIPActionAllow NetworkRuleIPAction = "Allow" +) + +func PossibleValuesForNetworkRuleIPAction() []string { + return []string{ + string(NetworkRuleIPActionAllow), + } +} + +func parseNetworkRuleIPAction(input string) (*NetworkRuleIPAction, error) { + vals := map[string]NetworkRuleIPAction{ + "allow": NetworkRuleIPActionAllow, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkRuleIPAction(input) + return &out, nil +} + +type PrivateLinkConnectionStatus string + +const ( + PrivateLinkConnectionStatusApproved PrivateLinkConnectionStatus = "Approved" + PrivateLinkConnectionStatusDisconnected PrivateLinkConnectionStatus = "Disconnected" + PrivateLinkConnectionStatusPending PrivateLinkConnectionStatus = "Pending" + PrivateLinkConnectionStatusRejected PrivateLinkConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateLinkConnectionStatus() []string { + return []string{ + string(PrivateLinkConnectionStatusApproved), + string(PrivateLinkConnectionStatusDisconnected), + string(PrivateLinkConnectionStatusPending), + string(PrivateLinkConnectionStatusRejected), + } +} + +func parsePrivateLinkConnectionStatus(input string) (*PrivateLinkConnectionStatus, error) { + vals := map[string]PrivateLinkConnectionStatus{ + "approved": PrivateLinkConnectionStatusApproved, + "disconnected": PrivateLinkConnectionStatusDisconnected, + "pending": PrivateLinkConnectionStatusPending, + "rejected": PrivateLinkConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkConnectionStatus(input) + return &out, nil +} + +type PublicNetworkAccessFlag string + +const ( + PublicNetworkAccessFlagDisabled PublicNetworkAccessFlag = "Disabled" + PublicNetworkAccessFlagEnabled PublicNetworkAccessFlag = "Enabled" +) + +func PossibleValuesForPublicNetworkAccessFlag() []string { + return []string{ + string(PublicNetworkAccessFlagDisabled), + string(PublicNetworkAccessFlagEnabled), + } +} + +func parsePublicNetworkAccessFlag(input string) (*PublicNetworkAccessFlag, error) { + vals := map[string]PublicNetworkAccessFlag{ + "disabled": PublicNetworkAccessFlagDisabled, + "enabled": PublicNetworkAccessFlagEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccessFlag(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNamePremium SkuName = "Premium" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNamePremium), + string(SkuNameStandard), + } +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "premium": SkuNamePremium, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type UnavailableReason string + +const ( + UnavailableReasonInvalidName UnavailableReason = "InvalidName" + UnavailableReasonNameInLockdown UnavailableReason = "NameInLockdown" + UnavailableReasonNameInUse UnavailableReason = "NameInUse" + UnavailableReasonNone UnavailableReason = "None" + UnavailableReasonSubscriptionIsDisabled UnavailableReason = "SubscriptionIsDisabled" + UnavailableReasonTooManyNamespaceInCurrentSubscription UnavailableReason = "TooManyNamespaceInCurrentSubscription" +) + +func PossibleValuesForUnavailableReason() []string { + return []string{ + string(UnavailableReasonInvalidName), + string(UnavailableReasonNameInLockdown), + string(UnavailableReasonNameInUse), + string(UnavailableReasonNone), + string(UnavailableReasonSubscriptionIsDisabled), + string(UnavailableReasonTooManyNamespaceInCurrentSubscription), + } +} + +func parseUnavailableReason(input string) (*UnavailableReason, error) { + vals := map[string]UnavailableReason{ + "invalidname": UnavailableReasonInvalidName, + "nameinlockdown": UnavailableReasonNameInLockdown, + "nameinuse": UnavailableReasonNameInUse, + "none": UnavailableReasonNone, + "subscriptionisdisabled": UnavailableReasonSubscriptionIsDisabled, + "toomanynamespaceincurrentsubscription": UnavailableReasonTooManyNamespaceInCurrentSubscription, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnavailableReason(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/id_namespace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/id_namespace.go new file mode 100644 index 000000000000..5157c14e1975 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/id_namespace.go @@ -0,0 +1,124 @@ +package namespaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = NamespaceId{} + +// NamespaceId is a struct representing the Resource ID for a Namespace +type NamespaceId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string +} + +// NewNamespaceID returns a new NamespaceId struct +func NewNamespaceID(subscriptionId string, resourceGroupName string, namespaceName string) NamespaceId { + return NamespaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + } +} + +// ParseNamespaceID parses 'input' into a NamespaceId +func ParseNamespaceID(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseNamespaceIDInsensitively parses 'input' case-insensitively into a NamespaceId +// note: this method should only be used for API response data and not user input +func ParseNamespaceIDInsensitively(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateNamespaceID checks that 'input' can be parsed as a Namespace ID +func ValidateNamespaceID(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 := ParseNamespaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Namespace ID +func (id NamespaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Namespace ID +func (id NamespaceId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + } +} + +// String returns a human-readable description of this Namespace ID +func (id NamespaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + } + return fmt.Sprintf("Namespace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_checknameavailability_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_checknameavailability_autorest.go new file mode 100644 index 000000000000..15a555f0713e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_checknameavailability_autorest.go @@ -0,0 +1,70 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c NamespacesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { + req, err := c.preparerForCheckNameAvailability(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCheckNameAvailability(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCheckNameAvailability prepares the CheckNameAvailability request. +func (c NamespacesClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ServiceBus/checkNameAvailability", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_createorupdate_autorest.go new file mode 100644 index 000000000000..dd5c74b4b2fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_createorupdate_autorest.go @@ -0,0 +1,79 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// 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 { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c NamespacesClient) CreateOrUpdate(ctx context.Context, id NamespaceId, input SBNamespace) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NamespacesClient) CreateOrUpdateThenPoll(ctx context.Context, id NamespaceId, input SBNamespace) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c NamespacesClient) preparerForCreateOrUpdate(ctx context.Context, id NamespaceId, input SBNamespace) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c NamespacesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_createorupdatenetworkruleset_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_createorupdatenetworkruleset_autorest.go new file mode 100644 index 000000000000..47ba03628477 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_createorupdatenetworkruleset_autorest.go @@ -0,0 +1,69 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateNetworkRuleSetOperationResponse struct { + HttpResponse *http.Response + Model *NetworkRuleSet +} + +// CreateOrUpdateNetworkRuleSet ... +func (c NamespacesClient) CreateOrUpdateNetworkRuleSet(ctx context.Context, id NamespaceId, input NetworkRuleSet) (result CreateOrUpdateNetworkRuleSetOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdateNetworkRuleSet(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateNetworkRuleSet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateNetworkRuleSet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdateNetworkRuleSet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateNetworkRuleSet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdateNetworkRuleSet prepares the CreateOrUpdateNetworkRuleSet request. +func (c NamespacesClient) preparerForCreateOrUpdateNetworkRuleSet(ctx context.Context, id NamespaceId, input NetworkRuleSet) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/networkRuleSets/default", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdateNetworkRuleSet handles the response to the CreateOrUpdateNetworkRuleSet request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForCreateOrUpdateNetworkRuleSet(resp *http.Response) (result CreateOrUpdateNetworkRuleSetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_delete_autorest.go new file mode 100644 index 000000000000..968dfe754f22 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_delete_autorest.go @@ -0,0 +1,78 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// 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 { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c NamespacesClient) Delete(ctx context.Context, id NamespaceId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NamespacesClient) DeleteThenPoll(ctx context.Context, id NamespaceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c NamespacesClient) preparerForDelete(ctx context.Context, id NamespaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c NamespacesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_get_autorest.go new file mode 100644 index 000000000000..403daa159d33 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_get_autorest.go @@ -0,0 +1,67 @@ +package namespaces + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBNamespace +} + +// Get ... +func (c NamespacesClient) Get(ctx context.Context, id NamespaceId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c NamespacesClient) preparerForGet(ctx context.Context, id NamespaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_getnetworkruleset_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_getnetworkruleset_autorest.go new file mode 100644 index 000000000000..929737999ebf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_getnetworkruleset_autorest.go @@ -0,0 +1,68 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNetworkRuleSetOperationResponse struct { + HttpResponse *http.Response + Model *NetworkRuleSet +} + +// GetNetworkRuleSet ... +func (c NamespacesClient) GetNetworkRuleSet(ctx context.Context, id NamespaceId) (result GetNetworkRuleSetOperationResponse, err error) { + req, err := c.preparerForGetNetworkRuleSet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetNetworkRuleSet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetNetworkRuleSet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetNetworkRuleSet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetNetworkRuleSet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetNetworkRuleSet prepares the GetNetworkRuleSet request. +func (c NamespacesClient) preparerForGetNetworkRuleSet(ctx context.Context, id NamespaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/networkRuleSets/default", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetNetworkRuleSet handles the response to the GetNetworkRuleSet request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForGetNetworkRuleSet(resp *http.Response) (result GetNetworkRuleSetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_list_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_list_autorest.go new file mode 100644 index 000000000000..462132445705 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_list_autorest.go @@ -0,0 +1,187 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]SBNamespace + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []SBNamespace +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// List ... +func (c NamespacesClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c NamespacesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SBNamespaceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c NamespacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SBNamespaceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]SBNamespace, 0) + + page, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForList prepares the List request. +func (c NamespacesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ServiceBus/namespaces", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c NamespacesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []SBNamespace `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..3fd7cc3216d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_listbyresourcegroup_autorest.go @@ -0,0 +1,187 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]SBNamespace + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []SBNamespace +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c NamespacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c NamespacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SBNamespaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c NamespacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SBNamespaceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]SBNamespace, 0) + + page, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c NamespacesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ServiceBus/namespaces", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c NamespacesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []SBNamespace `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_listnetworkrulesets_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_listnetworkrulesets_autorest.go new file mode 100644 index 000000000000..3993bb002402 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_listnetworkrulesets_autorest.go @@ -0,0 +1,186 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNetworkRuleSetsOperationResponse struct { + HttpResponse *http.Response + Model *[]NetworkRuleSet + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListNetworkRuleSetsOperationResponse, error) +} + +type ListNetworkRuleSetsCompleteResult struct { + Items []NetworkRuleSet +} + +func (r ListNetworkRuleSetsOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListNetworkRuleSetsOperationResponse) LoadMore(ctx context.Context) (resp ListNetworkRuleSetsOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListNetworkRuleSets ... +func (c NamespacesClient) ListNetworkRuleSets(ctx context.Context, id NamespaceId) (resp ListNetworkRuleSetsOperationResponse, err error) { + req, err := c.preparerForListNetworkRuleSets(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListNetworkRuleSets", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListNetworkRuleSets", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListNetworkRuleSets(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListNetworkRuleSets", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListNetworkRuleSetsComplete retrieves all of the results into a single object +func (c NamespacesClient) ListNetworkRuleSetsComplete(ctx context.Context, id NamespaceId) (ListNetworkRuleSetsCompleteResult, error) { + return c.ListNetworkRuleSetsCompleteMatchingPredicate(ctx, id, NetworkRuleSetOperationPredicate{}) +} + +// ListNetworkRuleSetsCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c NamespacesClient) ListNetworkRuleSetsCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate NetworkRuleSetOperationPredicate) (resp ListNetworkRuleSetsCompleteResult, err error) { + items := make([]NetworkRuleSet, 0) + + page, err := c.ListNetworkRuleSets(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListNetworkRuleSetsCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListNetworkRuleSets prepares the ListNetworkRuleSets request. +func (c NamespacesClient) preparerForListNetworkRuleSets(ctx context.Context, id NamespaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/networkRuleSets", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListNetworkRuleSetsWithNextLink prepares the ListNetworkRuleSets request with the given nextLink token. +func (c NamespacesClient) preparerForListNetworkRuleSetsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListNetworkRuleSets handles the response to the ListNetworkRuleSets request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForListNetworkRuleSets(resp *http.Response) (result ListNetworkRuleSetsOperationResponse, err error) { + type page struct { + Values []NetworkRuleSet `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListNetworkRuleSetsOperationResponse, err error) { + req, err := c.preparerForListNetworkRuleSetsWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListNetworkRuleSets", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListNetworkRuleSets", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListNetworkRuleSets(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListNetworkRuleSets", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_update_autorest.go new file mode 100644 index 000000000000..09f620ced474 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/method_update_autorest.go @@ -0,0 +1,68 @@ +package namespaces + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBNamespace +} + +// Update ... +func (c NamespacesClient) Update(ctx context.Context, id NamespaceId, input SBNamespaceUpdateParameters) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c NamespacesClient) preparerForUpdate(ctx context.Context, id NamespaceId, input SBNamespaceUpdateParameters) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c NamespacesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_checknameavailability.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_checknameavailability.go new file mode 100644 index 000000000000..611253e0b836 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_checknameavailability.go @@ -0,0 +1,8 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailability struct { + Name string `json:"name"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_checknameavailabilityresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_checknameavailabilityresult.go new file mode 100644 index 000000000000..9d301c5d67a8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *UnavailableReason `json:"reason,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_connectionstate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_connectionstate.go new file mode 100644 index 000000000000..022aa980debf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_connectionstate.go @@ -0,0 +1,9 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionState struct { + Description *string `json:"description,omitempty"` + Status *PrivateLinkConnectionStatus `json:"status,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_encryption.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_encryption.go new file mode 100644 index 000000000000..c33fdbc6fad2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_encryption.go @@ -0,0 +1,10 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Encryption struct { + KeySource *KeySource `json:"keySource,omitempty"` + KeyVaultProperties *[]KeyVaultProperties `json:"keyVaultProperties,omitempty"` + RequireInfrastructureEncryption *bool `json:"requireInfrastructureEncryption,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_keyvaultproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_keyvaultproperties.go new file mode 100644 index 000000000000..b0dfb9a4e063 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_keyvaultproperties.go @@ -0,0 +1,11 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultProperties struct { + Identity *UserAssignedIdentityProperties `json:"identity,omitempty"` + KeyName *string `json:"keyName,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + KeyVersion *string `json:"keyVersion,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_networkruleset.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_networkruleset.go new file mode 100644 index 000000000000..de435f2efd13 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_networkruleset.go @@ -0,0 +1,16 @@ +package namespaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkRuleSet struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkRuleSetProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_networkrulesetproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_networkrulesetproperties.go new file mode 100644 index 000000000000..b7de4f3f9e31 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_networkrulesetproperties.go @@ -0,0 +1,12 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkRuleSetProperties struct { + DefaultAction *DefaultAction `json:"defaultAction,omitempty"` + IpRules *[]NWRuleSetIpRules `json:"ipRules,omitempty"` + PublicNetworkAccess *PublicNetworkAccessFlag `json:"publicNetworkAccess,omitempty"` + TrustedServiceAccessEnabled *bool `json:"trustedServiceAccessEnabled,omitempty"` + VirtualNetworkRules *[]NWRuleSetVirtualNetworkRules `json:"virtualNetworkRules,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_nwrulesetiprules.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_nwrulesetiprules.go new file mode 100644 index 000000000000..311b4eed0bf5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_nwrulesetiprules.go @@ -0,0 +1,9 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NWRuleSetIpRules struct { + Action *NetworkRuleIPAction `json:"action,omitempty"` + IpMask *string `json:"ipMask,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_nwrulesetvirtualnetworkrules.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_nwrulesetvirtualnetworkrules.go new file mode 100644 index 000000000000..284f1c7eaba1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_nwrulesetvirtualnetworkrules.go @@ -0,0 +1,9 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NWRuleSetVirtualNetworkRules struct { + IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpoint.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpoint.go new file mode 100644 index 000000000000..3dec0387e5f1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpoint.go @@ -0,0 +1,8 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpointconnection.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpointconnection.go new file mode 100644 index 000000000000..d60671cf999e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpointconnection.go @@ -0,0 +1,16 @@ +package namespaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpointconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..e0aa15c59571 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_privateendpointconnectionproperties.go @@ -0,0 +1,10 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *ConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *EndPointProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespace.go new file mode 100644 index 000000000000..396988a40b8d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespace.go @@ -0,0 +1,21 @@ +package namespaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBNamespace struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SBNamespaceProperties `json:"properties,omitempty"` + Sku *SBSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespaceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespaceproperties.go new file mode 100644 index 000000000000..8d542149d699 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespaceproperties.go @@ -0,0 +1,47 @@ +package namespaces + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBNamespaceProperties struct { + CreatedAt *string `json:"createdAt,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + MetricId *string `json:"metricId,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` + Status *string `json:"status,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *SBNamespaceProperties) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBNamespaceProperties) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SBNamespaceProperties) GetUpdatedAtAsTime() (*time.Time, error) { + if o.UpdatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBNamespaceProperties) SetUpdatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespaceupdateparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespaceupdateparameters.go new file mode 100644 index 000000000000..777d5348737b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbnamespaceupdateparameters.go @@ -0,0 +1,19 @@ +package namespaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBNamespaceUpdateParameters struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBNamespaceProperties `json:"properties,omitempty"` + Sku *SBSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbsku.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbsku.go new file mode 100644 index 000000000000..669994013767 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_sbsku.go @@ -0,0 +1,10 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Name SkuName `json:"name"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_subnet.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_subnet.go new file mode 100644 index 000000000000..418829480082 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_subnet.go @@ -0,0 +1,8 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Id string `json:"id"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_userassignedidentityproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_userassignedidentityproperties.go new file mode 100644 index 000000000000..0685aa3ea141 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/model_userassignedidentityproperties.go @@ -0,0 +1,8 @@ +package namespaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/predicates.go new file mode 100644 index 000000000000..b944fa7149b5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/predicates.go @@ -0,0 +1,52 @@ +package namespaces + +type NetworkRuleSetOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NetworkRuleSetOperationPredicate) Matches(input NetworkRuleSet) 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 +} + +type SBNamespaceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SBNamespaceOperationPredicate) Matches(input SBNamespace) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + 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/servicebus/2021-06-01-preview/namespaces/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/version.go new file mode 100644 index 000000000000..90d6cc833546 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces/version.go @@ -0,0 +1,12 @@ +package namespaces + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/namespaces/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/README.md new file mode 100644 index 000000000000..d0b6b63a6237 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/README.md @@ -0,0 +1,127 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule` Documentation + +The `namespacesauthorizationrule` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/namespacesauthorizationrule" +``` + + +### Client Initialization + +```go +client := namespacesauthorizationrule.NewNamespacesAuthorizationRuleClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NamespacesAuthorizationRuleClient.NamespacesCreateOrUpdateAuthorizationRule` + +```go +ctx := context.TODO() +id := namespacesauthorizationrule.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +payload := namespacesauthorizationrule.SBAuthorizationRule{ + // ... +} + + +read, err := client.NamespacesCreateOrUpdateAuthorizationRule(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesAuthorizationRuleClient.NamespacesDeleteAuthorizationRule` + +```go +ctx := context.TODO() +id := namespacesauthorizationrule.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +read, err := client.NamespacesDeleteAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesAuthorizationRuleClient.NamespacesGetAuthorizationRule` + +```go +ctx := context.TODO() +id := namespacesauthorizationrule.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +read, err := client.NamespacesGetAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesAuthorizationRuleClient.NamespacesListAuthorizationRules` + +```go +ctx := context.TODO() +id := namespacesauthorizationrule.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +// alternatively `client.NamespacesListAuthorizationRules(ctx, id)` can be used to do batched pagination +items, err := client.NamespacesListAuthorizationRulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NamespacesAuthorizationRuleClient.NamespacesListKeys` + +```go +ctx := context.TODO() +id := namespacesauthorizationrule.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +read, err := client.NamespacesListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NamespacesAuthorizationRuleClient.NamespacesRegenerateKeys` + +```go +ctx := context.TODO() +id := namespacesauthorizationrule.NewAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "authorizationRuleValue") + +payload := namespacesauthorizationrule.RegenerateAccessKeyParameters{ + // ... +} + + +read, err := client.NamespacesRegenerateKeys(ctx, id, payload) +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/servicebus/2021-06-01-preview/namespacesauthorizationrule/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/client.go new file mode 100644 index 000000000000..e4aacfdfcd63 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/client.go @@ -0,0 +1,18 @@ +package namespacesauthorizationrule + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesAuthorizationRuleClient struct { + Client autorest.Client + baseUri string +} + +func NewNamespacesAuthorizationRuleClientWithBaseURI(endpoint string) NamespacesAuthorizationRuleClient { + return NamespacesAuthorizationRuleClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/constants.go new file mode 100644 index 000000000000..9e833425f0bd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/constants.go @@ -0,0 +1,65 @@ +package namespacesauthorizationrule + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessRights string + +const ( + AccessRightsListen AccessRights = "Listen" + AccessRightsManage AccessRights = "Manage" + AccessRightsSend AccessRights = "Send" +) + +func PossibleValuesForAccessRights() []string { + return []string{ + string(AccessRightsListen), + string(AccessRightsManage), + string(AccessRightsSend), + } +} + +func parseAccessRights(input string) (*AccessRights, error) { + vals := map[string]AccessRights{ + "listen": AccessRightsListen, + "manage": AccessRightsManage, + "send": AccessRightsSend, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessRights(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimaryKey KeyType = "PrimaryKey" + KeyTypeSecondaryKey KeyType = "SecondaryKey" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimaryKey), + string(KeyTypeSecondaryKey), + } +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primarykey": KeyTypePrimaryKey, + "secondarykey": KeyTypeSecondaryKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/id_authorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/id_authorizationrule.go new file mode 100644 index 000000000000..efd5e0b02d9d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/id_authorizationrule.go @@ -0,0 +1,137 @@ +package namespacesauthorizationrule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = AuthorizationRuleId{} + +// AuthorizationRuleId is a struct representing the Resource ID for a Authorization Rule +type AuthorizationRuleId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + AuthorizationRuleName string +} + +// NewAuthorizationRuleID returns a new AuthorizationRuleId struct +func NewAuthorizationRuleID(subscriptionId string, resourceGroupName string, namespaceName string, authorizationRuleName string) AuthorizationRuleId { + return AuthorizationRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + AuthorizationRuleName: authorizationRuleName, + } +} + +// ParseAuthorizationRuleID parses 'input' into a AuthorizationRuleId +func ParseAuthorizationRuleID(input string) (*AuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(AuthorizationRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseAuthorizationRuleIDInsensitively parses 'input' case-insensitively into a AuthorizationRuleId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationRuleIDInsensitively(input string) (*AuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(AuthorizationRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateAuthorizationRuleID checks that 'input' can be parsed as a Authorization Rule ID +func ValidateAuthorizationRuleID(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 := ParseAuthorizationRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization Rule ID +func (id AuthorizationRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/authorizationRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.AuthorizationRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization Rule ID +func (id AuthorizationRuleId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticAuthorizationRules", "authorizationRules", "authorizationRules"), + resourceids.UserSpecifiedSegment("authorizationRuleName", "authorizationRuleValue"), + } +} + +// String returns a human-readable description of this Authorization Rule ID +func (id AuthorizationRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Authorization Rule Name: %q", id.AuthorizationRuleName), + } + return fmt.Sprintf("Authorization Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/id_namespace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/id_namespace.go new file mode 100644 index 000000000000..f0bc18d1dbb4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/id_namespace.go @@ -0,0 +1,124 @@ +package namespacesauthorizationrule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = NamespaceId{} + +// NamespaceId is a struct representing the Resource ID for a Namespace +type NamespaceId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string +} + +// NewNamespaceID returns a new NamespaceId struct +func NewNamespaceID(subscriptionId string, resourceGroupName string, namespaceName string) NamespaceId { + return NamespaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + } +} + +// ParseNamespaceID parses 'input' into a NamespaceId +func ParseNamespaceID(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseNamespaceIDInsensitively parses 'input' case-insensitively into a NamespaceId +// note: this method should only be used for API response data and not user input +func ParseNamespaceIDInsensitively(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateNamespaceID checks that 'input' can be parsed as a Namespace ID +func ValidateNamespaceID(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 := ParseNamespaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Namespace ID +func (id NamespaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Namespace ID +func (id NamespaceId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + } +} + +// String returns a human-readable description of this Namespace ID +func (id NamespaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + } + return fmt.Sprintf("Namespace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacescreateorupdateauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacescreateorupdateauthorizationrule_autorest.go new file mode 100644 index 000000000000..da678cb00879 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacescreateorupdateauthorizationrule_autorest.go @@ -0,0 +1,68 @@ +package namespacesauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesCreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// NamespacesCreateOrUpdateAuthorizationRule ... +func (c NamespacesAuthorizationRuleClient) NamespacesCreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input SBAuthorizationRule) (result NamespacesCreateOrUpdateAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForNamespacesCreateOrUpdateAuthorizationRule(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesCreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesCreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForNamespacesCreateOrUpdateAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesCreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForNamespacesCreateOrUpdateAuthorizationRule prepares the NamespacesCreateOrUpdateAuthorizationRule request. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesCreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input SBAuthorizationRule) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForNamespacesCreateOrUpdateAuthorizationRule handles the response to the NamespacesCreateOrUpdateAuthorizationRule request. The method always +// closes the http.Response Body. +func (c NamespacesAuthorizationRuleClient) responderForNamespacesCreateOrUpdateAuthorizationRule(resp *http.Response) (result NamespacesCreateOrUpdateAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesdeleteauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesdeleteauthorizationrule_autorest.go new file mode 100644 index 000000000000..12b549e99e4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesdeleteauthorizationrule_autorest.go @@ -0,0 +1,65 @@ +package namespacesauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesDeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response +} + +// NamespacesDeleteAuthorizationRule ... +func (c NamespacesAuthorizationRuleClient) NamespacesDeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result NamespacesDeleteAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForNamespacesDeleteAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesDeleteAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesDeleteAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForNamespacesDeleteAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesDeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForNamespacesDeleteAuthorizationRule prepares the NamespacesDeleteAuthorizationRule request. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesDeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForNamespacesDeleteAuthorizationRule handles the response to the NamespacesDeleteAuthorizationRule request. The method always +// closes the http.Response Body. +func (c NamespacesAuthorizationRuleClient) responderForNamespacesDeleteAuthorizationRule(resp *http.Response) (result NamespacesDeleteAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesgetauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesgetauthorizationrule_autorest.go new file mode 100644 index 000000000000..91f182aa4553 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesgetauthorizationrule_autorest.go @@ -0,0 +1,67 @@ +package namespacesauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesGetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// NamespacesGetAuthorizationRule ... +func (c NamespacesAuthorizationRuleClient) NamespacesGetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result NamespacesGetAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForNamespacesGetAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesGetAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesGetAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForNamespacesGetAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesGetAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForNamespacesGetAuthorizationRule prepares the NamespacesGetAuthorizationRule request. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesGetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForNamespacesGetAuthorizationRule handles the response to the NamespacesGetAuthorizationRule request. The method always +// closes the http.Response Body. +func (c NamespacesAuthorizationRuleClient) responderForNamespacesGetAuthorizationRule(resp *http.Response) (result NamespacesGetAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespaceslistauthorizationrules_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespaceslistauthorizationrules_autorest.go new file mode 100644 index 000000000000..d1b97182d315 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespaceslistauthorizationrules_autorest.go @@ -0,0 +1,186 @@ +package namespacesauthorizationrule + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + Model *[]SBAuthorizationRule + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (NamespacesListAuthorizationRulesOperationResponse, error) +} + +type NamespacesListAuthorizationRulesCompleteResult struct { + Items []SBAuthorizationRule +} + +func (r NamespacesListAuthorizationRulesOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r NamespacesListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp NamespacesListAuthorizationRulesOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// NamespacesListAuthorizationRules ... +func (c NamespacesAuthorizationRuleClient) NamespacesListAuthorizationRules(ctx context.Context, id NamespaceId) (resp NamespacesListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForNamespacesListAuthorizationRules(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListAuthorizationRules", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListAuthorizationRules", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForNamespacesListAuthorizationRules(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListAuthorizationRules", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// NamespacesListAuthorizationRulesComplete retrieves all of the results into a single object +func (c NamespacesAuthorizationRuleClient) NamespacesListAuthorizationRulesComplete(ctx context.Context, id NamespaceId) (NamespacesListAuthorizationRulesCompleteResult, error) { + return c.NamespacesListAuthorizationRulesCompleteMatchingPredicate(ctx, id, SBAuthorizationRuleOperationPredicate{}) +} + +// NamespacesListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c NamespacesAuthorizationRuleClient) NamespacesListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate SBAuthorizationRuleOperationPredicate) (resp NamespacesListAuthorizationRulesCompleteResult, err error) { + items := make([]SBAuthorizationRule, 0) + + page, err := c.NamespacesListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := NamespacesListAuthorizationRulesCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForNamespacesListAuthorizationRules prepares the NamespacesListAuthorizationRules request. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesListAuthorizationRules(ctx context.Context, id NamespaceId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForNamespacesListAuthorizationRulesWithNextLink prepares the NamespacesListAuthorizationRules request with the given nextLink token. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForNamespacesListAuthorizationRules handles the response to the NamespacesListAuthorizationRules request. The method always +// closes the http.Response Body. +func (c NamespacesAuthorizationRuleClient) responderForNamespacesListAuthorizationRules(resp *http.Response) (result NamespacesListAuthorizationRulesOperationResponse, err error) { + type page struct { + Values []SBAuthorizationRule `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result NamespacesListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForNamespacesListAuthorizationRulesWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListAuthorizationRules", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListAuthorizationRules", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForNamespacesListAuthorizationRules(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListAuthorizationRules", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespaceslistkeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespaceslistkeys_autorest.go new file mode 100644 index 000000000000..29d9575e85fa --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespaceslistkeys_autorest.go @@ -0,0 +1,68 @@ +package namespacesauthorizationrule + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesListKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// NamespacesListKeys ... +func (c NamespacesAuthorizationRuleClient) NamespacesListKeys(ctx context.Context, id AuthorizationRuleId) (result NamespacesListKeysOperationResponse, err error) { + req, err := c.preparerForNamespacesListKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForNamespacesListKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesListKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForNamespacesListKeys prepares the NamespacesListKeys request. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesListKeys(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForNamespacesListKeys handles the response to the NamespacesListKeys request. The method always +// closes the http.Response Body. +func (c NamespacesAuthorizationRuleClient) responderForNamespacesListKeys(resp *http.Response) (result NamespacesListKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesregeneratekeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesregeneratekeys_autorest.go new file mode 100644 index 000000000000..93d0753f72bb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/method_namespacesregeneratekeys_autorest.go @@ -0,0 +1,69 @@ +package namespacesauthorizationrule + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacesRegenerateKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// NamespacesRegenerateKeys ... +func (c NamespacesAuthorizationRuleClient) NamespacesRegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (result NamespacesRegenerateKeysOperationResponse, err error) { + req, err := c.preparerForNamespacesRegenerateKeys(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesRegenerateKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesRegenerateKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForNamespacesRegenerateKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "namespacesauthorizationrule.NamespacesAuthorizationRuleClient", "NamespacesRegenerateKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForNamespacesRegenerateKeys prepares the NamespacesRegenerateKeys request. +func (c NamespacesAuthorizationRuleClient) preparerForNamespacesRegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForNamespacesRegenerateKeys handles the response to the NamespacesRegenerateKeys request. The method always +// closes the http.Response Body. +func (c NamespacesAuthorizationRuleClient) responderForNamespacesRegenerateKeys(resp *http.Response) (result NamespacesRegenerateKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_accesskeys.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_accesskeys.go new file mode 100644 index 000000000000..7c9ec1504776 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_accesskeys.go @@ -0,0 +1,14 @@ +package namespacesauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessKeys struct { + AliasPrimaryConnectionString *string `json:"aliasPrimaryConnectionString,omitempty"` + AliasSecondaryConnectionString *string `json:"aliasSecondaryConnectionString,omitempty"` + KeyName *string `json:"keyName,omitempty"` + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_regenerateaccesskeyparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_regenerateaccesskeyparameters.go new file mode 100644 index 000000000000..ec4bc454a57a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_regenerateaccesskeyparameters.go @@ -0,0 +1,9 @@ +package namespacesauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateAccessKeyParameters struct { + Key *string `json:"key,omitempty"` + KeyType KeyType `json:"keyType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_sbauthorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_sbauthorizationrule.go new file mode 100644 index 000000000000..dc46cb0f367e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_sbauthorizationrule.go @@ -0,0 +1,16 @@ +package namespacesauthorizationrule + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBAuthorizationRuleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_sbauthorizationruleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_sbauthorizationruleproperties.go new file mode 100644 index 000000000000..ef02ce304561 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/model_sbauthorizationruleproperties.go @@ -0,0 +1,8 @@ +package namespacesauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRuleProperties struct { + Rights []AccessRights `json:"rights"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/predicates.go new file mode 100644 index 000000000000..a9141050f2a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/predicates.go @@ -0,0 +1,24 @@ +package namespacesauthorizationrule + +type SBAuthorizationRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBAuthorizationRuleOperationPredicate) Matches(input SBAuthorizationRule) 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/servicebus/2021-06-01-preview/namespacesauthorizationrule/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/version.go new file mode 100644 index 000000000000..885c529038e1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule/version.go @@ -0,0 +1,12 @@ +package namespacesauthorizationrule + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/namespacesauthorizationrule/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/README.md new file mode 100644 index 000000000000..0e4e9288f7e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues` Documentation + +The `queues` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/queues" +``` + + +### Client Initialization + +```go +client := queues.NewQueuesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueuesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := queues.NewQueueID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue") + +payload := queues.SBQueue{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueuesClient.Delete` + +```go +ctx := context.TODO() +id := queues.NewQueueID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueuesClient.Get` + +```go +ctx := context.TODO() +id := queues.NewQueueID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue") + +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: `QueuesClient.ListByNamespace` + +```go +ctx := context.TODO() +id := queues.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +// alternatively `client.ListByNamespace(ctx, id, queues.DefaultListByNamespaceOperationOptions())` can be used to do batched pagination +items, err := client.ListByNamespaceComplete(ctx, id, queues.DefaultListByNamespaceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/client.go new file mode 100644 index 000000000000..9f002f842f12 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/client.go @@ -0,0 +1,18 @@ +package queues + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesClient struct { + Client autorest.Client + baseUri string +} + +func NewQueuesClientWithBaseURI(endpoint string) QueuesClient { + return QueuesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/constants.go new file mode 100644 index 000000000000..a7102ca2f172 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/constants.go @@ -0,0 +1,55 @@ +package queues + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EntityStatus string + +const ( + EntityStatusActive EntityStatus = "Active" + EntityStatusCreating EntityStatus = "Creating" + EntityStatusDeleting EntityStatus = "Deleting" + EntityStatusDisabled EntityStatus = "Disabled" + EntityStatusReceiveDisabled EntityStatus = "ReceiveDisabled" + EntityStatusRenaming EntityStatus = "Renaming" + EntityStatusRestoring EntityStatus = "Restoring" + EntityStatusSendDisabled EntityStatus = "SendDisabled" + EntityStatusUnknown EntityStatus = "Unknown" +) + +func PossibleValuesForEntityStatus() []string { + return []string{ + string(EntityStatusActive), + string(EntityStatusCreating), + string(EntityStatusDeleting), + string(EntityStatusDisabled), + string(EntityStatusReceiveDisabled), + string(EntityStatusRenaming), + string(EntityStatusRestoring), + string(EntityStatusSendDisabled), + string(EntityStatusUnknown), + } +} + +func parseEntityStatus(input string) (*EntityStatus, error) { + vals := map[string]EntityStatus{ + "active": EntityStatusActive, + "creating": EntityStatusCreating, + "deleting": EntityStatusDeleting, + "disabled": EntityStatusDisabled, + "receivedisabled": EntityStatusReceiveDisabled, + "renaming": EntityStatusRenaming, + "restoring": EntityStatusRestoring, + "senddisabled": EntityStatusSendDisabled, + "unknown": EntityStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EntityStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/id_namespace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/id_namespace.go new file mode 100644 index 000000000000..03c340b86d41 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/id_namespace.go @@ -0,0 +1,124 @@ +package queues + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = NamespaceId{} + +// NamespaceId is a struct representing the Resource ID for a Namespace +type NamespaceId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string +} + +// NewNamespaceID returns a new NamespaceId struct +func NewNamespaceID(subscriptionId string, resourceGroupName string, namespaceName string) NamespaceId { + return NamespaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + } +} + +// ParseNamespaceID parses 'input' into a NamespaceId +func ParseNamespaceID(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseNamespaceIDInsensitively parses 'input' case-insensitively into a NamespaceId +// note: this method should only be used for API response data and not user input +func ParseNamespaceIDInsensitively(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateNamespaceID checks that 'input' can be parsed as a Namespace ID +func ValidateNamespaceID(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 := ParseNamespaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Namespace ID +func (id NamespaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Namespace ID +func (id NamespaceId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + } +} + +// String returns a human-readable description of this Namespace ID +func (id NamespaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + } + return fmt.Sprintf("Namespace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/id_queue.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/id_queue.go new file mode 100644 index 000000000000..db105521f86f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/id_queue.go @@ -0,0 +1,137 @@ +package queues + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = QueueId{} + +// QueueId is a struct representing the Resource ID for a Queue +type QueueId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + QueueName string +} + +// NewQueueID returns a new QueueId struct +func NewQueueID(subscriptionId string, resourceGroupName string, namespaceName string, queueName string) QueueId { + return QueueId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + QueueName: queueName, + } +} + +// ParseQueueID parses 'input' into a QueueId +func ParseQueueID(input string) (*QueueId, error) { + parser := resourceids.NewParserFromResourceIdType(QueueId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueueId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.QueueName, ok = parsed.Parsed["queueName"]; !ok { + return nil, fmt.Errorf("the segment 'queueName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseQueueIDInsensitively parses 'input' case-insensitively into a QueueId +// note: this method should only be used for API response data and not user input +func ParseQueueIDInsensitively(input string) (*QueueId, error) { + parser := resourceids.NewParserFromResourceIdType(QueueId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueueId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.QueueName, ok = parsed.Parsed["queueName"]; !ok { + return nil, fmt.Errorf("the segment 'queueName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateQueueID checks that 'input' can be parsed as a Queue ID +func ValidateQueueID(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 := ParseQueueID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Queue ID +func (id QueueId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/queues/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.QueueName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Queue ID +func (id QueueId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticQueues", "queues", "queues"), + resourceids.UserSpecifiedSegment("queueName", "queueValue"), + } +} + +// String returns a human-readable description of this Queue ID +func (id QueueId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Queue Name: %q", id.QueueName), + } + return fmt.Sprintf("Queue (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_createorupdate_autorest.go new file mode 100644 index 000000000000..7503be89cbd9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_createorupdate_autorest.go @@ -0,0 +1,68 @@ +package queues + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBQueue +} + +// CreateOrUpdate ... +func (c QueuesClient) CreateOrUpdate(ctx context.Context, id QueueId, input SBQueue) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c QueuesClient) preparerForCreateOrUpdate(ctx context.Context, id QueueId, input SBQueue) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c QueuesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_delete_autorest.go new file mode 100644 index 000000000000..ba7742cf4101 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_delete_autorest.go @@ -0,0 +1,65 @@ +package queues + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 +} + +// Delete ... +func (c QueuesClient) Delete(ctx context.Context, id QueueId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c QueuesClient) preparerForDelete(ctx context.Context, id QueueId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c QueuesClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_get_autorest.go new file mode 100644 index 000000000000..5f4b20ea427e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_get_autorest.go @@ -0,0 +1,67 @@ +package queues + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBQueue +} + +// Get ... +func (c QueuesClient) Get(ctx context.Context, id QueueId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c QueuesClient) preparerForGet(ctx context.Context, id QueueId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c QueuesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_listbynamespace_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_listbynamespace_autorest.go new file mode 100644 index 000000000000..53be58663414 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/method_listbynamespace_autorest.go @@ -0,0 +1,220 @@ +package queues + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByNamespaceOperationResponse struct { + HttpResponse *http.Response + Model *[]SBQueue + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByNamespaceOperationResponse, error) +} + +type ListByNamespaceCompleteResult struct { + Items []SBQueue +} + +func (r ListByNamespaceOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByNamespaceOperationResponse) LoadMore(ctx context.Context) (resp ListByNamespaceOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByNamespaceOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByNamespaceOperationOptions() ListByNamespaceOperationOptions { + return ListByNamespaceOperationOptions{} +} + +func (o ListByNamespaceOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByNamespaceOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Skip != nil { + out["$skip"] = *o.Skip + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListByNamespace ... +func (c QueuesClient) ListByNamespace(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions) (resp ListByNamespaceOperationResponse, err error) { + req, err := c.preparerForListByNamespace(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "ListByNamespace", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "ListByNamespace", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByNamespace(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "ListByNamespace", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByNamespaceComplete retrieves all of the results into a single object +func (c QueuesClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions) (ListByNamespaceCompleteResult, error) { + return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, options, SBQueueOperationPredicate{}) +} + +// ListByNamespaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c QueuesClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions, predicate SBQueueOperationPredicate) (resp ListByNamespaceCompleteResult, err error) { + items := make([]SBQueue, 0) + + page, err := c.ListByNamespace(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByNamespaceCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByNamespace prepares the ListByNamespace request. +func (c QueuesClient) preparerForListByNamespace(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/queues", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByNamespaceWithNextLink prepares the ListByNamespace request with the given nextLink token. +func (c QueuesClient) preparerForListByNamespaceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByNamespace handles the response to the ListByNamespace request. The method always +// closes the http.Response Body. +func (c QueuesClient) responderForListByNamespace(resp *http.Response) (result ListByNamespaceOperationResponse, err error) { + type page struct { + Values []SBQueue `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByNamespaceOperationResponse, err error) { + req, err := c.preparerForListByNamespaceWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "ListByNamespace", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "ListByNamespace", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByNamespace(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queues.QueuesClient", "ListByNamespace", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_messagecountdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_messagecountdetails.go new file mode 100644 index 000000000000..9bd16f13f687 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_messagecountdetails.go @@ -0,0 +1,12 @@ +package queues + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageCountDetails struct { + ActiveMessageCount *int64 `json:"activeMessageCount,omitempty"` + DeadLetterMessageCount *int64 `json:"deadLetterMessageCount,omitempty"` + ScheduledMessageCount *int64 `json:"scheduledMessageCount,omitempty"` + TransferDeadLetterMessageCount *int64 `json:"transferDeadLetterMessageCount,omitempty"` + TransferMessageCount *int64 `json:"transferMessageCount,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_sbqueue.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_sbqueue.go new file mode 100644 index 000000000000..9a8f302b7e8f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_sbqueue.go @@ -0,0 +1,16 @@ +package queues + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBQueue struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBQueueProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_sbqueueproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_sbqueueproperties.go new file mode 100644 index 000000000000..ed1ff71a7fc8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/model_sbqueueproperties.go @@ -0,0 +1,71 @@ +package queues + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBQueueProperties struct { + AccessedAt *string `json:"accessedAt,omitempty"` + AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` + CountDetails *MessageCountDetails `json:"countDetails,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + DeadLetteringOnMessageExpiration *bool `json:"deadLetteringOnMessageExpiration,omitempty"` + DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` + DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` + EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` + EnableExpress *bool `json:"enableExpress,omitempty"` + EnablePartitioning *bool `json:"enablePartitioning,omitempty"` + ForwardDeadLetteredMessagesTo *string `json:"forwardDeadLetteredMessagesTo,omitempty"` + ForwardTo *string `json:"forwardTo,omitempty"` + LockDuration *string `json:"lockDuration,omitempty"` + MaxDeliveryCount *int64 `json:"maxDeliveryCount,omitempty"` + MaxMessageSizeInKilobytes *int64 `json:"maxMessageSizeInKilobytes,omitempty"` + MaxSizeInMegabytes *int64 `json:"maxSizeInMegabytes,omitempty"` + MessageCount *int64 `json:"messageCount,omitempty"` + RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"` + RequiresSession *bool `json:"requiresSession,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + Status *EntityStatus `json:"status,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` +} + +func (o *SBQueueProperties) GetAccessedAtAsTime() (*time.Time, error) { + if o.AccessedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AccessedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBQueueProperties) SetAccessedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AccessedAt = &formatted +} + +func (o *SBQueueProperties) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBQueueProperties) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SBQueueProperties) GetUpdatedAtAsTime() (*time.Time, error) { + if o.UpdatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBQueueProperties) SetUpdatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/predicates.go new file mode 100644 index 000000000000..0a1854098288 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/predicates.go @@ -0,0 +1,24 @@ +package queues + +type SBQueueOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBQueueOperationPredicate) Matches(input SBQueue) 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/servicebus/2021-06-01-preview/queues/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/version.go new file mode 100644 index 000000000000..49e5f391bc33 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues/version.go @@ -0,0 +1,12 @@ +package queues + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/queues/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/README.md new file mode 100644 index 000000000000..5f09a842c30d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/README.md @@ -0,0 +1,127 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule` Documentation + +The `queuesauthorizationrule` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/queuesauthorizationrule" +``` + + +### Client Initialization + +```go +client := queuesauthorizationrule.NewQueuesAuthorizationRuleClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QueuesAuthorizationRuleClient.QueuesCreateOrUpdateAuthorizationRule` + +```go +ctx := context.TODO() +id := queuesauthorizationrule.NewQueueAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue", "authorizationRuleValue") + +payload := queuesauthorizationrule.SBAuthorizationRule{ + // ... +} + + +read, err := client.QueuesCreateOrUpdateAuthorizationRule(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueuesAuthorizationRuleClient.QueuesDeleteAuthorizationRule` + +```go +ctx := context.TODO() +id := queuesauthorizationrule.NewQueueAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue", "authorizationRuleValue") + +read, err := client.QueuesDeleteAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueuesAuthorizationRuleClient.QueuesGetAuthorizationRule` + +```go +ctx := context.TODO() +id := queuesauthorizationrule.NewQueueAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue", "authorizationRuleValue") + +read, err := client.QueuesGetAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueuesAuthorizationRuleClient.QueuesListAuthorizationRules` + +```go +ctx := context.TODO() +id := queuesauthorizationrule.NewQueueID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue") + +// alternatively `client.QueuesListAuthorizationRules(ctx, id)` can be used to do batched pagination +items, err := client.QueuesListAuthorizationRulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `QueuesAuthorizationRuleClient.QueuesListKeys` + +```go +ctx := context.TODO() +id := queuesauthorizationrule.NewQueueAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue", "authorizationRuleValue") + +read, err := client.QueuesListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `QueuesAuthorizationRuleClient.QueuesRegenerateKeys` + +```go +ctx := context.TODO() +id := queuesauthorizationrule.NewQueueAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "queueValue", "authorizationRuleValue") + +payload := queuesauthorizationrule.RegenerateAccessKeyParameters{ + // ... +} + + +read, err := client.QueuesRegenerateKeys(ctx, id, payload) +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/servicebus/2021-06-01-preview/queuesauthorizationrule/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/client.go new file mode 100644 index 000000000000..2f12c809683b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/client.go @@ -0,0 +1,18 @@ +package queuesauthorizationrule + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesAuthorizationRuleClient struct { + Client autorest.Client + baseUri string +} + +func NewQueuesAuthorizationRuleClientWithBaseURI(endpoint string) QueuesAuthorizationRuleClient { + return QueuesAuthorizationRuleClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/constants.go new file mode 100644 index 000000000000..376d0d9c7719 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/constants.go @@ -0,0 +1,65 @@ +package queuesauthorizationrule + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessRights string + +const ( + AccessRightsListen AccessRights = "Listen" + AccessRightsManage AccessRights = "Manage" + AccessRightsSend AccessRights = "Send" +) + +func PossibleValuesForAccessRights() []string { + return []string{ + string(AccessRightsListen), + string(AccessRightsManage), + string(AccessRightsSend), + } +} + +func parseAccessRights(input string) (*AccessRights, error) { + vals := map[string]AccessRights{ + "listen": AccessRightsListen, + "manage": AccessRightsManage, + "send": AccessRightsSend, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessRights(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimaryKey KeyType = "PrimaryKey" + KeyTypeSecondaryKey KeyType = "SecondaryKey" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimaryKey), + string(KeyTypeSecondaryKey), + } +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primarykey": KeyTypePrimaryKey, + "secondarykey": KeyTypeSecondaryKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/id_queue.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/id_queue.go new file mode 100644 index 000000000000..349e72ef938a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/id_queue.go @@ -0,0 +1,137 @@ +package queuesauthorizationrule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = QueueId{} + +// QueueId is a struct representing the Resource ID for a Queue +type QueueId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + QueueName string +} + +// NewQueueID returns a new QueueId struct +func NewQueueID(subscriptionId string, resourceGroupName string, namespaceName string, queueName string) QueueId { + return QueueId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + QueueName: queueName, + } +} + +// ParseQueueID parses 'input' into a QueueId +func ParseQueueID(input string) (*QueueId, error) { + parser := resourceids.NewParserFromResourceIdType(QueueId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueueId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.QueueName, ok = parsed.Parsed["queueName"]; !ok { + return nil, fmt.Errorf("the segment 'queueName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseQueueIDInsensitively parses 'input' case-insensitively into a QueueId +// note: this method should only be used for API response data and not user input +func ParseQueueIDInsensitively(input string) (*QueueId, error) { + parser := resourceids.NewParserFromResourceIdType(QueueId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueueId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.QueueName, ok = parsed.Parsed["queueName"]; !ok { + return nil, fmt.Errorf("the segment 'queueName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateQueueID checks that 'input' can be parsed as a Queue ID +func ValidateQueueID(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 := ParseQueueID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Queue ID +func (id QueueId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/queues/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.QueueName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Queue ID +func (id QueueId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticQueues", "queues", "queues"), + resourceids.UserSpecifiedSegment("queueName", "queueValue"), + } +} + +// String returns a human-readable description of this Queue ID +func (id QueueId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Queue Name: %q", id.QueueName), + } + return fmt.Sprintf("Queue (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/id_queueauthorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/id_queueauthorizationrule.go new file mode 100644 index 000000000000..34fc91ea4a63 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/id_queueauthorizationrule.go @@ -0,0 +1,150 @@ +package queuesauthorizationrule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = QueueAuthorizationRuleId{} + +// QueueAuthorizationRuleId is a struct representing the Resource ID for a Queue Authorization Rule +type QueueAuthorizationRuleId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + QueueName string + AuthorizationRuleName string +} + +// NewQueueAuthorizationRuleID returns a new QueueAuthorizationRuleId struct +func NewQueueAuthorizationRuleID(subscriptionId string, resourceGroupName string, namespaceName string, queueName string, authorizationRuleName string) QueueAuthorizationRuleId { + return QueueAuthorizationRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + QueueName: queueName, + AuthorizationRuleName: authorizationRuleName, + } +} + +// ParseQueueAuthorizationRuleID parses 'input' into a QueueAuthorizationRuleId +func ParseQueueAuthorizationRuleID(input string) (*QueueAuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(QueueAuthorizationRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueueAuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.QueueName, ok = parsed.Parsed["queueName"]; !ok { + return nil, fmt.Errorf("the segment 'queueName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseQueueAuthorizationRuleIDInsensitively parses 'input' case-insensitively into a QueueAuthorizationRuleId +// note: this method should only be used for API response data and not user input +func ParseQueueAuthorizationRuleIDInsensitively(input string) (*QueueAuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(QueueAuthorizationRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := QueueAuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.QueueName, ok = parsed.Parsed["queueName"]; !ok { + return nil, fmt.Errorf("the segment 'queueName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateQueueAuthorizationRuleID checks that 'input' can be parsed as a Queue Authorization Rule ID +func ValidateQueueAuthorizationRuleID(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 := ParseQueueAuthorizationRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Queue Authorization Rule ID +func (id QueueAuthorizationRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/queues/%s/authorizationRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.QueueName, id.AuthorizationRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Queue Authorization Rule ID +func (id QueueAuthorizationRuleId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticQueues", "queues", "queues"), + resourceids.UserSpecifiedSegment("queueName", "queueValue"), + resourceids.StaticSegment("staticAuthorizationRules", "authorizationRules", "authorizationRules"), + resourceids.UserSpecifiedSegment("authorizationRuleName", "authorizationRuleValue"), + } +} + +// String returns a human-readable description of this Queue Authorization Rule ID +func (id QueueAuthorizationRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Queue Name: %q", id.QueueName), + fmt.Sprintf("Authorization Rule Name: %q", id.AuthorizationRuleName), + } + return fmt.Sprintf("Queue Authorization Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuescreateorupdateauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuescreateorupdateauthorizationrule_autorest.go new file mode 100644 index 000000000000..a76a6e5ba0bf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuescreateorupdateauthorizationrule_autorest.go @@ -0,0 +1,68 @@ +package queuesauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesCreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// QueuesCreateOrUpdateAuthorizationRule ... +func (c QueuesAuthorizationRuleClient) QueuesCreateOrUpdateAuthorizationRule(ctx context.Context, id QueueAuthorizationRuleId, input SBAuthorizationRule) (result QueuesCreateOrUpdateAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForQueuesCreateOrUpdateAuthorizationRule(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesCreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesCreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueuesCreateOrUpdateAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesCreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueuesCreateOrUpdateAuthorizationRule prepares the QueuesCreateOrUpdateAuthorizationRule request. +func (c QueuesAuthorizationRuleClient) preparerForQueuesCreateOrUpdateAuthorizationRule(ctx context.Context, id QueueAuthorizationRuleId, input SBAuthorizationRule) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueuesCreateOrUpdateAuthorizationRule handles the response to the QueuesCreateOrUpdateAuthorizationRule request. The method always +// closes the http.Response Body. +func (c QueuesAuthorizationRuleClient) responderForQueuesCreateOrUpdateAuthorizationRule(resp *http.Response) (result QueuesCreateOrUpdateAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesdeleteauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesdeleteauthorizationrule_autorest.go new file mode 100644 index 000000000000..46cbf6b6d0ce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesdeleteauthorizationrule_autorest.go @@ -0,0 +1,65 @@ +package queuesauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesDeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response +} + +// QueuesDeleteAuthorizationRule ... +func (c QueuesAuthorizationRuleClient) QueuesDeleteAuthorizationRule(ctx context.Context, id QueueAuthorizationRuleId) (result QueuesDeleteAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForQueuesDeleteAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesDeleteAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesDeleteAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueuesDeleteAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesDeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueuesDeleteAuthorizationRule prepares the QueuesDeleteAuthorizationRule request. +func (c QueuesAuthorizationRuleClient) preparerForQueuesDeleteAuthorizationRule(ctx context.Context, id QueueAuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueuesDeleteAuthorizationRule handles the response to the QueuesDeleteAuthorizationRule request. The method always +// closes the http.Response Body. +func (c QueuesAuthorizationRuleClient) responderForQueuesDeleteAuthorizationRule(resp *http.Response) (result QueuesDeleteAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesgetauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesgetauthorizationrule_autorest.go new file mode 100644 index 000000000000..a5af12fc8df3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesgetauthorizationrule_autorest.go @@ -0,0 +1,67 @@ +package queuesauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesGetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// QueuesGetAuthorizationRule ... +func (c QueuesAuthorizationRuleClient) QueuesGetAuthorizationRule(ctx context.Context, id QueueAuthorizationRuleId) (result QueuesGetAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForQueuesGetAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesGetAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesGetAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueuesGetAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesGetAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueuesGetAuthorizationRule prepares the QueuesGetAuthorizationRule request. +func (c QueuesAuthorizationRuleClient) preparerForQueuesGetAuthorizationRule(ctx context.Context, id QueueAuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueuesGetAuthorizationRule handles the response to the QueuesGetAuthorizationRule request. The method always +// closes the http.Response Body. +func (c QueuesAuthorizationRuleClient) responderForQueuesGetAuthorizationRule(resp *http.Response) (result QueuesGetAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queueslistauthorizationrules_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queueslistauthorizationrules_autorest.go new file mode 100644 index 000000000000..82e7db8815eb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queueslistauthorizationrules_autorest.go @@ -0,0 +1,186 @@ +package queuesauthorizationrule + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + Model *[]SBAuthorizationRule + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (QueuesListAuthorizationRulesOperationResponse, error) +} + +type QueuesListAuthorizationRulesCompleteResult struct { + Items []SBAuthorizationRule +} + +func (r QueuesListAuthorizationRulesOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r QueuesListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp QueuesListAuthorizationRulesOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// QueuesListAuthorizationRules ... +func (c QueuesAuthorizationRuleClient) QueuesListAuthorizationRules(ctx context.Context, id QueueId) (resp QueuesListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForQueuesListAuthorizationRules(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListAuthorizationRules", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListAuthorizationRules", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForQueuesListAuthorizationRules(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListAuthorizationRules", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// QueuesListAuthorizationRulesComplete retrieves all of the results into a single object +func (c QueuesAuthorizationRuleClient) QueuesListAuthorizationRulesComplete(ctx context.Context, id QueueId) (QueuesListAuthorizationRulesCompleteResult, error) { + return c.QueuesListAuthorizationRulesCompleteMatchingPredicate(ctx, id, SBAuthorizationRuleOperationPredicate{}) +} + +// QueuesListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c QueuesAuthorizationRuleClient) QueuesListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id QueueId, predicate SBAuthorizationRuleOperationPredicate) (resp QueuesListAuthorizationRulesCompleteResult, err error) { + items := make([]SBAuthorizationRule, 0) + + page, err := c.QueuesListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := QueuesListAuthorizationRulesCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForQueuesListAuthorizationRules prepares the QueuesListAuthorizationRules request. +func (c QueuesAuthorizationRuleClient) preparerForQueuesListAuthorizationRules(ctx context.Context, id QueueId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForQueuesListAuthorizationRulesWithNextLink prepares the QueuesListAuthorizationRules request with the given nextLink token. +func (c QueuesAuthorizationRuleClient) preparerForQueuesListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueuesListAuthorizationRules handles the response to the QueuesListAuthorizationRules request. The method always +// closes the http.Response Body. +func (c QueuesAuthorizationRuleClient) responderForQueuesListAuthorizationRules(resp *http.Response) (result QueuesListAuthorizationRulesOperationResponse, err error) { + type page struct { + Values []SBAuthorizationRule `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result QueuesListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForQueuesListAuthorizationRulesWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListAuthorizationRules", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListAuthorizationRules", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueuesListAuthorizationRules(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListAuthorizationRules", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queueslistkeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queueslistkeys_autorest.go new file mode 100644 index 000000000000..511eafdbdbe4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queueslistkeys_autorest.go @@ -0,0 +1,68 @@ +package queuesauthorizationrule + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesListKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// QueuesListKeys ... +func (c QueuesAuthorizationRuleClient) QueuesListKeys(ctx context.Context, id QueueAuthorizationRuleId) (result QueuesListKeysOperationResponse, err error) { + req, err := c.preparerForQueuesListKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueuesListKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesListKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueuesListKeys prepares the QueuesListKeys request. +func (c QueuesAuthorizationRuleClient) preparerForQueuesListKeys(ctx context.Context, id QueueAuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueuesListKeys handles the response to the QueuesListKeys request. The method always +// closes the http.Response Body. +func (c QueuesAuthorizationRuleClient) responderForQueuesListKeys(resp *http.Response) (result QueuesListKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesregeneratekeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesregeneratekeys_autorest.go new file mode 100644 index 000000000000..4bea7e0efe4b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/method_queuesregeneratekeys_autorest.go @@ -0,0 +1,69 @@ +package queuesauthorizationrule + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueuesRegenerateKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// QueuesRegenerateKeys ... +func (c QueuesAuthorizationRuleClient) QueuesRegenerateKeys(ctx context.Context, id QueueAuthorizationRuleId, input RegenerateAccessKeyParameters) (result QueuesRegenerateKeysOperationResponse, err error) { + req, err := c.preparerForQueuesRegenerateKeys(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesRegenerateKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesRegenerateKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForQueuesRegenerateKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "queuesauthorizationrule.QueuesAuthorizationRuleClient", "QueuesRegenerateKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForQueuesRegenerateKeys prepares the QueuesRegenerateKeys request. +func (c QueuesAuthorizationRuleClient) preparerForQueuesRegenerateKeys(ctx context.Context, id QueueAuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForQueuesRegenerateKeys handles the response to the QueuesRegenerateKeys request. The method always +// closes the http.Response Body. +func (c QueuesAuthorizationRuleClient) responderForQueuesRegenerateKeys(resp *http.Response) (result QueuesRegenerateKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_accesskeys.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_accesskeys.go new file mode 100644 index 000000000000..6483a26ef744 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_accesskeys.go @@ -0,0 +1,14 @@ +package queuesauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessKeys struct { + AliasPrimaryConnectionString *string `json:"aliasPrimaryConnectionString,omitempty"` + AliasSecondaryConnectionString *string `json:"aliasSecondaryConnectionString,omitempty"` + KeyName *string `json:"keyName,omitempty"` + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_regenerateaccesskeyparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_regenerateaccesskeyparameters.go new file mode 100644 index 000000000000..b6a32491737c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_regenerateaccesskeyparameters.go @@ -0,0 +1,9 @@ +package queuesauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateAccessKeyParameters struct { + Key *string `json:"key,omitempty"` + KeyType KeyType `json:"keyType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_sbauthorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_sbauthorizationrule.go new file mode 100644 index 000000000000..13f457c78149 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_sbauthorizationrule.go @@ -0,0 +1,16 @@ +package queuesauthorizationrule + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBAuthorizationRuleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_sbauthorizationruleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_sbauthorizationruleproperties.go new file mode 100644 index 000000000000..c4ccb568d3fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/model_sbauthorizationruleproperties.go @@ -0,0 +1,8 @@ +package queuesauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRuleProperties struct { + Rights []AccessRights `json:"rights"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/predicates.go new file mode 100644 index 000000000000..721dce865ede --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/predicates.go @@ -0,0 +1,24 @@ +package queuesauthorizationrule + +type SBAuthorizationRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBAuthorizationRuleOperationPredicate) Matches(input SBAuthorizationRule) 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/servicebus/2021-06-01-preview/queuesauthorizationrule/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/version.go new file mode 100644 index 000000000000..65270c408ffb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule/version.go @@ -0,0 +1,12 @@ +package queuesauthorizationrule + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/queuesauthorizationrule/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/README.md new file mode 100644 index 000000000000..80162617b4fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules` Documentation + +The `rules` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/rules" +``` + + +### Client Initialization + +```go +client := rules.NewRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := rules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue", "ruleValue") + +payload := rules.Rule{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RulesClient.Delete` + +```go +ctx := context.TODO() +id := rules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue", "ruleValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RulesClient.ListBySubscriptions` + +```go +ctx := context.TODO() +id := rules.NewSubscriptions2ID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue") + +// alternatively `client.ListBySubscriptions(ctx, id, rules.DefaultListBySubscriptionsOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionsComplete(ctx, id, rules.DefaultListBySubscriptionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/client.go new file mode 100644 index 000000000000..7e1e300eef3c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/client.go @@ -0,0 +1,18 @@ +package rules + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RulesClient struct { + Client autorest.Client + baseUri string +} + +func NewRulesClientWithBaseURI(endpoint string) RulesClient { + return RulesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/constants.go new file mode 100644 index 000000000000..06236708fc2d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/constants.go @@ -0,0 +1,34 @@ +package rules + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FilterType string + +const ( + FilterTypeCorrelationFilter FilterType = "CorrelationFilter" + FilterTypeSqlFilter FilterType = "SqlFilter" +) + +func PossibleValuesForFilterType() []string { + return []string{ + string(FilterTypeCorrelationFilter), + string(FilterTypeSqlFilter), + } +} + +func parseFilterType(input string) (*FilterType, error) { + vals := map[string]FilterType{ + "correlationfilter": FilterTypeCorrelationFilter, + "sqlfilter": FilterTypeSqlFilter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FilterType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/id_rule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/id_rule.go new file mode 100644 index 000000000000..0b106b550949 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/id_rule.go @@ -0,0 +1,163 @@ +package rules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = RuleId{} + +// RuleId is a struct representing the Resource ID for a Rule +type RuleId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string + SubscriptionName string + RuleName string +} + +// NewRuleID returns a new RuleId struct +func NewRuleID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) RuleId { + return RuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + SubscriptionName: subscriptionName, + RuleName: ruleName, + } +} + +// ParseRuleID parses 'input' into a RuleId +func ParseRuleID(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(RuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + if id.RuleName, ok = parsed.Parsed["ruleName"]; !ok { + return nil, fmt.Errorf("the segment 'ruleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseRuleIDInsensitively parses 'input' case-insensitively into a RuleId +// note: this method should only be used for API response data and not user input +func ParseRuleIDInsensitively(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(RuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + if id.RuleName, ok = parsed.Parsed["ruleName"]; !ok { + return nil, fmt.Errorf("the segment 'ruleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateRuleID checks that 'input' can be parsed as a Rule ID +func ValidateRuleID(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 := ParseRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule ID +func (id RuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/subscriptions/%s/rules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName, id.SubscriptionName, id.RuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule ID +func (id RuleId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + resourceids.StaticSegment("staticSubscriptions2", "subscriptions", "subscriptions"), + resourceids.UserSpecifiedSegment("subscriptionName", "subscriptionValue"), + resourceids.StaticSegment("staticRules", "rules", "rules"), + resourceids.UserSpecifiedSegment("ruleName", "ruleValue"), + } +} + +// String returns a human-readable description of this Rule ID +func (id RuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + fmt.Sprintf("Subscription Name: %q", id.SubscriptionName), + fmt.Sprintf("Rule Name: %q", id.RuleName), + } + return fmt.Sprintf("Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/id_subscriptions2.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/id_subscriptions2.go new file mode 100644 index 000000000000..827ea8781694 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/id_subscriptions2.go @@ -0,0 +1,150 @@ +package rules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = Subscriptions2Id{} + +// Subscriptions2Id is a struct representing the Resource ID for a Subscriptions 2 +type Subscriptions2Id struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string + SubscriptionName string +} + +// NewSubscriptions2ID returns a new Subscriptions2Id struct +func NewSubscriptions2ID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string, subscriptionName string) Subscriptions2Id { + return Subscriptions2Id{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + SubscriptionName: subscriptionName, + } +} + +// ParseSubscriptions2ID parses 'input' into a Subscriptions2Id +func ParseSubscriptions2ID(input string) (*Subscriptions2Id, error) { + parser := resourceids.NewParserFromResourceIdType(Subscriptions2Id{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := Subscriptions2Id{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseSubscriptions2IDInsensitively parses 'input' case-insensitively into a Subscriptions2Id +// note: this method should only be used for API response data and not user input +func ParseSubscriptions2IDInsensitively(input string) (*Subscriptions2Id, error) { + parser := resourceids.NewParserFromResourceIdType(Subscriptions2Id{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := Subscriptions2Id{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateSubscriptions2ID checks that 'input' can be parsed as a Subscriptions 2 ID +func ValidateSubscriptions2ID(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 := ParseSubscriptions2ID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Subscriptions 2 ID +func (id Subscriptions2Id) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/subscriptions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName, id.SubscriptionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Subscriptions 2 ID +func (id Subscriptions2Id) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + resourceids.StaticSegment("staticSubscriptions2", "subscriptions", "subscriptions"), + resourceids.UserSpecifiedSegment("subscriptionName", "subscriptionValue"), + } +} + +// String returns a human-readable description of this Subscriptions 2 ID +func (id Subscriptions2Id) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + fmt.Sprintf("Subscription Name: %q", id.SubscriptionName), + } + return fmt.Sprintf("Subscriptions 2 (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_createorupdate_autorest.go new file mode 100644 index 000000000000..7e69a145d81e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_createorupdate_autorest.go @@ -0,0 +1,68 @@ +package rules + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *Rule +} + +// CreateOrUpdate ... +func (c RulesClient) CreateOrUpdate(ctx context.Context, id RuleId, input Rule) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c RulesClient) preparerForCreateOrUpdate(ctx context.Context, id RuleId, input Rule) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c RulesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_delete_autorest.go new file mode 100644 index 000000000000..cd3d2426af6f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_delete_autorest.go @@ -0,0 +1,65 @@ +package rules + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 +} + +// Delete ... +func (c RulesClient) Delete(ctx context.Context, id RuleId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c RulesClient) preparerForDelete(ctx context.Context, id RuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c RulesClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_listbysubscriptions_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_listbysubscriptions_autorest.go new file mode 100644 index 000000000000..57c918acc5f7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/method_listbysubscriptions_autorest.go @@ -0,0 +1,220 @@ +package rules + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionsOperationResponse struct { + HttpResponse *http.Response + Model *[]Rule + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionsOperationResponse, error) +} + +type ListBySubscriptionsCompleteResult struct { + Items []Rule +} + +func (r ListBySubscriptionsOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListBySubscriptionsOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionsOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListBySubscriptionsOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListBySubscriptionsOperationOptions() ListBySubscriptionsOperationOptions { + return ListBySubscriptionsOperationOptions{} +} + +func (o ListBySubscriptionsOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListBySubscriptionsOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Skip != nil { + out["$skip"] = *o.Skip + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListBySubscriptions ... +func (c RulesClient) ListBySubscriptions(ctx context.Context, id Subscriptions2Id, options ListBySubscriptionsOperationOptions) (resp ListBySubscriptionsOperationResponse, err error) { + req, err := c.preparerForListBySubscriptions(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "ListBySubscriptions", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "ListBySubscriptions", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListBySubscriptions(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "ListBySubscriptions", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListBySubscriptionsComplete retrieves all of the results into a single object +func (c RulesClient) ListBySubscriptionsComplete(ctx context.Context, id Subscriptions2Id, options ListBySubscriptionsOperationOptions) (ListBySubscriptionsCompleteResult, error) { + return c.ListBySubscriptionsCompleteMatchingPredicate(ctx, id, options, RuleOperationPredicate{}) +} + +// ListBySubscriptionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RulesClient) ListBySubscriptionsCompleteMatchingPredicate(ctx context.Context, id Subscriptions2Id, options ListBySubscriptionsOperationOptions, predicate RuleOperationPredicate) (resp ListBySubscriptionsCompleteResult, err error) { + items := make([]Rule, 0) + + page, err := c.ListBySubscriptions(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListBySubscriptionsCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListBySubscriptions prepares the ListBySubscriptions request. +func (c RulesClient) preparerForListBySubscriptions(ctx context.Context, id Subscriptions2Id, options ListBySubscriptionsOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/rules", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListBySubscriptionsWithNextLink prepares the ListBySubscriptions request with the given nextLink token. +func (c RulesClient) preparerForListBySubscriptionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListBySubscriptions handles the response to the ListBySubscriptions request. The method always +// closes the http.Response Body. +func (c RulesClient) responderForListBySubscriptions(resp *http.Response) (result ListBySubscriptionsOperationResponse, err error) { + type page struct { + Values []Rule `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionsOperationResponse, err error) { + req, err := c.preparerForListBySubscriptionsWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "ListBySubscriptions", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "ListBySubscriptions", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListBySubscriptions(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "rules.RulesClient", "ListBySubscriptions", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_action.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_action.go new file mode 100644 index 000000000000..5583dfbfe784 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_action.go @@ -0,0 +1,10 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Action struct { + CompatibilityLevel *int64 `json:"compatibilityLevel,omitempty"` + RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` + SqlExpression *string `json:"sqlExpression,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_correlationfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_correlationfilter.go new file mode 100644 index 000000000000..a2daf0699687 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_correlationfilter.go @@ -0,0 +1,17 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorrelationFilter struct { + ContentType *string `json:"contentType,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + Label *string `json:"label,omitempty"` + MessageId *string `json:"messageId,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ReplyTo *string `json:"replyTo,omitempty"` + ReplyToSessionId *string `json:"replyToSessionId,omitempty"` + RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` + SessionId *string `json:"sessionId,omitempty"` + To *string `json:"to,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_rule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_rule.go new file mode 100644 index 000000000000..7c81240b66ea --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_rule.go @@ -0,0 +1,16 @@ +package rules + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *Ruleproperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_ruleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_ruleproperties.go new file mode 100644 index 000000000000..96bf533f35fb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_ruleproperties.go @@ -0,0 +1,11 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ruleproperties struct { + Action *Action `json:"action,omitempty"` + CorrelationFilter *CorrelationFilter `json:"correlationFilter,omitempty"` + FilterType *FilterType `json:"filterType,omitempty"` + SqlFilter *SqlFilter `json:"sqlFilter,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_sqlfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_sqlfilter.go new file mode 100644 index 000000000000..fc16bab7c6ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/model_sqlfilter.go @@ -0,0 +1,10 @@ +package rules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlFilter struct { + CompatibilityLevel *int64 `json:"compatibilityLevel,omitempty"` + RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` + SqlExpression *string `json:"sqlExpression,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/predicates.go new file mode 100644 index 000000000000..c9b9b4dc5d6f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/predicates.go @@ -0,0 +1,24 @@ +package rules + +type RuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RuleOperationPredicate) Matches(input Rule) 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/servicebus/2021-06-01-preview/rules/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/version.go new file mode 100644 index 000000000000..e9a07c4c0584 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules/version.go @@ -0,0 +1,12 @@ +package rules + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/rules/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/README.md new file mode 100644 index 000000000000..08287c5e5dc4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/README.md @@ -0,0 +1,106 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions` Documentation + +The `subscriptions` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/subscriptions" +``` + + +### Client Initialization + +```go +client := subscriptions.NewSubscriptionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SubscriptionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := subscriptions.NewSubscriptions2ID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue") + +payload := subscriptions.SBSubscription{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SubscriptionsClient.Delete` + +```go +ctx := context.TODO() +id := subscriptions.NewSubscriptions2ID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SubscriptionsClient.Get` + +```go +ctx := context.TODO() +id := subscriptions.NewSubscriptions2ID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue") + +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: `SubscriptionsClient.ListByTopic` + +```go +ctx := context.TODO() +id := subscriptions.NewTopicID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue") + +// alternatively `client.ListByTopic(ctx, id, subscriptions.DefaultListByTopicOperationOptions())` can be used to do batched pagination +items, err := client.ListByTopicComplete(ctx, id, subscriptions.DefaultListByTopicOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SubscriptionsClient.RulesGet` + +```go +ctx := context.TODO() +id := subscriptions.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "subscriptionValue", "ruleValue") + +read, err := client.RulesGet(ctx, id) +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/servicebus/2021-06-01-preview/subscriptions/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/client.go new file mode 100644 index 000000000000..da1257d5d970 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/client.go @@ -0,0 +1,18 @@ +package subscriptions + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionsClient struct { + Client autorest.Client + baseUri string +} + +func NewSubscriptionsClientWithBaseURI(endpoint string) SubscriptionsClient { + return SubscriptionsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/constants.go new file mode 100644 index 000000000000..971bb325a5f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/constants.go @@ -0,0 +1,83 @@ +package subscriptions + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EntityStatus string + +const ( + EntityStatusActive EntityStatus = "Active" + EntityStatusCreating EntityStatus = "Creating" + EntityStatusDeleting EntityStatus = "Deleting" + EntityStatusDisabled EntityStatus = "Disabled" + EntityStatusReceiveDisabled EntityStatus = "ReceiveDisabled" + EntityStatusRenaming EntityStatus = "Renaming" + EntityStatusRestoring EntityStatus = "Restoring" + EntityStatusSendDisabled EntityStatus = "SendDisabled" + EntityStatusUnknown EntityStatus = "Unknown" +) + +func PossibleValuesForEntityStatus() []string { + return []string{ + string(EntityStatusActive), + string(EntityStatusCreating), + string(EntityStatusDeleting), + string(EntityStatusDisabled), + string(EntityStatusReceiveDisabled), + string(EntityStatusRenaming), + string(EntityStatusRestoring), + string(EntityStatusSendDisabled), + string(EntityStatusUnknown), + } +} + +func parseEntityStatus(input string) (*EntityStatus, error) { + vals := map[string]EntityStatus{ + "active": EntityStatusActive, + "creating": EntityStatusCreating, + "deleting": EntityStatusDeleting, + "disabled": EntityStatusDisabled, + "receivedisabled": EntityStatusReceiveDisabled, + "renaming": EntityStatusRenaming, + "restoring": EntityStatusRestoring, + "senddisabled": EntityStatusSendDisabled, + "unknown": EntityStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EntityStatus(input) + return &out, nil +} + +type FilterType string + +const ( + FilterTypeCorrelationFilter FilterType = "CorrelationFilter" + FilterTypeSqlFilter FilterType = "SqlFilter" +) + +func PossibleValuesForFilterType() []string { + return []string{ + string(FilterTypeCorrelationFilter), + string(FilterTypeSqlFilter), + } +} + +func parseFilterType(input string) (*FilterType, error) { + vals := map[string]FilterType{ + "correlationfilter": FilterTypeCorrelationFilter, + "sqlfilter": FilterTypeSqlFilter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FilterType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_rule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_rule.go new file mode 100644 index 000000000000..ad54fab384d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_rule.go @@ -0,0 +1,163 @@ +package subscriptions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = RuleId{} + +// RuleId is a struct representing the Resource ID for a Rule +type RuleId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string + SubscriptionName string + RuleName string +} + +// NewRuleID returns a new RuleId struct +func NewRuleID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string, subscriptionName string, ruleName string) RuleId { + return RuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + SubscriptionName: subscriptionName, + RuleName: ruleName, + } +} + +// ParseRuleID parses 'input' into a RuleId +func ParseRuleID(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(RuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + if id.RuleName, ok = parsed.Parsed["ruleName"]; !ok { + return nil, fmt.Errorf("the segment 'ruleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseRuleIDInsensitively parses 'input' case-insensitively into a RuleId +// note: this method should only be used for API response data and not user input +func ParseRuleIDInsensitively(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(RuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := RuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + if id.RuleName, ok = parsed.Parsed["ruleName"]; !ok { + return nil, fmt.Errorf("the segment 'ruleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateRuleID checks that 'input' can be parsed as a Rule ID +func ValidateRuleID(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 := ParseRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule ID +func (id RuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/subscriptions/%s/rules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName, id.SubscriptionName, id.RuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule ID +func (id RuleId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + resourceids.StaticSegment("staticSubscriptions2", "subscriptions", "subscriptions"), + resourceids.UserSpecifiedSegment("subscriptionName", "subscriptionValue"), + resourceids.StaticSegment("staticRules", "rules", "rules"), + resourceids.UserSpecifiedSegment("ruleName", "ruleValue"), + } +} + +// String returns a human-readable description of this Rule ID +func (id RuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + fmt.Sprintf("Subscription Name: %q", id.SubscriptionName), + fmt.Sprintf("Rule Name: %q", id.RuleName), + } + return fmt.Sprintf("Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_subscriptions2.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_subscriptions2.go new file mode 100644 index 000000000000..a29559cdc8ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_subscriptions2.go @@ -0,0 +1,150 @@ +package subscriptions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = Subscriptions2Id{} + +// Subscriptions2Id is a struct representing the Resource ID for a Subscriptions 2 +type Subscriptions2Id struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string + SubscriptionName string +} + +// NewSubscriptions2ID returns a new Subscriptions2Id struct +func NewSubscriptions2ID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string, subscriptionName string) Subscriptions2Id { + return Subscriptions2Id{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + SubscriptionName: subscriptionName, + } +} + +// ParseSubscriptions2ID parses 'input' into a Subscriptions2Id +func ParseSubscriptions2ID(input string) (*Subscriptions2Id, error) { + parser := resourceids.NewParserFromResourceIdType(Subscriptions2Id{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := Subscriptions2Id{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseSubscriptions2IDInsensitively parses 'input' case-insensitively into a Subscriptions2Id +// note: this method should only be used for API response data and not user input +func ParseSubscriptions2IDInsensitively(input string) (*Subscriptions2Id, error) { + parser := resourceids.NewParserFromResourceIdType(Subscriptions2Id{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := Subscriptions2Id{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.SubscriptionName, ok = parsed.Parsed["subscriptionName"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateSubscriptions2ID checks that 'input' can be parsed as a Subscriptions 2 ID +func ValidateSubscriptions2ID(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 := ParseSubscriptions2ID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Subscriptions 2 ID +func (id Subscriptions2Id) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/subscriptions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName, id.SubscriptionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Subscriptions 2 ID +func (id Subscriptions2Id) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + resourceids.StaticSegment("staticSubscriptions2", "subscriptions", "subscriptions"), + resourceids.UserSpecifiedSegment("subscriptionName", "subscriptionValue"), + } +} + +// String returns a human-readable description of this Subscriptions 2 ID +func (id Subscriptions2Id) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + fmt.Sprintf("Subscription Name: %q", id.SubscriptionName), + } + return fmt.Sprintf("Subscriptions 2 (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_topic.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_topic.go new file mode 100644 index 000000000000..3c57014bca0d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/id_topic.go @@ -0,0 +1,137 @@ +package subscriptions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = TopicId{} + +// TopicId is a struct representing the Resource ID for a Topic +type TopicId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string +} + +// NewTopicID returns a new TopicId struct +func NewTopicID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string) TopicId { + return TopicId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + } +} + +// ParseTopicID parses 'input' into a TopicId +func ParseTopicID(input string) (*TopicId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseTopicIDInsensitively parses 'input' case-insensitively into a TopicId +// note: this method should only be used for API response data and not user input +func ParseTopicIDInsensitively(input string) (*TopicId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateTopicID checks that 'input' can be parsed as a Topic ID +func ValidateTopicID(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 := ParseTopicID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Topic ID +func (id TopicId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Topic ID +func (id TopicId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + } +} + +// String returns a human-readable description of this Topic ID +func (id TopicId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + } + return fmt.Sprintf("Topic (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_createorupdate_autorest.go new file mode 100644 index 000000000000..2cc752f083cd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_createorupdate_autorest.go @@ -0,0 +1,68 @@ +package subscriptions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBSubscription +} + +// CreateOrUpdate ... +func (c SubscriptionsClient) CreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SBSubscription) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c SubscriptionsClient) preparerForCreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SBSubscription) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c SubscriptionsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_delete_autorest.go new file mode 100644 index 000000000000..8a96fdd572fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_delete_autorest.go @@ -0,0 +1,65 @@ +package subscriptions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 +} + +// Delete ... +func (c SubscriptionsClient) Delete(ctx context.Context, id Subscriptions2Id) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c SubscriptionsClient) preparerForDelete(ctx context.Context, id Subscriptions2Id) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c SubscriptionsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_get_autorest.go new file mode 100644 index 000000000000..c8aabc90096a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_get_autorest.go @@ -0,0 +1,67 @@ +package subscriptions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBSubscription +} + +// Get ... +func (c SubscriptionsClient) Get(ctx context.Context, id Subscriptions2Id) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c SubscriptionsClient) preparerForGet(ctx context.Context, id Subscriptions2Id) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c SubscriptionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_listbytopic_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_listbytopic_autorest.go new file mode 100644 index 000000000000..42884bed6c53 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_listbytopic_autorest.go @@ -0,0 +1,220 @@ +package subscriptions + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByTopicOperationResponse struct { + HttpResponse *http.Response + Model *[]SBSubscription + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByTopicOperationResponse, error) +} + +type ListByTopicCompleteResult struct { + Items []SBSubscription +} + +func (r ListByTopicOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByTopicOperationResponse) LoadMore(ctx context.Context) (resp ListByTopicOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByTopicOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByTopicOperationOptions() ListByTopicOperationOptions { + return ListByTopicOperationOptions{} +} + +func (o ListByTopicOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByTopicOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Skip != nil { + out["$skip"] = *o.Skip + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListByTopic ... +func (c SubscriptionsClient) ListByTopic(ctx context.Context, id TopicId, options ListByTopicOperationOptions) (resp ListByTopicOperationResponse, err error) { + req, err := c.preparerForListByTopic(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "ListByTopic", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "ListByTopic", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByTopic(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "ListByTopic", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByTopicComplete retrieves all of the results into a single object +func (c SubscriptionsClient) ListByTopicComplete(ctx context.Context, id TopicId, options ListByTopicOperationOptions) (ListByTopicCompleteResult, error) { + return c.ListByTopicCompleteMatchingPredicate(ctx, id, options, SBSubscriptionOperationPredicate{}) +} + +// ListByTopicCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c SubscriptionsClient) ListByTopicCompleteMatchingPredicate(ctx context.Context, id TopicId, options ListByTopicOperationOptions, predicate SBSubscriptionOperationPredicate) (resp ListByTopicCompleteResult, err error) { + items := make([]SBSubscription, 0) + + page, err := c.ListByTopic(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByTopicCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByTopic prepares the ListByTopic request. +func (c SubscriptionsClient) preparerForListByTopic(ctx context.Context, id TopicId, options ListByTopicOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByTopicWithNextLink prepares the ListByTopic request with the given nextLink token. +func (c SubscriptionsClient) preparerForListByTopicWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByTopic handles the response to the ListByTopic request. The method always +// closes the http.Response Body. +func (c SubscriptionsClient) responderForListByTopic(resp *http.Response) (result ListByTopicOperationResponse, err error) { + type page struct { + Values []SBSubscription `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByTopicOperationResponse, err error) { + req, err := c.preparerForListByTopicWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "ListByTopic", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "ListByTopic", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByTopic(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "ListByTopic", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_rulesget_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_rulesget_autorest.go new file mode 100644 index 000000000000..07c4d322e1e7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/method_rulesget_autorest.go @@ -0,0 +1,67 @@ +package subscriptions + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RulesGetOperationResponse struct { + HttpResponse *http.Response + Model *Rule +} + +// RulesGet ... +func (c SubscriptionsClient) RulesGet(ctx context.Context, id RuleId) (result RulesGetOperationResponse, err error) { + req, err := c.preparerForRulesGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "RulesGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "RulesGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRulesGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "subscriptions.SubscriptionsClient", "RulesGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRulesGet prepares the RulesGet request. +func (c SubscriptionsClient) preparerForRulesGet(ctx context.Context, id RuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRulesGet handles the response to the RulesGet request. The method always +// closes the http.Response Body. +func (c SubscriptionsClient) responderForRulesGet(resp *http.Response) (result RulesGetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_action.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_action.go new file mode 100644 index 000000000000..305f58fb92c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_action.go @@ -0,0 +1,10 @@ +package subscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Action struct { + CompatibilityLevel *int64 `json:"compatibilityLevel,omitempty"` + RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` + SqlExpression *string `json:"sqlExpression,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_correlationfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_correlationfilter.go new file mode 100644 index 000000000000..7caba4aa70d7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_correlationfilter.go @@ -0,0 +1,17 @@ +package subscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorrelationFilter struct { + ContentType *string `json:"contentType,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + Label *string `json:"label,omitempty"` + MessageId *string `json:"messageId,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ReplyTo *string `json:"replyTo,omitempty"` + ReplyToSessionId *string `json:"replyToSessionId,omitempty"` + RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` + SessionId *string `json:"sessionId,omitempty"` + To *string `json:"to,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_messagecountdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_messagecountdetails.go new file mode 100644 index 000000000000..72c8d97e6af8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_messagecountdetails.go @@ -0,0 +1,12 @@ +package subscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageCountDetails struct { + ActiveMessageCount *int64 `json:"activeMessageCount,omitempty"` + DeadLetterMessageCount *int64 `json:"deadLetterMessageCount,omitempty"` + ScheduledMessageCount *int64 `json:"scheduledMessageCount,omitempty"` + TransferDeadLetterMessageCount *int64 `json:"transferDeadLetterMessageCount,omitempty"` + TransferMessageCount *int64 `json:"transferMessageCount,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_rule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_rule.go new file mode 100644 index 000000000000..f4af4e85a276 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_rule.go @@ -0,0 +1,16 @@ +package subscriptions + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *Ruleproperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_ruleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_ruleproperties.go new file mode 100644 index 000000000000..05dd1c71de3b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_ruleproperties.go @@ -0,0 +1,11 @@ +package subscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ruleproperties struct { + Action *Action `json:"action,omitempty"` + CorrelationFilter *CorrelationFilter `json:"correlationFilter,omitempty"` + FilterType *FilterType `json:"filterType,omitempty"` + SqlFilter *SqlFilter `json:"sqlFilter,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbclientaffineproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbclientaffineproperties.go new file mode 100644 index 000000000000..8a8832d705a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbclientaffineproperties.go @@ -0,0 +1,10 @@ +package subscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBClientAffineProperties struct { + ClientId *string `json:"clientId,omitempty"` + IsDurable *bool `json:"isDurable,omitempty"` + IsShared *bool `json:"isShared,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbsubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbsubscription.go new file mode 100644 index 000000000000..7079232703ee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbsubscription.go @@ -0,0 +1,16 @@ +package subscriptions + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBSubscription struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBSubscriptionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbsubscriptionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbsubscriptionproperties.go new file mode 100644 index 000000000000..fae0f41f9b7a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sbsubscriptionproperties.go @@ -0,0 +1,68 @@ +package subscriptions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBSubscriptionProperties struct { + AccessedAt *string `json:"accessedAt,omitempty"` + AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` + ClientAffineProperties *SBClientAffineProperties `json:"clientAffineProperties,omitempty"` + CountDetails *MessageCountDetails `json:"countDetails,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + DeadLetteringOnFilterEvaluationExceptions *bool `json:"deadLetteringOnFilterEvaluationExceptions,omitempty"` + DeadLetteringOnMessageExpiration *bool `json:"deadLetteringOnMessageExpiration,omitempty"` + DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` + DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` + EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` + ForwardDeadLetteredMessagesTo *string `json:"forwardDeadLetteredMessagesTo,omitempty"` + ForwardTo *string `json:"forwardTo,omitempty"` + IsClientAffine *bool `json:"isClientAffine,omitempty"` + LockDuration *string `json:"lockDuration,omitempty"` + MaxDeliveryCount *int64 `json:"maxDeliveryCount,omitempty"` + MessageCount *int64 `json:"messageCount,omitempty"` + RequiresSession *bool `json:"requiresSession,omitempty"` + Status *EntityStatus `json:"status,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` +} + +func (o *SBSubscriptionProperties) GetAccessedAtAsTime() (*time.Time, error) { + if o.AccessedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AccessedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBSubscriptionProperties) SetAccessedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AccessedAt = &formatted +} + +func (o *SBSubscriptionProperties) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBSubscriptionProperties) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SBSubscriptionProperties) GetUpdatedAtAsTime() (*time.Time, error) { + if o.UpdatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBSubscriptionProperties) SetUpdatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sqlfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sqlfilter.go new file mode 100644 index 000000000000..2980ee7e2ad9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/model_sqlfilter.go @@ -0,0 +1,10 @@ +package subscriptions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlFilter struct { + CompatibilityLevel *int64 `json:"compatibilityLevel,omitempty"` + RequiresPreprocessing *bool `json:"requiresPreprocessing,omitempty"` + SqlExpression *string `json:"sqlExpression,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/predicates.go new file mode 100644 index 000000000000..755e5d7fc260 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/predicates.go @@ -0,0 +1,24 @@ +package subscriptions + +type SBSubscriptionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBSubscriptionOperationPredicate) Matches(input SBSubscription) 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/servicebus/2021-06-01-preview/subscriptions/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/version.go new file mode 100644 index 000000000000..0ee9e9513ad2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions/version.go @@ -0,0 +1,12 @@ +package subscriptions + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/subscriptions/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/README.md new file mode 100644 index 000000000000..bff215cc2ccd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics` Documentation + +The `topics` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/topics" +``` + + +### Client Initialization + +```go +client := topics.NewTopicsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TopicsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := topics.NewTopicID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue") + +payload := topics.SBTopic{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopicsClient.Delete` + +```go +ctx := context.TODO() +id := topics.NewTopicID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopicsClient.Get` + +```go +ctx := context.TODO() +id := topics.NewTopicID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue") + +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: `TopicsClient.ListByNamespace` + +```go +ctx := context.TODO() +id := topics.NewNamespaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue") + +// alternatively `client.ListByNamespace(ctx, id, topics.DefaultListByNamespaceOperationOptions())` can be used to do batched pagination +items, err := client.ListByNamespaceComplete(ctx, id, topics.DefaultListByNamespaceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/client.go new file mode 100644 index 000000000000..d5c9fa358795 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/client.go @@ -0,0 +1,18 @@ +package topics + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsClient struct { + Client autorest.Client + baseUri string +} + +func NewTopicsClientWithBaseURI(endpoint string) TopicsClient { + return TopicsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/constants.go new file mode 100644 index 000000000000..07f1029faba1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/constants.go @@ -0,0 +1,55 @@ +package topics + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EntityStatus string + +const ( + EntityStatusActive EntityStatus = "Active" + EntityStatusCreating EntityStatus = "Creating" + EntityStatusDeleting EntityStatus = "Deleting" + EntityStatusDisabled EntityStatus = "Disabled" + EntityStatusReceiveDisabled EntityStatus = "ReceiveDisabled" + EntityStatusRenaming EntityStatus = "Renaming" + EntityStatusRestoring EntityStatus = "Restoring" + EntityStatusSendDisabled EntityStatus = "SendDisabled" + EntityStatusUnknown EntityStatus = "Unknown" +) + +func PossibleValuesForEntityStatus() []string { + return []string{ + string(EntityStatusActive), + string(EntityStatusCreating), + string(EntityStatusDeleting), + string(EntityStatusDisabled), + string(EntityStatusReceiveDisabled), + string(EntityStatusRenaming), + string(EntityStatusRestoring), + string(EntityStatusSendDisabled), + string(EntityStatusUnknown), + } +} + +func parseEntityStatus(input string) (*EntityStatus, error) { + vals := map[string]EntityStatus{ + "active": EntityStatusActive, + "creating": EntityStatusCreating, + "deleting": EntityStatusDeleting, + "disabled": EntityStatusDisabled, + "receivedisabled": EntityStatusReceiveDisabled, + "renaming": EntityStatusRenaming, + "restoring": EntityStatusRestoring, + "senddisabled": EntityStatusSendDisabled, + "unknown": EntityStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EntityStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/id_namespace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/id_namespace.go new file mode 100644 index 000000000000..dd4c6ad03273 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/id_namespace.go @@ -0,0 +1,124 @@ +package topics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = NamespaceId{} + +// NamespaceId is a struct representing the Resource ID for a Namespace +type NamespaceId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string +} + +// NewNamespaceID returns a new NamespaceId struct +func NewNamespaceID(subscriptionId string, resourceGroupName string, namespaceName string) NamespaceId { + return NamespaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + } +} + +// ParseNamespaceID parses 'input' into a NamespaceId +func ParseNamespaceID(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseNamespaceIDInsensitively parses 'input' case-insensitively into a NamespaceId +// note: this method should only be used for API response data and not user input +func ParseNamespaceIDInsensitively(input string) (*NamespaceId, error) { + parser := resourceids.NewParserFromResourceIdType(NamespaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := NamespaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateNamespaceID checks that 'input' can be parsed as a Namespace ID +func ValidateNamespaceID(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 := ParseNamespaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Namespace ID +func (id NamespaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Namespace ID +func (id NamespaceId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + } +} + +// String returns a human-readable description of this Namespace ID +func (id NamespaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + } + return fmt.Sprintf("Namespace (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/id_topic.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/id_topic.go new file mode 100644 index 000000000000..fd9ec22d0b4b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/id_topic.go @@ -0,0 +1,137 @@ +package topics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = TopicId{} + +// TopicId is a struct representing the Resource ID for a Topic +type TopicId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string +} + +// NewTopicID returns a new TopicId struct +func NewTopicID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string) TopicId { + return TopicId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + } +} + +// ParseTopicID parses 'input' into a TopicId +func ParseTopicID(input string) (*TopicId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseTopicIDInsensitively parses 'input' case-insensitively into a TopicId +// note: this method should only be used for API response data and not user input +func ParseTopicIDInsensitively(input string) (*TopicId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateTopicID checks that 'input' can be parsed as a Topic ID +func ValidateTopicID(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 := ParseTopicID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Topic ID +func (id TopicId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Topic ID +func (id TopicId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + } +} + +// String returns a human-readable description of this Topic ID +func (id TopicId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + } + return fmt.Sprintf("Topic (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_createorupdate_autorest.go new file mode 100644 index 000000000000..53df3d9cebc9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_createorupdate_autorest.go @@ -0,0 +1,68 @@ +package topics + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBTopic +} + +// CreateOrUpdate ... +func (c TopicsClient) CreateOrUpdate(ctx context.Context, id TopicId, input SBTopic) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c TopicsClient) preparerForCreateOrUpdate(ctx context.Context, id TopicId, input SBTopic) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c TopicsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_delete_autorest.go new file mode 100644 index 000000000000..1fc80a781ea8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_delete_autorest.go @@ -0,0 +1,65 @@ +package topics + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 +} + +// Delete ... +func (c TopicsClient) Delete(ctx context.Context, id TopicId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c TopicsClient) preparerForDelete(ctx context.Context, id TopicId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c TopicsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_get_autorest.go new file mode 100644 index 000000000000..e5084f1628fe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_get_autorest.go @@ -0,0 +1,67 @@ +package topics + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// 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 + Model *SBTopic +} + +// Get ... +func (c TopicsClient) Get(ctx context.Context, id TopicId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c TopicsClient) preparerForGet(ctx context.Context, id TopicId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c TopicsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_listbynamespace_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_listbynamespace_autorest.go new file mode 100644 index 000000000000..1f202d4aeef9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/method_listbynamespace_autorest.go @@ -0,0 +1,220 @@ +package topics + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByNamespaceOperationResponse struct { + HttpResponse *http.Response + Model *[]SBTopic + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByNamespaceOperationResponse, error) +} + +type ListByNamespaceCompleteResult struct { + Items []SBTopic +} + +func (r ListByNamespaceOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByNamespaceOperationResponse) LoadMore(ctx context.Context) (resp ListByNamespaceOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListByNamespaceOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByNamespaceOperationOptions() ListByNamespaceOperationOptions { + return ListByNamespaceOperationOptions{} +} + +func (o ListByNamespaceOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListByNamespaceOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Skip != nil { + out["$skip"] = *o.Skip + } + + if o.Top != nil { + out["$top"] = *o.Top + } + + return out +} + +// ListByNamespace ... +func (c TopicsClient) ListByNamespace(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions) (resp ListByNamespaceOperationResponse, err error) { + req, err := c.preparerForListByNamespace(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "ListByNamespace", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "ListByNamespace", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByNamespace(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "ListByNamespace", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByNamespaceComplete retrieves all of the results into a single object +func (c TopicsClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions) (ListByNamespaceCompleteResult, error) { + return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, options, SBTopicOperationPredicate{}) +} + +// ListByNamespaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c TopicsClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions, predicate SBTopicOperationPredicate) (resp ListByNamespaceCompleteResult, err error) { + items := make([]SBTopic, 0) + + page, err := c.ListByNamespace(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByNamespaceCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByNamespace prepares the ListByNamespace request. +func (c TopicsClient) preparerForListByNamespace(ctx context.Context, id NamespaceId, options ListByNamespaceOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/topics", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByNamespaceWithNextLink prepares the ListByNamespace request with the given nextLink token. +func (c TopicsClient) preparerForListByNamespaceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByNamespace handles the response to the ListByNamespace request. The method always +// closes the http.Response Body. +func (c TopicsClient) responderForListByNamespace(resp *http.Response) (result ListByNamespaceOperationResponse, err error) { + type page struct { + Values []SBTopic `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByNamespaceOperationResponse, err error) { + req, err := c.preparerForListByNamespaceWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "ListByNamespace", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "ListByNamespace", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByNamespace(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topics.TopicsClient", "ListByNamespace", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_messagecountdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_messagecountdetails.go new file mode 100644 index 000000000000..4035d658e9c4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_messagecountdetails.go @@ -0,0 +1,12 @@ +package topics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MessageCountDetails struct { + ActiveMessageCount *int64 `json:"activeMessageCount,omitempty"` + DeadLetterMessageCount *int64 `json:"deadLetterMessageCount,omitempty"` + ScheduledMessageCount *int64 `json:"scheduledMessageCount,omitempty"` + TransferDeadLetterMessageCount *int64 `json:"transferDeadLetterMessageCount,omitempty"` + TransferMessageCount *int64 `json:"transferMessageCount,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_sbtopic.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_sbtopic.go new file mode 100644 index 000000000000..8143c623d4ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_sbtopic.go @@ -0,0 +1,16 @@ +package topics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBTopic struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBTopicProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_sbtopicproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_sbtopicproperties.go new file mode 100644 index 000000000000..ef51e8fe89f7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/model_sbtopicproperties.go @@ -0,0 +1,66 @@ +package topics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBTopicProperties struct { + AccessedAt *string `json:"accessedAt,omitempty"` + AutoDeleteOnIdle *string `json:"autoDeleteOnIdle,omitempty"` + CountDetails *MessageCountDetails `json:"countDetails,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + DefaultMessageTimeToLive *string `json:"defaultMessageTimeToLive,omitempty"` + DuplicateDetectionHistoryTimeWindow *string `json:"duplicateDetectionHistoryTimeWindow,omitempty"` + EnableBatchedOperations *bool `json:"enableBatchedOperations,omitempty"` + EnableExpress *bool `json:"enableExpress,omitempty"` + EnablePartitioning *bool `json:"enablePartitioning,omitempty"` + MaxMessageSizeInKilobytes *int64 `json:"maxMessageSizeInKilobytes,omitempty"` + MaxSizeInMegabytes *int64 `json:"maxSizeInMegabytes,omitempty"` + RequiresDuplicateDetection *bool `json:"requiresDuplicateDetection,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + Status *EntityStatus `json:"status,omitempty"` + SubscriptionCount *int64 `json:"subscriptionCount,omitempty"` + SupportOrdering *bool `json:"supportOrdering,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` +} + +func (o *SBTopicProperties) GetAccessedAtAsTime() (*time.Time, error) { + if o.AccessedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AccessedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBTopicProperties) SetAccessedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AccessedAt = &formatted +} + +func (o *SBTopicProperties) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBTopicProperties) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SBTopicProperties) GetUpdatedAtAsTime() (*time.Time, error) { + if o.UpdatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SBTopicProperties) SetUpdatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/predicates.go new file mode 100644 index 000000000000..0a1a4cf85b27 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/predicates.go @@ -0,0 +1,24 @@ +package topics + +type SBTopicOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBTopicOperationPredicate) Matches(input SBTopic) 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/servicebus/2021-06-01-preview/topics/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/version.go new file mode 100644 index 000000000000..f30136ef355c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics/version.go @@ -0,0 +1,12 @@ +package topics + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/topics/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/README.md new file mode 100644 index 000000000000..9f43c536d697 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/README.md @@ -0,0 +1,127 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule` Documentation + +The `topicsauthorizationrule` SDK allows for interaction with the Azure Resource Manager Service `servicebus` (API Version `2021-06-01-preview`). + +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/servicebus/2021-06-01-preview/topicsauthorizationrule" +``` + + +### Client Initialization + +```go +client := topicsauthorizationrule.NewTopicsAuthorizationRuleClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TopicsAuthorizationRuleClient.TopicsCreateOrUpdateAuthorizationRule` + +```go +ctx := context.TODO() +id := topicsauthorizationrule.NewTopicAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "authorizationRuleValue") + +payload := topicsauthorizationrule.SBAuthorizationRule{ + // ... +} + + +read, err := client.TopicsCreateOrUpdateAuthorizationRule(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopicsAuthorizationRuleClient.TopicsDeleteAuthorizationRule` + +```go +ctx := context.TODO() +id := topicsauthorizationrule.NewTopicAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "authorizationRuleValue") + +read, err := client.TopicsDeleteAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopicsAuthorizationRuleClient.TopicsGetAuthorizationRule` + +```go +ctx := context.TODO() +id := topicsauthorizationrule.NewTopicAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "authorizationRuleValue") + +read, err := client.TopicsGetAuthorizationRule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopicsAuthorizationRuleClient.TopicsListAuthorizationRules` + +```go +ctx := context.TODO() +id := topicsauthorizationrule.NewTopicID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue") + +// alternatively `client.TopicsListAuthorizationRules(ctx, id)` can be used to do batched pagination +items, err := client.TopicsListAuthorizationRulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `TopicsAuthorizationRuleClient.TopicsListKeys` + +```go +ctx := context.TODO() +id := topicsauthorizationrule.NewTopicAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "authorizationRuleValue") + +read, err := client.TopicsListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopicsAuthorizationRuleClient.TopicsRegenerateKeys` + +```go +ctx := context.TODO() +id := topicsauthorizationrule.NewTopicAuthorizationRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceValue", "topicValue", "authorizationRuleValue") + +payload := topicsauthorizationrule.RegenerateAccessKeyParameters{ + // ... +} + + +read, err := client.TopicsRegenerateKeys(ctx, id, payload) +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/servicebus/2021-06-01-preview/topicsauthorizationrule/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/client.go new file mode 100644 index 000000000000..271398331b71 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/client.go @@ -0,0 +1,18 @@ +package topicsauthorizationrule + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsAuthorizationRuleClient struct { + Client autorest.Client + baseUri string +} + +func NewTopicsAuthorizationRuleClientWithBaseURI(endpoint string) TopicsAuthorizationRuleClient { + return TopicsAuthorizationRuleClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/constants.go new file mode 100644 index 000000000000..36f8229f8068 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/constants.go @@ -0,0 +1,65 @@ +package topicsauthorizationrule + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessRights string + +const ( + AccessRightsListen AccessRights = "Listen" + AccessRightsManage AccessRights = "Manage" + AccessRightsSend AccessRights = "Send" +) + +func PossibleValuesForAccessRights() []string { + return []string{ + string(AccessRightsListen), + string(AccessRightsManage), + string(AccessRightsSend), + } +} + +func parseAccessRights(input string) (*AccessRights, error) { + vals := map[string]AccessRights{ + "listen": AccessRightsListen, + "manage": AccessRightsManage, + "send": AccessRightsSend, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessRights(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimaryKey KeyType = "PrimaryKey" + KeyTypeSecondaryKey KeyType = "SecondaryKey" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimaryKey), + string(KeyTypeSecondaryKey), + } +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primarykey": KeyTypePrimaryKey, + "secondarykey": KeyTypeSecondaryKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/id_topic.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/id_topic.go new file mode 100644 index 000000000000..909935c8ca78 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/id_topic.go @@ -0,0 +1,137 @@ +package topicsauthorizationrule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = TopicId{} + +// TopicId is a struct representing the Resource ID for a Topic +type TopicId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string +} + +// NewTopicID returns a new TopicId struct +func NewTopicID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string) TopicId { + return TopicId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + } +} + +// ParseTopicID parses 'input' into a TopicId +func ParseTopicID(input string) (*TopicId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseTopicIDInsensitively parses 'input' case-insensitively into a TopicId +// note: this method should only be used for API response data and not user input +func ParseTopicIDInsensitively(input string) (*TopicId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateTopicID checks that 'input' can be parsed as a Topic ID +func ValidateTopicID(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 := ParseTopicID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Topic ID +func (id TopicId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Topic ID +func (id TopicId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + } +} + +// String returns a human-readable description of this Topic ID +func (id TopicId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + } + return fmt.Sprintf("Topic (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/id_topicauthorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/id_topicauthorizationrule.go new file mode 100644 index 000000000000..349c1a5a24a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/id_topicauthorizationrule.go @@ -0,0 +1,150 @@ +package topicsauthorizationrule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = TopicAuthorizationRuleId{} + +// TopicAuthorizationRuleId is a struct representing the Resource ID for a Topic Authorization Rule +type TopicAuthorizationRuleId struct { + SubscriptionId string + ResourceGroupName string + NamespaceName string + TopicName string + AuthorizationRuleName string +} + +// NewTopicAuthorizationRuleID returns a new TopicAuthorizationRuleId struct +func NewTopicAuthorizationRuleID(subscriptionId string, resourceGroupName string, namespaceName string, topicName string, authorizationRuleName string) TopicAuthorizationRuleId { + return TopicAuthorizationRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NamespaceName: namespaceName, + TopicName: topicName, + AuthorizationRuleName: authorizationRuleName, + } +} + +// ParseTopicAuthorizationRuleID parses 'input' into a TopicAuthorizationRuleId +func ParseTopicAuthorizationRuleID(input string) (*TopicAuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicAuthorizationRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicAuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseTopicAuthorizationRuleIDInsensitively parses 'input' case-insensitively into a TopicAuthorizationRuleId +// note: this method should only be used for API response data and not user input +func ParseTopicAuthorizationRuleIDInsensitively(input string) (*TopicAuthorizationRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(TopicAuthorizationRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := TopicAuthorizationRuleId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.NamespaceName, ok = parsed.Parsed["namespaceName"]; !ok { + return nil, fmt.Errorf("the segment 'namespaceName' was not found in the resource id %q", input) + } + + if id.TopicName, ok = parsed.Parsed["topicName"]; !ok { + return nil, fmt.Errorf("the segment 'topicName' was not found in the resource id %q", input) + } + + if id.AuthorizationRuleName, ok = parsed.Parsed["authorizationRuleName"]; !ok { + return nil, fmt.Errorf("the segment 'authorizationRuleName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateTopicAuthorizationRuleID checks that 'input' can be parsed as a Topic Authorization Rule ID +func ValidateTopicAuthorizationRuleID(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 := ParseTopicAuthorizationRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Topic Authorization Rule ID +func (id TopicAuthorizationRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceBus/namespaces/%s/topics/%s/authorizationRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NamespaceName, id.TopicName, id.AuthorizationRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Topic Authorization Rule ID +func (id TopicAuthorizationRuleId) 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("staticMicrosoftServiceBus", "Microsoft.ServiceBus", "Microsoft.ServiceBus"), + resourceids.StaticSegment("staticNamespaces", "namespaces", "namespaces"), + resourceids.UserSpecifiedSegment("namespaceName", "namespaceValue"), + resourceids.StaticSegment("staticTopics", "topics", "topics"), + resourceids.UserSpecifiedSegment("topicName", "topicValue"), + resourceids.StaticSegment("staticAuthorizationRules", "authorizationRules", "authorizationRules"), + resourceids.UserSpecifiedSegment("authorizationRuleName", "authorizationRuleValue"), + } +} + +// String returns a human-readable description of this Topic Authorization Rule ID +func (id TopicAuthorizationRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Namespace Name: %q", id.NamespaceName), + fmt.Sprintf("Topic Name: %q", id.TopicName), + fmt.Sprintf("Authorization Rule Name: %q", id.AuthorizationRuleName), + } + return fmt.Sprintf("Topic Authorization Rule (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicscreateorupdateauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicscreateorupdateauthorizationrule_autorest.go new file mode 100644 index 000000000000..e3feda073643 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicscreateorupdateauthorizationrule_autorest.go @@ -0,0 +1,68 @@ +package topicsauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsCreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// TopicsCreateOrUpdateAuthorizationRule ... +func (c TopicsAuthorizationRuleClient) TopicsCreateOrUpdateAuthorizationRule(ctx context.Context, id TopicAuthorizationRuleId, input SBAuthorizationRule) (result TopicsCreateOrUpdateAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForTopicsCreateOrUpdateAuthorizationRule(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsCreateOrUpdateAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsCreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTopicsCreateOrUpdateAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsCreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTopicsCreateOrUpdateAuthorizationRule prepares the TopicsCreateOrUpdateAuthorizationRule request. +func (c TopicsAuthorizationRuleClient) preparerForTopicsCreateOrUpdateAuthorizationRule(ctx context.Context, id TopicAuthorizationRuleId, input SBAuthorizationRule) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTopicsCreateOrUpdateAuthorizationRule handles the response to the TopicsCreateOrUpdateAuthorizationRule request. The method always +// closes the http.Response Body. +func (c TopicsAuthorizationRuleClient) responderForTopicsCreateOrUpdateAuthorizationRule(resp *http.Response) (result TopicsCreateOrUpdateAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsdeleteauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsdeleteauthorizationrule_autorest.go new file mode 100644 index 000000000000..7368dc04b0b9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsdeleteauthorizationrule_autorest.go @@ -0,0 +1,65 @@ +package topicsauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsDeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response +} + +// TopicsDeleteAuthorizationRule ... +func (c TopicsAuthorizationRuleClient) TopicsDeleteAuthorizationRule(ctx context.Context, id TopicAuthorizationRuleId) (result TopicsDeleteAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForTopicsDeleteAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsDeleteAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsDeleteAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTopicsDeleteAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsDeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTopicsDeleteAuthorizationRule prepares the TopicsDeleteAuthorizationRule request. +func (c TopicsAuthorizationRuleClient) preparerForTopicsDeleteAuthorizationRule(ctx context.Context, id TopicAuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTopicsDeleteAuthorizationRule handles the response to the TopicsDeleteAuthorizationRule request. The method always +// closes the http.Response Body. +func (c TopicsAuthorizationRuleClient) responderForTopicsDeleteAuthorizationRule(resp *http.Response) (result TopicsDeleteAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsgetauthorizationrule_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsgetauthorizationrule_autorest.go new file mode 100644 index 000000000000..f55209f3388a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsgetauthorizationrule_autorest.go @@ -0,0 +1,67 @@ +package topicsauthorizationrule + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsGetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + Model *SBAuthorizationRule +} + +// TopicsGetAuthorizationRule ... +func (c TopicsAuthorizationRuleClient) TopicsGetAuthorizationRule(ctx context.Context, id TopicAuthorizationRuleId) (result TopicsGetAuthorizationRuleOperationResponse, err error) { + req, err := c.preparerForTopicsGetAuthorizationRule(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsGetAuthorizationRule", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsGetAuthorizationRule", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTopicsGetAuthorizationRule(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsGetAuthorizationRule", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTopicsGetAuthorizationRule prepares the TopicsGetAuthorizationRule request. +func (c TopicsAuthorizationRuleClient) preparerForTopicsGetAuthorizationRule(ctx context.Context, id TopicAuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTopicsGetAuthorizationRule handles the response to the TopicsGetAuthorizationRule request. The method always +// closes the http.Response Body. +func (c TopicsAuthorizationRuleClient) responderForTopicsGetAuthorizationRule(resp *http.Response) (result TopicsGetAuthorizationRuleOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicslistauthorizationrules_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicslistauthorizationrules_autorest.go new file mode 100644 index 000000000000..23dad36ef651 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicslistauthorizationrules_autorest.go @@ -0,0 +1,186 @@ +package topicsauthorizationrule + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + Model *[]SBAuthorizationRule + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (TopicsListAuthorizationRulesOperationResponse, error) +} + +type TopicsListAuthorizationRulesCompleteResult struct { + Items []SBAuthorizationRule +} + +func (r TopicsListAuthorizationRulesOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r TopicsListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp TopicsListAuthorizationRulesOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// TopicsListAuthorizationRules ... +func (c TopicsAuthorizationRuleClient) TopicsListAuthorizationRules(ctx context.Context, id TopicId) (resp TopicsListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForTopicsListAuthorizationRules(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListAuthorizationRules", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListAuthorizationRules", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForTopicsListAuthorizationRules(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListAuthorizationRules", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// TopicsListAuthorizationRulesComplete retrieves all of the results into a single object +func (c TopicsAuthorizationRuleClient) TopicsListAuthorizationRulesComplete(ctx context.Context, id TopicId) (TopicsListAuthorizationRulesCompleteResult, error) { + return c.TopicsListAuthorizationRulesCompleteMatchingPredicate(ctx, id, SBAuthorizationRuleOperationPredicate{}) +} + +// TopicsListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c TopicsAuthorizationRuleClient) TopicsListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id TopicId, predicate SBAuthorizationRuleOperationPredicate) (resp TopicsListAuthorizationRulesCompleteResult, err error) { + items := make([]SBAuthorizationRule, 0) + + page, err := c.TopicsListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := TopicsListAuthorizationRulesCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForTopicsListAuthorizationRules prepares the TopicsListAuthorizationRules request. +func (c TopicsAuthorizationRuleClient) preparerForTopicsListAuthorizationRules(ctx context.Context, id TopicId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForTopicsListAuthorizationRulesWithNextLink prepares the TopicsListAuthorizationRules request with the given nextLink token. +func (c TopicsAuthorizationRuleClient) preparerForTopicsListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTopicsListAuthorizationRules handles the response to the TopicsListAuthorizationRules request. The method always +// closes the http.Response Body. +func (c TopicsAuthorizationRuleClient) responderForTopicsListAuthorizationRules(resp *http.Response) (result TopicsListAuthorizationRulesOperationResponse, err error) { + type page struct { + Values []SBAuthorizationRule `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result TopicsListAuthorizationRulesOperationResponse, err error) { + req, err := c.preparerForTopicsListAuthorizationRulesWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListAuthorizationRules", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListAuthorizationRules", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTopicsListAuthorizationRules(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListAuthorizationRules", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicslistkeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicslistkeys_autorest.go new file mode 100644 index 000000000000..3b9921636828 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicslistkeys_autorest.go @@ -0,0 +1,68 @@ +package topicsauthorizationrule + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsListKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// TopicsListKeys ... +func (c TopicsAuthorizationRuleClient) TopicsListKeys(ctx context.Context, id TopicAuthorizationRuleId) (result TopicsListKeysOperationResponse, err error) { + req, err := c.preparerForTopicsListKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTopicsListKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsListKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTopicsListKeys prepares the TopicsListKeys request. +func (c TopicsAuthorizationRuleClient) preparerForTopicsListKeys(ctx context.Context, id TopicAuthorizationRuleId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTopicsListKeys handles the response to the TopicsListKeys request. The method always +// closes the http.Response Body. +func (c TopicsAuthorizationRuleClient) responderForTopicsListKeys(resp *http.Response) (result TopicsListKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsregeneratekeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsregeneratekeys_autorest.go new file mode 100644 index 000000000000..16508044d8bf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/method_topicsregeneratekeys_autorest.go @@ -0,0 +1,69 @@ +package topicsauthorizationrule + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopicsRegenerateKeysOperationResponse struct { + HttpResponse *http.Response + Model *AccessKeys +} + +// TopicsRegenerateKeys ... +func (c TopicsAuthorizationRuleClient) TopicsRegenerateKeys(ctx context.Context, id TopicAuthorizationRuleId, input RegenerateAccessKeyParameters) (result TopicsRegenerateKeysOperationResponse, err error) { + req, err := c.preparerForTopicsRegenerateKeys(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsRegenerateKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsRegenerateKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTopicsRegenerateKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "topicsauthorizationrule.TopicsAuthorizationRuleClient", "TopicsRegenerateKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTopicsRegenerateKeys prepares the TopicsRegenerateKeys request. +func (c TopicsAuthorizationRuleClient) preparerForTopicsRegenerateKeys(ctx context.Context, id TopicAuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTopicsRegenerateKeys handles the response to the TopicsRegenerateKeys request. The method always +// closes the http.Response Body. +func (c TopicsAuthorizationRuleClient) responderForTopicsRegenerateKeys(resp *http.Response) (result TopicsRegenerateKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_accesskeys.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_accesskeys.go new file mode 100644 index 000000000000..88589044cc64 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_accesskeys.go @@ -0,0 +1,14 @@ +package topicsauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessKeys struct { + AliasPrimaryConnectionString *string `json:"aliasPrimaryConnectionString,omitempty"` + AliasSecondaryConnectionString *string `json:"aliasSecondaryConnectionString,omitempty"` + KeyName *string `json:"keyName,omitempty"` + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_regenerateaccesskeyparameters.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_regenerateaccesskeyparameters.go new file mode 100644 index 000000000000..30ff1e93bdb3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_regenerateaccesskeyparameters.go @@ -0,0 +1,9 @@ +package topicsauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateAccessKeyParameters struct { + Key *string `json:"key,omitempty"` + KeyType KeyType `json:"keyType"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_sbauthorizationrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_sbauthorizationrule.go new file mode 100644 index 000000000000..09528bbcee5d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_sbauthorizationrule.go @@ -0,0 +1,16 @@ +package topicsauthorizationrule + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SBAuthorizationRuleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_sbauthorizationruleproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_sbauthorizationruleproperties.go new file mode 100644 index 000000000000..eb1e1b6eeabb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/model_sbauthorizationruleproperties.go @@ -0,0 +1,8 @@ +package topicsauthorizationrule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SBAuthorizationRuleProperties struct { + Rights []AccessRights `json:"rights"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/predicates.go new file mode 100644 index 000000000000..0d5880d8427b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/predicates.go @@ -0,0 +1,24 @@ +package topicsauthorizationrule + +type SBAuthorizationRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SBAuthorizationRuleOperationPredicate) Matches(input SBAuthorizationRule) 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/servicebus/2021-06-01-preview/topicsauthorizationrule/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/version.go new file mode 100644 index 000000000000..744b13fb7f30 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule/version.go @@ -0,0 +1,12 @@ +package topicsauthorizationrule + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/topicsauthorizationrule/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 085c18ef82e2..c58333770961 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -64,7 +64,6 @@ github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2019-06-01-pre github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2021-06-01-preview/policy github.com/Azure/azure-sdk-for-go/services/preview/security/mgmt/v3.0/security github.com/Azure/azure-sdk-for-go/services/preview/securityinsight/mgmt/2021-09-01-preview/securityinsight -github.com/Azure/azure-sdk-for-go/services/preview/servicebus/mgmt/2021-06-01-preview/servicebus github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2018-06-01-preview/sql github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql @@ -261,6 +260,15 @@ github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/namespaces github.com/hashicorp/go-azure-sdk/resource-manager/search/2020-03-13/adminkeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2020-03-13/querykeys github.com/hashicorp/go-azure-sdk/resource-manager/search/2020-03-13/services +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespaces +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/namespacesauthorizationrule +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queuesauthorizationrule +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/rules +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics +github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topicsauthorizationrule github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/managedcluster github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2021-05-01/nodetype github.com/hashicorp/go-azure-sdk/resource-manager/signalr/2022-02-01/signalr