From 689911d862e79503c7de95dc565482cc82bf04a6 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Sat, 30 Jan 2021 12:54:32 -0300 Subject: [PATCH 01/14] adding purview account resource --- azurerm/internal/clients/client.go | 3 + .../services/purview/client/client.go | 19 ++ .../services/purview/parse/account.go | 69 +++++ .../services/purview/parse/account_test.go | 112 ++++++++ .../purview/purview_account_resource.go | 239 ++++++++++++++++++ .../internal/services/purview/registration.go | 31 +++ .../internal/services/purview/resourceids.go | 3 + .../services/purview/validate/account_id.go | 23 ++ .../purview/validate/account_id_test.go | 76 ++++++ .../services/purview/validate/account_name.go | 14 + 10 files changed, 589 insertions(+) create mode 100644 azurerm/internal/services/purview/client/client.go create mode 100644 azurerm/internal/services/purview/parse/account.go create mode 100644 azurerm/internal/services/purview/parse/account_test.go create mode 100644 azurerm/internal/services/purview/purview_account_resource.go create mode 100644 azurerm/internal/services/purview/registration.go create mode 100644 azurerm/internal/services/purview/resourceids.go create mode 100644 azurerm/internal/services/purview/validate/account_id.go create mode 100644 azurerm/internal/services/purview/validate/account_id_test.go create mode 100644 azurerm/internal/services/purview/validate/account_name.go diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index 6fd55d78d53e..a23f7b4d523a 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -73,6 +73,7 @@ import ( postgres "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/postgres/client" powerBI "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/powerbi/client" privatedns "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/privatedns/client" + purview "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/purview/client" recoveryServices "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/recoveryservices/client" redis "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/redis/client" relay "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/relay/client" @@ -168,6 +169,7 @@ type Client struct { Postgres *postgres.Client PowerBI *powerBI.Client PrivateDns *privatedns.Client + Purview *purview.Client RecoveryServices *recoveryServices.Client Redis *redis.Client Relay *relay.Client @@ -265,6 +267,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.Postgres = postgres.NewClient(o) client.PowerBI = powerBI.NewClient(o) client.PrivateDns = privatedns.NewClient(o) + client.Purview = purview.NewClient(o) client.RecoveryServices = recoveryServices.NewClient(o) client.Redis = redis.NewClient(o) client.Relay = relay.NewClient(o) diff --git a/azurerm/internal/services/purview/client/client.go b/azurerm/internal/services/purview/client/client.go new file mode 100644 index 000000000000..a2ca4f8aa9ab --- /dev/null +++ b/azurerm/internal/services/purview/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" +) + +type Client struct { + AccountsClient *purview.AccountsClient +} + +func NewClient(o *common.ClientOptions) *Client { + accountsClient := purview.NewAccountsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&accountsClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + AccountsClient: &accountsClient, + } +} diff --git a/azurerm/internal/services/purview/parse/account.go b/azurerm/internal/services/purview/parse/account.go new file mode 100644 index 000000000000..e435a1776820 --- /dev/null +++ b/azurerm/internal/services/purview/parse/account.go @@ -0,0 +1,69 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type AccountId struct { + SubscriptionId string + ResourceGroup string + Name string +} + +func NewAccountID(subscriptionId, resourceGroup, name string) AccountId { + return AccountId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + Name: name, + } +} + +func (id AccountId) 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)", "Account", segmentsStr) +} + +func (id AccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Purview/accounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) +} + +// AccountID parses a Account ID into an AccountId struct +func AccountID(input string) (*AccountId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := AccountId{ + 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("accounts"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/azurerm/internal/services/purview/parse/account_test.go b/azurerm/internal/services/purview/parse/account_test.go new file mode 100644 index 000000000000..cd7ef9e7fe9e --- /dev/null +++ b/azurerm/internal/services/purview/parse/account_test.go @@ -0,0 +1,112 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/resourceid" +) + +var _ resourceid.Formatter = AccountId{} + +func TestAccountIDFormatter(t *testing.T) { + actual := NewAccountID("12345678-1234-9876-4563-123456789012", "resGroup1", "account1").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Purview/accounts/account1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestAccountID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccountId + }{ + + { + // 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.Purview/", + Error: true, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Purview/accounts/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Purview/accounts/account1", + Expected: &AccountId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "resGroup1", + Name: "account1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.PURVIEW/ACCOUNTS/ACCOUNT1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := AccountID(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/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go new file mode 100644 index 000000000000..b32a46cca47e --- /dev/null +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -0,0 +1,239 @@ +package purview + +import ( + "fmt" + "time" + + "github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview" + "github.com/hashicorp/go-azure-helpers/response" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/purview/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/purview/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourcePurviewAccount() *schema.Resource { + return &schema.Resource{ + Create: resourcePurviewAccountCreateUpdate, + Read: resourcePurviewAccountRead, + Update: resourcePurviewAccountCreateUpdate, + Delete: resourcePurviewAccountDelete, + + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(30 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.PurviewAccountName(), + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + "sku_capacity": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntInSlice([]int{ + 4, + 16, + }), + }, + + "public_network_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + + "identity": { + Type: schema.TypeList, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Computed: true, + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, + "tenant_id": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "tags": tags.Schema(), + }, + } +} + +func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Purview.AccountsClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + name := d.Get("name").(string) + location := azure.NormalizeLocation(d.Get("location").(string)) + resourceGroup := d.Get("resource_group_name").(string) + t := d.Get("tags").(map[string]interface{}) + + if d.IsNewResource() { + existing, err := client.Get(ctx, resourceGroup, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("Error checking for presence of existing Purview Account %q (Resource Group %q): %s", name, resourceGroup, err) + } + } + + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_purview_account", *existing.ID) + } + } + + account := purview.Account{ + AccountProperties: &purview.AccountProperties{}, + Identity: &purview.Identity{ + Type: purview.SystemAssigned, + }, + Location: &location, + Sku: &purview.AccountSku{ + Capacity: utils.Int32(d.Get("sku_capacity").(int32)), + Name: purview.Standard, + }, + Tags: tags.Expand(t), + } + + if d.Get("public_network_enabled").(bool) { + account.AccountProperties.PublicNetworkAccess = purview.Enabled + } else { + account.AccountProperties.PublicNetworkAccess = purview.Disabled + } + + if _, err := client.CreateOrUpdate(ctx, resourceGroup, name, account); err != nil { + return fmt.Errorf("Error creating/updating Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + resp, err := client.Get(ctx, resourceGroup, name) + if err != nil { + return fmt.Errorf("Error retrieving Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) + } + + if resp.ID == nil { + return fmt.Errorf("Cannot read Purview Account %q (Resource Group %q) ID", name, resourceGroup) + } + + d.SetId(*resp.ID) + + return resourcePurviewAccountRead(d, meta) +} + +func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Purview.AccountsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AccountID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + + return fmt.Errorf("Error retrieving Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("location", location.NormalizeNilable(resp.Location)) + + if sku := resp.Sku; sku != nil { + if err := d.Set("sku_capacity", *sku.Capacity); err != nil { + return fmt.Errorf("Error setting `sku_capacity`: %+v", err) + } + } + + if props := resp.AccountProperties; props != nil { + if err := d.Set("public_network_enabled", props.PublicNetworkAccess == purview.Enabled); err != nil { + return fmt.Errorf("Error setting `public_network_enabled`: %+v", err) + } + } + + if err := d.Set("identity", flattenPurviewAccountIdentity(resp.Identity)); err != nil { + return fmt.Errorf("Error flattening `identity`: %+v", err) + } + + return tags.FlattenAndSet(d, resp.Tags) +} + +func resourcePurviewAccountDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Purview.AccountsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.AccountID(d.Id()) + if err != nil { + return err + } + + future, err := client.Delete(ctx, id.ResourceGroup, id.Name) + + if err != nil { + return fmt.Errorf("Error deleting Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + if !response.WasNotFound(future.Response()) { + return fmt.Errorf("Error deleting Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + } + + return nil +} + +func flattenPurviewAccountIdentity(identity *purview.Identity) interface{} { + if identity == nil { + return make([]interface{}, 0) + } + + result := make(map[string]interface{}) + if identity.Type != "" { + result["type"] = identity.Type + } + if identity.PrincipalID != nil { + result["principal_id"] = *identity.PrincipalID + } + if identity.TenantID != nil { + result["tenant_id"] = *identity.TenantID + } + + return []interface{}{result} +} diff --git a/azurerm/internal/services/purview/registration.go b/azurerm/internal/services/purview/registration.go new file mode 100644 index 000000000000..100bb6117718 --- /dev/null +++ b/azurerm/internal/services/purview/registration.go @@ -0,0 +1,31 @@ +package purview + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +type Registration struct{} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Purview" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Purview", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*schema.Resource { + return map[string]*schema.Resource{} +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*schema.Resource { + return map[string]*schema.Resource{ + "azurerm_purview_account": resourcePurviewAccount(), + } +} diff --git a/azurerm/internal/services/purview/resourceids.go b/azurerm/internal/services/purview/resourceids.go new file mode 100644 index 000000000000..7e72a4eb176b --- /dev/null +++ b/azurerm/internal/services/purview/resourceids.go @@ -0,0 +1,3 @@ +package purview + +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Account -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Purview/accounts/account1 diff --git a/azurerm/internal/services/purview/validate/account_id.go b/azurerm/internal/services/purview/validate/account_id.go new file mode 100644 index 000000000000..b17745b64f4a --- /dev/null +++ b/azurerm/internal/services/purview/validate/account_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/purview/parse" +) + +func AccountID(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.AccountID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/azurerm/internal/services/purview/validate/account_id_test.go b/azurerm/internal/services/purview/validate/account_id_test.go new file mode 100644 index 000000000000..d7e9439b73cf --- /dev/null +++ b/azurerm/internal/services/purview/validate/account_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestAccountID(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.Purview/", + Valid: false, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Purview/accounts/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Purview/accounts/account1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.PURVIEW/ACCOUNTS/ACCOUNT1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := AccountID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/azurerm/internal/services/purview/validate/account_name.go b/azurerm/internal/services/purview/validate/account_name.go new file mode 100644 index 000000000000..f2b97ef74d46 --- /dev/null +++ b/azurerm/internal/services/purview/validate/account_name.go @@ -0,0 +1,14 @@ +package validate + +import ( + "regexp" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func PurviewAccountName() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile(`^[a-zA-Z0-9][-a-zA-Z0-9]{1,61}[a-zA-Z0-9]$`), + "The Purview account name must be between 3 and 63 characters long, it can contain only letters, numbers and hyphens, and the first and last characters must be a letter or number.") +} From c8207c16e99c7c21fed3720432b2e9edca846af3 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Sat, 30 Jan 2021 13:33:52 -0300 Subject: [PATCH 02/14] including computed fields for purview --- .../purview/purview_account_resource.go | 60 +++++++++++++++- .../services/purview/validate/account_name.go | 2 +- .../purview/validate/account_name_test.go | 68 +++++++++++++++++++ 3 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 azurerm/internal/services/purview/validate/account_name_test.go diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index b32a46cca47e..ee85aec5d62b 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -42,7 +42,7 @@ func resourcePurviewAccount() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.PurviewAccountName(), + ValidateFunc: validate.AccountName(), }, "resource_group_name": azure.SchemaResourceGroupName(), @@ -86,6 +86,33 @@ func resourcePurviewAccount() *schema.Resource { }, }, + "catalog_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "guardian_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "scan_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + + "atlas_kafka_endpoint_primary_connection_string": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + + "atlas_kafka_endpoint_secondary_connection_string": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + "tags": tags.Schema(), }, } @@ -181,14 +208,41 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error } } + if err := d.Set("identity", flattenPurviewAccountIdentity(resp.Identity)); err != nil { + return fmt.Errorf("Error flattening `identity`: %+v", err) + } + if props := resp.AccountProperties; props != nil { if err := d.Set("public_network_enabled", props.PublicNetworkAccess == purview.Enabled); err != nil { return fmt.Errorf("Error setting `public_network_enabled`: %+v", err) } + + if endpoints := resp.Endpoints; endpoints != nil { + if err := d.Set("catalog_endpoint", *endpoints.Catalog); err != nil { + return fmt.Errorf("Error setting `catalog_endpoint`: %+v", err) + } + if err := d.Set("guardian_endpoint", *endpoints.Guardian); err != nil { + return fmt.Errorf("Error setting `guardian_endpoint`: %+v", err) + } + if err := d.Set("scan_endpoint", *endpoints.Scan); err != nil { + return fmt.Errorf("Error setting `scan_endpoint`: %+v", err) + } + } } - if err := d.Set("identity", flattenPurviewAccountIdentity(resp.Identity)); err != nil { - return fmt.Errorf("Error flattening `identity`: %+v", err) + keys, err := client.ListKeys(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("Error retrieving Purview Account keys %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + if primary := keys.AtlasKafkaPrimaryEndpoint; primary != nil { + if err := d.Set("atlas_kafka_endpoint_primary_connection_string", *primary); err != nil { + return fmt.Errorf("Error setting `atlas_kafka_endpoint_primary_connection_string`: %+v", err) + } + } + if secondary := keys.AtlasKafkaSecondaryEndpoint; secondary != nil { + if err := d.Set("atlas_kafka_endpoint_secondary_connection_string", *secondary); err != nil { + return fmt.Errorf("Error setting `atlas_kafka_endpoint_secondary_connection_string`: %+v", err) + } } return tags.FlattenAndSet(d, resp.Tags) diff --git a/azurerm/internal/services/purview/validate/account_name.go b/azurerm/internal/services/purview/validate/account_name.go index f2b97ef74d46..19375c05e284 100644 --- a/azurerm/internal/services/purview/validate/account_name.go +++ b/azurerm/internal/services/purview/validate/account_name.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/validation" ) -func PurviewAccountName() schema.SchemaValidateFunc { +func AccountName() schema.SchemaValidateFunc { return validation.StringMatch( regexp.MustCompile(`^[a-zA-Z0-9][-a-zA-Z0-9]{1,61}[a-zA-Z0-9]$`), "The Purview account name must be between 3 and 63 characters long, it can contain only letters, numbers and hyphens, and the first and last characters must be a letter or number.") diff --git a/azurerm/internal/services/purview/validate/account_name_test.go b/azurerm/internal/services/purview/validate/account_name_test.go new file mode 100644 index 000000000000..a9226a9bfd24 --- /dev/null +++ b/azurerm/internal/services/purview/validate/account_name_test.go @@ -0,0 +1,68 @@ +package validate + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" +) + +func TestAccountName(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + { + Input: "", + Valid: false, + }, + { + Input: "a", + Valid: false, + }, + { + Input: "ab", + Valid: false, + }, + { + Input: "abc-", + Valid: false, + }, + { + Input: "-abc", + Valid: false, + }, + { + Input: acctest.RandString(64), + Valid: false, + }, + { + Input: "abc", + Valid: true, + }, + { + Input: "ABC", + Valid: true, + }, + { + Input: "1a3", + Valid: true, + }, + { + Input: "account-purview-01", + Valid: true, + }, + { + Input: acctest.RandString(63), + Valid: true, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := AccountName()(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} From 1658e517e36183d62c8f84dbabd26f0c42262785 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Sun, 31 Jan 2021 01:06:47 -0300 Subject: [PATCH 03/14] registering purview in services --- .teamcity/components/generated/services.kt | 1 + azurerm/internal/provider/services.go | 2 + .../purview/purview_account_resource.go | 9 +- .../purview/purview_account_resource_test.go | 85 +++++++++++++++++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 azurerm/internal/services/purview/purview_account_resource_test.go diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 0358f33ce913..d4cb03d22601 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -65,6 +65,7 @@ var services = mapOf( "postgres" to "PostgreSQL", "powerbi" to "PowerBI", "privatedns" to "Private DNS", + "purview" to "Purview", "recoveryservices" to "Recovery Services", "redis" to "Redis", "relay" to "Relay", diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index e6163f338390..bad0b492310f 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -68,6 +68,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/postgres" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/powerbi" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/privatedns" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/purview" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/recoveryservices" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/redis" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/relay" @@ -166,6 +167,7 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration { postgres.Registration{}, powerbi.Registration{}, privatedns.Registration{}, + purview.Registration{}, recoveryservices.Registration{}, redis.Registration{}, relay.Registration{}, diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index ee85aec5d62b..f0baec098e90 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -148,7 +148,7 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} }, Location: &location, Sku: &purview.AccountSku{ - Capacity: utils.Int32(d.Get("sku_capacity").(int32)), + Capacity: utils.Int32(int32(d.Get("sku_capacity").(int))), Name: purview.Standard, }, Tags: tags.Expand(t), @@ -160,10 +160,15 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} account.AccountProperties.PublicNetworkAccess = purview.Disabled } - if _, err := client.CreateOrUpdate(ctx, resourceGroup, name, account); err != nil { + future, err := client.CreateOrUpdate(ctx, resourceGroup, name, account) + if err != nil { return fmt.Errorf("Error creating/updating Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) } + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting creation of Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) + } + resp, err := client.Get(ctx, resourceGroup, name) if err != nil { return fmt.Errorf("Error retrieving Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) diff --git a/azurerm/internal/services/purview/purview_account_resource_test.go b/azurerm/internal/services/purview/purview_account_resource_test.go new file mode 100644 index 000000000000..896cd99de058 --- /dev/null +++ b/azurerm/internal/services/purview/purview_account_resource_test.go @@ -0,0 +1,85 @@ +package purview_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance/check" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/purview/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +type PurviewAccountResource struct{} + +func TestAccPurviewAccount_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_purview_account", "test") + r := PurviewAccountResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.basic(data), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("sku_capacity").HasValue("4"), + check.That(data.ResourceName).Key("public_network_enabled").HasValue("true"), + check.That(data.ResourceName).Key("identity.0.type").Exists(), + check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), + check.That(data.ResourceName).Key("identity.0.tenant_id").Exists(), + check.That(data.ResourceName).Key("catalog_endpoint").Exists(), + check.That(data.ResourceName).Key("guardian_endpoint").Exists(), + check.That(data.ResourceName).Key("scan_endpoint").Exists(), + check.That(data.ResourceName).Key("atlas_kafka_endpoint_primary_connection_string").Exists(), + check.That(data.ResourceName).Key("atlas_kafka_endpoint_secondary_connection_string").Exists(), + ), + }, + }) +} + +func (r PurviewAccountResource) Exists(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error) { + id, err := parse.AccountID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.Purview.AccountsClient.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + } + + return utils.Bool(true), nil +} + +func (r PurviewAccountResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +resource "azurerm_purview_account" "test" { + name = "acctestsw%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku_capacity = 4 +} +`, template, data.RandomInteger) +} + +func (r PurviewAccountResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-Purview-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} From 7e8debb2c092504ced531676e2810d637b2984c6 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Mon, 15 Feb 2021 10:02:39 -0300 Subject: [PATCH 04/14] vendor: purview --- .../2020-12-01-preview/purview/CHANGELOG.md | 5 + .../2020-12-01-preview/purview/accounts.go | 805 +++++++++ .../mgmt/2020-12-01-preview/purview/client.go | 52 + .../purview/defaultaccounts.go | 267 +++ .../mgmt/2020-12-01-preview/purview/enums.go | 139 ++ .../mgmt/2020-12-01-preview/purview/models.go | 1607 +++++++++++++++++ .../2020-12-01-preview/purview/operations.go | 151 ++ .../purview/privateendpointconnections.go | 416 +++++ .../purview/privatelinkresources.go | 239 +++ .../2020-12-01-preview/purview/version.go | 30 + vendor/modules.txt | 1 + 11 files changed, 3712 insertions(+) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/enums.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privatelinkresources.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/version.go diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md new file mode 100644 index 000000000000..653178fbe387 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md @@ -0,0 +1,5 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/138759b8a5987252fd66658078907e1d93969c85//specification/purview/resource-manager/readme.md tag: `package-2020-12-01-preview` + +Code generator @microsoft.azure/autorest.go@2.1.171 + + diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go new file mode 100644 index 000000000000..c7f3bdb62592 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go @@ -0,0 +1,805 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" +) + +// AccountsClient is the creates a Microsoft.Purview management client. +type AccountsClient struct { + BaseClient +} + +// NewAccountsClient creates an instance of the AccountsClient client. +func NewAccountsClient(subscriptionID string) AccountsClient { + return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountsClientWithBaseURI creates an instance of the AccountsClient 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 NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { + return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability checks if account name is available. +// Parameters: +// checkNameAvailabilityRequest - the check name availability request. +func (client AccountsClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest) (result CheckNameAvailabilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CheckNameAvailabilityPreparer(ctx, checkNameAvailabilityRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client AccountsClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/checkNameAvailability", pathParameters), + autorest.WithJSON(checkNameAvailabilityRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client AccountsClient) CheckNameAvailabilityResponder(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 an account +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// account - the account. +func (client AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, account Account) (result AccountsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, account) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "CreateOrUpdate", nil, "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, account Account) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}", pathParameters), + autorest.WithJSON(account), + 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 AccountsClient) CreateOrUpdateSender(req *http.Request) (future AccountsCreateOrUpdateFuture, err error) { + var resp *http.Response + 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 = func(client AccountsClient) (a Account, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("purview.AccountsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + a.Response.Response, err = future.GetResult(sender) + if a.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "purview.AccountsCreateOrUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.CreateOrUpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsCreateOrUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccountsClient) CreateOrUpdateResponder(resp *http.Response) (result Account, 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 account resource +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result AccountsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}", 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 AccountsClient) DeleteSender(req *http.Request) (future AccountsDeleteFuture, err error) { + var resp *http.Response + 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 = func(client AccountsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("purview.AccountsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccountsClient) 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 get an account +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}", 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 AccountsClient) 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 AccountsClient) GetResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup list accounts in ResourceGroup +// Parameters: +// resourceGroupName - the resource group name. +// skipToken - the skip token. +func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, skipToken string) (result AccountListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.al, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts", 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 AccountsClient) 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 AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountList, 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 AccountsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AccountList) (result AccountList, err error) { + req, err := lastResults.accountListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "purview.AccountsClient", "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, "purview.AccountsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, skipToken string) (result AccountListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.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, skipToken) + return +} + +// ListBySubscription list accounts in Subscription +// Parameters: +// skipToken - the skip token. +func (client AccountsClient) ListBySubscription(ctx context.Context, skipToken string) (result AccountListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListBySubscription") + defer func() { + sc := -1 + if result.al.Response.Response != nil { + sc = result.al.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.al.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.al, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.al.hasNextLink() && result.al.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AccountsClient) ListBySubscriptionPreparer(ctx context.Context, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Purview/accounts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListBySubscriptionResponder(resp *http.Response) (result AccountList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client AccountsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AccountList) (result AccountList, err error) { + req, err := lastResults.accountListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "purview.AccountsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "purview.AccountsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountsClient) ListBySubscriptionComplete(ctx context.Context, skipToken string) (result AccountListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListBySubscription") + 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.ListBySubscription(ctx, skipToken) + return +} + +// ListKeys list the authorization keys associated with this account. +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccessKeys, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListKeys") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListKeys", resp, "Failure sending request") + return + } + + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "ListKeys", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}/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 AccountsClient) 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 AccountsClient) 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 +} + +// Update updates an account +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// accountUpdateParameters - the account update parameters. +func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, accountUpdateParameters AccountUpdateParameters) (result AccountsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, accountUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsClient", "Update", nil, "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, accountUpdateParameters AccountUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}", pathParameters), + autorest.WithJSON(accountUpdateParameters), + 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 AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFuture, err error) { + var resp *http.Response + 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 = func(client AccountsClient) (a Account, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("purview.AccountsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + a.Response.Response, err = future.GetResult(sender) + if a.Response.Response == nil && err == nil { + err = autorest.NewErrorWithError(err, "purview.AccountsUpdateFuture", "Result", nil, "received nil response and error") + } + if err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.UpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.AccountsUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return + } + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, 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/purview/mgmt/2020-12-01-preview/purview/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/client.go new file mode 100644 index 000000000000..c7d917b25b87 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/client.go @@ -0,0 +1,52 @@ +// Package purview implements the Azure ARM Purview service API version 2020-12-01-preview. +// +// Creates a Microsoft.Purview management client. +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 Purview + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Purview. +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/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go new file mode 100644 index 000000000000..bb0ff561cd82 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go @@ -0,0 +1,267 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" + "github.com/satori/go.uuid" + "net/http" +) + +// DefaultAccountsClient is the creates a Microsoft.Purview management client. +type DefaultAccountsClient struct { + BaseClient +} + +// NewDefaultAccountsClient creates an instance of the DefaultAccountsClient client. +func NewDefaultAccountsClient(subscriptionID string) DefaultAccountsClient { + return NewDefaultAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDefaultAccountsClientWithBaseURI creates an instance of the DefaultAccountsClient 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 NewDefaultAccountsClientWithBaseURI(baseURI string, subscriptionID string) DefaultAccountsClient { + return DefaultAccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the default account for the scope. +// Parameters: +// scopeTenantID - the tenant ID. +// scopeType - the scope for the default account. +// scope - the Id of the scope object, for example if the scope is "Subscription" then it is the ID of that +// subscription. +func (client DefaultAccountsClient) Get(ctx context.Context, scopeTenantID uuid.UUID, scopeType ScopeType, scope string) (result DefaultAccountPayload, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DefaultAccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scopeTenantID, scopeType, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DefaultAccountsClient) GetPreparer(ctx context.Context, scopeTenantID uuid.UUID, scopeType ScopeType, scope string) (*http.Request, error) { + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "scopeTenantId": autorest.Encode("query", scopeTenantID), + "scopeType": autorest.Encode("query", scopeType), + } + if len(scope) > 0 { + queryParameters["scope"] = autorest.Encode("query", scope) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Purview/getDefaultAccount"), + 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 DefaultAccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DefaultAccountsClient) GetResponder(resp *http.Response) (result DefaultAccountPayload, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Remove remove the default account from the scope. +// Parameters: +// scopeTenantID - the tenant ID. +// scopeType - the scope for the default account. +// scope - the Id of the scope object, for example if the scope is "Subscription" then it is the ID of that +// subscription. +func (client DefaultAccountsClient) Remove(ctx context.Context, scopeTenantID uuid.UUID, scopeType ScopeType, scope string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DefaultAccountsClient.Remove") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.RemovePreparer(ctx, scopeTenantID, scopeType, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Remove", nil, "Failure preparing request") + return + } + + resp, err := client.RemoveSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Remove", resp, "Failure sending request") + return + } + + result, err = client.RemoveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Remove", resp, "Failure responding to request") + return + } + + return +} + +// RemovePreparer prepares the Remove request. +func (client DefaultAccountsClient) RemovePreparer(ctx context.Context, scopeTenantID uuid.UUID, scopeType ScopeType, scope string) (*http.Request, error) { + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "scopeTenantId": autorest.Encode("query", scopeTenantID), + "scopeType": autorest.Encode("query", scopeType), + } + if len(scope) > 0 { + queryParameters["scope"] = autorest.Encode("query", scope) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Purview/removeDefaultAccount"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RemoveSender sends the Remove request. The method will close the +// http.Response Body if it receives an error. +func (client DefaultAccountsClient) RemoveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// RemoveResponder handles the response to the Remove request. The method always +// closes the http.Response Body. +func (client DefaultAccountsClient) RemoveResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Set set the default account for the scope. +// Parameters: +// defaultAccountPayload - the payload containing the default account information and the scope. +func (client DefaultAccountsClient) Set(ctx context.Context, defaultAccountPayload DefaultAccountPayload) (result DefaultAccountPayload, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DefaultAccountsClient.Set") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.SetPreparer(ctx, defaultAccountPayload) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Set", nil, "Failure preparing request") + return + } + + resp, err := client.SetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Set", resp, "Failure sending request") + return + } + + result, err = client.SetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.DefaultAccountsClient", "Set", resp, "Failure responding to request") + return + } + + return +} + +// SetPreparer prepares the Set request. +func (client DefaultAccountsClient) SetPreparer(ctx context.Context, defaultAccountPayload DefaultAccountPayload) (*http.Request, error) { + const APIVersion = "2020-12-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.WithPath("/providers/Microsoft.Purview/setDefaultAccount"), + autorest.WithJSON(defaultAccountPayload), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SetSender sends the Set request. The method will close the +// http.Response Body if it receives an error. +func (client DefaultAccountsClient) SetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// SetResponder handles the response to the Set request. The method always +// closes the http.Response Body. +func (client DefaultAccountsClient) SetResponder(resp *http.Response) (result DefaultAccountPayload, 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/purview/mgmt/2020-12-01-preview/purview/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/enums.go new file mode 100644 index 000000000000..592a516f7642 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/enums.go @@ -0,0 +1,139 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// Name enumerates the values for name. +type Name string + +const ( + // Standard ... + Standard Name = "Standard" +) + +// PossibleNameValues returns an array of possible values for the Name const type. +func PossibleNameValues() []Name { + return []Name{Standard} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Moving ... + Moving ProvisioningState = "Moving" + // SoftDeleted ... + SoftDeleted ProvisioningState = "SoftDeleted" + // SoftDeleting ... + SoftDeleting ProvisioningState = "SoftDeleting" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Unknown ... + Unknown ProvisioningState = "Unknown" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Creating, Deleting, Failed, Moving, SoftDeleted, SoftDeleting, Succeeded, Unknown} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" + // NotSpecified ... + NotSpecified PublicNetworkAccess = "NotSpecified" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled, NotSpecified} +} + +// Reason enumerates the values for reason. +type Reason string + +const ( + // AlreadyExists ... + AlreadyExists Reason = "AlreadyExists" + // Invalid ... + Invalid Reason = "Invalid" +) + +// PossibleReasonValues returns an array of possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{AlreadyExists, Invalid} +} + +// ScopeType enumerates the values for scope type. +type ScopeType string + +const ( + // Subscription ... + Subscription ScopeType = "Subscription" + // Tenant ... + Tenant ScopeType = "Tenant" +) + +// PossibleScopeTypeValues returns an array of possible values for the ScopeType const type. +func PossibleScopeTypeValues() []ScopeType { + return []ScopeType{Subscription, Tenant} +} + +// Status enumerates the values for status. +type Status string + +const ( + // StatusApproved ... + StatusApproved Status = "Approved" + // StatusDisconnected ... + StatusDisconnected Status = "Disconnected" + // StatusPending ... + StatusPending Status = "Pending" + // StatusRejected ... + StatusRejected Status = "Rejected" + // StatusUnknown ... + StatusUnknown Status = "Unknown" +) + +// PossibleStatusValues returns an array of possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{StatusApproved, StatusDisconnected, StatusPending, StatusRejected, StatusUnknown} +} + +// Type enumerates the values for type. +type Type string + +const ( + // SystemAssigned ... + SystemAssigned Type = "SystemAssigned" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{SystemAssigned} +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/models.go new file mode 100644 index 000000000000..570c6202a314 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/models.go @@ -0,0 +1,1607 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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/purview/mgmt/2020-12-01-preview/purview" + +// AccessKeys the Account access keys. +type AccessKeys struct { + autorest.Response `json:"-"` + // AtlasKafkaPrimaryEndpoint - Gets or sets the primary connection string. + AtlasKafkaPrimaryEndpoint *string `json:"atlasKafkaPrimaryEndpoint,omitempty"` + // AtlasKafkaSecondaryEndpoint - Gets or sets the secondary connection string. + AtlasKafkaSecondaryEndpoint *string `json:"atlasKafkaSecondaryEndpoint,omitempty"` +} + +// Account account resource +type Account struct { + autorest.Response `json:"-"` + // AccountProperties - Gets or sets the properties. + *AccountProperties `json:"properties,omitempty"` + // Sku - Gets or sets the Sku. + Sku *AccountSku `json:"sku,omitempty"` + // ID - READ-ONLY; Gets or sets the identifier. + ID *string `json:"id,omitempty"` + // Identity - Identity Info on the tracked resource + Identity *Identity `json:"identity,omitempty"` + // Location - Gets or sets the location. + Location *string `json:"location,omitempty"` + // Name - READ-ONLY; Gets or sets the name. + Name *string `json:"name,omitempty"` + // Tags - Tags on the azure resource. + Tags map[string]*string `json:"tags"` + // Type - READ-ONLY; Gets or sets the type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AccountProperties != nil { + objectMap["properties"] = a.AccountProperties + } + if a.Sku != nil { + objectMap["sku"] = a.Sku + } + if a.Identity != nil { + objectMap["identity"] = a.Identity + } + if a.Location != nil { + objectMap["location"] = a.Location + } + if a.Tags != nil { + objectMap["tags"] = a.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Account struct. +func (a *Account) 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 accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + a.AccountProperties = &accountProperties + } + case "sku": + if v != nil { + var sku AccountSku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + a.Sku = &sku + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + a.Identity = &identity + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + a.Location = &location + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AccountEndpoints the account endpoints +type AccountEndpoints struct { + // Catalog - READ-ONLY; Gets the catalog endpoint. + Catalog *string `json:"catalog,omitempty"` + // Guardian - READ-ONLY; Gets the guardian endpoint. + Guardian *string `json:"guardian,omitempty"` + // Scan - READ-ONLY; Gets the scan endpoint. + Scan *string `json:"scan,omitempty"` +} + +// AccountList paged list of account resources +type AccountList struct { + autorest.Response `json:"-"` + // Count - Total item count. + Count *int64 `json:"count,omitempty"` + // NextLink - The Url of next result page. + NextLink *string `json:"nextLink,omitempty"` + // Value - Collection of items of type results. + Value *[]Account `json:"value,omitempty"` +} + +// AccountListIterator provides access to a complete listing of Account values. +type AccountListIterator struct { + i int + page AccountListPage +} + +// 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 *AccountListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountListIterator.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 *AccountListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccountListIterator) 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 AccountListIterator) Response() AccountList { + 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 AccountListIterator) Value() Account { + if !iter.page.NotDone() { + return Account{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AccountListIterator type. +func NewAccountListIterator(page AccountListPage) AccountListIterator { + return AccountListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (al AccountList) IsEmpty() bool { + return al.Value == nil || len(*al.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (al AccountList) hasNextLink() bool { + return al.NextLink != nil && len(*al.NextLink) != 0 +} + +// accountListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (al AccountList) accountListPreparer(ctx context.Context) (*http.Request, error) { + if !al.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(al.NextLink))) +} + +// AccountListPage contains a page of Account values. +type AccountListPage struct { + fn func(context.Context, AccountList) (AccountList, error) + al AccountList +} + +// 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 *AccountListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountListPage.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.al) + if err != nil { + return err + } + page.al = 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 *AccountListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccountListPage) NotDone() bool { + return !page.al.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccountListPage) Response() AccountList { + return page.al +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccountListPage) Values() []Account { + if page.al.IsEmpty() { + return nil + } + return *page.al.Value +} + +// Creates a new instance of the AccountListPage type. +func NewAccountListPage(cur AccountList, getNextPage func(context.Context, AccountList) (AccountList, error)) AccountListPage { + return AccountListPage{ + fn: getNextPage, + al: cur, + } +} + +// AccountProperties the account properties +type AccountProperties struct { + // CloudConnectors - Cloud connectors. + // External cloud identifier used as part of scanning configuration. + CloudConnectors *CloudConnectors `json:"cloudConnectors,omitempty"` + // CreatedAt - READ-ONLY; Gets the time at which the entity was created. + CreatedAt *date.Time `json:"createdAt,omitempty"` + // CreatedBy - READ-ONLY; Gets the creator of the entity. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByObjectID - READ-ONLY; Gets the creators of the entity's object id. + CreatedByObjectID *string `json:"createdByObjectId,omitempty"` + // Endpoints - READ-ONLY; The URIs that are the public endpoints of the account. + Endpoints *AccountPropertiesEndpoints `json:"endpoints,omitempty"` + // FriendlyName - READ-ONLY; Gets or sets the friendly name. + FriendlyName *string `json:"friendlyName,omitempty"` + // ManagedResources - READ-ONLY; Gets the resource identifiers of the managed resources. + ManagedResources *AccountPropertiesManagedResources `json:"managedResources,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Gets the private endpoint connections information. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // ProvisioningState - READ-ONLY; Gets or sets the state of the provisioning. Possible values include: 'Unknown', 'Creating', 'Moving', 'Deleting', 'SoftDeleting', 'SoftDeleted', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // PublicNetworkAccess - Gets or sets the public network access. Possible values include: 'NotSpecified', 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountProperties. +func (ap AccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ap.CloudConnectors != nil { + objectMap["cloudConnectors"] = ap.CloudConnectors + } + if ap.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = ap.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// AccountPropertiesEndpoints the URIs that are the public endpoints of the account. +type AccountPropertiesEndpoints struct { + // Catalog - READ-ONLY; Gets the catalog endpoint. + Catalog *string `json:"catalog,omitempty"` + // Guardian - READ-ONLY; Gets the guardian endpoint. + Guardian *string `json:"guardian,omitempty"` + // Scan - READ-ONLY; Gets the scan endpoint. + Scan *string `json:"scan,omitempty"` +} + +// AccountPropertiesManagedResources gets the resource identifiers of the managed resources. +type AccountPropertiesManagedResources struct { + // EventHubNamespace - READ-ONLY; Gets the managed event hub namespace resource identifier. + EventHubNamespace *string `json:"eventHubNamespace,omitempty"` + // ResourceGroup - READ-ONLY; Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // StorageAccount - READ-ONLY; Gets the managed storage account resource identifier. + StorageAccount *string `json:"storageAccount,omitempty"` +} + +// AccountsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountsClient) (Account, error) +} + +// AccountsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountsClient) (autorest.Response, error) +} + +// AccountSku the Sku +type AccountSku struct { + // Capacity - Gets or sets the sku capacity. Possible values include: 4, 16 + Capacity *int32 `json:"capacity,omitempty"` + // Name - Gets or sets the sku name. Possible values include: 'Standard' + Name Name `json:"name,omitempty"` +} + +// AccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(AccountsClient) (Account, error) +} + +// AccountUpdateParameters the account update properties. +type AccountUpdateParameters struct { + // AccountProperties - The account properties. + *AccountProperties `json:"properties,omitempty"` + // Tags - Tags on the azure resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for AccountUpdateParameters. +func (aup AccountUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aup.AccountProperties != nil { + objectMap["properties"] = aup.AccountProperties + } + if aup.Tags != nil { + objectMap["tags"] = aup.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountUpdateParameters struct. +func (aup *AccountUpdateParameters) 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 accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + aup.AccountProperties = &accountProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + aup.Tags = tags + } + } + } + + return nil +} + +// CheckNameAvailabilityRequest the request payload for CheckNameAvailability API +type CheckNameAvailabilityRequest struct { + // Name - Resource name to verify for availability + Name *string `json:"name,omitempty"` + // Type - Fully qualified resource type which includes provider namespace + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResult the response payload for CheckNameAvailability API +type CheckNameAvailabilityResult struct { + autorest.Response `json:"-"` + // Message - Error message + Message *string `json:"message,omitempty"` + // NameAvailable - Indicates if name is valid and available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - The reason the name is not available. Possible values include: 'Invalid', 'AlreadyExists' + Reason Reason `json:"reason,omitempty"` +} + +// CloudConnectors properties for configuring third party cloud connections. +type CloudConnectors struct { + // AwsExternalID - READ-ONLY; AWS external identifier. + // Configured in AWS to allow use of the role arn used for scanning + AwsExternalID *string `json:"awsExternalId,omitempty"` +} + +// DefaultAccountPayload payload to get and set the default account in the given scope +type DefaultAccountPayload struct { + autorest.Response `json:"-"` + // AccountName - The name of the account that is set as the default. + AccountName *string `json:"accountName,omitempty"` + // ResourceGroupName - The resource group name of the account that is set as the default. + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // Scope - The scope object ID. For example, sub ID or tenant ID. + Scope *string `json:"scope,omitempty"` + // ScopeTenantID - The scope tenant in which the default account is set. + ScopeTenantID *string `json:"scopeTenantId,omitempty"` + // ScopeType - The scope where the default account is set. Possible values include: 'Tenant', 'Subscription' + ScopeType ScopeType `json:"scopeType,omitempty"` + // SubscriptionID - The subscription ID of the account that is set as the default. + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// DeletedAccount soft Deleted Account resource +type DeletedAccount struct { + // DeletedAccountProperties - READ-ONLY; Gets or sets the properties. + *DeletedAccountProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Gets or sets the identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Gets or sets the name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Gets or sets the type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeletedAccount. +func (da DeletedAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DeletedAccount struct. +func (da *DeletedAccount) 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 deletedAccountProperties DeletedAccountProperties + err = json.Unmarshal(*v, &deletedAccountProperties) + if err != nil { + return err + } + da.DeletedAccountProperties = &deletedAccountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + da.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + da.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + da.Type = &typeVar + } + } + } + + return nil +} + +// DeletedAccountList paged list of soft deleted account resources +type DeletedAccountList struct { + // Count - Total item count. + Count *int64 `json:"count,omitempty"` + // NextLink - The Url of next result page. + NextLink *string `json:"nextLink,omitempty"` + // Value - Collection of items of type results. + Value *[]DeletedAccount `json:"value,omitempty"` +} + +// DeletedAccountProperties gets or sets the properties. +type DeletedAccountProperties struct { + // AccountID - READ-ONLY; Gets the account identifier associated with resource. + AccountID *string `json:"accountId,omitempty"` + // DeletedBy - READ-ONLY; Gets the user identifier that deleted resource. + DeletedBy *string `json:"deletedBy,omitempty"` + // DeletionDate - READ-ONLY; Gets the time at which the resource was soft deleted. + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // Location - READ-ONLY; Gets the resource location. + Location *string `json:"location,omitempty"` + // ScheduledPurgeDate - READ-ONLY; Gets the scheduled purge datetime. + ScheduledPurgeDate *date.Time `json:"scheduledPurgeDate,omitempty"` + // Tags - READ-ONLY; Gets the account tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DeletedAccountProperties. +func (da DeletedAccountProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DeletedAccountPropertiesModel the soft deleted account properties +type DeletedAccountPropertiesModel struct { + // AccountID - READ-ONLY; Gets the account identifier associated with resource. + AccountID *string `json:"accountId,omitempty"` + // DeletedBy - READ-ONLY; Gets the user identifier that deleted resource. + DeletedBy *string `json:"deletedBy,omitempty"` + // DeletionDate - READ-ONLY; Gets the time at which the resource was soft deleted. + DeletionDate *date.Time `json:"deletionDate,omitempty"` + // Location - READ-ONLY; Gets the resource location. + Location *string `json:"location,omitempty"` + // ScheduledPurgeDate - READ-ONLY; Gets the scheduled purge datetime. + ScheduledPurgeDate *date.Time `json:"scheduledPurgeDate,omitempty"` + // Tags - READ-ONLY; Gets the account tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for DeletedAccountPropertiesModel. +func (dapm DeletedAccountPropertiesModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DimensionProperties properties for dimension +type DimensionProperties struct { + // DisplayName - localized display name of the dimension to customer + DisplayName *string `json:"displayName,omitempty"` + // Name - dimension name + Name *string `json:"name,omitempty"` + // ToBeExportedForCustomer - flag indicating whether this dimension should be included to the customer in Azure Monitor logs (aka Shoebox) + ToBeExportedForCustomer *bool `json:"toBeExportedForCustomer,omitempty"` +} + +// ErrorModel default error model +type ErrorModel struct { + // Code - READ-ONLY; Gets or sets the code. + Code *string `json:"code,omitempty"` + // Details - READ-ONLY; Gets or sets the details. + Details *[]ErrorModel `json:"details,omitempty"` + // Message - READ-ONLY; Gets or sets the messages. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; Gets or sets the target. + Target *string `json:"target,omitempty"` +} + +// ErrorResponseModel default error response model +type ErrorResponseModel struct { + // Error - READ-ONLY; Gets or sets the error. + Error *ErrorResponseModelError `json:"error,omitempty"` +} + +// ErrorResponseModelError gets or sets the error. +type ErrorResponseModelError struct { + // Code - READ-ONLY; Gets or sets the code. + Code *string `json:"code,omitempty"` + // Details - READ-ONLY; Gets or sets the details. + Details *[]ErrorModel `json:"details,omitempty"` + // Message - READ-ONLY; Gets or sets the messages. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; Gets or sets the target. + Target *string `json:"target,omitempty"` +} + +// Identity the Managed Identity of the resource +type Identity struct { + // PrincipalID - READ-ONLY; Service principal object Id + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; Tenant Id + TenantID *string `json:"tenantId,omitempty"` + // Type - Identity Type. Possible values include: 'SystemAssigned' + Type Type `json:"type,omitempty"` +} + +// 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 + } + return json.Marshal(objectMap) +} + +// ManagedResources the managed resources in customer subscription. +type ManagedResources struct { + // EventHubNamespace - READ-ONLY; Gets the managed event hub namespace resource identifier. + EventHubNamespace *string `json:"eventHubNamespace,omitempty"` + // ResourceGroup - READ-ONLY; Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // StorageAccount - READ-ONLY; Gets the managed storage account resource identifier. + StorageAccount *string `json:"storageAccount,omitempty"` +} + +// Operation operation resource +type Operation struct { + // Display - Properties on the operation + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Whether operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` + // Name - Operation name for display purposes + Name *string `json:"name,omitempty"` + // Origin - origin of the operation + Origin *string `json:"origin,omitempty"` + // OperationProperties - properties for the operation meta info + *OperationProperties `json:"properties,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 + } + if o.IsDataAction != nil { + objectMap["isDataAction"] = o.IsDataAction + } + if o.Name != nil { + objectMap["name"] = o.Name + } + if o.Origin != nil { + objectMap["origin"] = o.Origin + } + if o.OperationProperties != nil { + objectMap["properties"] = o.OperationProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Operation struct. +func (o *Operation) 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 "display": + if v != nil { + var display OperationDisplay + err = json.Unmarshal(*v, &display) + if err != nil { + return err + } + o.Display = &display + } + case "isDataAction": + if v != nil { + var isDataAction bool + err = json.Unmarshal(*v, &isDataAction) + if err != nil { + return err + } + o.IsDataAction = &isDataAction + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + o.Name = &name + } + case "origin": + if v != nil { + var origin string + err = json.Unmarshal(*v, &origin) + if err != nil { + return err + } + o.Origin = &origin + } + case "properties": + if v != nil { + var operationProperties OperationProperties + err = json.Unmarshal(*v, &operationProperties) + if err != nil { + return err + } + o.OperationProperties = &operationProperties + } + } + } + + return nil +} + +// OperationDisplay the response model for get operation properties +type OperationDisplay struct { + // Description - Description of the operation for display purposes + Description *string `json:"description,omitempty"` + // Operation - Name of the operation for display purposes + Operation *string `json:"operation,omitempty"` + // Provider - Name of the provider for display purposes + Provider *string `json:"provider,omitempty"` + // Resource - Name of the resource type for display purposes + Resource *string `json:"resource,omitempty"` +} + +// OperationList paged list of operation resources +type OperationList struct { + autorest.Response `json:"-"` + // Count - Total item count. + Count *int64 `json:"count,omitempty"` + // NextLink - The Url of next result page. + NextLink *string `json:"nextLink,omitempty"` + // Value - Collection of items of type results. + Value *[]Operation `json:"value,omitempty"` +} + +// OperationListIterator provides access to a complete listing of Operation values. +type OperationListIterator struct { + i int + page OperationListPage +} + +// 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 *OperationListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.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 *OperationListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListIterator) 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 OperationListIterator) Response() OperationList { + 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 OperationListIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListIterator type. +func NewOperationListIterator(page OperationListPage) OperationListIterator { + return OperationListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ol OperationList) IsEmpty() bool { + return ol.Value == nil || len(*ol.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ol OperationList) hasNextLink() bool { + return ol.NextLink != nil && len(*ol.NextLink) != 0 +} + +// operationListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { + if !ol.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ol.NextLink))) +} + +// OperationListPage contains a page of Operation values. +type OperationListPage struct { + fn func(context.Context, OperationList) (OperationList, error) + ol OperationList +} + +// 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 *OperationListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.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.ol) + if err != nil { + return err + } + page.ol = 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 *OperationListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListPage) NotDone() bool { + return !page.ol.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListPage) Response() OperationList { + return page.ol +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListPage) Values() []Operation { + if page.ol.IsEmpty() { + return nil + } + return *page.ol.Value +} + +// Creates a new instance of the OperationListPage type. +func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { + return OperationListPage{ + fn: getNextPage, + ol: cur, + } +} + +// OperationMetaLogSpecification log specifications for operation api +type OperationMetaLogSpecification struct { + // BlobDuration - blob duration of the log + BlobDuration *string `json:"blobDuration,omitempty"` + // DisplayName - localized name of the log category + DisplayName *string `json:"displayName,omitempty"` + // Name - name of the log category + Name *string `json:"name,omitempty"` +} + +// OperationMetaMetricSpecification metric specifications for the operation +type OperationMetaMetricSpecification struct { + // AggregationType - aggregation type of metric + AggregationType *string `json:"aggregationType,omitempty"` + // Dimensions - properties for dimension + Dimensions *[]DimensionProperties `json:"dimensions,omitempty"` + // DisplayDescription - description of the metric + DisplayDescription *string `json:"displayDescription,omitempty"` + // DisplayName - localized name of the metric + DisplayName *string `json:"displayName,omitempty"` + // EnableRegionalMdmAccount - enable regional mdm account + EnableRegionalMdmAccount *string `json:"enableRegionalMdmAccount,omitempty"` + // InternalMetricName - internal metric name + InternalMetricName *string `json:"internalMetricName,omitempty"` + // Name - name of the metric + Name *string `json:"name,omitempty"` + // ResourceIDDimensionNameOverride - dimension name use to replace resource id if specified + ResourceIDDimensionNameOverride *string `json:"resourceIdDimensionNameOverride,omitempty"` + // SourceMdmNamespace - Metric namespace. + // Only set the namespace if different from the default value, + // leaving it empty makes it use the value from the ARM manifest. + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty"` + // SupportedAggregationTypes - supported aggregation types + SupportedAggregationTypes *[]string `json:"supportedAggregationTypes,omitempty"` + // SupportedTimeGrainTypes - supported time grain types + SupportedTimeGrainTypes *[]string `json:"supportedTimeGrainTypes,omitempty"` + // Unit - units for the metric + Unit *string `json:"unit,omitempty"` +} + +// OperationMetaServiceSpecification the operation meta service specification +type OperationMetaServiceSpecification struct { + // LogSpecifications - log specifications for the operation + LogSpecifications *[]OperationMetaLogSpecification `json:"logSpecifications,omitempty"` + // MetricSpecifications - metric specifications for the operation + MetricSpecifications *[]OperationMetaMetricSpecification `json:"metricSpecifications,omitempty"` +} + +// OperationProperties properties on meta info +type OperationProperties struct { + // ServiceSpecification - meta service specification + ServiceSpecification *OperationMetaServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// PrivateEndpoint a private endpoint class. +type PrivateEndpoint struct { + // ID - The private endpoint identifier. + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection class. +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - The connection identifier. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Gets or sets the identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Gets or sets the name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Gets or sets the 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 "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 +} + +// PrivateEndpointConnectionList paged list of private endpoint connections +type PrivateEndpointConnectionList struct { + autorest.Response `json:"-"` + // Count - Total item count. + Count *int64 `json:"count,omitempty"` + // NextLink - The Url of next result page. + NextLink *string `json:"nextLink,omitempty"` + // Value - Collection of items of type results. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// PrivateEndpointConnectionListIterator provides access to a complete listing of PrivateEndpointConnection +// values. +type PrivateEndpointConnectionListIterator struct { + i int + page PrivateEndpointConnectionListPage +} + +// 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 *PrivateEndpointConnectionListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListIterator.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 *PrivateEndpointConnectionListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateEndpointConnectionListIterator) 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 PrivateEndpointConnectionListIterator) Response() PrivateEndpointConnectionList { + 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 PrivateEndpointConnectionListIterator) Value() PrivateEndpointConnection { + if !iter.page.NotDone() { + return PrivateEndpointConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateEndpointConnectionListIterator type. +func NewPrivateEndpointConnectionListIterator(page PrivateEndpointConnectionListPage) PrivateEndpointConnectionListIterator { + return PrivateEndpointConnectionListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (pecl PrivateEndpointConnectionList) IsEmpty() bool { + return pecl.Value == nil || len(*pecl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (pecl PrivateEndpointConnectionList) hasNextLink() bool { + return pecl.NextLink != nil && len(*pecl.NextLink) != 0 +} + +// privateEndpointConnectionListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (pecl PrivateEndpointConnectionList) privateEndpointConnectionListPreparer(ctx context.Context) (*http.Request, error) { + if !pecl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(pecl.NextLink))) +} + +// PrivateEndpointConnectionListPage contains a page of PrivateEndpointConnection values. +type PrivateEndpointConnectionListPage struct { + fn func(context.Context, PrivateEndpointConnectionList) (PrivateEndpointConnectionList, error) + pecl PrivateEndpointConnectionList +} + +// 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 *PrivateEndpointConnectionListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionListPage.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.pecl) + if err != nil { + return err + } + page.pecl = 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 *PrivateEndpointConnectionListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateEndpointConnectionListPage) NotDone() bool { + return !page.pecl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateEndpointConnectionListPage) Response() PrivateEndpointConnectionList { + return page.pecl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateEndpointConnectionListPage) Values() []PrivateEndpointConnection { + if page.pecl.IsEmpty() { + return nil + } + return *page.pecl.Value +} + +// Creates a new instance of the PrivateEndpointConnectionListPage type. +func NewPrivateEndpointConnectionListPage(cur PrivateEndpointConnectionList, getNextPage func(context.Context, PrivateEndpointConnectionList) (PrivateEndpointConnectionList, error)) PrivateEndpointConnectionListPage { + return PrivateEndpointConnectionListPage{ + fn: getNextPage, + pecl: cur, + } +} + +// PrivateEndpointConnectionProperties a private endpoint connection properties class. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The private endpoint information. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - The private link service connection state. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// 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) +} + +// PrivateLinkResource a privately linkable resource. +type PrivateLinkResource struct { + autorest.Response `json:"-"` + // PrivateLinkResourceProperties - READ-ONLY; The private link resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Gets or sets the identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Gets or sets the name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Gets or sets the type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 +} + +// PrivateLinkResourceList paged list of private link resources +type PrivateLinkResourceList struct { + autorest.Response `json:"-"` + // Count - Total item count. + Count *int64 `json:"count,omitempty"` + // NextLink - The Url of next result page. + NextLink *string `json:"nextLink,omitempty"` + // Value - Collection of items of type results. + Value *[]PrivateLinkResource `json:"value,omitempty"` +} + +// PrivateLinkResourceListIterator provides access to a complete listing of PrivateLinkResource values. +type PrivateLinkResourceListIterator struct { + i int + page PrivateLinkResourceListPage +} + +// 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 *PrivateLinkResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListIterator.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 *PrivateLinkResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListIterator) 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 PrivateLinkResourceListIterator) Response() PrivateLinkResourceList { + 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 PrivateLinkResourceListIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListIterator type. +func NewPrivateLinkResourceListIterator(page PrivateLinkResourceListPage) PrivateLinkResourceListIterator { + return PrivateLinkResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrl PrivateLinkResourceList) IsEmpty() bool { + return plrl.Value == nil || len(*plrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrl PrivateLinkResourceList) hasNextLink() bool { + return plrl.NextLink != nil && len(*plrl.NextLink) != 0 +} + +// privateLinkResourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrl PrivateLinkResourceList) privateLinkResourceListPreparer(ctx context.Context) (*http.Request, error) { + if !plrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrl.NextLink))) +} + +// PrivateLinkResourceListPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListPage struct { + fn func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error) + plrl PrivateLinkResourceList +} + +// 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 *PrivateLinkResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListPage.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.plrl) + if err != nil { + return err + } + page.plrl = 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 *PrivateLinkResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListPage) NotDone() bool { + return !page.plrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListPage) Response() PrivateLinkResourceList { + return page.plrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListPage) Values() []PrivateLinkResource { + if page.plrl.IsEmpty() { + return nil + } + return *page.plrl.Value +} + +// Creates a new instance of the PrivateLinkResourceListPage type. +func NewPrivateLinkResourceListPage(cur PrivateLinkResourceList, getNextPage func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error)) PrivateLinkResourceListPage { + return PrivateLinkResourceListPage{ + fn: getNextPage, + plrl: cur, + } +} + +// PrivateLinkResourceProperties a privately linkable resource properties. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group identifier. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; This translates to how many Private IPs should be created for each privately linkable resource. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - READ-ONLY; The required zone names for private link resource. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// PrivateLinkServiceConnectionState the private link service connection state. +type PrivateLinkServiceConnectionState struct { + // ActionsRequired - The required actions. + ActionsRequired *string `json:"actionsRequired,omitempty"` + // Description - The description. + Description *string `json:"description,omitempty"` + // Status - The status. Possible values include: 'StatusUnknown', 'StatusPending', 'StatusApproved', 'StatusRejected', 'StatusDisconnected' + Status Status `json:"status,omitempty"` +} + +// ProxyResource proxy Azure Resource +type ProxyResource struct { + // ID - READ-ONLY; Gets or sets the identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Gets or sets the name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Gets or sets the type. + Type *string `json:"type,omitempty"` +} + +// TrackedResource azure ARM Tracked Resource +type TrackedResource struct { + // ID - READ-ONLY; Gets or sets the identifier. + ID *string `json:"id,omitempty"` + // Identity - Identity Info on the tracked resource + Identity *Identity `json:"identity,omitempty"` + // Location - Gets or sets the location. + Location *string `json:"location,omitempty"` + // Name - READ-ONLY; Gets or sets the name. + Name *string `json:"name,omitempty"` + // Tags - Tags on the azure resource. + Tags map[string]*string `json:"tags"` + // Type - READ-ONLY; Gets or sets the 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.Identity != nil { + objectMap["identity"] = tr.Identity + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/operations.go new file mode 100644 index 000000000000..b2c470735430 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/operations.go @@ -0,0 +1,151 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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 creates a Microsoft.Purview management client. +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 list of available operations +func (client OperationsClient) List(ctx context.Context) (result OperationListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.ol.Response.Response != nil { + sc = result.ol.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ol.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.ol, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.ol.hasNextLink() && result.ol.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Purview/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 OperationList, 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 OperationList) (result OperationList, err error) { + req, err := lastResults.operationListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "purview.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, "purview.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.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 OperationListIterator, 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/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go new file mode 100644 index 000000000000..cfa1abf323d1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go @@ -0,0 +1,416 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" +) + +// PrivateEndpointConnectionsClient is the creates a Microsoft.Purview management client. +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 create or update a private endpoint connection +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// privateEndpointConnectionName - name of the private endpoint connection. +// request - the request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, request 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) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName, request) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.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, "purview.PrivateEndpointConnectionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, request PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(request), + 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 delete a private endpoint connection +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// privateEndpointConnectionName - name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}/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 + 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 = func(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("purview.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + 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 get a private endpoint connection +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// privateEndpointConnectionName - name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName 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) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.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, "purview.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}/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 +} + +// ListByAccount get private endpoint connections for account +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// skipToken - the skip token. +func (client PrivateEndpointConnectionsClient) ListByAccount(ctx context.Context, resourceGroupName string, accountName string, skipToken string) (result PrivateEndpointConnectionListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByAccount") + defer func() { + sc := -1 + if result.pecl.Response.Response != nil { + sc = result.pecl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAccountNextResults + req, err := client.ListByAccountPreparer(ctx, resourceGroupName, accountName, skipToken) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "ListByAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAccountSender(req) + if err != nil { + result.pecl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "ListByAccount", resp, "Failure sending request") + return + } + + result.pecl, err = client.ListByAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "ListByAccount", resp, "Failure responding to request") + return + } + if result.pecl.hasNextLink() && result.pecl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAccountPreparer prepares the ListByAccount request. +func (client PrivateEndpointConnectionsClient) ListByAccountPreparer(ctx context.Context, resourceGroupName string, accountName string, skipToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["$skipToken"] = autorest.Encode("query", skipToken) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAccountSender sends the ListByAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAccountResponder handles the response to the ListByAccount request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByAccountResponder(resp *http.Response) (result PrivateEndpointConnectionList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAccountNextResults retrieves the next set of results, if any. +func (client PrivateEndpointConnectionsClient) listByAccountNextResults(ctx context.Context, lastResults PrivateEndpointConnectionList) (result PrivateEndpointConnectionList, err error) { + req, err := lastResults.privateEndpointConnectionListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "listByAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "listByAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateEndpointConnectionsClient", "listByAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateEndpointConnectionsClient) ListByAccountComplete(ctx context.Context, resourceGroupName string, accountName string, skipToken string) (result PrivateEndpointConnectionListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByAccount") + 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.ListByAccount(ctx, resourceGroupName, accountName, skipToken) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privatelinkresources.go new file mode 100644 index 000000000000..507ad25bbb0b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privatelinkresources.go @@ -0,0 +1,239 @@ +package purview + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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" +) + +// PrivateLinkResourcesClient is the creates a Microsoft.Purview management client. +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)} +} + +// GetByGroupID gets a privately linkable resources for an account with given group identifier +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +// groupID - the group identifier. +func (client PrivateLinkResourcesClient) GetByGroupID(ctx context.Context, resourceGroupName string, accountName string, groupID string) (result PrivateLinkResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.GetByGroupID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByGroupIDPreparer(ctx, resourceGroupName, accountName, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "GetByGroupID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByGroupIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "GetByGroupID", resp, "Failure sending request") + return + } + + result, err = client.GetByGroupIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "GetByGroupID", resp, "Failure responding to request") + return + } + + return +} + +// GetByGroupIDPreparer prepares the GetByGroupID request. +func (client PrivateLinkResourcesClient) GetByGroupIDPreparer(ctx context.Context, resourceGroupName string, accountName string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}/privateLinkResources/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByGroupIDSender sends the GetByGroupID request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetByGroupIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetByGroupIDResponder handles the response to the GetByGroupID request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetByGroupIDResponder(resp *http.Response) (result PrivateLinkResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByAccount gets a list of privately linkable resources for an account +// Parameters: +// resourceGroupName - the resource group name. +// accountName - the name of the account. +func (client PrivateLinkResourcesClient) ListByAccount(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByAccount") + defer func() { + sc := -1 + if result.plrl.Response.Response != nil { + sc = result.plrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByAccountNextResults + req, err := client.ListByAccountPreparer(ctx, resourceGroupName, accountName) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "ListByAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByAccountSender(req) + if err != nil { + result.plrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "ListByAccount", resp, "Failure sending request") + return + } + + result.plrl, err = client.ListByAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "ListByAccount", resp, "Failure responding to request") + return + } + if result.plrl.hasNextLink() && result.plrl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByAccountPreparer prepares the ListByAccount request. +func (client PrivateLinkResourcesClient) ListByAccountPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-12-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.Purview/accounts/{accountName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByAccountSender sends the ListByAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByAccountResponder handles the response to the ListByAccount request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByAccountResponder(resp *http.Response) (result PrivateLinkResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByAccountNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listByAccountNextResults(ctx context.Context, lastResults PrivateLinkResourceList) (result PrivateLinkResourceList, err error) { + req, err := lastResults.privateLinkResourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "listByAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "listByAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "purview.PrivateLinkResourcesClient", "listByAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListByAccountComplete(ctx context.Context, resourceGroupName string, accountName string) (result PrivateLinkResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByAccount") + 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.ListByAccount(ctx, resourceGroupName, accountName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/version.go new file mode 100644 index 000000000000..c3249e032f13 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/version.go @@ -0,0 +1,30 @@ +package purview + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// 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() + " purview/2020-12-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6cbf737e8a90..fba91ffee91f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -80,6 +80,7 @@ github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2019-06-01/insig github.com/Azure/azure-sdk-for-go/services/preview/operationsmanagement/mgmt/2015-11-01-preview/operationsmanagement github.com/Azure/azure-sdk-for-go/services/preview/policyinsights/mgmt/2019-10-01-preview/policyinsights github.com/Azure/azure-sdk-for-go/services/preview/portal/mgmt/2019-01-01-preview/portal +github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2018-03-01-preview/managementgroups 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/2019-01-01-preview/securityinsight From 8f2e0344c06a9aed08a65d16253a15bb78780e6e Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Mon, 15 Feb 2021 10:40:58 -0300 Subject: [PATCH 05/14] docs: purview account --- website/allowed-subcategories | 1 + website/docs/r/purview_account.html.markdown | 90 ++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 website/docs/r/purview_account.html.markdown diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 0ac3ba5cbb59..6543e3693ab1 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -56,6 +56,7 @@ Policy Portal PowerBI Private DNS +Purview Recovery Services Redis Search diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown new file mode 100644 index 000000000000..089a3f3f2836 --- /dev/null +++ b/website/docs/r/purview_account.html.markdown @@ -0,0 +1,90 @@ +--- +subcategory: "Purview" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_purview_account" +description: |- + Manages a Purview Account. +--- + +# azurerm_purview_account + +Manages a Purview Account. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example" + location = "West US" +} + +resource "azurerm_purview_account" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + sku_capacity = 4 +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `location` - (Required) The Azure Region where the Purview Account should exist. Changing this forces a new Purview Account to be created. + +* `name` - (Required) The name which should be used for this Purview Account. Changing this forces a new Purview Account to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Purview Account should exist. Changing this forces a new Purview Account to be created. + +* `sku_capacity` - (Required) SKU capacity for platform size and catalog capabilities. Accepted values are `4` and `16`. + +--- + +* `public_network_enabled` - (Optional) Should the Purview Account be visible to the public network? Defaults to `true`. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Purview Account. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Purview Account. + +* `atlas_kafka_endpoint_primary_connection_string` - Atlas Kafka endpoint primary connection string. + +* `atlas_kafka_endpoint_secondary_connection_string` - Atlas Kafka endpoint secondary connection string. + +* `catalog_endpoint` - Catalog endpoint. + +* `guardian_endpoint` - Guardian endpoint. + +* `scan_endpoint` - Scan endpoint. + +* `identity` - A `identity` block as defined below. + +--- + +A `identity` block exports the following: + +* `principal_id` - The ID of the Principal (Client) in Azure Active Directory. + +* `tenant_id` - The ID of the Azure Active Directory Tenant. + +* `type` - The identity type. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Purview Account. +* `read` - (Defaults to 5 minutes) Used when retrieving the Purview Account. +* `update` - (Defaults to 30 minutes) Used when updating the Purview Account. +* `delete` - (Defaults to 30 minutes) Used when deleting the Purview Account. + +## Import + +Purview Accounts can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_purview_account.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Purview/accounts/account1 +``` \ No newline at end of file From ce8fc480ad4de135e3daa5aa41e1a5bc9fb5f29a Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Mon, 15 Feb 2021 10:50:37 -0300 Subject: [PATCH 06/14] linting website doc --- website/docs/r/purview_account.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 089a3f3f2836..0f1c98f2ea8d 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -19,10 +19,10 @@ resource "azurerm_resource_group" "example" { } resource "azurerm_purview_account" "example" { - name = "example" + name = "example" resource_group_name = azurerm_resource_group.example.name - location = azurerm_resource_group.example.location - sku_capacity = 4 + location = azurerm_resource_group.example.location + sku_capacity = 4 } ``` @@ -87,4 +87,4 @@ Purview Accounts can be imported using the `resource id`, e.g. ```shell terraform import azurerm_purview_account.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Purview/accounts/account1 -``` \ No newline at end of file +``` From c349d2b449e2138ba111254e55d04f449990c356 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Tue, 9 Mar 2021 17:33:11 -0300 Subject: [PATCH 07/14] fixing pointer problems; using new id convention --- .../purview/purview_account_resource.go | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index f0baec098e90..996d1bc81ea8 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -67,7 +67,6 @@ func resourcePurviewAccount() *schema.Resource { "identity": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "type": { @@ -120,6 +119,7 @@ func resourcePurviewAccount() *schema.Resource { func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{}) error { client := meta.(*clients.Client).Purview.AccountsClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -169,16 +169,8 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} return fmt.Errorf("Error waiting creation of Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) } - resp, err := client.Get(ctx, resourceGroup, name) - if err != nil { - return fmt.Errorf("Error retrieving Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - if resp.ID == nil { - return fmt.Errorf("Cannot read Purview Account %q (Resource Group %q) ID", name, resourceGroup) - } - - d.SetId(*resp.ID) + id := parse.NewAccountID(subscriptionId, resourceGroup, name) + d.SetId(id.ID()) return resourcePurviewAccountRead(d, meta) } @@ -208,7 +200,7 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error d.Set("location", location.NormalizeNilable(resp.Location)) if sku := resp.Sku; sku != nil { - if err := d.Set("sku_capacity", *sku.Capacity); err != nil { + if err := d.Set("sku_capacity", sku.Capacity); err != nil { return fmt.Errorf("Error setting `sku_capacity`: %+v", err) } } @@ -223,13 +215,13 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error } if endpoints := resp.Endpoints; endpoints != nil { - if err := d.Set("catalog_endpoint", *endpoints.Catalog); err != nil { + if err := d.Set("catalog_endpoint", endpoints.Catalog); err != nil { return fmt.Errorf("Error setting `catalog_endpoint`: %+v", err) } - if err := d.Set("guardian_endpoint", *endpoints.Guardian); err != nil { + if err := d.Set("guardian_endpoint", endpoints.Guardian); err != nil { return fmt.Errorf("Error setting `guardian_endpoint`: %+v", err) } - if err := d.Set("scan_endpoint", *endpoints.Scan); err != nil { + if err := d.Set("scan_endpoint", endpoints.Scan); err != nil { return fmt.Errorf("Error setting `scan_endpoint`: %+v", err) } } @@ -240,12 +232,12 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error retrieving Purview Account keys %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) } if primary := keys.AtlasKafkaPrimaryEndpoint; primary != nil { - if err := d.Set("atlas_kafka_endpoint_primary_connection_string", *primary); err != nil { + if err := d.Set("atlas_kafka_endpoint_primary_connection_string", primary); err != nil { return fmt.Errorf("Error setting `atlas_kafka_endpoint_primary_connection_string`: %+v", err) } } if secondary := keys.AtlasKafkaSecondaryEndpoint; secondary != nil { - if err := d.Set("atlas_kafka_endpoint_secondary_connection_string", *secondary); err != nil { + if err := d.Set("atlas_kafka_endpoint_secondary_connection_string", secondary); err != nil { return fmt.Errorf("Error setting `atlas_kafka_endpoint_secondary_connection_string`: %+v", err) } } From 6c5a53c2b826eac1170c755ec4952006846ec049 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Tue, 9 Mar 2021 17:48:37 -0300 Subject: [PATCH 08/14] dep: purview vendor --- .../mgmt/2020-12-01-preview/purview/CHANGELOG.md | 2 +- .../mgmt/2020-12-01-preview/purview/accounts.go | 12 ++++++------ .../2020-12-01-preview/purview/defaultaccounts.go | 2 +- .../purview/privateendpointconnections.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md index 653178fbe387..3a7e0d7a143f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/CHANGELOG.md @@ -1,5 +1,5 @@ Generated from https://github.com/Azure/azure-rest-api-specs/tree/138759b8a5987252fd66658078907e1d93969c85//specification/purview/resource-manager/readme.md tag: `package-2020-12-01-preview` -Code generator @microsoft.azure/autorest.go@2.1.171 +Code generator @microsoft.azure/autorest.go@2.1.175 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go index c7f3bdb62592..13fc6fd92e7c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/accounts.go @@ -126,8 +126,8 @@ func (client AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupNa ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CreateOrUpdate") defer func() { sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -229,8 +229,8 @@ func (client AccountsClient) Delete(ctx context.Context, resourceGroupName strin ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete") defer func() { sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() @@ -710,8 +710,8 @@ func (client AccountsClient) Update(ctx context.Context, resourceGroupName strin ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") defer func() { sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go index bb0ff561cd82..1f46f7417c59 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/defaultaccounts.go @@ -22,7 +22,7 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/tracing" - "github.com/satori/go.uuid" + "github.com/gofrs/uuid" "net/http" ) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go index cfa1abf323d1..4e57e81bf998 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview/privateendpointconnections.go @@ -133,8 +133,8 @@ func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resou ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") defer func() { sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode } tracing.EndSpan(ctx, sc, err) }() From 95b9b351fa4f804a6b226dbb884ebf9d502640cc Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Tue, 9 Mar 2021 18:15:03 -0300 Subject: [PATCH 09/14] Update website/docs/r/purview_account.html.markdown Co-authored-by: kt --- website/docs/r/purview_account.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 0f1c98f2ea8d..0d49c076abb5 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -36,7 +36,7 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the Resource Group where the Purview Account should exist. Changing this forces a new Purview Account to be created. -* `sku_capacity` - (Required) SKU capacity for platform size and catalog capabilities. Accepted values are `4` and `16`. +* `sku_capacity` - (Required) The SKU's capacity for platform size and catalog capabilities. Accepted values are `4` and `16`. --- From e6f4efbf59175f0e3ee3d4dff9269195c69eb300 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Wed, 10 Mar 2021 14:02:34 -0300 Subject: [PATCH 10/14] exposing sku_name prop --- .../services/purview/purview_account_resource.go | 14 +++++++++++++- .../purview/purview_account_resource_test.go | 1 + website/docs/r/purview_account.html.markdown | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index 996d1bc81ea8..6d49be73e54d 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -58,6 +58,15 @@ func resourcePurviewAccount() *schema.Resource { }), }, + "sku_name": { + Type: schema.TypeString, + Required: false, + Default: string(purview.Standard), + ValidateFunc: validation.StringInSlice([]string{ + string(purview.Standard), + }, false), + }, + "public_network_enabled": { Type: schema.TypeBool, Optional: true, @@ -149,7 +158,7 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} Location: &location, Sku: &purview.AccountSku{ Capacity: utils.Int32(int32(d.Get("sku_capacity").(int))), - Name: purview.Standard, + Name: purview.Name(d.Get("sku_name").(string)), }, Tags: tags.Expand(t), } @@ -203,6 +212,9 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("sku_capacity", sku.Capacity); err != nil { return fmt.Errorf("Error setting `sku_capacity`: %+v", err) } + if err := d.Set("sku_name", sku.Name); err != nil { + return fmt.Errorf("Error setting `sku_name`: %+v", err) + } } if err := d.Set("identity", flattenPurviewAccountIdentity(resp.Identity)); err != nil { diff --git a/azurerm/internal/services/purview/purview_account_resource_test.go b/azurerm/internal/services/purview/purview_account_resource_test.go index 896cd99de058..a4b1a3536201 100644 --- a/azurerm/internal/services/purview/purview_account_resource_test.go +++ b/azurerm/internal/services/purview/purview_account_resource_test.go @@ -26,6 +26,7 @@ func TestAccPurviewAccount_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("sku_capacity").HasValue("4"), + check.That(data.ResourceName).Key("sku_name").HasValue("Standard"), check.That(data.ResourceName).Key("public_network_enabled").HasValue("true"), check.That(data.ResourceName).Key("identity.0.type").Exists(), check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 0f1c98f2ea8d..b640a55efb62 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -40,6 +40,8 @@ The following arguments are supported: --- +* `sku_name` - (Optional) SKU name for platform size and catalog capabilities. Accepted value is `Standard`. + * `public_network_enabled` - (Optional) Should the Purview Account be visible to the public network? Defaults to `true`. * `tags` - (Optional) A mapping of tags which should be assigned to the Purview Account. From 85df110b468c7fadf9a136a3c323b93498e97aa1 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Wed, 10 Mar 2021 14:15:51 -0300 Subject: [PATCH 11/14] setting sku_name as optional --- azurerm/internal/services/purview/purview_account_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index 6d49be73e54d..2c7f6cf3c8ba 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -60,7 +60,7 @@ func resourcePurviewAccount() *schema.Resource { "sku_name": { Type: schema.TypeString, - Required: false, + Optional: true, Default: string(purview.Standard), ValidateFunc: validation.StringInSlice([]string{ string(purview.Standard), From f46423b9e766c22cd2c7099e5c0bfcf0dcf313c9 Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:01:34 -0300 Subject: [PATCH 12/14] refactoring sku_name --- .../purview/purview_account_resource.go | 52 +++++++++++-------- .../purview/purview_account_resource_test.go | 5 +- website/docs/r/purview_account.html.markdown | 6 +-- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index 2c7f6cf3c8ba..950ee7858d40 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -49,21 +49,12 @@ func resourcePurviewAccount() *schema.Resource { "location": azure.SchemaLocation(), - "sku_capacity": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntInSlice([]int{ - 4, - 16, - }), - }, - "sku_name": { Type: schema.TypeString, - Optional: true, - Default: string(purview.Standard), + Required: true, ValidateFunc: validation.StringInSlice([]string{ - string(purview.Standard), + "Standard_4", + "Standard_16", }, false), }, @@ -156,11 +147,8 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} Type: purview.SystemAssigned, }, Location: &location, - Sku: &purview.AccountSku{ - Capacity: utils.Int32(int32(d.Get("sku_capacity").(int))), - Name: purview.Name(d.Get("sku_name").(string)), - }, - Tags: tags.Expand(t), + Sku: expandPurviewSkuName(d), + Tags: tags.Expand(t), } if d.Get("public_network_enabled").(bool) { @@ -209,10 +197,7 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error d.Set("location", location.NormalizeNilable(resp.Location)) if sku := resp.Sku; sku != nil { - if err := d.Set("sku_capacity", sku.Capacity); err != nil { - return fmt.Errorf("Error setting `sku_capacity`: %+v", err) - } - if err := d.Set("sku_name", sku.Name); err != nil { + if err := d.Set("sku_name", flattenPurviewSkuName(sku)); err != nil { return fmt.Errorf("Error setting `sku_name`: %+v", err) } } @@ -282,6 +267,31 @@ func resourcePurviewAccountDelete(d *schema.ResourceData, meta interface{}) erro return nil } +func expandPurviewSkuName(d *schema.ResourceData) *purview.AccountSku { + vs := d.Get("sku_name").(string) + + if len(vs) == 0 { + return nil + } + + name, capacity, err := azure.SplitSku(vs) + if err != nil { + return nil + } + return &purview.AccountSku{ + Name: purview.Name(name), + Capacity: utils.Int32(capacity), + } +} + +func flattenPurviewSkuName(input *purview.AccountSku) string { + if input == nil { + return "" + } + + return fmt.Sprintf("%s_%d", string(input.Name), *input.Capacity) +} + func flattenPurviewAccountIdentity(identity *purview.Identity) interface{} { if identity == nil { return make([]interface{}, 0) diff --git a/azurerm/internal/services/purview/purview_account_resource_test.go b/azurerm/internal/services/purview/purview_account_resource_test.go index a4b1a3536201..29051cab60a6 100644 --- a/azurerm/internal/services/purview/purview_account_resource_test.go +++ b/azurerm/internal/services/purview/purview_account_resource_test.go @@ -25,8 +25,7 @@ func TestAccPurviewAccount_basic(t *testing.T) { Config: r.basic(data), Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("sku_capacity").HasValue("4"), - check.That(data.ResourceName).Key("sku_name").HasValue("Standard"), + check.That(data.ResourceName).Key("sku_name").HasValue("Standard_4"), check.That(data.ResourceName).Key("public_network_enabled").HasValue("true"), check.That(data.ResourceName).Key("identity.0.type").Exists(), check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), @@ -67,7 +66,7 @@ resource "azurerm_purview_account" "test" { name = "acctestsw%d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - sku_capacity = 4 + sku_name = "Standard_4" } `, template, data.RandomInteger) } diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 4337adb65bec..3d760783a94a 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -22,7 +22,7 @@ resource "azurerm_purview_account" "example" { name = "example" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location - sku_capacity = 4 + sku_name = "Standard_4" } ``` @@ -36,12 +36,10 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the Resource Group where the Purview Account should exist. Changing this forces a new Purview Account to be created. -* `sku_capacity` - (Required) The SKU's capacity for platform size and catalog capabilities. Accepted values are `4` and `16`. +* `sku_name` - (Required) The SKU's capacity for platform size and catalog capabilities. Accepted values are `Standard_4` and `Standard_16`. --- -* `sku_name` - (Optional) SKU name for platform size and catalog capabilities. Accepted value is `Standard`. - * `public_network_enabled` - (Optional) Should the Purview Account be visible to the public network? Defaults to `true`. * `tags` - (Optional) A mapping of tags which should be assigned to the Purview Account. From e77f3051fbb2bc285d89a5d75f0e70fb27ff31cd Mon Sep 17 00:00:00 2001 From: Allan Targino <13934447+allantargino@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:04:04 -0300 Subject: [PATCH 13/14] sku var name --- .../internal/services/purview/purview_account_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index 950ee7858d40..aebf88bd21b4 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -268,13 +268,13 @@ func resourcePurviewAccountDelete(d *schema.ResourceData, meta interface{}) erro } func expandPurviewSkuName(d *schema.ResourceData) *purview.AccountSku { - vs := d.Get("sku_name").(string) + sku := d.Get("sku_name").(string) - if len(vs) == 0 { + if len(sku) == 0 { return nil } - name, capacity, err := azure.SplitSku(vs) + name, capacity, err := azure.SplitSku(sku) if err != nil { return nil } From 0c40029bff2ba4b4ec333f48105071a39b608313 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 11 Mar 2021 11:14:42 +0100 Subject: [PATCH 14/14] comments from code review --- .../purview/purview_account_resource.go | 100 +++++++----------- .../purview/purview_account_resource_test.go | 40 +++++-- website/docs/r/purview_account.html.markdown | 6 +- 3 files changed, 72 insertions(+), 74 deletions(-) diff --git a/azurerm/internal/services/purview/purview_account_resource.go b/azurerm/internal/services/purview/purview_account_resource.go index aebf88bd21b4..5702393eeb4a 100644 --- a/azurerm/internal/services/purview/purview_account_resource.go +++ b/azurerm/internal/services/purview/purview_account_resource.go @@ -4,8 +4,9 @@ import ( "fmt" "time" + azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" + "github.com/Azure/azure-sdk-for-go/services/preview/purview/mgmt/2020-12-01-preview/purview" - "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -26,9 +27,10 @@ func resourcePurviewAccount() *schema.Resource { Update: resourcePurviewAccountCreateUpdate, Delete: resourcePurviewAccountDelete, - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, + Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error { + _, err := parse.AccountID(id) + return err + }), Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), @@ -123,21 +125,20 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - name := d.Get("name").(string) location := azure.NormalizeLocation(d.Get("location").(string)) - resourceGroup := d.Get("resource_group_name").(string) t := d.Get("tags").(map[string]interface{}) + id := parse.NewAccountID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, name) + existing, err := client.Get(ctx, id.ResourceGroup, id.Name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of existing Purview Account %q (Resource Group %q): %s", name, resourceGroup, err) + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_purview_account", *existing.ID) + if !utils.ResponseWasNotFound(existing.Response) { + return tf.ImportAsExistsError("azurerm_purview_account", id.ID()) } } @@ -157,18 +158,16 @@ func resourcePurviewAccountCreateUpdate(d *schema.ResourceData, meta interface{} account.AccountProperties.PublicNetworkAccess = purview.Disabled } - future, err := client.CreateOrUpdate(ctx, resourceGroup, name, account) + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, account) if err != nil { - return fmt.Errorf("Error creating/updating Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) + return fmt.Errorf("creating/updating %s: %+v", id, err) } if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("Error waiting creation of Purview Account %q (Resource Group %q): %+v", name, resourceGroup, err) + return fmt.Errorf("waiting for create/update of %s: %+v", id, err) } - id := parse.NewAccountID(subscriptionId, resourceGroup, name) d.SetId(id.ID()) - return resourcePurviewAccountRead(d, meta) } @@ -189,55 +188,34 @@ func resourcePurviewAccountRead(d *schema.ResourceData, meta interface{}) error return nil } - return fmt.Errorf("Error retrieving Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + 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)) - - if sku := resp.Sku; sku != nil { - if err := d.Set("sku_name", flattenPurviewSkuName(sku)); err != nil { - return fmt.Errorf("Error setting `sku_name`: %+v", err) - } - } + d.Set("sku_name", flattenPurviewSkuName(resp.Sku)) if err := d.Set("identity", flattenPurviewAccountIdentity(resp.Identity)); err != nil { - return fmt.Errorf("Error flattening `identity`: %+v", err) + return fmt.Errorf("flattening `identity`: %+v", err) } if props := resp.AccountProperties; props != nil { - if err := d.Set("public_network_enabled", props.PublicNetworkAccess == purview.Enabled); err != nil { - return fmt.Errorf("Error setting `public_network_enabled`: %+v", err) - } + d.Set("public_network_enabled", props.PublicNetworkAccess == purview.Enabled) if endpoints := resp.Endpoints; endpoints != nil { - if err := d.Set("catalog_endpoint", endpoints.Catalog); err != nil { - return fmt.Errorf("Error setting `catalog_endpoint`: %+v", err) - } - if err := d.Set("guardian_endpoint", endpoints.Guardian); err != nil { - return fmt.Errorf("Error setting `guardian_endpoint`: %+v", err) - } - if err := d.Set("scan_endpoint", endpoints.Scan); err != nil { - return fmt.Errorf("Error setting `scan_endpoint`: %+v", err) - } + d.Set("catalog_endpoint", endpoints.Catalog) + d.Set("guardian_endpoint", endpoints.Guardian) + d.Set("scan_endpoint", endpoints.Scan) } } keys, err := client.ListKeys(ctx, id.ResourceGroup, id.Name) if err != nil { - return fmt.Errorf("Error retrieving Purview Account keys %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } - if primary := keys.AtlasKafkaPrimaryEndpoint; primary != nil { - if err := d.Set("atlas_kafka_endpoint_primary_connection_string", primary); err != nil { - return fmt.Errorf("Error setting `atlas_kafka_endpoint_primary_connection_string`: %+v", err) - } - } - if secondary := keys.AtlasKafkaSecondaryEndpoint; secondary != nil { - if err := d.Set("atlas_kafka_endpoint_secondary_connection_string", secondary); err != nil { - return fmt.Errorf("Error setting `atlas_kafka_endpoint_secondary_connection_string`: %+v", err) - } + return fmt.Errorf("retrieving Keys for %s: %+v", *id, err) } + d.Set("atlas_kafka_endpoint_primary_connection_string", keys.AtlasKafkaPrimaryEndpoint) + d.Set("atlas_kafka_endpoint_secondary_connection_string", keys.AtlasKafkaSecondaryEndpoint) return tags.FlattenAndSet(d, resp.Tags) } @@ -253,15 +231,12 @@ func resourcePurviewAccountDelete(d *schema.ResourceData, meta interface{}) erro } future, err := client.Delete(ctx, id.ResourceGroup, id.Name) - if err != nil { - return fmt.Errorf("Error deleting Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + 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("Error deleting Purview Account %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) - } + return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) } return nil @@ -285,7 +260,7 @@ func expandPurviewSkuName(d *schema.ResourceData) *purview.AccountSku { } func flattenPurviewSkuName(input *purview.AccountSku) string { - if input == nil { + if input == nil || input.Capacity == nil { return "" } @@ -293,20 +268,23 @@ func flattenPurviewSkuName(input *purview.AccountSku) string { } func flattenPurviewAccountIdentity(identity *purview.Identity) interface{} { - if identity == nil { + if identity == nil || identity.Type == "None" { return make([]interface{}, 0) } - result := make(map[string]interface{}) - if identity.Type != "" { - result["type"] = identity.Type - } + principalId := "" if identity.PrincipalID != nil { - result["principal_id"] = *identity.PrincipalID + principalId = *identity.PrincipalID } + tenantId := "" if identity.TenantID != nil { - result["tenant_id"] = *identity.TenantID + tenantId = *identity.TenantID + } + return []interface{}{ + map[string]interface{}{ + "type": string(identity.Type), + "principal_id": principalId, + "tenant_id": tenantId, + }, } - - return []interface{}{result} } diff --git a/azurerm/internal/services/purview/purview_account_resource_test.go b/azurerm/internal/services/purview/purview_account_resource_test.go index 29051cab60a6..9c0fb2538788 100644 --- a/azurerm/internal/services/purview/purview_account_resource_test.go +++ b/azurerm/internal/services/purview/purview_account_resource_test.go @@ -25,18 +25,24 @@ func TestAccPurviewAccount_basic(t *testing.T) { Config: r.basic(data), Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("sku_name").HasValue("Standard_4"), - check.That(data.ResourceName).Key("public_network_enabled").HasValue("true"), - check.That(data.ResourceName).Key("identity.0.type").Exists(), - check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), - check.That(data.ResourceName).Key("identity.0.tenant_id").Exists(), - check.That(data.ResourceName).Key("catalog_endpoint").Exists(), - check.That(data.ResourceName).Key("guardian_endpoint").Exists(), - check.That(data.ResourceName).Key("scan_endpoint").Exists(), - check.That(data.ResourceName).Key("atlas_kafka_endpoint_primary_connection_string").Exists(), - check.That(data.ResourceName).Key("atlas_kafka_endpoint_secondary_connection_string").Exists(), ), }, + data.ImportStep(), + }) +} + +func TestAccPurviewAccount_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_purview_account", "test") + r := PurviewAccountResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.basic(data), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), }) } @@ -71,6 +77,20 @@ resource "azurerm_purview_account" "test" { `, template, data.RandomInteger) } +func (r PurviewAccountResource) requiresImport(data acceptance.TestData) string { + template := r.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_purview_account" "import" { + name = azurerm_purview_account.test.name + resource_group_name = azurerm_purview_account.test.resource_group_name + location = azurerm_purview_account.test.location + sku_name = azurerm_purview_account.test.sku_name +} +`, template) +} + func (r PurviewAccountResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 3d760783a94a..5dd28559bd43 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -14,8 +14,8 @@ Manages a Purview Account. ```hcl resource "azurerm_resource_group" "example" { - name = "example" - location = "West US" + name = "example-resources" + location = "West Europe" } resource "azurerm_purview_account" "example" { @@ -70,7 +70,7 @@ A `identity` block exports the following: * `tenant_id` - The ID of the Azure Active Directory Tenant. -* `type` - The identity type. +* `type` - The type of Managed Identity assigned to this Purview Account. ## Timeouts