From d769ed8a8a1bddb092ef7b1f426e8060c71b5fca Mon Sep 17 00:00:00 2001 From: wuxu Date: Mon, 30 May 2022 21:48:20 +0800 Subject: [PATCH 01/30] add fluid relay resource fix fluid relay create/update with cmk --- internal/clients/client.go | 3 + internal/provider/services.go | 2 + internal/services/fluidrelay/client/client.go | 19 + .../fluid_relay_servers_resource.go | 408 ++++++++++++++++++ .../services/fluidrelay/parse/fluid_relay.go | 69 +++ .../fluidrelay/parse/fluid_relay_servers.go | 69 +++ .../parse/fluid_relay_servers_test.go | 112 +++++ .../fluidrelay/parse/fluid_relay_test.go | 112 +++++ internal/services/fluidrelay/registration.go | 27 ++ internal/services/fluidrelay/resourceids.go | 4 + .../2022-04-21/fluidrelaycontainers/client.go | 18 + .../fluidrelaycontainers/constants.go | 71 +++ .../id_fluidrelaycontainer.go | 137 ++++++ .../id_fluidrelaycontainer_test.go | 324 ++++++++++++++ .../id_fluidrelayserver.go | 124 ++++++ .../id_fluidrelayserver_test.go | 279 ++++++++++++ .../method_delete_autorest.go | 62 +++ .../method_get_autorest.go | 64 +++ ...method_listbyfluidrelayservers_autorest.go | 183 ++++++++ .../model_fluidrelaycontainer.go | 12 + .../model_fluidrelaycontainerproperties.go | 10 + .../fluidrelaycontainers/model_systemdata.go | 43 ++ .../fluidrelaycontainers/predicates.go | 24 ++ .../fluidrelaycontainers/version.go | 12 + .../2022-04-21/fluidrelayservers/client.go | 18 + .../2022-04-21/fluidrelayservers/constants.go | 127 ++++++ .../fluidrelayservers/id_fluidrelayserver.go | 124 ++++++ .../id_fluidrelayserver_test.go | 279 ++++++++++++ .../method_createorupdate_autorest.go | 65 +++ .../method_delete_autorest.go | 62 +++ .../fluidrelayservers/method_get_autorest.go | 64 +++ .../method_getkeys_autorest.go | 65 +++ .../method_listbyresourcegroup_autorest.go | 184 ++++++++ .../method_listbysubscription_autorest.go | 184 ++++++++ .../method_listkeys_autorest.go | 65 +++ .../method_regeneratekey_autorest.go | 66 +++ .../method_update_autorest.go | 65 +++ ..._customermanagedkeyencryptionproperties.go | 9 + ...ptionpropertieskeyencryptionkeyidentity.go | 9 + .../model_encryptionproperties.go | 8 + .../model_fluidrelayendpoints.go | 9 + .../model_fluidrelayserver.go | 19 + .../model_fluidrelayserverkeys.go | 9 + .../model_fluidrelayserverproperties.go | 11 + .../model_fluidrelayserverupdate.go | 15 + .../model_fluidrelayserverupdateproperties.go | 8 + .../model_regeneratekeyrequest.go | 8 + .../fluidrelayservers/model_systemdata.go | 43 ++ .../fluidrelayservers/predicates.go | 29 ++ .../2022-04-21/fluidrelayservers/version.go | 12 + .../validate/fluid_relay_servers_id.go | 23 + .../validate/fluid_relay_servers_id_test.go | 76 ++++ .../fluidrelay/validate/server_name.go | 21 + .../fluidrelay/validate/server_name_test.go | 63 +++ utils/pointer.go | 36 ++ utils/pointer_test.go | 58 +++ 56 files changed, 4022 insertions(+) create mode 100644 internal/services/fluidrelay/client/client.go create mode 100644 internal/services/fluidrelay/fluid_relay_servers_resource.go create mode 100644 internal/services/fluidrelay/parse/fluid_relay.go create mode 100644 internal/services/fluidrelay/parse/fluid_relay_servers.go create mode 100644 internal/services/fluidrelay/parse/fluid_relay_servers_test.go create mode 100644 internal/services/fluidrelay/parse/fluid_relay_test.go create mode 100644 internal/services/fluidrelay/registration.go create mode 100644 internal/services/fluidrelay/resourceids.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/client.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer_test.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver_test.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_delete_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_get_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/predicates.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/client.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver_test.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_createorupdate_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_delete_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_get_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_getkeys_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbyresourcegroup_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbysubscription_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listkeys_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_regeneratekey_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_update_autorest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionproperties.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_encryptionproperties.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverkeys.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdate.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdateproperties.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_regeneratekeyrequest.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/predicates.go create mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go create mode 100644 internal/services/fluidrelay/validate/fluid_relay_servers_id.go create mode 100644 internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go create mode 100644 internal/services/fluidrelay/validate/server_name.go create mode 100644 internal/services/fluidrelay/validate/server_name_test.go create mode 100644 utils/pointer_test.go diff --git a/internal/clients/client.go b/internal/clients/client.go index f460294421c9..a1db6778fa33 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -48,6 +48,7 @@ import ( eventgrid "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid/client" eventhub "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/client" firewall "github.com/hashicorp/terraform-provider-azurerm/internal/services/firewall/client" + fluidrelay "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/client" frontdoor "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor/client" hdinsight "github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight/client" healthcare "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/client" @@ -159,6 +160,7 @@ type Client struct { EventGrid *eventgrid.Client Eventhub *eventhub.Client Firewall *firewall.Client + FluidRelay *fluidrelay.Client Frontdoor *frontdoor.Client HPCCache *hpccache.Client HSM *hsm.Client @@ -272,6 +274,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.EventGrid = eventgrid.NewClient(o) client.Eventhub = eventhub.NewClient(o) client.Firewall = firewall.NewClient(o) + client.FluidRelay = fluidrelay.NewClient(o) client.Frontdoor = frontdoor.NewClient(o) client.HPCCache = hpccache.NewClient(o) client.HSM = hsm.NewClient(o) diff --git a/internal/provider/services.go b/internal/provider/services.go index ca6cd4ec3882..1f7aa9a62075 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -44,6 +44,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid" "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub" "github.com/hashicorp/terraform-provider-azurerm/internal/services/firewall" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay" "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor" "github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare" @@ -121,6 +122,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { costmanagement.Registration{}, disks.Registration{}, eventhub.Registration{}, + fluidrelay.Registration{}, keyvault.Registration{}, loadbalancer.Registration{}, loadtest.Registration{}, diff --git a/internal/services/fluidrelay/client/client.go b/internal/services/fluidrelay/client/client.go new file mode 100644 index 000000000000..5a72a871138e --- /dev/null +++ b/internal/services/fluidrelay/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/common" + servers "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers" +) + +type Client struct { + ServerClient *servers.FluidRelayServersClient +} + +func NewClient(o *common.ClientOptions) *Client { + serverClient := servers.NewFluidRelayServersClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&serverClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + ServerClient: &serverClient, + } +} diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go new file mode 100644 index 000000000000..b252a0533d59 --- /dev/null +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -0,0 +1,408 @@ +package fluidrelay + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/msi/sdk/2018-11-30/managedidentity" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +//type Identity struct { +// Type string `tfschema:"type"` +// PrincipalID string `tfschema:"principal_id"` +// TenantID string `tfschea:"tenant_id"` +//} + +type UserAssignedIdentity struct { + IdentityID string `tfschema:"identity_id"` + ClientID string `tfschema:"client_id"` + PrincipalID string `tfschema:"principal_id"` +} + +type Encryption struct { + IdentityType string `tfschema:"identity_type"` + IdentityResourceId string `tfschema:"identity_resource_id"` + KeyEncryptionKeyUrl string `tfschema:"key_encryption_key_url"` +} + +type ServersModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` + FrsTenantId string `tfschema:"frs_tenant_id"` + ProvisioningState string `tfschema:"provisioning_state"` + OrdererEndpoints []string `tfschema:"orderer_endpoints"` + StorageEndpoints []string `tfschema:"storage_endpoints"` + IdentityType string `tfschema:"identity_type"` + TenantID string `tfschema:"tenant_id"` + PrincipalID string `tfschema:"principal_id"` + UserAssignedIdentities []UserAssignedIdentity `tfschema:"user_assigned_identity"` + Encryption []Encryption `tfschema:"encryption"` +} + +func (s *ServersModel) GenUserIdentities() *identity.SystemAndUserAssignedMap { + res := &identity.SystemAndUserAssignedMap{ + Type: "None", + } + if s == nil || len(s.UserAssignedIdentities) == 0 { + return res + } + if s.IdentityType != "" { + res.Type = identity.Type(s.IdentityType) + } + if s.PrincipalID != "" { + res.PrincipalId = s.PrincipalID + } + if s.TenantID != "" { + res.TenantId = s.TenantID + } + res.IdentityIds = map[string]identity.UserAssignedIdentityDetails{} + for _, id := range s.UserAssignedIdentities { + res.IdentityIds[id.IdentityID] = identity.UserAssignedIdentityDetails{ + ClientId: utils.Ptr(id.ClientID), + PrincipalId: utils.Ptr(id.PrincipalID), + } + } + return res +} + +func (s *ServersModel) GenEncryption() *fluidrelayservers.EncryptionProperties { + if len(s.Encryption) == 0 { + return nil + } + encryption := s.Encryption[0] + res := &fluidrelayservers.EncryptionProperties{ + CustomerManagedKeyEncryption: &fluidrelayservers.CustomerManagedKeyEncryptionProperties{ + KeyEncryptionKeyIdentity: &fluidrelayservers.CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity{ + IdentityType: utils.Ptr(fluidrelayservers.CmkIdentityType(encryption.IdentityType)), + UserAssignedIdentityResourceId: utils.Ptr(encryption.IdentityResourceId), + }, + KeyEncryptionKeyUrl: utils.Ptr(encryption.KeyEncryptionKeyUrl), + }} + return res +} + +type Servers struct{} + +var _ sdk.ResourceWithUpdate = (*Servers)(nil) + +func (s Servers) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + Description: "The Fluid Relay server resource name", + ValidateFunc: validate.FluidRelayServerName, + }, + "resource_group_name": commonschema.ResourceGroupName(), + "location": commonschema.Location(), + "tags": commonschema.Tags(), + "identity_type": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + //Default: "SystemAssigned", + ValidateFunc: validation.StringInSlice([]string{ + "SystemAssigned", + "UserAssigned", + "SystemAssigned, UserAssigned", + "None", + }, false), + }, + "user_assigned_identity": { + Type: pluginsdk.TypeList, + Optional: true, + Computed: true, + ConfigMode: pluginsdk.SchemaConfigModeBlock, + Description: "The list of user identities associated with the resource.", + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "identity_id": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + ValidateFunc: managedidentity.ValidateUserAssignedIdentitiesID, + }, + "client_id": { + Type: pluginsdk.TypeString, + Computed: true, + Optional: true, + Description: "The client id of user assigned identity.", + }, + "principal_id": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + Description: "The principal id of user assigned identity.", + }, + }, + }, + }, + "encryption": { + Type: pluginsdk.TypeList, + Optional: true, + Description: "Create with Cmk.", + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "identity_type": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice( + fluidrelayservers.PossibleValuesForCmkIdentityType(), + false), + Description: "Values can be SystemAssigned or UserAssigned.", + }, + "key_encryption_key_url": { + Type: pluginsdk.TypeString, + Optional: true, + Description: "user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity.", + }, + "identity_resource_id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: managedidentity.ValidateUserAssignedIdentitiesID, + }, + }, + }, + }, + } +} + +func (s Servers) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "frs_tenant_id": { + Type: pluginsdk.TypeString, + Computed: true, + Description: "The Fluid tenantId for this server", + }, + "provisioning_state": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "orderer_endpoints": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + "storage_endpoints": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + "principal_id": { + Type: pluginsdk.TypeString, + Computed: true, + Description: "The principal ID of resource identity", + }, + "tenant_id": { + Type: pluginsdk.TypeString, + Computed: true, + Description: "The tenant ID of resource", + }, + } +} + +func (s Servers) ModelObject() interface{} { + return &ServersModel{} +} + +func (s Servers) ResourceType() string { + return "azurerm_fluid_relay_servers" +} + +func (s Servers) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { + client := meta.Client.FluidRelay.ServerClient + + var model ServersModel + if err = meta.Decode(&model); err != nil { + return err + } + + account := meta.Client.Account + id := fluidrelayservers.NewFluidRelayServerID(account.SubscriptionId, model.ResourceGroup, model.Name) + + existing, err := client.Get(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + + return meta.ResourceRequiresImport(s.ResourceType(), id) + } + + serverReq := fluidrelayservers.FluidRelayServer{ + Location: azure.NormalizeLocation(model.Location), + Name: utils.Ptr(model.Name), + } + serverReq.Tags = utils.TryPtr(model.Tags) + serverReq.Properties = &fluidrelayservers.FluidRelayServerProperties{} + serverReq.Properties.Encryption = model.GenEncryption() + serverReq.Identity = model.GenUserIdentities() + + log := fmt.Sprintf("generate req: %s by model: %s", utils.JSONStr(serverReq), utils.JSONStr(model)) + meta.Logger.Infof("start creating: %s, data: %s", id, log) + //return fmt.Errorf("interrupt by test: %s", log) + resp, err := client.CreateOrUpdate(ctx, id, serverReq) + if err != nil { + return fmt.Errorf("creating %v err: %+v, resp: %+v", id, err, resp) + } + meta.SetID(id) + + return nil + }, + } +} + +// Update tags +func (s Servers) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 10 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { + client := meta.Client.FluidRelay.ServerClient + id, err := fluidrelayservers.ParseFluidRelayServerIDInsensitively(meta.ResourceData.Id()) + if err != nil { + return err + } + + var model ServersModel + if err = meta.Decode(&model); err != nil { + return fmt.Errorf("decoding err: %+v", err) + } + + var upd fluidrelayservers.FluidRelayServerUpdate + if meta.ResourceData.HasChanges("tags", "location") { + upd.Tags = &model.Tags + upd.Location = utils.String(azure.NormalizeLocation(model.Location)) + } + if meta.ResourceData.HasChanges("identity_type", "user_assigned_identity") { + upd.Identity = model.GenUserIdentities() + } + if meta.ResourceData.HasChanges("encryption") { + upd.Properties = &fluidrelayservers.FluidRelayServerUpdateProperties{} + upd.Properties.Encryption = model.GenEncryption() + } + _, err = client.Update(ctx, *id, upd) + if err != nil { + return fmt.Errorf("updating fluid relay err: %v", err) + } + // do a read after update + return nil + }, + } +} + +func (s Servers) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + client := meta.Client.FluidRelay.ServerClient + + id, err := fluidrelayservers.ParseFluidRelayServerID(meta.ResourceData.Id()) + if err != nil { + return err + } + + if id == nil { + return fmt.Errorf("parsed id is nil") + } + + server, err := client.Get(ctx, *id) + if err != nil { + return err + } + + model := server.Model + if model == nil { + return fmt.Errorf("got fluid relay server as nil") + } + + output := ServersModel{ + Name: id.FluidRelayServerName, + ResourceGroup: id.ResourceGroup, + Location: model.Location, + IdentityType: string(model.Identity.Type), + } + if model.Identity != nil { + output.TenantID = model.Identity.TenantId + output.PrincipalID = model.Identity.PrincipalId + for id, details := range model.Identity.IdentityIds { + // try parse id, because the response id could be modified to lower-case + iid, err := commonids.ParseUserAssignedIdentityIDInsensitively(id) + if err != nil { + meta.Logger.Warnf("normalize managed identity id `%s` parse err: %v", id, err) + } else { + id = iid.ID() + } + output.UserAssignedIdentities = append(output.UserAssignedIdentities, UserAssignedIdentity{ + IdentityID: id, + ClientID: utils.Value(details.ClientId), + PrincipalID: utils.Value(details.PrincipalId), + }) + } + } + output.Tags = utils.Value(server.Model.Tags) + if prop := model.Properties; prop != nil { + if prop.FrsTenantId != nil { + output.FrsTenantId = *prop.FrsTenantId + } + if prop.ProvisioningState != nil { + output.ProvisioningState = string(*prop.ProvisioningState) + } + if points := prop.FluidRelayEndpoints; points != nil { + if points.OrdererEndpoints != nil { + output.OrdererEndpoints = *points.OrdererEndpoints + } + if points.StorageEndpoints != nil { + output.StorageEndpoints = *points.StorageEndpoints + } + } + } + return meta.Encode(&output) + }, + } +} + +func (s Servers) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 10 * time.Minute, + Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { + client := meta.Client.FluidRelay.ServerClient + + id, err := fluidrelayservers.ParseFluidRelayServerID(meta.ResourceData.Id()) + if err != nil { + return err + } + + meta.Logger.Infof("deleting %s", id) + if _, err := client.Delete(ctx, *id); err != nil { + return fmt.Errorf("delete %s err: %v", id, err) + } + return nil + }, + } +} + +func (s Servers) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return fluidrelayservers.ValidateFluidRelayServerID +} diff --git a/internal/services/fluidrelay/parse/fluid_relay.go b/internal/services/fluidrelay/parse/fluid_relay.go new file mode 100644 index 000000000000..1a256fc789e5 --- /dev/null +++ b/internal/services/fluidrelay/parse/fluid_relay.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/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type FluidRelayId struct { + SubscriptionId string + ResourceGroup string + FluidRelayServerName string +} + +func NewFluidRelayID(subscriptionId, resourceGroup, fluidRelayServerName string) FluidRelayId { + return FluidRelayId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + FluidRelayServerName: fluidRelayServerName, + } +} + +func (id FluidRelayId) String() string { + segments := []string{ + fmt.Sprintf("Fluid Relay Server Name %q", id.FluidRelayServerName), + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Fluid Relay", segmentsStr) +} + +func (id FluidRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) +} + +// FluidRelayID parses a FluidRelay ID into an FluidRelayId struct +func FluidRelayID(input string) (*FluidRelayId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := FluidRelayId{ + 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.FluidRelayServerName, err = id.PopSegment("fluidRelayServers"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/fluidrelay/parse/fluid_relay_servers.go b/internal/services/fluidrelay/parse/fluid_relay_servers.go new file mode 100644 index 000000000000..05a91ba4b37a --- /dev/null +++ b/internal/services/fluidrelay/parse/fluid_relay_servers.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/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type FluidRelayServersId struct { + SubscriptionId string + ResourceGroup string + FluidRelayServerName string +} + +func NewFluidRelayServersID(subscriptionId, resourceGroup, fluidRelayServerName string) FluidRelayServersId { + return FluidRelayServersId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + FluidRelayServerName: fluidRelayServerName, + } +} + +func (id FluidRelayServersId) String() string { + segments := []string{ + fmt.Sprintf("Fluid Relay Server Name %q", id.FluidRelayServerName), + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Fluid Relay Servers", segmentsStr) +} + +func (id FluidRelayServersId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) +} + +// FluidRelayServersID parses a FluidRelayServers ID into an FluidRelayServersId struct +func FluidRelayServersID(input string) (*FluidRelayServersId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := FluidRelayServersId{ + 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.FluidRelayServerName, err = id.PopSegment("fluidRelayServers"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/fluidrelay/parse/fluid_relay_servers_test.go b/internal/services/fluidrelay/parse/fluid_relay_servers_test.go new file mode 100644 index 000000000000..672eb1e9705c --- /dev/null +++ b/internal/services/fluidrelay/parse/fluid_relay_servers_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/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = FluidRelayServersId{} + +func TestFluidRelayServersIDFormatter(t *testing.T) { + actual := NewFluidRelayServersID("67a9759d-d099-4aa8-8675-e6cfd669c3f4", "myrg", "myFluid").ID() + expected := "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestFluidRelayServersID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayServersId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/", + Error: true, + }, + + { + // missing FluidRelayServerName + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/", + Error: true, + }, + + { + // missing value for FluidRelayServerName + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid", + Expected: &FluidRelayServersId{ + SubscriptionId: "67a9759d-d099-4aa8-8675-e6cfd669c3f4", + ResourceGroup: "myrg", + FluidRelayServerName: "myFluid", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/67A9759D-D099-4AA8-8675-E6CFD669C3F4/RESOURCEGROUPS/MYRG/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/MYFLUID", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := FluidRelayServersID(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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + } +} diff --git a/internal/services/fluidrelay/parse/fluid_relay_test.go b/internal/services/fluidrelay/parse/fluid_relay_test.go new file mode 100644 index 000000000000..d9713ad2a35d --- /dev/null +++ b/internal/services/fluidrelay/parse/fluid_relay_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/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = FluidRelayId{} + +func TestFluidRelayIDFormatter(t *testing.T) { + actual := NewFluidRelayID("67a9759d-d099-4aa8-8675-e6cfd669c3f4", "myrg", "myFluid").ID() + expected := "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestFluidRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/", + Error: true, + }, + + { + // missing FluidRelayServerName + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/", + Error: true, + }, + + { + // missing value for FluidRelayServerName + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid", + Expected: &FluidRelayId{ + SubscriptionId: "67a9759d-d099-4aa8-8675-e6cfd669c3f4", + ResourceGroup: "myrg", + FluidRelayServerName: "myFluid", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/67A9759D-D099-4AA8-8675-E6CFD669C3F4/RESOURCEGROUPS/MYRG/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/MYFLUID", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := FluidRelayID(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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + } +} diff --git a/internal/services/fluidrelay/registration.go b/internal/services/fluidrelay/registration.go new file mode 100644 index 000000000000..52100f5fc921 --- /dev/null +++ b/internal/services/fluidrelay/registration.go @@ -0,0 +1,27 @@ +package fluidrelay + +import "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + +type Registration struct{} + +func (r Registration) Name() string { + return "Fluid Relay" +} + +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + Servers{}, + } +} + +func (r Registration) WebsiteCategories() []string { + return []string{} +} + +var ( + _ sdk.TypedServiceRegistration = (*Registration)(nil) +) diff --git a/internal/services/fluidrelay/resourceids.go b/internal/services/fluidrelay/resourceids.go new file mode 100644 index 000000000000..0d5fb25a81b9 --- /dev/null +++ b/internal/services/fluidrelay/resourceids.go @@ -0,0 +1,4 @@ +package fluidrelay + +// Fluid Relay IDs +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FluidRelayServers -id=/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/client.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/client.go new file mode 100644 index 000000000000..8a5997945975 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/client.go @@ -0,0 +1,18 @@ +package fluidrelaycontainers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewFluidRelayContainersClientWithBaseURI(endpoint string) FluidRelayContainersClient { + return FluidRelayContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go new file mode 100644 index 000000000000..a4c9dded6e32 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go @@ -0,0 +1,71 @@ +package fluidrelaycontainers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer.go new file mode 100644 index 000000000000..54beab85637c --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer.go @@ -0,0 +1,137 @@ +package fluidrelaycontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayContainerId{} + +// FluidRelayContainerId is a struct representing the Resource ID for a Fluid Relay Container +type FluidRelayContainerId struct { + SubscriptionId string + ResourceGroup string + FluidRelayServerName string + FluidRelayContainerName string +} + +// NewFluidRelayContainerID returns a new FluidRelayContainerId struct +func NewFluidRelayContainerID(subscriptionId string, resourceGroup string, fluidRelayServerName string, fluidRelayContainerName string) FluidRelayContainerId { + return FluidRelayContainerId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + FluidRelayServerName: fluidRelayServerName, + FluidRelayContainerName: fluidRelayContainerName, + } +} + +// ParseFluidRelayContainerID parses 'input' into a FluidRelayContainerId +func ParseFluidRelayContainerID(input string) (*FluidRelayContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayContainerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + if id.FluidRelayContainerName, ok = parsed.Parsed["fluidRelayContainerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayContainerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseFluidRelayContainerIDInsensitively parses 'input' case-insensitively into a FluidRelayContainerId +// note: this method should only be used for API response data and not user input +func ParseFluidRelayContainerIDInsensitively(input string) (*FluidRelayContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayContainerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + if id.FluidRelayContainerName, ok = parsed.Parsed["fluidRelayContainerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayContainerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateFluidRelayContainerID checks that 'input' can be parsed as a Fluid Relay Container ID +func ValidateFluidRelayContainerID(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 := ParseFluidRelayContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fluid Relay Container ID +func (id FluidRelayContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s/fluidRelayContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName, id.FluidRelayContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Container ID +func (id FluidRelayContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), + resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), + resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), + resourceids.StaticSegment("staticFluidRelayContainers", "fluidRelayContainers", "fluidRelayContainers"), + resourceids.UserSpecifiedSegment("fluidRelayContainerName", "fluidRelayContainerValue"), + } +} + +// String returns a human-readable description of this Fluid Relay Container ID +func (id FluidRelayContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group: %q", id.ResourceGroup), + fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), + fmt.Sprintf("Fluid Relay Container Name: %q", id.FluidRelayContainerName), + } + return fmt.Sprintf("Fluid Relay Container (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer_test.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer_test.go new file mode 100644 index 000000000000..154ad3ab54f9 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer_test.go @@ -0,0 +1,324 @@ +package fluidrelaycontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayContainerId{} + +func TestNewFluidRelayContainerID(t *testing.T) { + id := NewFluidRelayContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue", "fluidRelayContainerValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroup != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroup'", id.ResourceGroup, "example-resource-group") + } + + if id.FluidRelayServerName != "fluidRelayServerValue" { + t.Fatalf("Expected %q but got %q for Segment 'FluidRelayServerName'", id.FluidRelayServerName, "fluidRelayServerValue") + } + + if id.FluidRelayContainerName != "fluidRelayContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'FluidRelayContainerName'", id.FluidRelayContainerName, "fluidRelayContainerValue") + } +} + +func TestFormatFluidRelayContainerID(t *testing.T) { + actual := NewFluidRelayContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue", "fluidRelayContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFluidRelayContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue", + Expected: &FluidRelayContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "example-resource-group", + FluidRelayServerName: "fluidRelayServerValue", + FluidRelayContainerName: "fluidRelayContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFluidRelayContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + + if actual.FluidRelayContainerName != v.Expected.FluidRelayContainerName { + t.Fatalf("Expected %q but got %q for FluidRelayContainerName", v.Expected.FluidRelayContainerName, actual.FluidRelayContainerName) + } + + } +} + +func TestParseFluidRelayContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/fLuIdReLaYcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue", + Expected: &FluidRelayContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "example-resource-group", + FluidRelayServerName: "fluidRelayServerValue", + FluidRelayContainerName: "fluidRelayContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/fLuIdReLaYcOnTaInErS/fLuIdReLaYcOnTaInErVaLuE", + Expected: &FluidRelayContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "eXaMpLe-rEsOuRcE-GrOuP", + FluidRelayServerName: "fLuIdReLaYsErVeRvAlUe", + FluidRelayContainerName: "fLuIdReLaYcOnTaInErVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/fLuIdReLaYcOnTaInErS/fLuIdReLaYcOnTaInErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFluidRelayContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + + if actual.FluidRelayContainerName != v.Expected.FluidRelayContainerName { + t.Fatalf("Expected %q but got %q for FluidRelayContainerName", v.Expected.FluidRelayContainerName, actual.FluidRelayContainerName) + } + + } +} + +func TestSegmentsForFluidRelayContainerId(t *testing.T) { + segments := FluidRelayContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FluidRelayContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver.go new file mode 100644 index 000000000000..17b8d121e1e0 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver.go @@ -0,0 +1,124 @@ +package fluidrelaycontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayServerId{} + +// FluidRelayServerId is a struct representing the Resource ID for a Fluid Relay Server +type FluidRelayServerId struct { + SubscriptionId string + ResourceGroup string + FluidRelayServerName string +} + +// NewFluidRelayServerID returns a new FluidRelayServerId struct +func NewFluidRelayServerID(subscriptionId string, resourceGroup string, fluidRelayServerName string) FluidRelayServerId { + return FluidRelayServerId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + FluidRelayServerName: fluidRelayServerName, + } +} + +// ParseFluidRelayServerID parses 'input' into a FluidRelayServerId +func ParseFluidRelayServerID(input string) (*FluidRelayServerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayServerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseFluidRelayServerIDInsensitively parses 'input' case-insensitively into a FluidRelayServerId +// note: this method should only be used for API response data and not user input +func ParseFluidRelayServerIDInsensitively(input string) (*FluidRelayServerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayServerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateFluidRelayServerID checks that 'input' can be parsed as a Fluid Relay Server ID +func ValidateFluidRelayServerID(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 := ParseFluidRelayServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fluid Relay Server ID +func (id FluidRelayServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Server ID +func (id FluidRelayServerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), + resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), + resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), + } +} + +// String returns a human-readable description of this Fluid Relay Server ID +func (id FluidRelayServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group: %q", id.ResourceGroup), + fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), + } + return fmt.Sprintf("Fluid Relay Server (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver_test.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver_test.go new file mode 100644 index 000000000000..3f3e1fabf50e --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver_test.go @@ -0,0 +1,279 @@ +package fluidrelaycontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayServerId{} + +func TestNewFluidRelayServerID(t *testing.T) { + id := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroup != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroup'", id.ResourceGroup, "example-resource-group") + } + + if id.FluidRelayServerName != "fluidRelayServerValue" { + t.Fatalf("Expected %q but got %q for Segment 'FluidRelayServerName'", id.FluidRelayServerName, "fluidRelayServerValue") + } +} + +func TestFormatFluidRelayServerID(t *testing.T) { + actual := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFluidRelayServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayServerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", + Expected: &FluidRelayServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "example-resource-group", + FluidRelayServerName: "fluidRelayServerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFluidRelayServerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + + } +} + +func TestParseFluidRelayServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayServerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", + Expected: &FluidRelayServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "example-resource-group", + FluidRelayServerName: "fluidRelayServerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe", + Expected: &FluidRelayServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "eXaMpLe-rEsOuRcE-GrOuP", + FluidRelayServerName: "fLuIdReLaYsErVeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFluidRelayServerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + + } +} + +func TestSegmentsForFluidRelayServerId(t *testing.T) { + segments := FluidRelayServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FluidRelayServerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_delete_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_delete_autorest.go new file mode 100644 index 000000000000..91c5fe5e10b7 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_delete_autorest.go @@ -0,0 +1,62 @@ +package fluidrelaycontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c FluidRelayContainersClient) Delete(ctx context.Context, id FluidRelayContainerId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c FluidRelayContainersClient) preparerForDelete(ctx context.Context, id FluidRelayContainerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c FluidRelayContainersClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_get_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_get_autorest.go new file mode 100644 index 000000000000..294fc3a1bb6e --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_get_autorest.go @@ -0,0 +1,64 @@ +package fluidrelaycontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayContainer +} + +// Get ... +func (c FluidRelayContainersClient) Get(ctx context.Context, id FluidRelayContainerId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c FluidRelayContainersClient) preparerForGet(ctx context.Context, id FluidRelayContainerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c FluidRelayContainersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go new file mode 100644 index 000000000000..88eecb698ef3 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go @@ -0,0 +1,183 @@ +package fluidrelaycontainers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByFluidRelayServersOperationResponse struct { + HttpResponse *http.Response + Model *[]FluidRelayContainer + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByFluidRelayServersOperationResponse, error) +} + +type ListByFluidRelayServersCompleteResult struct { + Items []FluidRelayContainer +} + +func (r ListByFluidRelayServersOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByFluidRelayServersOperationResponse) LoadMore(ctx context.Context) (resp ListByFluidRelayServersOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByFluidRelayServers ... +func (c FluidRelayContainersClient) ListByFluidRelayServers(ctx context.Context, id FluidRelayServerId) (resp ListByFluidRelayServersOperationResponse, err error) { + req, err := c.preparerForListByFluidRelayServers(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByFluidRelayServers(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByFluidRelayServersComplete retrieves all of the results into a single object +func (c FluidRelayContainersClient) ListByFluidRelayServersComplete(ctx context.Context, id FluidRelayServerId) (ListByFluidRelayServersCompleteResult, error) { + return c.ListByFluidRelayServersCompleteMatchingPredicate(ctx, id, FluidRelayContainerOperationPredicate{}) +} + +// ListByFluidRelayServersCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c FluidRelayContainersClient) ListByFluidRelayServersCompleteMatchingPredicate(ctx context.Context, id FluidRelayServerId, predicate FluidRelayContainerOperationPredicate) (resp ListByFluidRelayServersCompleteResult, err error) { + items := make([]FluidRelayContainer, 0) + + page, err := c.ListByFluidRelayServers(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByFluidRelayServersCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByFluidRelayServers prepares the ListByFluidRelayServers request. +func (c FluidRelayContainersClient) preparerForListByFluidRelayServers(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/fluidRelayContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByFluidRelayServersWithNextLink prepares the ListByFluidRelayServers request with the given nextLink token. +func (c FluidRelayContainersClient) preparerForListByFluidRelayServersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByFluidRelayServers handles the response to the ListByFluidRelayServers request. The method always +// closes the http.Response Body. +func (c FluidRelayContainersClient) responderForListByFluidRelayServers(resp *http.Response) (result ListByFluidRelayServersOperationResponse, err error) { + type page struct { + Values []FluidRelayContainer `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByFluidRelayServersOperationResponse, err error) { + req, err := c.preparerForListByFluidRelayServersWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByFluidRelayServers(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go new file mode 100644 index 000000000000..4222eb048f15 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go @@ -0,0 +1,12 @@ +package fluidrelaycontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayContainer struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FluidRelayContainerProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go new file mode 100644 index 000000000000..1cafc0ee93e3 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go @@ -0,0 +1,10 @@ +package fluidrelaycontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayContainerProperties struct { + FrsContainerId *string `json:"frsContainerId,omitempty"` + FrsTenantId *string `json:"frsTenantId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go new file mode 100644 index 000000000000..f08898fa092c --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go @@ -0,0 +1,43 @@ +package fluidrelaycontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/predicates.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/predicates.go new file mode 100644 index 000000000000..1dd30d665d90 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/predicates.go @@ -0,0 +1,24 @@ +package fluidrelaycontainers + +type FluidRelayContainerOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FluidRelayContainerOperationPredicate) Matches(input FluidRelayContainer) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go new file mode 100644 index 000000000000..1e9cdb04a805 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go @@ -0,0 +1,12 @@ +package fluidrelaycontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-04-21" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelaycontainers/%s", defaultApiVersion) +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/client.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/client.go new file mode 100644 index 000000000000..bd29abddd025 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/client.go @@ -0,0 +1,18 @@ +package fluidrelayservers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServersClient struct { + Client autorest.Client + baseUri string +} + +func NewFluidRelayServersClientWithBaseURI(endpoint string) FluidRelayServersClient { + return FluidRelayServersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go new file mode 100644 index 000000000000..61a9dc7d62e2 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go @@ -0,0 +1,127 @@ +package fluidrelayservers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkIdentityType string + +const ( + CmkIdentityTypeSystemAssigned CmkIdentityType = "SystemAssigned" + CmkIdentityTypeUserAssigned CmkIdentityType = "UserAssigned" +) + +func PossibleValuesForCmkIdentityType() []string { + return []string{ + string(CmkIdentityTypeSystemAssigned), + string(CmkIdentityTypeUserAssigned), + } +} + +func parseCmkIdentityType(input string) (*CmkIdentityType, error) { + vals := map[string]CmkIdentityType{ + "systemassigned": CmkIdentityTypeSystemAssigned, + "userassigned": CmkIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CmkIdentityType(input) + return &out, nil +} + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type KeyName string + +const ( + KeyNameKeyOne KeyName = "key1" + KeyNameKeyTwo KeyName = "key2" +) + +func PossibleValuesForKeyName() []string { + return []string{ + string(KeyNameKeyOne), + string(KeyNameKeyTwo), + } +} + +func parseKeyName(input string) (*KeyName, error) { + vals := map[string]KeyName{ + "key1": KeyNameKeyOne, + "key2": KeyNameKeyTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyName(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver.go new file mode 100644 index 000000000000..bc41376a2926 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver.go @@ -0,0 +1,124 @@ +package fluidrelayservers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayServerId{} + +// FluidRelayServerId is a struct representing the Resource ID for a Fluid Relay Server +type FluidRelayServerId struct { + SubscriptionId string + ResourceGroup string + FluidRelayServerName string +} + +// NewFluidRelayServerID returns a new FluidRelayServerId struct +func NewFluidRelayServerID(subscriptionId string, resourceGroup string, fluidRelayServerName string) FluidRelayServerId { + return FluidRelayServerId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + FluidRelayServerName: fluidRelayServerName, + } +} + +// ParseFluidRelayServerID parses 'input' into a FluidRelayServerId +func ParseFluidRelayServerID(input string) (*FluidRelayServerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayServerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseFluidRelayServerIDInsensitively parses 'input' case-insensitively into a FluidRelayServerId +// note: this method should only be used for API response data and not user input +func ParseFluidRelayServerIDInsensitively(input string) (*FluidRelayServerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayServerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateFluidRelayServerID checks that 'input' can be parsed as a Fluid Relay Server ID +func ValidateFluidRelayServerID(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 := ParseFluidRelayServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fluid Relay Server ID +func (id FluidRelayServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Server ID +func (id FluidRelayServerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), + resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), + resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), + } +} + +// String returns a human-readable description of this Fluid Relay Server ID +func (id FluidRelayServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group: %q", id.ResourceGroup), + fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), + } + return fmt.Sprintf("Fluid Relay Server (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver_test.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver_test.go new file mode 100644 index 000000000000..786a42e6df6f --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver_test.go @@ -0,0 +1,279 @@ +package fluidrelayservers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayServerId{} + +func TestNewFluidRelayServerID(t *testing.T) { + id := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroup != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroup'", id.ResourceGroup, "example-resource-group") + } + + if id.FluidRelayServerName != "fluidRelayServerValue" { + t.Fatalf("Expected %q but got %q for Segment 'FluidRelayServerName'", id.FluidRelayServerName, "fluidRelayServerValue") + } +} + +func TestFormatFluidRelayServerID(t *testing.T) { + actual := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFluidRelayServerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayServerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", + Expected: &FluidRelayServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "example-resource-group", + FluidRelayServerName: "fluidRelayServerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFluidRelayServerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + + } +} + +func TestParseFluidRelayServerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FluidRelayServerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", + Expected: &FluidRelayServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "example-resource-group", + FluidRelayServerName: "fluidRelayServerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe", + Expected: &FluidRelayServerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "eXaMpLe-rEsOuRcE-GrOuP", + FluidRelayServerName: "fLuIdReLaYsErVeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFluidRelayServerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { + t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) + } + + } +} + +func TestSegmentsForFluidRelayServerId(t *testing.T) { + segments := FluidRelayServerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FluidRelayServerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_createorupdate_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_createorupdate_autorest.go new file mode 100644 index 000000000000..cc614a566e49 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_createorupdate_autorest.go @@ -0,0 +1,65 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServer +} + +// CreateOrUpdate ... +func (c FluidRelayServersClient) CreateOrUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServer) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c FluidRelayServersClient) preparerForCreateOrUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServer) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_delete_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_delete_autorest.go new file mode 100644 index 000000000000..25ab8f8ede19 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_delete_autorest.go @@ -0,0 +1,62 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c FluidRelayServersClient) Delete(ctx context.Context, id FluidRelayServerId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c FluidRelayServersClient) preparerForDelete(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_get_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_get_autorest.go new file mode 100644 index 000000000000..dec2740f199b --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_get_autorest.go @@ -0,0 +1,64 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServer +} + +// Get ... +func (c FluidRelayServersClient) Get(ctx context.Context, id FluidRelayServerId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c FluidRelayServersClient) preparerForGet(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_getkeys_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_getkeys_autorest.go new file mode 100644 index 000000000000..332732b57b6d --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_getkeys_autorest.go @@ -0,0 +1,65 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetKeysOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServerKeys +} + +// GetKeys ... +func (c FluidRelayServersClient) GetKeys(ctx context.Context, id FluidRelayServerId) (result GetKeysOperationResponse, err error) { + req, err := c.preparerForGetKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetKeys prepares the GetKeys request. +func (c FluidRelayServersClient) preparerForGetKeys(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/getKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetKeys handles the response to the GetKeys request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForGetKeys(resp *http.Response) (result GetKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbyresourcegroup_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..035383748434 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbyresourcegroup_autorest.go @@ -0,0 +1,184 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]FluidRelayServer + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []FluidRelayServer +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c FluidRelayServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c FluidRelayServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, FluidRelayServerOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c FluidRelayServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate FluidRelayServerOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]FluidRelayServer, 0) + + page, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c FluidRelayServersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.FluidRelay/fluidRelayServers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c FluidRelayServersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []FluidRelayServer `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbysubscription_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbysubscription_autorest.go new file mode 100644 index 000000000000..73a6677c19d9 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbysubscription_autorest.go @@ -0,0 +1,184 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + Model *[]FluidRelayServer + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) +} + +type ListBySubscriptionCompleteResult struct { + Items []FluidRelayServer +} + +func (r ListBySubscriptionOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListBySubscription ... +func (c FluidRelayServersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscription(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListBySubscription(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListBySubscriptionComplete retrieves all of the results into a single object +func (c FluidRelayServersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, FluidRelayServerOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c FluidRelayServersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate FluidRelayServerOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { + items := make([]FluidRelayServer, 0) + + page, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListBySubscriptionCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListBySubscription prepares the ListBySubscription request. +func (c FluidRelayServersClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.FluidRelay/fluidRelayServers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. +func (c FluidRelayServersClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListBySubscription handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { + type page struct { + Values []FluidRelayServer `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListBySubscription(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listkeys_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listkeys_autorest.go new file mode 100644 index 000000000000..d2dd3e44d036 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listkeys_autorest.go @@ -0,0 +1,65 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServerKeys +} + +// ListKeys ... +func (c FluidRelayServersClient) ListKeys(ctx context.Context, id FluidRelayServerId) (result ListKeysOperationResponse, err error) { + req, err := c.preparerForListKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListKeys prepares the ListKeys request. +func (c FluidRelayServersClient) preparerForListKeys(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListKeys handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_regeneratekey_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_regeneratekey_autorest.go new file mode 100644 index 000000000000..e29322a76f9e --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_regeneratekey_autorest.go @@ -0,0 +1,66 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type RegenerateKeyOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServerKeys +} + +// RegenerateKey ... +func (c FluidRelayServersClient) RegenerateKey(ctx context.Context, id FluidRelayServerId, input RegenerateKeyRequest) (result RegenerateKeyOperationResponse, err error) { + req, err := c.preparerForRegenerateKey(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRegenerateKey(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRegenerateKey prepares the RegenerateKey request. +func (c FluidRelayServersClient) preparerForRegenerateKey(ctx context.Context, id FluidRelayServerId, input RegenerateKeyRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRegenerateKey handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForRegenerateKey(resp *http.Response) (result RegenerateKeyOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_update_autorest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_update_autorest.go new file mode 100644 index 000000000000..19f38294cf24 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_update_autorest.go @@ -0,0 +1,65 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type UpdateOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServer +} + +// Update ... +func (c FluidRelayServersClient) Update(ctx context.Context, id FluidRelayServerId, input FluidRelayServerUpdate) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c FluidRelayServersClient) preparerForUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServerUpdate) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionproperties.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionproperties.go new file mode 100644 index 000000000000..c901b57f9097 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionproperties.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomerManagedKeyEncryptionProperties struct { + KeyEncryptionKeyIdentity *CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity `json:"keyEncryptionKeyIdentity,omitempty"` + KeyEncryptionKeyUrl *string `json:"keyEncryptionKeyUrl,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go new file mode 100644 index 000000000000..a14936a4cb8a --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity struct { + IdentityType *CmkIdentityType `json:"identityType,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_encryptionproperties.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_encryptionproperties.go new file mode 100644 index 000000000000..ebb20890ac63 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_encryptionproperties.go @@ -0,0 +1,8 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionProperties struct { + CustomerManagedKeyEncryption *CustomerManagedKeyEncryptionProperties `json:"customerManagedKeyEncryption,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go new file mode 100644 index 000000000000..175afee0e667 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayEndpoints struct { + OrdererEndpoints *[]string `json:"ordererEndpoints,omitempty"` + StorageEndpoints *[]string `json:"storageEndpoints,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go new file mode 100644 index 000000000000..ade1a2f546b2 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go @@ -0,0 +1,19 @@ +package fluidrelayservers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServer struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *FluidRelayServerProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverkeys.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverkeys.go new file mode 100644 index 000000000000..d70edabd7a0e --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverkeys.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerKeys struct { + Key1 *string `json:"key1,omitempty"` + Key2 *string `json:"key2,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go new file mode 100644 index 000000000000..05a534a33267 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go @@ -0,0 +1,11 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerProperties struct { + Encryption *EncryptionProperties `json:"encryption,omitempty"` + FluidRelayEndpoints *FluidRelayEndpoints `json:"fluidRelayEndpoints,omitempty"` + FrsTenantId *string `json:"frsTenantId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdate.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdate.go new file mode 100644 index 000000000000..51e0c55443ff --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdate.go @@ -0,0 +1,15 @@ +package fluidrelayservers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerUpdate struct { + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Properties *FluidRelayServerUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdateproperties.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdateproperties.go new file mode 100644 index 000000000000..d150ca43a28c --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdateproperties.go @@ -0,0 +1,8 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerUpdateProperties struct { + Encryption *EncryptionProperties `json:"encryption,omitempty"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_regeneratekeyrequest.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_regeneratekeyrequest.go new file mode 100644 index 000000000000..1aad29b69943 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_regeneratekeyrequest.go @@ -0,0 +1,8 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeyRequest struct { + KeyName KeyName `json:"keyName"` +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go new file mode 100644 index 000000000000..f98eeddbbe8e --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go @@ -0,0 +1,43 @@ +package fluidrelayservers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/predicates.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/predicates.go new file mode 100644 index 000000000000..e618e42269b5 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/predicates.go @@ -0,0 +1,29 @@ +package fluidrelayservers + +type FluidRelayServerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FluidRelayServerOperationPredicate) Matches(input FluidRelayServer) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go new file mode 100644 index 000000000000..0998dbb32074 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go @@ -0,0 +1,12 @@ +package fluidrelayservers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-04-21" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelayservers/%s", defaultApiVersion) +} diff --git a/internal/services/fluidrelay/validate/fluid_relay_servers_id.go b/internal/services/fluidrelay/validate/fluid_relay_servers_id.go new file mode 100644 index 000000000000..d4aedcc5f49a --- /dev/null +++ b/internal/services/fluidrelay/validate/fluid_relay_servers_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/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/parse" +) + +func FluidRelayServersID(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.FluidRelayServersID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go b/internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go new file mode 100644 index 000000000000..1c010b0a33ec --- /dev/null +++ b/internal/services/fluidrelay/validate/fluid_relay_servers_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 TestFluidRelayServersID(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/67a9759d-d099-4aa8-8675-e6cfd669c3f4/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/", + Valid: false, + }, + + { + // missing FluidRelayServerName + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/", + Valid: false, + }, + + { + // missing value for FluidRelayServerName + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/67A9759D-D099-4AA8-8675-E6CFD669C3F4/RESOURCEGROUPS/MYRG/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/MYFLUID", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := FluidRelayServersID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/internal/services/fluidrelay/validate/server_name.go b/internal/services/fluidrelay/validate/server_name.go new file mode 100644 index 000000000000..10aebff9c1a6 --- /dev/null +++ b/internal/services/fluidrelay/validate/server_name.go @@ -0,0 +1,21 @@ +package validate + +import ( + "fmt" + "regexp" +) + +var serverNameReg = regexp.MustCompile(`^[-0-9a-zA-Z]{1,50}$`) + +func FluidRelayServerName(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 + } + // Name should contain only alphanumeric characters and hyphens, up to 50 characters long. + if !serverNameReg.MatchString(v) { + errors = append(errors, fmt.Errorf("Name should contain only alphanumeric characters and hyphens, up to 50 characters long.")) + } + return +} diff --git a/internal/services/fluidrelay/validate/server_name_test.go b/internal/services/fluidrelay/validate/server_name_test.go new file mode 100644 index 000000000000..a849f0b6c6c1 --- /dev/null +++ b/internal/services/fluidrelay/validate/server_name_test.go @@ -0,0 +1,63 @@ +package validate + +import ( + "strconv" + "testing" +) + +func TestFluidRelayServerName(t *testing.T) { + type args struct { + Input string + Valid bool + } + tests := []args{ + { + Input: "", + Valid: false, + }, + { + Input: "Ahc_dfs", + Valid: false, + }, + { + Input: "fds##$%#", + Valid: false, + }, + { + Input: "SUlwnodfs", + Valid: true, + }, + { + Input: "09810-", + Valid: true, + }, + { + Input: "-u432948230", + Valid: true, + }, + { + Input: "jkfdsj_de", + Valid: false, + }, + { + Input: "njkjoinjknkjnakjvdsjaneoihroiwjioionb6789233jn", + Valid: true, + }, + { + Input: "njk joinjknkjnakjvdsjaneoihroiwjioionb6789233jn", + Valid: false, + }, + { + Input: "njk1234567890sdfghjklcvbnmkjhgfcvbnjoinjknkjnakjvdsjaneoihroiwjioionb6789233jn", + Valid: false, + }, + } + for idx, tt := range tests { + t.Run(strconv.FormatInt(int64(idx), 10), func(t *testing.T) { + _, gotErrors := FluidRelayServerName(tt.Input, "test") + if (len(gotErrors) == 0) != tt.Valid { + t.Fatalf("server name validate `%s` expect %#v but got %#v", tt.Input, tt.Valid, gotErrors) + } + }) + } +} diff --git a/utils/pointer.go b/utils/pointer.go index bba617138c05..c5ca3877e09c 100644 --- a/utils/pointer.go +++ b/utils/pointer.go @@ -1,5 +1,10 @@ package utils +import ( + "encoding/json" + "reflect" +) + func Bool(input bool) *bool { return &input } @@ -23,3 +28,34 @@ func Float(input float64) *float64 { func String(input string) *string { return &input } + +// Ptr input MUST be not nil object +func Ptr[T any](input T) *T { + //v := reflect.ValueOf(input) + return &input +} + +// TryPtr input can be nil of any type +func TryPtr[T any](input T) *T { + v := reflect.ValueOf(input) + switch v.Kind() { + case reflect.Ptr, reflect.Map, reflect.Slice, reflect.Interface: + if v.IsNil() { + return nil + } + } + return &input +} + +func Value[T any](ptr *T) T { + if ptr == nil { + t := new(T) + return *t + } + return *ptr +} + +func JSONStr(obj interface{}) string { + bs, _ := json.Marshal(obj) + return string(bs) +} diff --git a/utils/pointer_test.go b/utils/pointer_test.go new file mode 100644 index 000000000000..d79667ff2d8a --- /dev/null +++ b/utils/pointer_test.go @@ -0,0 +1,58 @@ +package utils_test + +import ( + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +func TestValue(t *testing.T) { + s := []struct { + ptr *string + want string + }{ + { + nil, + "", + }, + { + utils.Ptr("abc"), + "abc", + }, + { + utils.Ptr(""), + "", + }, + } + for _, arg := range s { + if arg.want != utils.Value(arg.ptr) { + t.Fatal(arg) + } + } + v := utils.Value((*map[string]string)(nil)) + if v != nil { + t.Fatal(v) + } +} + +func TestTryPtr(t *testing.T) { + args := [][2]interface{}{ + {"abc", "abc"}, + {nil, nil}, + {(map[string]string)(nil), nil}, + {(*int)(nil), nil}, + } + for _, arg := range args { + ptr := utils.TryPtr(arg[0]) + //t.Logf("arg: %+v, ptr: %v", arg, ptr) + if ptr == nil { + if arg[1] != nil { + t.Fatal(arg, ptr) + } + continue + } + if *ptr != arg[1] { + t.Fatal(arg, ptr) + } + } +} From 092858a5ba4696d12e34a17ab8570fa65e7e94c3 Mon Sep 17 00:00:00 2001 From: wuxu Date: Thu, 9 Jun 2022 10:54:07 +0800 Subject: [PATCH 02/30] add test for fluid relay server --- .../fluid_relay_servers_resource.go | 44 +++---- .../fluid_relay_servers_resource_test.go | 116 ++++++++++++++++++ internal/services/fluidrelay/registration.go | 6 +- .../docs/r/fluid_relay_servers.html.markdown | 105 ++++++++++++++++ .../r/mssql_server_dns_alias.html.markdown | 2 +- 5 files changed, 245 insertions(+), 28 deletions(-) create mode 100644 internal/services/fluidrelay/fluid_relay_servers_resource_test.go create mode 100644 website/docs/r/fluid_relay_servers.html.markdown diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index b252a0533d59..7569f4b4ad7b 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -19,12 +19,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/utils" ) -//type Identity struct { -// Type string `tfschema:"type"` -// PrincipalID string `tfschema:"principal_id"` -// TenantID string `tfschea:"tenant_id"` -//} - type UserAssignedIdentity struct { IdentityID string `tfschema:"identity_id"` ClientID string `tfschema:"client_id"` @@ -37,7 +31,7 @@ type Encryption struct { KeyEncryptionKeyUrl string `tfschema:"key_encryption_key_url"` } -type ServersModel struct { +type ServerModel struct { Name string `tfschema:"name"` ResourceGroup string `tfschema:"resource_group_name"` Location string `tfschema:"location"` @@ -53,7 +47,7 @@ type ServersModel struct { Encryption []Encryption `tfschema:"encryption"` } -func (s *ServersModel) GenUserIdentities() *identity.SystemAndUserAssignedMap { +func (s *ServerModel) GenUserIdentities() *identity.SystemAndUserAssignedMap { res := &identity.SystemAndUserAssignedMap{ Type: "None", } @@ -79,7 +73,7 @@ func (s *ServersModel) GenUserIdentities() *identity.SystemAndUserAssignedMap { return res } -func (s *ServersModel) GenEncryption() *fluidrelayservers.EncryptionProperties { +func (s *ServerModel) GenEncryption() *fluidrelayservers.EncryptionProperties { if len(s.Encryption) == 0 { return nil } @@ -95,11 +89,11 @@ func (s *ServersModel) GenEncryption() *fluidrelayservers.EncryptionProperties { return res } -type Servers struct{} +type Server struct{} -var _ sdk.ResourceWithUpdate = (*Servers)(nil) +var _ sdk.ResourceWithUpdate = (*Server)(nil) -func (s Servers) Arguments() map[string]*pluginsdk.Schema { +func (s Server) Arguments() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "name": { Type: pluginsdk.TypeString, @@ -182,7 +176,7 @@ func (s Servers) Arguments() map[string]*pluginsdk.Schema { } } -func (s Servers) Attributes() map[string]*pluginsdk.Schema { +func (s Server) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "frs_tenant_id": { Type: pluginsdk.TypeString, @@ -220,21 +214,21 @@ func (s Servers) Attributes() map[string]*pluginsdk.Schema { } } -func (s Servers) ModelObject() interface{} { - return &ServersModel{} +func (s Server) ModelObject() interface{} { + return &ServerModel{} } -func (s Servers) ResourceType() string { - return "azurerm_fluid_relay_servers" +func (s Server) ResourceType() string { + return "azurerm_fluid_relay_server" } -func (s Servers) Create() sdk.ResourceFunc { +func (s Server) Create() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 30 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { client := meta.Client.FluidRelay.ServerClient - var model ServersModel + var model ServerModel if err = meta.Decode(&model); err != nil { return err } @@ -275,7 +269,7 @@ func (s Servers) Create() sdk.ResourceFunc { } // Update tags -func (s Servers) Update() sdk.ResourceFunc { +func (s Server) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 10 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { @@ -285,7 +279,7 @@ func (s Servers) Update() sdk.ResourceFunc { return err } - var model ServersModel + var model ServerModel if err = meta.Decode(&model); err != nil { return fmt.Errorf("decoding err: %+v", err) } @@ -312,7 +306,7 @@ func (s Servers) Update() sdk.ResourceFunc { } } -func (s Servers) Read() sdk.ResourceFunc { +func (s Server) Read() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 5 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { @@ -337,7 +331,7 @@ func (s Servers) Read() sdk.ResourceFunc { return fmt.Errorf("got fluid relay server as nil") } - output := ServersModel{ + output := ServerModel{ Name: id.FluidRelayServerName, ResourceGroup: id.ResourceGroup, Location: model.Location, @@ -383,7 +377,7 @@ func (s Servers) Read() sdk.ResourceFunc { } } -func (s Servers) Delete() sdk.ResourceFunc { +func (s Server) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 10 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) error { @@ -403,6 +397,6 @@ func (s Servers) Delete() sdk.ResourceFunc { } } -func (s Servers) IDValidationFunc() pluginsdk.SchemaValidateFunc { +func (s Server) IDValidationFunc() pluginsdk.SchemaValidateFunc { return fluidrelayservers.ValidateFluidRelayServerID } diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go new file mode 100644 index 000000000000..5e43637341b9 --- /dev/null +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -0,0 +1,116 @@ +package fluidrelay_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers" + "github.com/hashicorp/terraform-provider-azurerm/utils" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay" +) + +type FluidRelayResource struct{} + +func (f FluidRelayResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := fluidrelayservers.ParseFluidRelayServerID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.FluidRelay.ServerClient.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Ptr(false), nil + } + return nil, fmt.Errorf("retriving %s: %v", id, err) + } + if response.WasNotFound(resp.HttpResponse) { + return utils.Ptr(false), nil + } + return utils.Ptr(true), nil +} + +var s = fluidrelay.Server{} + +func TestAccFluidRelay_basic(t *testing.T) { + data := acceptance.BuildTestData(t, s.ResourceType(), "test") + f := FluidRelayResource{} + + data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + }) +} + +func TestAccFluidRelayServer_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, s.ResourceType(), "test") + var f FluidRelayResource + + data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.RequiresImportErrorStep(f.requiresImport), + }) +} + +func (f FluidRelayResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-appServerDNSAlias-%[1]d" + location = "%[2]s" +} + +resource "azurerm_user_assigned_identity" "test" { + name = "acctestRG-userAssignedIdentity-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_fluid_relay_server" "test" { + name = "acctestRG-fuildRelayServer-%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = "%[2]s" + identity_type = "SystemAssigned, UserAssigned" + user_assigned_identity { + identity_id= azurerm_user_assigned_identity.test.id + } + tags = { + foo = "bar" + } +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (f FluidRelayResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` + +%s + +resource "azurerm_fluid_relay_server" "import" { + name = azurerm_fluid_relay_server.test.name + resource_group_name = azurerm_fluid_relay_server.test.resource_group_name + location = azurerm_fluid_relay_server.test.location +} +`, f.basic(data)) +} diff --git a/internal/services/fluidrelay/registration.go b/internal/services/fluidrelay/registration.go index 52100f5fc921..083fccb4a3de 100644 --- a/internal/services/fluidrelay/registration.go +++ b/internal/services/fluidrelay/registration.go @@ -14,12 +14,14 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ - Servers{}, + Server{}, } } func (r Registration) WebsiteCategories() []string { - return []string{} + return []string{ + "Active Directory Domain Service", + } } var ( diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown new file mode 100644 index 000000000000..145cbf300b0b --- /dev/null +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -0,0 +1,105 @@ +--- +subcategory: "Active Directory Domain Service" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_fluid_relay_server" +description: |- + Manages a Fuild Relay Server. +--- + +# azurerm_fluid_relay_server + +Manages a Fuild Relay Server. + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_fluid_relay_server" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `location` - (Required) The Azure Region where the Fuild Relay Server should exist. Changing this forces a new Fuild Relay Server to be created. + +* `name` - (Required) The name which should be used for this Fuild Relay Server. Changing this forces a new Fuild Relay Server to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Fuild Relay Server should exist. Changing this forces a new Fuild Relay Server to be created. + +--- + +* `encryption` - (Optional) One or more `encryption` blocks as defined below. + +* `identity_type` - (Optional) The identity type, value can be `SystemAssigned`, `UserAssigned`,`SystemAssigned, UserAssigned`, `None`. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Fuild Relay Server. + +* `user_assigned_identity` - (Optional) One or more `user_assigned_identity` blocks as defined below. + +--- + +A `encryption` block supports the following: + +* `identity_resource_id` - (Optional) user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. + +* `identity_type` - (Optional) Values can be `SystemAssigned` or `UserAssigned`. + +* `key_encryption_key_url` - (Optional) key encryption key Url, with or without a version. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek. Key auto rotation is enabled by providing a key uri without version. Otherwise, customer is responsible for rotating the key. The keyEncryptionKeyIdentity(either SystemAssigned or UserAssigned) should have permission to access this key url. + +--- + +A `user_assigned_identity` block supports the following: + +* `client_id` - (Optional) The client id of user assigned identity. + +* `identity_id` - (Optional) user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity.. + +* `principal_id` - (Optional) The principal id of user assigned identity. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Fuild Relay Server. + +* `frs_tenant_id` - The Fluid tenantId for this server. + +* `orderer_endpoints` - A `orderer_endpoints` block as defined below. + +* `principal_id` - The principal ID of resource identity. + +* `provisioning_state` - Provision states for FluidRelay RP, value can be `Succeeded`, `Failed`, `Canceled`. + +* `storage_endpoints` - A `storage_endpoints` block as defined below. + +* `tenant_id` - The tenant ID of resource. + +## 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 Fuild Relay Server. +* `read` - (Defaults to 5 minutes) Used when retrieving the Fuild Relay Server. +* `update` - (Defaults to 10 minutes) Used when updating the Fuild Relay Server. +* `delete` - (Defaults to 10 minutes) Used when deleting the Fuild Relay Server. + +## Import + +Fuild Relay Servers can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_fluid_relay_server.example /subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid +``` \ No newline at end of file diff --git a/website/docs/r/mssql_server_dns_alias.html.markdown b/website/docs/r/mssql_server_dns_alias.html.markdown index ad62b70d50a7..59acca2c3e4a 100644 --- a/website/docs/r/mssql_server_dns_alias.html.markdown +++ b/website/docs/r/mssql_server_dns_alias.html.markdown @@ -63,7 +63,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d ## Import -MSSQL Server DNS Aliass can be imported using the `resource id`, e.g. +MSSQL Server DNS Alias can be imported using the `resource id`, e.g. ```shell terraform import azurerm_mssql_server_dns_alias.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/dnsAliases/default From 4ce7843ad8ba058c99e621cede2fb51d6322c87b Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 13 Jun 2022 07:59:28 +0800 Subject: [PATCH 03/30] update fluid relay sdk version to 2022-05-26 --- internal/services/fluidrelay/client/client.go | 2 +- .../fluid_relay_servers_resource.go | 2 +- .../fluid_relay_servers_resource_test.go | 2 +- .../model_fluidrelaycontainerproperties.go | 10 --- .../fluidrelaycontainers/model_systemdata.go | 43 ------------- .../fluidrelayservers/model_systemdata.go | 43 ------------- .../fluidrelaycontainers/client.go | 0 .../fluidrelaycontainers/constants.go | 34 ---------- .../id_fluidrelaycontainer.go | 0 .../id_fluidrelaycontainer_test.go | 0 .../id_fluidrelayserver.go | 0 .../id_fluidrelayserver_test.go | 0 .../method_delete_autorest.go | 0 .../method_get_autorest.go | 0 ...method_listbyfluidrelayservers_autorest.go | 0 .../model_fluidrelaycontainer.go | 6 +- .../model_fluidrelaycontainerproperties.go | 42 +++++++++++++ .../fluidrelaycontainers/predicates.go | 0 .../fluidrelaycontainers/version.go | 2 +- .../fluidrelayservers/client.go | 0 .../fluidrelayservers/constants.go | 62 +++++++++---------- .../fluidrelayservers/id_fluidrelayserver.go | 0 .../id_fluidrelayserver_test.go | 0 .../method_createorupdate_autorest.go | 0 .../method_delete_autorest.go | 0 .../fluidrelayservers/method_get_autorest.go | 0 .../method_getkeys_autorest.go | 0 .../method_listbyresourcegroup_autorest.go | 0 .../method_listbysubscription_autorest.go | 0 .../method_listkeys_autorest.go | 0 .../method_regeneratekey_autorest.go | 0 .../method_update_autorest.go | 0 ..._customermanagedkeyencryptionproperties.go | 0 ...ptionpropertieskeyencryptionkeyidentity.go | 0 .../model_encryptionproperties.go | 0 .../model_fluidrelayendpoints.go | 1 + .../model_fluidrelayserver.go | 3 +- .../model_fluidrelayserverkeys.go | 0 .../model_fluidrelayserverproperties.go | 1 + .../model_fluidrelayserverupdate.go | 0 .../model_fluidrelayserverupdateproperties.go | 0 .../model_regeneratekeyrequest.go | 0 .../fluidrelayservers/predicates.go | 0 .../fluidrelayservers/version.go | 2 +- 44 files changed, 84 insertions(+), 171 deletions(-) delete mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go delete mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go delete mode 100644 internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/client.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/constants.go (52%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/id_fluidrelaycontainer.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/id_fluidrelaycontainer_test.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/id_fluidrelayserver.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/id_fluidrelayserver_test.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/method_delete_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/method_get_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/model_fluidrelaycontainer.go (77%) create mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/predicates.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelaycontainers/version.go (89%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/client.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/constants.go (76%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/id_fluidrelayserver.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/id_fluidrelayserver_test.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_createorupdate_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_delete_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_get_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_getkeys_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_listbyresourcegroup_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_listbysubscription_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_listkeys_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_regeneratekey_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/method_update_autorest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_customermanagedkeyencryptionproperties.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_encryptionproperties.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_fluidrelayendpoints.go (84%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_fluidrelayserver.go (85%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_fluidrelayserverkeys.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_fluidrelayserverproperties.go (88%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_fluidrelayserverupdate.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_fluidrelayserverupdateproperties.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/model_regeneratekeyrequest.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/predicates.go (100%) rename internal/services/fluidrelay/sdk/{2022-04-21 => 2022-05-26}/fluidrelayservers/version.go (88%) diff --git a/internal/services/fluidrelay/client/client.go b/internal/services/fluidrelay/client/client.go index 5a72a871138e..5a62e1143694 100644 --- a/internal/services/fluidrelay/client/client.go +++ b/internal/services/fluidrelay/client/client.go @@ -2,7 +2,7 @@ package client import ( "github.com/hashicorp/terraform-provider-azurerm/internal/common" - servers "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers" + servers "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" ) type Client struct { diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 7569f4b4ad7b..c8453dbdf61a 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/msi/sdk/2018-11-30/managedidentity" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 5e43637341b9..a22396637d95 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/utils" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go deleted file mode 100644 index 1cafc0ee93e3..000000000000 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainerproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package fluidrelaycontainers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayContainerProperties struct { - FrsContainerId *string `json:"frsContainerId,omitempty"` - FrsTenantId *string `json:"frsTenantId,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go deleted file mode 100644 index f08898fa092c..000000000000 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_systemdata.go +++ /dev/null @@ -1,43 +0,0 @@ -package fluidrelaycontainers - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o *SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go b/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go deleted file mode 100644 index f98eeddbbe8e..000000000000 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_systemdata.go +++ /dev/null @@ -1,43 +0,0 @@ -package fluidrelayservers - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o *SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/client.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/client.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/client.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/client.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go similarity index 52% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go index a4c9dded6e32..323b3e0df339 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/constants.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go @@ -5,40 +5,6 @@ import "strings" // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - type ProvisioningState string const ( diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer_test.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer_test.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelaycontainer_test.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer_test.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver_test.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver_test.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/id_fluidrelayserver_test.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver_test.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_delete_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_delete_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_delete_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_delete_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_get_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_get_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_get_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_get_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go similarity index 77% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go index 4222eb048f15..877b6b85d23c 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/model_fluidrelaycontainer.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go @@ -1,5 +1,9 @@ package fluidrelaycontainers +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -7,6 +11,6 @@ type FluidRelayContainer struct { Id *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` Properties *FluidRelayContainerProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` Type *string `json:"type,omitempty"` } diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go new file mode 100644 index 000000000000..8a8f859f4670 --- /dev/null +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go @@ -0,0 +1,42 @@ +package fluidrelaycontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayContainerProperties struct { + CreationTime *string `json:"creationTime,omitempty"` + FrsContainerId *string `json:"frsContainerId,omitempty"` + FrsTenantId *string `json:"frsTenantId,omitempty"` + LastAccessTime *string `json:"lastAccessTime,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} + +func (o *FluidRelayContainerProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *FluidRelayContainerProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *FluidRelayContainerProperties) GetLastAccessTimeAsTime() (*time.Time, error) { + if o.LastAccessTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastAccessTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *FluidRelayContainerProperties) SetLastAccessTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastAccessTime = &formatted +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/predicates.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/predicates.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/predicates.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/predicates.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go similarity index 89% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go index 1e9cdb04a805..b5d8c8f84670 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelaycontainers/version.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go @@ -5,7 +5,7 @@ import "fmt" // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2022-04-21" +const defaultApiVersion = "2022-05-26" func userAgent() string { return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelaycontainers/%s", defaultApiVersion) diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/client.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/client.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/client.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/client.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go similarity index 76% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go index 61a9dc7d62e2..1d0e44d42c6b 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/constants.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go @@ -33,40 +33,6 @@ func parseCmkIdentityType(input string) (*CmkIdentityType, error) { return &out, nil } -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - type KeyName string const ( @@ -125,3 +91,31 @@ func parseProvisioningState(input string) (*ProvisioningState, error) { out := ProvisioningState(input) return &out, nil } + +type StorageSKU string + +const ( + StorageSKUBasic StorageSKU = "basic" + StorageSKUStandard StorageSKU = "standard" +) + +func PossibleValuesForStorageSKU() []string { + return []string{ + string(StorageSKUBasic), + string(StorageSKUStandard), + } +} + +func parseStorageSKU(input string) (*StorageSKU, error) { + vals := map[string]StorageSKU{ + "basic": StorageSKUBasic, + "standard": StorageSKUStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageSKU(input) + return &out, nil +} diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver_test.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver_test.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/id_fluidrelayserver_test.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver_test.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_createorupdate_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_createorupdate_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_delete_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_delete_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_delete_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_delete_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_get_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_get_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_get_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_get_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_getkeys_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_getkeys_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_getkeys_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_getkeys_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbyresourcegroup_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbyresourcegroup_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbysubscription_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listbysubscription_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listkeys_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listkeys_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_listkeys_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listkeys_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_regeneratekey_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_regeneratekey_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_update_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_update_autorest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/method_update_autorest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_update_autorest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionproperties.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_encryptionproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_encryptionproperties.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_encryptionproperties.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_encryptionproperties.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go similarity index 84% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go index 175afee0e667..7d6f78c08fbd 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayendpoints.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go @@ -5,5 +5,6 @@ package fluidrelayservers type FluidRelayEndpoints struct { OrdererEndpoints *[]string `json:"ordererEndpoints,omitempty"` + ServiceEndpoints *[]string `json:"serviceEndpoints,omitempty"` StorageEndpoints *[]string `json:"storageEndpoints,omitempty"` } diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go similarity index 85% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go index ade1a2f546b2..2295c002065a 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserver.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go @@ -2,6 +2,7 @@ package fluidrelayservers import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" ) // Copyright (c) Microsoft Corporation. All rights reserved. @@ -13,7 +14,7 @@ type FluidRelayServer struct { Location string `json:"location"` Name *string `json:"name,omitempty"` Properties *FluidRelayServerProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` Tags *map[string]string `json:"tags,omitempty"` Type *string `json:"type,omitempty"` } diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverkeys.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverkeys.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go similarity index 88% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go index 05a534a33267..1c430eab5e3c 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverproperties.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go @@ -8,4 +8,5 @@ type FluidRelayServerProperties struct { FluidRelayEndpoints *FluidRelayEndpoints `json:"fluidRelayEndpoints,omitempty"` FrsTenantId *string `json:"frsTenantId,omitempty"` ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Storagesku *StorageSKU `json:"storagesku,omitempty"` } diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdate.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdate.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdateproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_fluidrelayserverupdateproperties.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_regeneratekeyrequest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/model_regeneratekeyrequest.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/predicates.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/predicates.go similarity index 100% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/predicates.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/predicates.go diff --git a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go similarity index 88% rename from internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go rename to internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go index 0998dbb32074..7664a0458cc0 100644 --- a/internal/services/fluidrelay/sdk/2022-04-21/fluidrelayservers/version.go +++ b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go @@ -5,7 +5,7 @@ import "fmt" // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2022-04-21" +const defaultApiVersion = "2022-05-26" func userAgent() string { return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelayservers/%s", defaultApiVersion) From 119cbca66a8673a55e3390e6e1586a29e3733235 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 14 Jun 2022 16:01:34 +0800 Subject: [PATCH 04/30] add relayfluid complete test and remove some log --- .../fluid_relay_servers_resource.go | 3 - .../fluid_relay_servers_resource_test.go | 58 +++++++++++++++++-- utils/pointer.go | 8 +-- 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index c8453dbdf61a..035c9d1b68ab 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -254,9 +254,6 @@ func (s Server) Create() sdk.ResourceFunc { serverReq.Properties.Encryption = model.GenEncryption() serverReq.Identity = model.GenUserIdentities() - log := fmt.Sprintf("generate req: %s by model: %s", utils.JSONStr(serverReq), utils.JSONStr(model)) - meta.Logger.Infof("start creating: %s, data: %s", id, log) - //return fmt.Errorf("interrupt by test: %s", log) resp, err := client.CreateOrUpdate(ctx, id, serverReq) if err != nil { return fmt.Errorf("creating %v err: %+v, resp: %+v", id, err, resp) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index a22396637d95..0bd42cf586ad 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -70,7 +70,30 @@ func TestAccFluidRelayServer_requiresImport(t *testing.T) { }) } -func (f FluidRelayResource) basic(data acceptance.TestData) string { +func TestAccFluidRelayServer_complete(t *testing.T) { + data := acceptance.BuildTestData(t, s.ResourceType(), "test") + var f FluidRelayResource + + data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + check.That(data.ResourceName).Key("tags.foo").HasValue("bar"), + ), + }, + data.ImportStep(), + { + Config: f.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + check.That(data.ResourceName).Key("tags.foo").HasValue("bar2"), + ), + }, + }) +} + +func (f FluidRelayResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -86,11 +109,18 @@ resource "azurerm_user_assigned_identity" "test" { resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } +`, data.RandomInteger, data.Locations.Primary) +} + +func (f FluidRelayResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s resource "azurerm_fluid_relay_server" "test" { - name = "acctestRG-fuildRelayServer-%[1]d" + name = "acctestRG-fuildRelayServer-%[2]d" resource_group_name = azurerm_resource_group.test.name - location = "%[2]s" + location = "%[3]s" identity_type = "SystemAssigned, UserAssigned" user_assigned_identity { identity_id= azurerm_user_assigned_identity.test.id @@ -99,7 +129,7 @@ resource "azurerm_fluid_relay_server" "test" { foo = "bar" } } -`, data.RandomInteger, data.Locations.Primary) +`, f.template(data), data.RandomInteger, data.Locations.Primary) } func (f FluidRelayResource) requiresImport(data acceptance.TestData) string { @@ -114,3 +144,23 @@ resource "azurerm_fluid_relay_server" "import" { } `, f.basic(data)) } + +func (f FluidRelayResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s + +resource "azurerm_fluid_relay_server" "test" { + name = "acctestRG-fuildRelayServer-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = "%[3]s" + identity_type = "SystemAssigned, UserAssigned" + user_assigned_identity { + identity_id= azurerm_user_assigned_identity.test.id + } + tags = { + foo = "bar2" + } +} +`, f.template(data), data.RandomInteger, data.Locations.Primary) +} diff --git a/utils/pointer.go b/utils/pointer.go index c5ca3877e09c..3948091fb1e2 100644 --- a/utils/pointer.go +++ b/utils/pointer.go @@ -1,7 +1,6 @@ package utils import ( - "encoding/json" "reflect" ) @@ -29,7 +28,7 @@ func String(input string) *string { return &input } -// Ptr input MUST be not nil object +// Ptr input MUST NOT be nil object func Ptr[T any](input T) *T { //v := reflect.ValueOf(input) return &input @@ -54,8 +53,3 @@ func Value[T any](ptr *T) T { } return *ptr } - -func JSONStr(obj interface{}) string { - bs, _ := json.Marshal(obj) - return string(bs) -} From 367a27f7816e4049a5cce709daf2717d0d027cdf Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 14 Jun 2022 16:10:26 +0800 Subject: [PATCH 05/30] update website categories of fluid relay --- internal/services/fluidrelay/registration.go | 2 +- utils/pointer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/fluidrelay/registration.go b/internal/services/fluidrelay/registration.go index 083fccb4a3de..b01ebceca832 100644 --- a/internal/services/fluidrelay/registration.go +++ b/internal/services/fluidrelay/registration.go @@ -20,7 +20,7 @@ func (r Registration) Resources() []sdk.Resource { func (r Registration) WebsiteCategories() []string { return []string{ - "Active Directory Domain Service", + "Active Directory Domain Services", } } diff --git a/utils/pointer.go b/utils/pointer.go index 3948091fb1e2..eb16dddde34a 100644 --- a/utils/pointer.go +++ b/utils/pointer.go @@ -28,7 +28,7 @@ func String(input string) *string { return &input } -// Ptr input MUST NOT be nil object +// Ptr input MUST NOT nil object func Ptr[T any](input T) *T { //v := reflect.ValueOf(input) return &input From 4fee5e44666a69e3888781f78df45fc6aed74efc Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 14 Jun 2022 17:47:54 +0800 Subject: [PATCH 06/30] fix some issues, need more fix --- .../fluid_relay_servers_resource.go | 53 ++++++++----------- internal/services/fluidrelay/resourceids.go | 2 +- .../fluidrelay/validate/server_name.go | 2 +- .../docs/r/fluid_relay_servers.html.markdown | 26 ++++----- .../r/mssql_server_dns_alias.html.markdown | 2 +- 5 files changed, 38 insertions(+), 47 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 035c9d1b68ab..aa8f666e4472 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -99,7 +99,6 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - Description: "The Fluid Relay server resource name", ValidateFunc: validate.FluidRelayServerName, }, "resource_group_name": commonschema.ResourceGroupName(), @@ -117,12 +116,12 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { "None", }, false), }, + "identity": commonschema.SystemOrUserAssignedIdentityOptional(), "user_assigned_identity": { - Type: pluginsdk.TypeList, - Optional: true, - Computed: true, - ConfigMode: pluginsdk.SchemaConfigModeBlock, - Description: "The list of user identities associated with the resource.", + Type: pluginsdk.TypeList, + Optional: true, + Computed: true, + ConfigMode: pluginsdk.SchemaConfigModeBlock, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "identity_id": { @@ -132,24 +131,21 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { ValidateFunc: managedidentity.ValidateUserAssignedIdentitiesID, }, "client_id": { - Type: pluginsdk.TypeString, - Computed: true, - Optional: true, - Description: "The client id of user assigned identity.", + Type: pluginsdk.TypeString, + Computed: true, + Optional: true, }, "principal_id": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, - Description: "The principal id of user assigned identity.", + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, }, }, }, }, "encryption": { - Type: pluginsdk.TypeList, - Optional: true, - Description: "Create with Cmk.", + Type: pluginsdk.TypeList, + Optional: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "identity_type": { @@ -158,12 +154,10 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { ValidateFunc: validation.StringInSlice( fluidrelayservers.PossibleValuesForCmkIdentityType(), false), - Description: "Values can be SystemAssigned or UserAssigned.", }, "key_encryption_key_url": { - Type: pluginsdk.TypeString, - Optional: true, - Description: "user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity.", + Type: pluginsdk.TypeString, + Optional: true, }, "identity_resource_id": { Type: pluginsdk.TypeString, @@ -179,9 +173,8 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { func (s Server) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "frs_tenant_id": { - Type: pluginsdk.TypeString, - Computed: true, - Description: "The Fluid tenantId for this server", + Type: pluginsdk.TypeString, + Computed: true, }, "provisioning_state": { Type: pluginsdk.TypeString, @@ -202,14 +195,12 @@ func (s Server) Attributes() map[string]*pluginsdk.Schema { }, }, "principal_id": { - Type: pluginsdk.TypeString, - Computed: true, - Description: "The principal ID of resource identity", + Type: pluginsdk.TypeString, + Computed: true, }, "tenant_id": { - Type: pluginsdk.TypeString, - Computed: true, - Description: "The tenant ID of resource", + Type: pluginsdk.TypeString, + Computed: true, }, } } @@ -256,7 +247,7 @@ func (s Server) Create() sdk.ResourceFunc { resp, err := client.CreateOrUpdate(ctx, id, serverReq) if err != nil { - return fmt.Errorf("creating %v err: %+v, resp: %+v", id, err, resp) + return fmt.Errorf("creating %v err: %+v", id, err) } meta.SetID(id) diff --git a/internal/services/fluidrelay/resourceids.go b/internal/services/fluidrelay/resourceids.go index 0d5fb25a81b9..84a7525948ab 100644 --- a/internal/services/fluidrelay/resourceids.go +++ b/internal/services/fluidrelay/resourceids.go @@ -1,4 +1,4 @@ package fluidrelay // Fluid Relay IDs -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FluidRelayServers -id=/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FluidRelayServers -id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1 diff --git a/internal/services/fluidrelay/validate/server_name.go b/internal/services/fluidrelay/validate/server_name.go index 10aebff9c1a6..68330fa3e235 100644 --- a/internal/services/fluidrelay/validate/server_name.go +++ b/internal/services/fluidrelay/validate/server_name.go @@ -5,7 +5,7 @@ import ( "regexp" ) -var serverNameReg = regexp.MustCompile(`^[-0-9a-zA-Z]{1,50}$`) +var serverNameReg = regexp.MustCompile(`^[-\w]{1,50}$`) func FluidRelayServerName(input interface{}, key string) (warnings []string, errors []error) { v, ok := input.(string) diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index 145cbf300b0b..aa2244f9add7 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -1,5 +1,5 @@ --- -subcategory: "Active Directory Domain Service" +subcategory: "Active Directory Domain Services" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_fluid_relay_server" description: |- @@ -43,15 +43,15 @@ The following arguments are supported: * `encryption` - (Optional) One or more `encryption` blocks as defined below. -* `identity_type` - (Optional) The identity type, value can be `SystemAssigned`, `UserAssigned`,`SystemAssigned, UserAssigned`, `None`. +* `identity_type` - (Optional) The identity type for this Fluid Relay Server. Possible values are `SystemAssigned`, `UserAssigned`,`SystemAssigned, UserAssigned` and `None`. * `tags` - (Optional) A mapping of tags which should be assigned to the Fuild Relay Server. -* `user_assigned_identity` - (Optional) One or more `user_assigned_identity` blocks as defined below. +* An `identity` block supports the following: --- -A `encryption` block supports the following: +An `encryption` block supports the following: * `identity_resource_id` - (Optional) user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. @@ -61,7 +61,9 @@ A `encryption` block supports the following: --- -A `user_assigned_identity` block supports the following: +An `identity` block supports the following: + +* `type` - can be `SystemAssigned` or `UserAssigned`. * `client_id` - (Optional) The client id of user assigned identity. @@ -77,15 +79,13 @@ In addition to the Arguments listed above - the following Attributes are exporte * `frs_tenant_id` - The Fluid tenantId for this server. -* `orderer_endpoints` - A `orderer_endpoints` block as defined below. - -* `principal_id` - The principal ID of resource identity. +* `orderer_endpoints` - The Fluid Relay Orderer endpoints. -* `provisioning_state` - Provision states for FluidRelay RP, value can be `Succeeded`, `Failed`, `Canceled`. +* `principal_id` - The principal ID of the Fluid Relay Server. -* `storage_endpoints` - A `storage_endpoints` block as defined below. +* `storage_endpoints` - The Fluid Relay storage endpoints. -* `tenant_id` - The tenant ID of resource. +* `tenant_id` - The tenant ID of the Fluid Relay Server. ## Timeouts @@ -101,5 +101,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d Fuild Relay Servers can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_fluid_relay_server.example /subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid -``` \ No newline at end of file +terraform import azurerm_fluid_relay_server.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1 +``` diff --git a/website/docs/r/mssql_server_dns_alias.html.markdown b/website/docs/r/mssql_server_dns_alias.html.markdown index 59acca2c3e4a..ad62b70d50a7 100644 --- a/website/docs/r/mssql_server_dns_alias.html.markdown +++ b/website/docs/r/mssql_server_dns_alias.html.markdown @@ -63,7 +63,7 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d ## Import -MSSQL Server DNS Alias can be imported using the `resource id`, e.g. +MSSQL Server DNS Aliass can be imported using the `resource id`, e.g. ```shell terraform import azurerm_mssql_server_dns_alias.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/dnsAliases/default From ceb3d57501f7ad850450ee7cda5aa71864f1c44f Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Wed, 15 Jun 2022 18:00:19 +0800 Subject: [PATCH 07/30] fix pr issue --- go.sum | 2 + .../fluid_relay_servers_resource.go | 228 +++++------------- .../fluid_relay_servers_resource_test.go | 90 ++++++- internal/services/fluidrelay/registration.go | 2 +- website/allowed-subcategories | 1 + .../docs/r/fluid_relay_servers.html.markdown | 42 ++-- 6 files changed, 161 insertions(+), 204 deletions(-) diff --git a/go.sum b/go.sum index 69aec316f38e..d46c234faa45 100644 --- a/go.sum +++ b/go.sum @@ -257,6 +257,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg= +github.com/hashicorp/go-azure-helpers v0.33.0 h1:ClAtKDk0g96eBv0PI/O/HkZXwLhaxSLtf9f3HqXRCtY= +github.com/hashicorp/go-azure-helpers v0.33.0/go.mod h1:gcutZ/Hf/O7YN9M3UIvyZ9l0Rxv7Yrc9x5sSfM9cuSw= github.com/hashicorp/go-azure-helpers v0.34.0 h1:Lvk3IgwFT51WVu1IK5rpUMd+rKnRylg9vMTt6Qx6xn4= github.com/hashicorp/go-azure-helpers v0.34.0/go.mod h1:gcutZ/Hf/O7YN9M3UIvyZ9l0Rxv7Yrc9x5sSfM9cuSw= github.com/hashicorp/go-azure-sdk v0.20220621.155357 h1:U6tH1S4ZzhAEBCD/WlVwUlNVU/EDXBeL9AqkpbMx2ls= diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index aa8f666e4472..eeda0e4f282f 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -5,17 +5,16 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/msi/sdk/2018-11-30/managedidentity" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -25,68 +24,51 @@ type UserAssignedIdentity struct { PrincipalID string `tfschema:"principal_id"` } -type Encryption struct { - IdentityType string `tfschema:"identity_type"` - IdentityResourceId string `tfschema:"identity_resource_id"` - KeyEncryptionKeyUrl string `tfschema:"key_encryption_key_url"` +type ServerModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` + FrsTenantId string `tfschema:"frs_tenant_id"` + OrdererEndpoints []string `tfschema:"orderer_endpoints"` + StorageEndpoints []string `tfschema:"storage_endpoints"` + //IdentityType string `tfschema:"identity_type"` + TenantID string `tfschema:"tenant_id"` + PrincipalID string `tfschema:"principal_id"` + //UserAssignedIdentities []UserAssignedIdentity `tfschema:"user_assigned_identity"` + Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"` } -type ServerModel struct { - Name string `tfschema:"name"` - ResourceGroup string `tfschema:"resource_group_name"` - Location string `tfschema:"location"` - Tags map[string]string `tfschema:"tags"` - FrsTenantId string `tfschema:"frs_tenant_id"` - ProvisioningState string `tfschema:"provisioning_state"` - OrdererEndpoints []string `tfschema:"orderer_endpoints"` - StorageEndpoints []string `tfschema:"storage_endpoints"` - IdentityType string `tfschema:"identity_type"` - TenantID string `tfschema:"tenant_id"` - PrincipalID string `tfschema:"principal_id"` - UserAssignedIdentities []UserAssignedIdentity `tfschema:"user_assigned_identity"` - Encryption []Encryption `tfschema:"encryption"` +func (s ServerModel) expandUserIdentities() (res *identity.SystemAndUserAssignedMap, err error) { + //res := &identity.SystemAndUserAssignedMap{ + // Type: "None", + //} + res, err = identity.ExpandSystemAndUserAssignedMapFromModel(s.Identity) + return res, err } -func (s *ServerModel) GenUserIdentities() *identity.SystemAndUserAssignedMap { - res := &identity.SystemAndUserAssignedMap{ - Type: "None", - } - if s == nil || len(s.UserAssignedIdentities) == 0 { - return res - } - if s.IdentityType != "" { - res.Type = identity.Type(s.IdentityType) - } - if s.PrincipalID != "" { - res.PrincipalId = s.PrincipalID +func (s *ServerModel) flattenIdentity(input *identity.SystemAndUserAssignedMap) error { + if input == nil { + return nil } - if s.TenantID != "" { - res.TenantId = s.TenantID + config := identity.SystemOrUserAssignedMap{ + Type: input.Type, + PrincipalId: input.PrincipalId, + TenantId: input.TenantId, + IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), } - res.IdentityIds = map[string]identity.UserAssignedIdentityDetails{} - for _, id := range s.UserAssignedIdentities { - res.IdentityIds[id.IdentityID] = identity.UserAssignedIdentityDetails{ - ClientId: utils.Ptr(id.ClientID), - PrincipalId: utils.Ptr(id.PrincipalID), + for k, v := range input.IdentityIds { + config.IdentityIds[k] = identity.UserAssignedIdentityDetails{ + ClientId: v.ClientId, + PrincipalId: v.PrincipalId, } } - return res -} - -func (s *ServerModel) GenEncryption() *fluidrelayservers.EncryptionProperties { - if len(s.Encryption) == 0 { - return nil + model, err := identity.FlattenSystemOrUserAssignedMapToModel(&config) + if err != nil { + return err } - encryption := s.Encryption[0] - res := &fluidrelayservers.EncryptionProperties{ - CustomerManagedKeyEncryption: &fluidrelayservers.CustomerManagedKeyEncryptionProperties{ - KeyEncryptionKeyIdentity: &fluidrelayservers.CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity{ - IdentityType: utils.Ptr(fluidrelayservers.CmkIdentityType(encryption.IdentityType)), - UserAssignedIdentityResourceId: utils.Ptr(encryption.IdentityResourceId), - }, - KeyEncryptionKeyUrl: utils.Ptr(encryption.KeyEncryptionKeyUrl), - }} - return res + s.Identity = *model + return nil } type Server struct{} @@ -104,69 +86,7 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { "resource_group_name": commonschema.ResourceGroupName(), "location": commonschema.Location(), "tags": commonschema.Tags(), - "identity_type": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, - //Default: "SystemAssigned", - ValidateFunc: validation.StringInSlice([]string{ - "SystemAssigned", - "UserAssigned", - "SystemAssigned, UserAssigned", - "None", - }, false), - }, - "identity": commonschema.SystemOrUserAssignedIdentityOptional(), - "user_assigned_identity": { - Type: pluginsdk.TypeList, - Optional: true, - Computed: true, - ConfigMode: pluginsdk.SchemaConfigModeBlock, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "identity_id": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, - ValidateFunc: managedidentity.ValidateUserAssignedIdentitiesID, - }, - "client_id": { - Type: pluginsdk.TypeString, - Computed: true, - Optional: true, - }, - "principal_id": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, - }, - }, - }, - }, - "encryption": { - Type: pluginsdk.TypeList, - Optional: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "identity_type": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice( - fluidrelayservers.PossibleValuesForCmkIdentityType(), - false), - }, - "key_encryption_key_url": { - Type: pluginsdk.TypeString, - Optional: true, - }, - "identity_resource_id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: managedidentity.ValidateUserAssignedIdentitiesID, - }, - }, - }, - }, + "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), } } @@ -176,10 +96,6 @@ func (s Server) Attributes() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Computed: true, }, - "provisioning_state": { - Type: pluginsdk.TypeString, - Computed: true, - }, "orderer_endpoints": { Type: pluginsdk.TypeList, Computed: true, @@ -242,10 +158,12 @@ func (s Server) Create() sdk.ResourceFunc { } serverReq.Tags = utils.TryPtr(model.Tags) serverReq.Properties = &fluidrelayservers.FluidRelayServerProperties{} - serverReq.Properties.Encryption = model.GenEncryption() - serverReq.Identity = model.GenUserIdentities() + serverReq.Identity, err = model.expandUserIdentities() + if err != nil { + return fmt.Errorf("expanding user identities: %+v", err) + } - resp, err := client.CreateOrUpdate(ctx, id, serverReq) + _, err = client.CreateOrUpdate(ctx, id, serverReq) if err != nil { return fmt.Errorf("creating %v err: %+v", id, err) } @@ -262,7 +180,7 @@ func (s Server) Update() sdk.ResourceFunc { Timeout: 10 * time.Minute, Func: func(ctx context.Context, meta sdk.ResourceMetaData) (err error) { client := meta.Client.FluidRelay.ServerClient - id, err := fluidrelayservers.ParseFluidRelayServerIDInsensitively(meta.ResourceData.Id()) + id, err := fluidrelayservers.ParseFluidRelayServerID(meta.ResourceData.Id()) if err != nil { return err } @@ -273,22 +191,22 @@ func (s Server) Update() sdk.ResourceFunc { } var upd fluidrelayservers.FluidRelayServerUpdate - if meta.ResourceData.HasChanges("tags", "location") { + if meta.ResourceData.HasChange("tags") { upd.Tags = &model.Tags - upd.Location = utils.String(azure.NormalizeLocation(model.Location)) - } - if meta.ResourceData.HasChanges("identity_type", "user_assigned_identity") { - upd.Identity = model.GenUserIdentities() } - if meta.ResourceData.HasChanges("encryption") { - upd.Properties = &fluidrelayservers.FluidRelayServerUpdateProperties{} - upd.Properties.Encryption = model.GenEncryption() + if meta.ResourceData.HasChange("identity") { + upd.Identity, err = model.expandUserIdentities() + if err != nil { + return fmt.Errorf("expanding user identities: %+v", err) + } } _, err = client.Update(ctx, *id, upd) if err != nil { - return fmt.Errorf("updating fluid relay err: %v", err) + return fmt.Errorf("updating %s: %v", id, err) } - // do a read after update + + meta.SetID(id) + return nil }, } @@ -305,52 +223,26 @@ func (s Server) Read() sdk.ResourceFunc { return err } - if id == nil { - return fmt.Errorf("parsed id is nil") - } - server, err := client.Get(ctx, *id) if err != nil { - return err + return fmt.Errorf("retrieving %s: %v", id, err) } model := server.Model - if model == nil { - return fmt.Errorf("got fluid relay server as nil") - } output := ServerModel{ Name: id.FluidRelayServerName, ResourceGroup: id.ResourceGroup, - Location: model.Location, - IdentityType: string(model.Identity.Type), + Location: location.Normalize(model.Location), } - if model.Identity != nil { - output.TenantID = model.Identity.TenantId - output.PrincipalID = model.Identity.PrincipalId - for id, details := range model.Identity.IdentityIds { - // try parse id, because the response id could be modified to lower-case - iid, err := commonids.ParseUserAssignedIdentityIDInsensitively(id) - if err != nil { - meta.Logger.Warnf("normalize managed identity id `%s` parse err: %v", id, err) - } else { - id = iid.ID() - } - output.UserAssignedIdentities = append(output.UserAssignedIdentities, UserAssignedIdentity{ - IdentityID: id, - ClientID: utils.Value(details.ClientId), - PrincipalID: utils.Value(details.PrincipalId), - }) - } + if err = output.flattenIdentity(model.Identity); err != nil { + return fmt.Errorf("flattening `identity`: %v", err) } output.Tags = utils.Value(server.Model.Tags) if prop := model.Properties; prop != nil { if prop.FrsTenantId != nil { output.FrsTenantId = *prop.FrsTenantId } - if prop.ProvisioningState != nil { - output.ProvisioningState = string(*prop.ProvisioningState) - } if points := prop.FluidRelayEndpoints; points != nil { if points.OrdererEndpoints != nil { output.OrdererEndpoints = *points.OrdererEndpoints @@ -378,7 +270,7 @@ func (s Server) Delete() sdk.ResourceFunc { meta.Logger.Infof("deleting %s", id) if _, err := client.Delete(ctx, *id); err != nil { - return fmt.Errorf("delete %s err: %v", id, err) + return fmt.Errorf("delete %s: %v", id, err) } return nil }, diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 0bd42cf586ad..e179140750c8 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -52,6 +52,37 @@ func TestAccFluidRelay_basic(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(f), ), }, + data.ImportStep(), + }) +} + +func TestAccFluidRelay_userAssigned(t *testing.T) { + data := acceptance.BuildTestData(t, s.ResourceType(), "test") + f := FluidRelayResource{} + + data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.userAssigned(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), + }) +} + +func TestAccFluidRelay_systemAssigned(t *testing.T) { + data := acceptance.BuildTestData(t, s.ResourceType(), "test") + f := FluidRelayResource{} + + data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.systemAssigned(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), }) } @@ -70,7 +101,7 @@ func TestAccFluidRelayServer_requiresImport(t *testing.T) { }) } -func TestAccFluidRelayServer_complete(t *testing.T) { +func TestAccFluidRelayServer_update(t *testing.T) { data := acceptance.BuildTestData(t, s.ResourceType(), "test") var f FluidRelayResource @@ -79,7 +110,6 @@ func TestAccFluidRelayServer_complete(t *testing.T) { Config: f.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(f), - check.That(data.ResourceName).Key("tags.foo").HasValue("bar"), ), }, data.ImportStep(), @@ -87,7 +117,13 @@ func TestAccFluidRelayServer_complete(t *testing.T) { Config: f.update(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(f), - check.That(data.ResourceName).Key("tags.foo").HasValue("bar2"), + ), + }, + data.ImportStep(), + { + Config: f.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), ), }, }) @@ -100,7 +136,7 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-appServerDNSAlias-%[1]d" + name = "acctestRG-fluidrelay-%[1]d" location = "%[2]s" } @@ -121,9 +157,41 @@ resource "azurerm_fluid_relay_server" "test" { name = "acctestRG-fuildRelayServer-%[2]d" resource_group_name = azurerm_resource_group.test.name location = "%[3]s" - identity_type = "SystemAssigned, UserAssigned" - user_assigned_identity { - identity_id= azurerm_user_assigned_identity.test.id + tags = { + foo = "bar" + } +} +`, f.template(data), data.RandomInteger, data.Locations.Primary) +} + +func (f FluidRelayResource) userAssigned(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s + +resource "azurerm_fluid_relay_server" "test" { + name = "acctestRG-fuildRelayServer-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = "%[3]s" + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } +} +`, f.template(data), data.RandomInteger, data.Locations.Primary) +} + +func (f FluidRelayResource) systemAssigned(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s + +resource "azurerm_fluid_relay_server" "test" { + name = "acctestRG-fuildRelayServer-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = "%[3]s" + identity { + type = "SystemAssigned" } tags = { foo = "bar" @@ -154,10 +222,10 @@ resource "azurerm_fluid_relay_server" "test" { name = "acctestRG-fuildRelayServer-%[2]d" resource_group_name = azurerm_resource_group.test.name location = "%[3]s" - identity_type = "SystemAssigned, UserAssigned" - user_assigned_identity { - identity_id= azurerm_user_assigned_identity.test.id - } +# identity { +# type = "SystemAssigned, UserAssigned" +# identity_ids = [azurerm_user_assigned_identity.test.id] +# } tags = { foo = "bar2" } diff --git a/internal/services/fluidrelay/registration.go b/internal/services/fluidrelay/registration.go index b01ebceca832..e71df0914f77 100644 --- a/internal/services/fluidrelay/registration.go +++ b/internal/services/fluidrelay/registration.go @@ -20,7 +20,7 @@ func (r Registration) Resources() []sdk.Resource { func (r Registration) WebsiteCategories() []string { return []string{ - "Active Directory Domain Services", + "Fluid Relay Service", } } diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 51d664b4bd6e..3f5fc39c7795 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -40,6 +40,7 @@ Dev Test Digital Twins Disks Elastic +Fluid Relay Service HDInsight Hardware Security Module Healthcare diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index aa2244f9add7..593ff06202f3 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -1,5 +1,5 @@ --- -subcategory: "Active Directory Domain Services" +subcategory: "Fluid Relay Service" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_fluid_relay_server" description: |- @@ -39,37 +39,21 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the Resource Group where the Fuild Relay Server should exist. Changing this forces a new Fuild Relay Server to be created. ---- - -* `encryption` - (Optional) One or more `encryption` blocks as defined below. - -* `identity_type` - (Optional) The identity type for this Fluid Relay Server. Possible values are `SystemAssigned`, `UserAssigned`,`SystemAssigned, UserAssigned` and `None`. - * `tags` - (Optional) A mapping of tags which should be assigned to the Fuild Relay Server. -* An `identity` block supports the following: - ---- - -An `encryption` block supports the following: - -* `identity_resource_id` - (Optional) user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. - -* `identity_type` - (Optional) Values can be `SystemAssigned` or `UserAssigned`. - -* `key_encryption_key_url` - (Optional) key encryption key Url, with or without a version. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek. Key auto rotation is enabled by providing a key uri without version. Otherwise, customer is responsible for rotating the key. The keyEncryptionKeyIdentity(either SystemAssigned or UserAssigned) should have permission to access this key url. +* `identity` - (Optional) An `identity` block as defined below. --- An `identity` block supports the following: -* `type` - can be `SystemAssigned` or `UserAssigned`. +* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this API Management Service. Possible values are `SystemAssigned`, `UserAssigned`. -* `client_id` - (Optional) The client id of user assigned identity. +* `identity_ids` - (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this API Management Service. -* `identity_id` - (Optional) user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity.. +~> **NOTE:** This is required when `type` is set to `UserAssigned` -* `principal_id` - (Optional) The principal id of user assigned identity. +~> **NOTE:** When `type` is set to `SystemAssigned`, the assigned `principal_id` and `tenant_id` can be retrieved after the Fluid Relay Server has been created. More details are available below. ## Attributes Reference @@ -79,14 +63,24 @@ In addition to the Arguments listed above - the following Attributes are exporte * `frs_tenant_id` - The Fluid tenantId for this server. -* `orderer_endpoints` - The Fluid Relay Orderer endpoints. +* `orderer_endpoints` - An array of the Fluid Relay Orderer endpoints. * `principal_id` - The principal ID of the Fluid Relay Server. -* `storage_endpoints` - The Fluid Relay storage endpoints. +* `storage_endpoints` - An array of the Fluid Relay storage endpoints. * `tenant_id` - The tenant ID of the Fluid Relay Server. +--- + +`identity` exports the following: + +* `principal_id` - The Principal ID for the Service Principal associated with the Identity of this SQL Server. + +* `tenant_id` - The Tenant ID for the Service Principal associated with the Identity of this SQL Server. + +-> You can access the Principal ID via `azurerm_fluid_relay_server.example.identity.0.principal_id` and the Tenant ID via `azurerm_fluid_relay_server.example.identity.0.tenant_id` + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: From 22e0fa3816473d418d70f8b1fd1475e1cacb2981 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 09:42:56 +0800 Subject: [PATCH 08/30] remove comment in test file --- .../services/fluidrelay/fluid_relay_servers_resource_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index e179140750c8..636ac0ec1954 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -222,10 +222,6 @@ resource "azurerm_fluid_relay_server" "test" { name = "acctestRG-fuildRelayServer-%[2]d" resource_group_name = azurerm_resource_group.test.name location = "%[3]s" -# identity { -# type = "SystemAssigned, UserAssigned" -# identity_ids = [azurerm_user_assigned_identity.test.id] -# } tags = { foo = "bar2" } From 29d6d7ea5e9cd2add5907d86031f9e60741dd3a7 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 09:45:17 +0800 Subject: [PATCH 09/30] fix typo --- .../services/fluidrelay/fluid_relay_servers_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 636ac0ec1954..057d0b6eeae1 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -31,7 +31,7 @@ func (f FluidRelayResource) Exists(ctx context.Context, client *clients.Client, if response.WasNotFound(resp.HttpResponse) { return utils.Ptr(false), nil } - return nil, fmt.Errorf("retriving %s: %v", id, err) + return nil, fmt.Errorf("retrieving %s: %v", id, err) } if response.WasNotFound(resp.HttpResponse) { return utils.Ptr(false), nil From b2f3a1a62686daff5489f3db160c77ea931025b9 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 14:14:10 +0800 Subject: [PATCH 10/30] add ami test, remove Ptr/Value generic functions in utils --- .../fluid_relay_servers_resource.go | 49 +++++++--------- .../fluid_relay_servers_resource_test.go | 43 +++++++++++--- internal/services/fluidrelay/registration.go | 2 +- utils/pointer.go | 30 ---------- utils/pointer_test.go | 58 ------------------- .../docs/r/fluid_relay_servers.html.markdown | 10 +--- 6 files changed, 58 insertions(+), 134 deletions(-) delete mode 100644 utils/pointer_test.go diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index eeda0e4f282f..88bc2a9263f2 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -25,26 +25,16 @@ type UserAssignedIdentity struct { } type ServerModel struct { - Name string `tfschema:"name"` - ResourceGroup string `tfschema:"resource_group_name"` - Location string `tfschema:"location"` - Tags map[string]string `tfschema:"tags"` - FrsTenantId string `tfschema:"frs_tenant_id"` - OrdererEndpoints []string `tfschema:"orderer_endpoints"` - StorageEndpoints []string `tfschema:"storage_endpoints"` - //IdentityType string `tfschema:"identity_type"` - TenantID string `tfschema:"tenant_id"` - PrincipalID string `tfschema:"principal_id"` - //UserAssignedIdentities []UserAssignedIdentity `tfschema:"user_assigned_identity"` - Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"` -} - -func (s ServerModel) expandUserIdentities() (res *identity.SystemAndUserAssignedMap, err error) { - //res := &identity.SystemAndUserAssignedMap{ - // Type: "None", - //} - res, err = identity.ExpandSystemAndUserAssignedMapFromModel(s.Identity) - return res, err + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` + FrsTenantId string `tfschema:"frs_tenant_id"` + OrdererEndpoints []string `tfschema:"orderer_endpoints"` + StorageEndpoints []string `tfschema:"storage_endpoints"` + TenantID string `tfschema:"tenant_id"` + PrincipalID string `tfschema:"principal_id"` + Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"` } func (s *ServerModel) flattenIdentity(input *identity.SystemAndUserAssignedMap) error { @@ -140,8 +130,8 @@ func (s Server) Create() sdk.ResourceFunc { return err } - account := meta.Client.Account - id := fluidrelayservers.NewFluidRelayServerID(account.SubscriptionId, model.ResourceGroup, model.Name) + subscriptionID := meta.Client.Account.SubscriptionId + id := fluidrelayservers.NewFluidRelayServerID(subscriptionID, model.ResourceGroup, model.Name) existing, err := client.Get(ctx, id) if !response.WasNotFound(existing.HttpResponse) { @@ -154,11 +144,13 @@ func (s Server) Create() sdk.ResourceFunc { serverReq := fluidrelayservers.FluidRelayServer{ Location: azure.NormalizeLocation(model.Location), - Name: utils.Ptr(model.Name), + Name: utils.String(model.Name), + } + if model.Tags != nil { + serverReq.Tags = &model.Tags } - serverReq.Tags = utils.TryPtr(model.Tags) serverReq.Properties = &fluidrelayservers.FluidRelayServerProperties{} - serverReq.Identity, err = model.expandUserIdentities() + serverReq.Identity, err = identity.ExpandSystemAndUserAssignedMapFromModel(model.Identity) if err != nil { return fmt.Errorf("expanding user identities: %+v", err) } @@ -174,7 +166,6 @@ func (s Server) Create() sdk.ResourceFunc { } } -// Update tags func (s Server) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 10 * time.Minute, @@ -195,7 +186,7 @@ func (s Server) Update() sdk.ResourceFunc { upd.Tags = &model.Tags } if meta.ResourceData.HasChange("identity") { - upd.Identity, err = model.expandUserIdentities() + upd.Identity, err = identity.ExpandSystemAndUserAssignedMapFromModel(model.Identity) if err != nil { return fmt.Errorf("expanding user identities: %+v", err) } @@ -238,7 +229,9 @@ func (s Server) Read() sdk.ResourceFunc { if err = output.flattenIdentity(model.Identity); err != nil { return fmt.Errorf("flattening `identity`: %v", err) } - output.Tags = utils.Value(server.Model.Tags) + if server.Model.Tags != nil { + output.Tags = *server.Model.Tags + } if prop := model.Properties; prop != nil { if prop.FrsTenantId != nil { output.FrsTenantId = *prop.FrsTenantId diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 057d0b6eeae1..077d088d10ee 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -56,11 +56,18 @@ func TestAccFluidRelay_basic(t *testing.T) { }) } -func TestAccFluidRelay_userAssigned(t *testing.T) { +func TestAccFluidRelay_ami(t *testing.T) { data := acceptance.BuildTestData(t, s.ResourceType(), "test") f := FluidRelayResource{} data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), { Config: f.userAssigned(data), Check: acceptance.ComposeTestCheckFunc( @@ -68,14 +75,6 @@ func TestAccFluidRelay_userAssigned(t *testing.T) { ), }, data.ImportStep(), - }) -} - -func TestAccFluidRelay_systemAssigned(t *testing.T) { - data := acceptance.BuildTestData(t, s.ResourceType(), "test") - f := FluidRelayResource{} - - data.ResourceTest(t, f, []acceptance.TestStep{ { Config: f.systemAssigned(data), Check: acceptance.ComposeTestCheckFunc( @@ -83,6 +82,13 @@ func TestAccFluidRelay_systemAssigned(t *testing.T) { ), }, data.ImportStep(), + { + Config: f.systemAndUserAssigned(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), }) } @@ -200,6 +206,25 @@ resource "azurerm_fluid_relay_server" "test" { `, f.template(data), data.RandomInteger, data.Locations.Primary) } +func (f FluidRelayResource) systemAndUserAssigned(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s + +resource "azurerm_fluid_relay_server" "test" { + name = "acctestRG-fuildRelayServer-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = "%[3]s" + identity { + type = "SystemAssigned" + } + tags = { + foo = "bar" + } +} +`, f.template(data), data.RandomInteger, data.Locations.Primary) +} + func (f FluidRelayResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` diff --git a/internal/services/fluidrelay/registration.go b/internal/services/fluidrelay/registration.go index e71df0914f77..dc66576f6c44 100644 --- a/internal/services/fluidrelay/registration.go +++ b/internal/services/fluidrelay/registration.go @@ -5,7 +5,7 @@ import "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" type Registration struct{} func (r Registration) Name() string { - return "Fluid Relay" + return "Fluid Relay Service" } func (r Registration) DataSources() []sdk.DataSource { diff --git a/utils/pointer.go b/utils/pointer.go index eb16dddde34a..bba617138c05 100644 --- a/utils/pointer.go +++ b/utils/pointer.go @@ -1,9 +1,5 @@ package utils -import ( - "reflect" -) - func Bool(input bool) *bool { return &input } @@ -27,29 +23,3 @@ func Float(input float64) *float64 { func String(input string) *string { return &input } - -// Ptr input MUST NOT nil object -func Ptr[T any](input T) *T { - //v := reflect.ValueOf(input) - return &input -} - -// TryPtr input can be nil of any type -func TryPtr[T any](input T) *T { - v := reflect.ValueOf(input) - switch v.Kind() { - case reflect.Ptr, reflect.Map, reflect.Slice, reflect.Interface: - if v.IsNil() { - return nil - } - } - return &input -} - -func Value[T any](ptr *T) T { - if ptr == nil { - t := new(T) - return *t - } - return *ptr -} diff --git a/utils/pointer_test.go b/utils/pointer_test.go deleted file mode 100644 index d79667ff2d8a..000000000000 --- a/utils/pointer_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package utils_test - -import ( - "testing" - - "github.com/hashicorp/terraform-provider-azurerm/utils" -) - -func TestValue(t *testing.T) { - s := []struct { - ptr *string - want string - }{ - { - nil, - "", - }, - { - utils.Ptr("abc"), - "abc", - }, - { - utils.Ptr(""), - "", - }, - } - for _, arg := range s { - if arg.want != utils.Value(arg.ptr) { - t.Fatal(arg) - } - } - v := utils.Value((*map[string]string)(nil)) - if v != nil { - t.Fatal(v) - } -} - -func TestTryPtr(t *testing.T) { - args := [][2]interface{}{ - {"abc", "abc"}, - {nil, nil}, - {(map[string]string)(nil), nil}, - {(*int)(nil), nil}, - } - for _, arg := range args { - ptr := utils.TryPtr(arg[0]) - //t.Logf("arg: %+v, ptr: %v", arg, ptr) - if ptr == nil { - if arg[1] != nil { - t.Fatal(arg, ptr) - } - continue - } - if *ptr != arg[1] { - t.Fatal(arg, ptr) - } - } -} diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index 593ff06202f3..b37bf2c88524 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -47,13 +47,9 @@ The following arguments are supported: An `identity` block supports the following: -* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this API Management Service. Possible values are `SystemAssigned`, `UserAssigned`. +* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Fluid Relay Service. Possible values are `SystemAssigned`,`UserAssigned` and `SystemAssigned, UserAssigned`. -* `identity_ids` - (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this API Management Service. - -~> **NOTE:** This is required when `type` is set to `UserAssigned` - -~> **NOTE:** When `type` is set to `SystemAssigned`, the assigned `principal_id` and `tenant_id` can be retrieved after the Fluid Relay Server has been created. More details are available below. +* `identity_ids` - (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this Fluid Relay Service. ## Attributes Reference @@ -79,8 +75,6 @@ In addition to the Arguments listed above - the following Attributes are exporte * `tenant_id` - The Tenant ID for the Service Principal associated with the Identity of this SQL Server. --> You can access the Principal ID via `azurerm_fluid_relay_server.example.identity.0.principal_id` and the Tenant ID via `azurerm_fluid_relay_server.example.identity.0.tenant_id` - ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: From d7dfbc8a48a664988222017ce508fb13c3893493 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 14:53:28 +0800 Subject: [PATCH 11/30] add computed filed check in fluid relay server --- .../fluidrelay/fluid_relay_servers_resource_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 077d088d10ee..d15bd91d7dc1 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -29,14 +29,14 @@ func (f FluidRelayResource) Exists(ctx context.Context, client *clients.Client, resp, err := client.FluidRelay.ServerClient.Get(ctx, *id) if err != nil { if response.WasNotFound(resp.HttpResponse) { - return utils.Ptr(false), nil + return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving %s: %v", id, err) } if response.WasNotFound(resp.HttpResponse) { - return utils.Ptr(false), nil + return utils.Bool(false), nil } - return utils.Ptr(true), nil + return utils.Bool(true), nil } var s = fluidrelay.Server{} @@ -50,6 +50,8 @@ func TestAccFluidRelay_basic(t *testing.T) { Config: f.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(f), + check.That(data.ResourceName).Key("frs_tenant_id").IsUUID(), + check.That(data.ResourceName).Key("orderer_endpoints.0").Exists(), ), }, data.ImportStep(), From ca4e4399b86224e7cc10b7325ca3ab8e0c9016cd Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 16:00:31 +0800 Subject: [PATCH 12/30] regenerate relay fluid --- .teamcity/components/generated/services.kt | 1 + go.sum | 2 -- .../parse/fluid_relay_servers_test.go | 22 +++++++++---------- .../validate/fluid_relay_servers_id_test.go | 12 +++++----- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 1cfc96510486..5e30d3d7ee10 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -43,6 +43,7 @@ var services = mapOf( "eventgrid" to "EventGrid", "eventhub" to "EventHub", "firewall" to "Firewall", + "fluidrelay" to "Fluid Relay Service", "frontdoor" to "FrontDoor", "hdinsight" to "HDInsight", "hpccache" to "HPC Cache", diff --git a/go.sum b/go.sum index d46c234faa45..69aec316f38e 100644 --- a/go.sum +++ b/go.sum @@ -257,8 +257,6 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg= -github.com/hashicorp/go-azure-helpers v0.33.0 h1:ClAtKDk0g96eBv0PI/O/HkZXwLhaxSLtf9f3HqXRCtY= -github.com/hashicorp/go-azure-helpers v0.33.0/go.mod h1:gcutZ/Hf/O7YN9M3UIvyZ9l0Rxv7Yrc9x5sSfM9cuSw= github.com/hashicorp/go-azure-helpers v0.34.0 h1:Lvk3IgwFT51WVu1IK5rpUMd+rKnRylg9vMTt6Qx6xn4= github.com/hashicorp/go-azure-helpers v0.34.0/go.mod h1:gcutZ/Hf/O7YN9M3UIvyZ9l0Rxv7Yrc9x5sSfM9cuSw= github.com/hashicorp/go-azure-sdk v0.20220621.155357 h1:U6tH1S4ZzhAEBCD/WlVwUlNVU/EDXBeL9AqkpbMx2ls= diff --git a/internal/services/fluidrelay/parse/fluid_relay_servers_test.go b/internal/services/fluidrelay/parse/fluid_relay_servers_test.go index 672eb1e9705c..eed09cfe0595 100644 --- a/internal/services/fluidrelay/parse/fluid_relay_servers_test.go +++ b/internal/services/fluidrelay/parse/fluid_relay_servers_test.go @@ -11,8 +11,8 @@ import ( var _ resourceids.Id = FluidRelayServersId{} func TestFluidRelayServersIDFormatter(t *testing.T) { - actual := NewFluidRelayServersID("67a9759d-d099-4aa8-8675-e6cfd669c3f4", "myrg", "myFluid").ID() - expected := "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid" + actual := NewFluidRelayServersID("00000000-0000-0000-0000-000000000000", "rg1", "server1").ID() + expected := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1" if actual != expected { t.Fatalf("Expected %q but got %q", expected, actual) } @@ -45,41 +45,41 @@ func TestFluidRelayServersID(t *testing.T) { { // missing ResourceGroup - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", Error: true, }, { // missing value for ResourceGroup - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", Error: true, }, { // missing FluidRelayServerName - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/", Error: true, }, { // missing value for FluidRelayServerName - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/", Error: true, }, { // valid - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1", Expected: &FluidRelayServersId{ - SubscriptionId: "67a9759d-d099-4aa8-8675-e6cfd669c3f4", - ResourceGroup: "myrg", - FluidRelayServerName: "myFluid", + SubscriptionId: "00000000-0000-0000-0000-000000000000", + ResourceGroup: "rg1", + FluidRelayServerName: "server1", }, }, { // upper-cased - Input: "/SUBSCRIPTIONS/67A9759D-D099-4AA8-8675-E6CFD669C3F4/RESOURCEGROUPS/MYRG/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/MYFLUID", + Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RG1/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/SERVER1", Error: true, }, } diff --git a/internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go b/internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go index 1c010b0a33ec..f0de817b98a8 100644 --- a/internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go +++ b/internal/services/fluidrelay/validate/fluid_relay_servers_id_test.go @@ -30,37 +30,37 @@ func TestFluidRelayServersID(t *testing.T) { { // missing ResourceGroup - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", Valid: false, }, { // missing value for ResourceGroup - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", Valid: false, }, { // missing FluidRelayServerName - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/", Valid: false, }, { // missing value for FluidRelayServerName - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/", Valid: false, }, { // valid - Input: "/subscriptions/67a9759d-d099-4aa8-8675-e6cfd669c3f4/resourceGroups/myrg/providers/Microsoft.FluidRelay/fluidRelayServers/myFluid", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1", Valid: true, }, { // upper-cased - Input: "/SUBSCRIPTIONS/67A9759D-D099-4AA8-8675-E6CFD669C3F4/RESOURCEGROUPS/MYRG/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/MYFLUID", + Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RG1/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/SERVER1", Valid: false, }, } From 78314065d1a01e7de623cfa4d04afb08ad6aaae5 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 16:04:06 +0800 Subject: [PATCH 13/30] update website markdown format --- website/docs/r/fluid_relay_servers.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index b37bf2c88524..f05eabadba0d 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -23,7 +23,7 @@ resource "azurerm_resource_group" "example" { } resource "azurerm_fluid_relay_server" "example" { - name = "example" + name = "example" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location } From 9270092a7d0239cfdec0837b78faf057792593c8 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 16 Jun 2022 16:21:20 +0800 Subject: [PATCH 14/30] terrafmt fluidrelay test --- .../fluidrelay/fluid_relay_servers_resource_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index d15bd91d7dc1..2727fc8d9625 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -175,6 +175,7 @@ resource "azurerm_fluid_relay_server" "test" { func (f FluidRelayResource) userAssigned(data acceptance.TestData) string { return fmt.Sprintf(` + %[1]s resource "azurerm_fluid_relay_server" "test" { @@ -182,8 +183,8 @@ resource "azurerm_fluid_relay_server" "test" { resource_group_name = azurerm_resource_group.test.name location = "%[3]s" identity { - type = "UserAssigned" - identity_ids = [azurerm_user_assigned_identity.test.id] + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] } } `, f.template(data), data.RandomInteger, data.Locations.Primary) @@ -192,6 +193,7 @@ resource "azurerm_fluid_relay_server" "test" { func (f FluidRelayResource) systemAssigned(data acceptance.TestData) string { return fmt.Sprintf(` + %[1]s resource "azurerm_fluid_relay_server" "test" { @@ -199,7 +201,7 @@ resource "azurerm_fluid_relay_server" "test" { resource_group_name = azurerm_resource_group.test.name location = "%[3]s" identity { - type = "SystemAssigned" + type = "SystemAssigned" } tags = { foo = "bar" @@ -211,6 +213,7 @@ resource "azurerm_fluid_relay_server" "test" { func (f FluidRelayResource) systemAndUserAssigned(data acceptance.TestData) string { return fmt.Sprintf(` + %[1]s resource "azurerm_fluid_relay_server" "test" { @@ -218,7 +221,7 @@ resource "azurerm_fluid_relay_server" "test" { resource_group_name = azurerm_resource_group.test.name location = "%[3]s" identity { - type = "SystemAssigned" + type = "SystemAssigned" } tags = { foo = "bar" From 307bd1144dc5de45f3cbff9551e8a6dea0e32e46 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 17 Jun 2022 10:33:19 +0800 Subject: [PATCH 15/30] fix systemAndUser identity and update test --- .../fluidrelay/fluid_relay_servers_resource.go | 10 ++++------ .../fluidrelay/fluid_relay_servers_resource_test.go | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 88bc2a9263f2..079beb772c82 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -41,7 +41,7 @@ func (s *ServerModel) flattenIdentity(input *identity.SystemAndUserAssignedMap) if input == nil { return nil } - config := identity.SystemOrUserAssignedMap{ + config := identity.SystemAndUserAssignedMap{ Type: input.Type, PrincipalId: input.PrincipalId, TenantId: input.TenantId, @@ -53,7 +53,7 @@ func (s *ServerModel) flattenIdentity(input *identity.SystemAndUserAssignedMap) PrincipalId: v.PrincipalId, } } - model, err := identity.FlattenSystemOrUserAssignedMapToModel(&config) + model, err := identity.FlattenSystemAndUserAssignedMapToModel(&config) if err != nil { return err } @@ -196,8 +196,6 @@ func (s Server) Update() sdk.ResourceFunc { return fmt.Errorf("updating %s: %v", id, err) } - meta.SetID(id) - return nil }, } @@ -221,7 +219,7 @@ func (s Server) Read() sdk.ResourceFunc { model := server.Model - output := ServerModel{ + output := &ServerModel{ Name: id.FluidRelayServerName, ResourceGroup: id.ResourceGroup, Location: location.Normalize(model.Location), @@ -245,7 +243,7 @@ func (s Server) Read() sdk.ResourceFunc { } } } - return meta.Encode(&output) + return meta.Encode(output) }, } } diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 2727fc8d9625..fb467d1d3a13 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -221,7 +221,8 @@ resource "azurerm_fluid_relay_server" "test" { resource_group_name = azurerm_resource_group.test.name location = "%[3]s" identity { - type = "SystemAssigned" + type = "SystemAssigned, UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] } tags = { foo = "bar" From 54afef02b07d4bf41bbd871bfc0e74646e665ecb Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 17 Jun 2022 10:51:12 +0800 Subject: [PATCH 16/30] terrafmt --- .../services/fluidrelay/fluid_relay_servers_resource_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index fb467d1d3a13..521a5aecfdf8 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -214,6 +214,8 @@ func (f FluidRelayResource) systemAndUserAssigned(data acceptance.TestData) stri return fmt.Sprintf(` + + %[1]s resource "azurerm_fluid_relay_server" "test" { @@ -221,7 +223,7 @@ resource "azurerm_fluid_relay_server" "test" { resource_group_name = azurerm_resource_group.test.name location = "%[3]s" identity { - type = "SystemAssigned, UserAssigned" + type = "SystemAssigned, UserAssigned" identity_ids = [azurerm_user_assigned_identity.test.id] } tags = { From af856575ef184344e1bf1104286f8b484a4a7170 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 17 Jun 2022 13:37:28 +0800 Subject: [PATCH 17/30] restore fluid relay server name validator --- internal/services/fluidrelay/validate/server_name.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/fluidrelay/validate/server_name.go b/internal/services/fluidrelay/validate/server_name.go index 68330fa3e235..10aebff9c1a6 100644 --- a/internal/services/fluidrelay/validate/server_name.go +++ b/internal/services/fluidrelay/validate/server_name.go @@ -5,7 +5,7 @@ import ( "regexp" ) -var serverNameReg = regexp.MustCompile(`^[-\w]{1,50}$`) +var serverNameReg = regexp.MustCompile(`^[-0-9a-zA-Z]{1,50}$`) func FluidRelayServerName(input interface{}, key string) (warnings []string, errors []error) { v, ok := input.(string) From b7c33a69945ea5d1eac396ace3f87ec606f70614 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Wed, 22 Jun 2022 16:55:57 +0800 Subject: [PATCH 18/30] remove embed pandora sdk --- internal/services/fluidrelay/registration.go | 4 +- .../2022-05-26/fluidrelaycontainers/client.go | 18 - .../fluidrelaycontainers/constants.go | 37 -- .../id_fluidrelaycontainer.go | 137 -------- .../id_fluidrelaycontainer_test.go | 324 ------------------ .../id_fluidrelayserver.go | 124 ------- .../id_fluidrelayserver_test.go | 279 --------------- .../method_delete_autorest.go | 62 ---- .../method_get_autorest.go | 64 ---- ...method_listbyfluidrelayservers_autorest.go | 183 ---------- .../model_fluidrelaycontainer.go | 16 - .../model_fluidrelaycontainerproperties.go | 42 --- .../fluidrelaycontainers/predicates.go | 24 -- .../fluidrelaycontainers/version.go | 12 - .../2022-05-26/fluidrelayservers/client.go | 18 - .../2022-05-26/fluidrelayservers/constants.go | 121 ------- .../fluidrelayservers/id_fluidrelayserver.go | 124 ------- .../id_fluidrelayserver_test.go | 279 --------------- .../method_createorupdate_autorest.go | 65 ---- .../method_delete_autorest.go | 62 ---- .../fluidrelayservers/method_get_autorest.go | 64 ---- .../method_getkeys_autorest.go | 65 ---- .../method_listbyresourcegroup_autorest.go | 184 ---------- .../method_listbysubscription_autorest.go | 184 ---------- .../method_listkeys_autorest.go | 65 ---- .../method_regeneratekey_autorest.go | 66 ---- .../method_update_autorest.go | 65 ---- ..._customermanagedkeyencryptionproperties.go | 9 - ...ptionpropertieskeyencryptionkeyidentity.go | 9 - .../model_encryptionproperties.go | 8 - .../model_fluidrelayendpoints.go | 10 - .../model_fluidrelayserver.go | 20 -- .../model_fluidrelayserverkeys.go | 9 - .../model_fluidrelayserverproperties.go | 12 - .../model_fluidrelayserverupdate.go | 15 - .../model_fluidrelayserverupdateproperties.go | 8 - .../model_regeneratekeyrequest.go | 8 - .../fluidrelayservers/predicates.go | 29 -- .../2022-05-26/fluidrelayservers/version.go | 12 - .../docs/r/fluid_relay_servers.html.markdown | 2 +- 40 files changed, 3 insertions(+), 2836 deletions(-) delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/client.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer_test.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver_test.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_delete_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_get_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/predicates.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/client.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver_test.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_delete_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_get_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_getkeys_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listkeys_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_update_autorest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_encryptionproperties.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/predicates.go delete mode 100644 internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go diff --git a/internal/services/fluidrelay/registration.go b/internal/services/fluidrelay/registration.go index dc66576f6c44..1dc2cd1f83d7 100644 --- a/internal/services/fluidrelay/registration.go +++ b/internal/services/fluidrelay/registration.go @@ -5,7 +5,7 @@ import "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" type Registration struct{} func (r Registration) Name() string { - return "Fluid Relay Service" + return "Fluid Relay" } func (r Registration) DataSources() []sdk.DataSource { @@ -20,7 +20,7 @@ func (r Registration) Resources() []sdk.Resource { func (r Registration) WebsiteCategories() []string { return []string{ - "Fluid Relay Service", + "Fluid Relay", } } diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/client.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/client.go deleted file mode 100644 index 8a5997945975..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package fluidrelaycontainers - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayContainersClient struct { - Client autorest.Client - baseUri string -} - -func NewFluidRelayContainersClientWithBaseURI(endpoint string) FluidRelayContainersClient { - return FluidRelayContainersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go deleted file mode 100644 index 323b3e0df339..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/constants.go +++ /dev/null @@ -1,37 +0,0 @@ -package fluidrelaycontainers - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ProvisioningState string - -const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "failed": ProvisioningStateFailed, - "succeeded": ProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer.go deleted file mode 100644 index 54beab85637c..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer.go +++ /dev/null @@ -1,137 +0,0 @@ -package fluidrelaycontainers - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FluidRelayContainerId{} - -// FluidRelayContainerId is a struct representing the Resource ID for a Fluid Relay Container -type FluidRelayContainerId struct { - SubscriptionId string - ResourceGroup string - FluidRelayServerName string - FluidRelayContainerName string -} - -// NewFluidRelayContainerID returns a new FluidRelayContainerId struct -func NewFluidRelayContainerID(subscriptionId string, resourceGroup string, fluidRelayServerName string, fluidRelayContainerName string) FluidRelayContainerId { - return FluidRelayContainerId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - FluidRelayServerName: fluidRelayServerName, - FluidRelayContainerName: fluidRelayContainerName, - } -} - -// ParseFluidRelayContainerID parses 'input' into a FluidRelayContainerId -func ParseFluidRelayContainerID(input string) (*FluidRelayContainerId, error) { - parser := resourceids.NewParserFromResourceIdType(FluidRelayContainerId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FluidRelayContainerId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) - } - - if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) - } - - if id.FluidRelayContainerName, ok = parsed.Parsed["fluidRelayContainerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayContainerName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseFluidRelayContainerIDInsensitively parses 'input' case-insensitively into a FluidRelayContainerId -// note: this method should only be used for API response data and not user input -func ParseFluidRelayContainerIDInsensitively(input string) (*FluidRelayContainerId, error) { - parser := resourceids.NewParserFromResourceIdType(FluidRelayContainerId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FluidRelayContainerId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) - } - - if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) - } - - if id.FluidRelayContainerName, ok = parsed.Parsed["fluidRelayContainerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayContainerName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateFluidRelayContainerID checks that 'input' can be parsed as a Fluid Relay Container ID -func ValidateFluidRelayContainerID(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 := ParseFluidRelayContainerID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Fluid Relay Container ID -func (id FluidRelayContainerId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s/fluidRelayContainers/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName, id.FluidRelayContainerName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Container ID -func (id FluidRelayContainerId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), - resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), - resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), - resourceids.StaticSegment("staticFluidRelayContainers", "fluidRelayContainers", "fluidRelayContainers"), - resourceids.UserSpecifiedSegment("fluidRelayContainerName", "fluidRelayContainerValue"), - } -} - -// String returns a human-readable description of this Fluid Relay Container ID -func (id FluidRelayContainerId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group: %q", id.ResourceGroup), - fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), - fmt.Sprintf("Fluid Relay Container Name: %q", id.FluidRelayContainerName), - } - return fmt.Sprintf("Fluid Relay Container (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer_test.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer_test.go deleted file mode 100644 index 154ad3ab54f9..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelaycontainer_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package fluidrelaycontainers - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FluidRelayContainerId{} - -func TestNewFluidRelayContainerID(t *testing.T) { - id := NewFluidRelayContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue", "fluidRelayContainerValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroup != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroup'", id.ResourceGroup, "example-resource-group") - } - - if id.FluidRelayServerName != "fluidRelayServerValue" { - t.Fatalf("Expected %q but got %q for Segment 'FluidRelayServerName'", id.FluidRelayServerName, "fluidRelayServerValue") - } - - if id.FluidRelayContainerName != "fluidRelayContainerValue" { - t.Fatalf("Expected %q but got %q for Segment 'FluidRelayContainerName'", id.FluidRelayContainerName, "fluidRelayContainerValue") - } -} - -func TestFormatFluidRelayContainerID(t *testing.T) { - actual := NewFluidRelayContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue", "fluidRelayContainerValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseFluidRelayContainerID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FluidRelayContainerId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue", - Expected: &FluidRelayContainerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "example-resource-group", - FluidRelayServerName: "fluidRelayServerValue", - FluidRelayContainerName: "fluidRelayContainerValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFluidRelayContainerID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { - t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) - } - - if actual.FluidRelayContainerName != v.Expected.FluidRelayContainerName { - t.Fatalf("Expected %q but got %q for FluidRelayContainerName", v.Expected.FluidRelayContainerName, actual.FluidRelayContainerName) - } - - } -} - -func TestParseFluidRelayContainerIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FluidRelayContainerId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/fLuIdReLaYcOnTaInErS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue", - Expected: &FluidRelayContainerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "example-resource-group", - FluidRelayServerName: "fluidRelayServerValue", - FluidRelayContainerName: "fluidRelayContainerValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/fluidRelayContainers/fluidRelayContainerValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/fLuIdReLaYcOnTaInErS/fLuIdReLaYcOnTaInErVaLuE", - Expected: &FluidRelayContainerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "eXaMpLe-rEsOuRcE-GrOuP", - FluidRelayServerName: "fLuIdReLaYsErVeRvAlUe", - FluidRelayContainerName: "fLuIdReLaYcOnTaInErVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/fLuIdReLaYcOnTaInErS/fLuIdReLaYcOnTaInErVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFluidRelayContainerIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { - t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) - } - - if actual.FluidRelayContainerName != v.Expected.FluidRelayContainerName { - t.Fatalf("Expected %q but got %q for FluidRelayContainerName", v.Expected.FluidRelayContainerName, actual.FluidRelayContainerName) - } - - } -} - -func TestSegmentsForFluidRelayContainerId(t *testing.T) { - segments := FluidRelayContainerId{}.Segments() - if len(segments) == 0 { - t.Fatalf("FluidRelayContainerId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver.go deleted file mode 100644 index 17b8d121e1e0..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver.go +++ /dev/null @@ -1,124 +0,0 @@ -package fluidrelaycontainers - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FluidRelayServerId{} - -// FluidRelayServerId is a struct representing the Resource ID for a Fluid Relay Server -type FluidRelayServerId struct { - SubscriptionId string - ResourceGroup string - FluidRelayServerName string -} - -// NewFluidRelayServerID returns a new FluidRelayServerId struct -func NewFluidRelayServerID(subscriptionId string, resourceGroup string, fluidRelayServerName string) FluidRelayServerId { - return FluidRelayServerId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - FluidRelayServerName: fluidRelayServerName, - } -} - -// ParseFluidRelayServerID parses 'input' into a FluidRelayServerId -func ParseFluidRelayServerID(input string) (*FluidRelayServerId, error) { - parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FluidRelayServerId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) - } - - if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseFluidRelayServerIDInsensitively parses 'input' case-insensitively into a FluidRelayServerId -// note: this method should only be used for API response data and not user input -func ParseFluidRelayServerIDInsensitively(input string) (*FluidRelayServerId, error) { - parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FluidRelayServerId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) - } - - if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateFluidRelayServerID checks that 'input' can be parsed as a Fluid Relay Server ID -func ValidateFluidRelayServerID(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 := ParseFluidRelayServerID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Fluid Relay Server ID -func (id FluidRelayServerId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Server ID -func (id FluidRelayServerId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), - resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), - resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), - } -} - -// String returns a human-readable description of this Fluid Relay Server ID -func (id FluidRelayServerId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group: %q", id.ResourceGroup), - fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), - } - return fmt.Sprintf("Fluid Relay Server (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver_test.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver_test.go deleted file mode 100644 index 3f3e1fabf50e..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/id_fluidrelayserver_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package fluidrelaycontainers - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FluidRelayServerId{} - -func TestNewFluidRelayServerID(t *testing.T) { - id := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroup != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroup'", id.ResourceGroup, "example-resource-group") - } - - if id.FluidRelayServerName != "fluidRelayServerValue" { - t.Fatalf("Expected %q but got %q for Segment 'FluidRelayServerName'", id.FluidRelayServerName, "fluidRelayServerValue") - } -} - -func TestFormatFluidRelayServerID(t *testing.T) { - actual := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseFluidRelayServerID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FluidRelayServerId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", - Expected: &FluidRelayServerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "example-resource-group", - FluidRelayServerName: "fluidRelayServerValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFluidRelayServerID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { - t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) - } - - } -} - -func TestParseFluidRelayServerIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FluidRelayServerId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", - Expected: &FluidRelayServerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "example-resource-group", - FluidRelayServerName: "fluidRelayServerValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe", - Expected: &FluidRelayServerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "eXaMpLe-rEsOuRcE-GrOuP", - FluidRelayServerName: "fLuIdReLaYsErVeRvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFluidRelayServerIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { - t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) - } - - } -} - -func TestSegmentsForFluidRelayServerId(t *testing.T) { - segments := FluidRelayServerId{}.Segments() - if len(segments) == 0 { - t.Fatalf("FluidRelayServerId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_delete_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_delete_autorest.go deleted file mode 100644 index 91c5fe5e10b7..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_delete_autorest.go +++ /dev/null @@ -1,62 +0,0 @@ -package fluidrelaycontainers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c FluidRelayContainersClient) Delete(ctx context.Context, id FluidRelayContainerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c FluidRelayContainersClient) preparerForDelete(ctx context.Context, id FluidRelayContainerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c FluidRelayContainersClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_get_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_get_autorest.go deleted file mode 100644 index 294fc3a1bb6e..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package fluidrelaycontainers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayContainer -} - -// Get ... -func (c FluidRelayContainersClient) Get(ctx context.Context, id FluidRelayContainerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c FluidRelayContainersClient) preparerForGet(ctx context.Context, id FluidRelayContainerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c FluidRelayContainersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go deleted file mode 100644 index 88eecb698ef3..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/method_listbyfluidrelayservers_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package fluidrelaycontainers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByFluidRelayServersOperationResponse struct { - HttpResponse *http.Response - Model *[]FluidRelayContainer - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByFluidRelayServersOperationResponse, error) -} - -type ListByFluidRelayServersCompleteResult struct { - Items []FluidRelayContainer -} - -func (r ListByFluidRelayServersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByFluidRelayServersOperationResponse) LoadMore(ctx context.Context) (resp ListByFluidRelayServersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByFluidRelayServers ... -func (c FluidRelayContainersClient) ListByFluidRelayServers(ctx context.Context, id FluidRelayServerId) (resp ListByFluidRelayServersOperationResponse, err error) { - req, err := c.preparerForListByFluidRelayServers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByFluidRelayServers(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByFluidRelayServersComplete retrieves all of the results into a single object -func (c FluidRelayContainersClient) ListByFluidRelayServersComplete(ctx context.Context, id FluidRelayServerId) (ListByFluidRelayServersCompleteResult, error) { - return c.ListByFluidRelayServersCompleteMatchingPredicate(ctx, id, FluidRelayContainerOperationPredicate{}) -} - -// ListByFluidRelayServersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FluidRelayContainersClient) ListByFluidRelayServersCompleteMatchingPredicate(ctx context.Context, id FluidRelayServerId, predicate FluidRelayContainerOperationPredicate) (resp ListByFluidRelayServersCompleteResult, err error) { - items := make([]FluidRelayContainer, 0) - - page, err := c.ListByFluidRelayServers(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByFluidRelayServersCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByFluidRelayServers prepares the ListByFluidRelayServers request. -func (c FluidRelayContainersClient) preparerForListByFluidRelayServers(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/fluidRelayContainers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByFluidRelayServersWithNextLink prepares the ListByFluidRelayServers request with the given nextLink token. -func (c FluidRelayContainersClient) preparerForListByFluidRelayServersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByFluidRelayServers handles the response to the ListByFluidRelayServers request. The method always -// closes the http.Response Body. -func (c FluidRelayContainersClient) responderForListByFluidRelayServers(resp *http.Response) (result ListByFluidRelayServersOperationResponse, err error) { - type page struct { - Values []FluidRelayContainer `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByFluidRelayServersOperationResponse, err error) { - req, err := c.preparerForListByFluidRelayServersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByFluidRelayServers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelaycontainers.FluidRelayContainersClient", "ListByFluidRelayServers", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go deleted file mode 100644 index 877b6b85d23c..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainer.go +++ /dev/null @@ -1,16 +0,0 @@ -package fluidrelaycontainers - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayContainer struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *FluidRelayContainerProperties `json:"properties,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go deleted file mode 100644 index 8a8f859f4670..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/model_fluidrelaycontainerproperties.go +++ /dev/null @@ -1,42 +0,0 @@ -package fluidrelaycontainers - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayContainerProperties struct { - CreationTime *string `json:"creationTime,omitempty"` - FrsContainerId *string `json:"frsContainerId,omitempty"` - FrsTenantId *string `json:"frsTenantId,omitempty"` - LastAccessTime *string `json:"lastAccessTime,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} - -func (o *FluidRelayContainerProperties) GetCreationTimeAsTime() (*time.Time, error) { - if o.CreationTime == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") -} - -func (o *FluidRelayContainerProperties) SetCreationTimeAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreationTime = &formatted -} - -func (o *FluidRelayContainerProperties) GetLastAccessTimeAsTime() (*time.Time, error) { - if o.LastAccessTime == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastAccessTime, "2006-01-02T15:04:05Z07:00") -} - -func (o *FluidRelayContainerProperties) SetLastAccessTimeAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastAccessTime = &formatted -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/predicates.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/predicates.go deleted file mode 100644 index 1dd30d665d90..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/predicates.go +++ /dev/null @@ -1,24 +0,0 @@ -package fluidrelaycontainers - -type FluidRelayContainerOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p FluidRelayContainerOperationPredicate) Matches(input FluidRelayContainer) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go deleted file mode 100644 index b5d8c8f84670..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelaycontainers/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package fluidrelaycontainers - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-05-26" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelaycontainers/%s", defaultApiVersion) -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/client.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/client.go deleted file mode 100644 index bd29abddd025..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/client.go +++ /dev/null @@ -1,18 +0,0 @@ -package fluidrelayservers - -import "github.com/Azure/go-autorest/autorest" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayServersClient struct { - Client autorest.Client - baseUri string -} - -func NewFluidRelayServersClientWithBaseURI(endpoint string) FluidRelayServersClient { - return FluidRelayServersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go deleted file mode 100644 index 1d0e44d42c6b..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/constants.go +++ /dev/null @@ -1,121 +0,0 @@ -package fluidrelayservers - -import "strings" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CmkIdentityType string - -const ( - CmkIdentityTypeSystemAssigned CmkIdentityType = "SystemAssigned" - CmkIdentityTypeUserAssigned CmkIdentityType = "UserAssigned" -) - -func PossibleValuesForCmkIdentityType() []string { - return []string{ - string(CmkIdentityTypeSystemAssigned), - string(CmkIdentityTypeUserAssigned), - } -} - -func parseCmkIdentityType(input string) (*CmkIdentityType, error) { - vals := map[string]CmkIdentityType{ - "systemassigned": CmkIdentityTypeSystemAssigned, - "userassigned": CmkIdentityTypeUserAssigned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CmkIdentityType(input) - return &out, nil -} - -type KeyName string - -const ( - KeyNameKeyOne KeyName = "key1" - KeyNameKeyTwo KeyName = "key2" -) - -func PossibleValuesForKeyName() []string { - return []string{ - string(KeyNameKeyOne), - string(KeyNameKeyTwo), - } -} - -func parseKeyName(input string) (*KeyName, error) { - vals := map[string]KeyName{ - "key1": KeyNameKeyOne, - "key2": KeyNameKeyTwo, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := KeyName(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "failed": ProvisioningStateFailed, - "succeeded": ProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type StorageSKU string - -const ( - StorageSKUBasic StorageSKU = "basic" - StorageSKUStandard StorageSKU = "standard" -) - -func PossibleValuesForStorageSKU() []string { - return []string{ - string(StorageSKUBasic), - string(StorageSKUStandard), - } -} - -func parseStorageSKU(input string) (*StorageSKU, error) { - vals := map[string]StorageSKU{ - "basic": StorageSKUBasic, - "standard": StorageSKUStandard, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := StorageSKU(input) - return &out, nil -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver.go deleted file mode 100644 index bc41376a2926..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver.go +++ /dev/null @@ -1,124 +0,0 @@ -package fluidrelayservers - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FluidRelayServerId{} - -// FluidRelayServerId is a struct representing the Resource ID for a Fluid Relay Server -type FluidRelayServerId struct { - SubscriptionId string - ResourceGroup string - FluidRelayServerName string -} - -// NewFluidRelayServerID returns a new FluidRelayServerId struct -func NewFluidRelayServerID(subscriptionId string, resourceGroup string, fluidRelayServerName string) FluidRelayServerId { - return FluidRelayServerId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - FluidRelayServerName: fluidRelayServerName, - } -} - -// ParseFluidRelayServerID parses 'input' into a FluidRelayServerId -func ParseFluidRelayServerID(input string) (*FluidRelayServerId, error) { - parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FluidRelayServerId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) - } - - if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseFluidRelayServerIDInsensitively parses 'input' case-insensitively into a FluidRelayServerId -// note: this method should only be used for API response data and not user input -func ParseFluidRelayServerIDInsensitively(input string) (*FluidRelayServerId, error) { - parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FluidRelayServerId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) - } - - if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { - return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateFluidRelayServerID checks that 'input' can be parsed as a Fluid Relay Server ID -func ValidateFluidRelayServerID(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 := ParseFluidRelayServerID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Fluid Relay Server ID -func (id FluidRelayServerId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Server ID -func (id FluidRelayServerId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), - resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), - resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), - } -} - -// String returns a human-readable description of this Fluid Relay Server ID -func (id FluidRelayServerId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group: %q", id.ResourceGroup), - fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), - } - return fmt.Sprintf("Fluid Relay Server (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver_test.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver_test.go deleted file mode 100644 index 786a42e6df6f..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/id_fluidrelayserver_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package fluidrelayservers - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FluidRelayServerId{} - -func TestNewFluidRelayServerID(t *testing.T) { - id := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroup != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroup'", id.ResourceGroup, "example-resource-group") - } - - if id.FluidRelayServerName != "fluidRelayServerValue" { - t.Fatalf("Expected %q but got %q for Segment 'FluidRelayServerName'", id.FluidRelayServerName, "fluidRelayServerValue") - } -} - -func TestFormatFluidRelayServerID(t *testing.T) { - actual := NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseFluidRelayServerID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FluidRelayServerId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", - Expected: &FluidRelayServerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "example-resource-group", - FluidRelayServerName: "fluidRelayServerValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFluidRelayServerID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { - t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) - } - - } -} - -func TestParseFluidRelayServerIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FluidRelayServerId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue", - Expected: &FluidRelayServerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "example-resource-group", - FluidRelayServerName: "fluidRelayServerValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.FluidRelay/fluidRelayServers/fluidRelayServerValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe", - Expected: &FluidRelayServerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "eXaMpLe-rEsOuRcE-GrOuP", - FluidRelayServerName: "fLuIdReLaYsErVeRvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.fLuIdReLaY/fLuIdReLaYsErVeRs/fLuIdReLaYsErVeRvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFluidRelayServerIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", 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.FluidRelayServerName != v.Expected.FluidRelayServerName { - t.Fatalf("Expected %q but got %q for FluidRelayServerName", v.Expected.FluidRelayServerName, actual.FluidRelayServerName) - } - - } -} - -func TestSegmentsForFluidRelayServerId(t *testing.T) { - segments := FluidRelayServerId{}.Segments() - if len(segments) == 0 { - t.Fatalf("FluidRelayServerId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go deleted file mode 100644 index cc614a566e49..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayServer -} - -// CreateOrUpdate ... -func (c FluidRelayServersClient) CreateOrUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServer) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c FluidRelayServersClient) preparerForCreateOrUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServer) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_delete_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_delete_autorest.go deleted file mode 100644 index 25ab8f8ede19..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_delete_autorest.go +++ /dev/null @@ -1,62 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c FluidRelayServersClient) Delete(ctx context.Context, id FluidRelayServerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c FluidRelayServersClient) preparerForDelete(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_get_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_get_autorest.go deleted file mode 100644 index dec2740f199b..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayServer -} - -// Get ... -func (c FluidRelayServersClient) Get(ctx context.Context, id FluidRelayServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c FluidRelayServersClient) preparerForGet(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_getkeys_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_getkeys_autorest.go deleted file mode 100644 index 332732b57b6d..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_getkeys_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetKeysOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayServerKeys -} - -// GetKeys ... -func (c FluidRelayServersClient) GetKeys(ctx context.Context, id FluidRelayServerId) (result GetKeysOperationResponse, err error) { - req, err := c.preparerForGetKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetKeys prepares the GetKeys request. -func (c FluidRelayServersClient) preparerForGetKeys(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/getKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetKeys handles the response to the GetKeys request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForGetKeys(resp *http.Response) (result GetKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 035383748434..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]FluidRelayServer - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []FluidRelayServer -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c FluidRelayServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c FluidRelayServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, FluidRelayServerOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FluidRelayServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate FluidRelayServerOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]FluidRelayServer, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c FluidRelayServersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.FluidRelay/fluidRelayServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c FluidRelayServersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []FluidRelayServer `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go deleted file mode 100644 index 73a6677c19d9..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]FluidRelayServer - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []FluidRelayServer -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c FluidRelayServersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c FluidRelayServersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, FluidRelayServerOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FluidRelayServersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate FluidRelayServerOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]FluidRelayServer, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c FluidRelayServersClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.FluidRelay/fluidRelayServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c FluidRelayServersClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []FluidRelayServer `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listkeys_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listkeys_autorest.go deleted file mode 100644 index d2dd3e44d036..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_listkeys_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayServerKeys -} - -// ListKeys ... -func (c FluidRelayServersClient) ListKeys(ctx context.Context, id FluidRelayServerId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c FluidRelayServersClient) preparerForListKeys(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go deleted file mode 100644 index e29322a76f9e..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type RegenerateKeyOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayServerKeys -} - -// RegenerateKey ... -func (c FluidRelayServersClient) RegenerateKey(ctx context.Context, id FluidRelayServerId, input RegenerateKeyRequest) (result RegenerateKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKey prepares the RegenerateKey request. -func (c FluidRelayServersClient) preparerForRegenerateKey(ctx context.Context, id FluidRelayServerId, input RegenerateKeyRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKey handles the response to the RegenerateKey request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForRegenerateKey(resp *http.Response) (result RegenerateKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_update_autorest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_update_autorest.go deleted file mode 100644 index 19f38294cf24..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/method_update_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package fluidrelayservers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *FluidRelayServer -} - -// Update ... -func (c FluidRelayServersClient) Update(ctx context.Context, id FluidRelayServerId, input FluidRelayServerUpdate) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c FluidRelayServersClient) preparerForUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServerUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c FluidRelayServersClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go deleted file mode 100644 index c901b57f9097..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go +++ /dev/null @@ -1,9 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomerManagedKeyEncryptionProperties struct { - KeyEncryptionKeyIdentity *CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity `json:"keyEncryptionKeyIdentity,omitempty"` - KeyEncryptionKeyUrl *string `json:"keyEncryptionKeyUrl,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go deleted file mode 100644 index a14936a4cb8a..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go +++ /dev/null @@ -1,9 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity struct { - IdentityType *CmkIdentityType `json:"identityType,omitempty"` - UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_encryptionproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_encryptionproperties.go deleted file mode 100644 index ebb20890ac63..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_encryptionproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type EncryptionProperties struct { - CustomerManagedKeyEncryption *CustomerManagedKeyEncryptionProperties `json:"customerManagedKeyEncryption,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go deleted file mode 100644 index 7d6f78c08fbd..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go +++ /dev/null @@ -1,10 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayEndpoints struct { - OrdererEndpoints *[]string `json:"ordererEndpoints,omitempty"` - ServiceEndpoints *[]string `json:"serviceEndpoints,omitempty"` - StorageEndpoints *[]string `json:"storageEndpoints,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go deleted file mode 100644 index 2295c002065a..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserver.go +++ /dev/null @@ -1,20 +0,0 @@ -package fluidrelayservers - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" - "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayServer struct { - Id *string `json:"id,omitempty"` - Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *FluidRelayServerProperties `json:"properties,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go deleted file mode 100644 index d70edabd7a0e..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go +++ /dev/null @@ -1,9 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayServerKeys struct { - Key1 *string `json:"key1,omitempty"` - Key2 *string `json:"key2,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go deleted file mode 100644 index 1c430eab5e3c..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go +++ /dev/null @@ -1,12 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayServerProperties struct { - Encryption *EncryptionProperties `json:"encryption,omitempty"` - FluidRelayEndpoints *FluidRelayEndpoints `json:"fluidRelayEndpoints,omitempty"` - FrsTenantId *string `json:"frsTenantId,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - Storagesku *StorageSKU `json:"storagesku,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go deleted file mode 100644 index 51e0c55443ff..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go +++ /dev/null @@ -1,15 +0,0 @@ -package fluidrelayservers - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayServerUpdate struct { - Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` - Location *string `json:"location,omitempty"` - Properties *FluidRelayServerUpdateProperties `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go deleted file mode 100644 index d150ca43a28c..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type FluidRelayServerUpdateProperties struct { - Encryption *EncryptionProperties `json:"encryption,omitempty"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go deleted file mode 100644 index 1aad29b69943..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go +++ /dev/null @@ -1,8 +0,0 @@ -package fluidrelayservers - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeyRequest struct { - KeyName KeyName `json:"keyName"` -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/predicates.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/predicates.go deleted file mode 100644 index e618e42269b5..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/predicates.go +++ /dev/null @@ -1,29 +0,0 @@ -package fluidrelayservers - -type FluidRelayServerOperationPredicate struct { - Id *string - Location *string - Name *string - Type *string -} - -func (p FluidRelayServerOperationPredicate) Matches(input FluidRelayServer) bool { - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go b/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go deleted file mode 100644 index 7664a0458cc0..000000000000 --- a/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers/version.go +++ /dev/null @@ -1,12 +0,0 @@ -package fluidrelayservers - -import "fmt" - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -const defaultApiVersion = "2022-05-26" - -func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelayservers/%s", defaultApiVersion) -} diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index f05eabadba0d..217f8eb30d18 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -1,5 +1,5 @@ --- -subcategory: "Fluid Relay Service" +subcategory: "Fluid Relay" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_fluid_relay_server" description: |- From 29f6b24bb585ce4dee4b83fdf6666ad039facbe3 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Wed, 22 Jun 2022 17:02:49 +0800 Subject: [PATCH 19/30] use go-azure-sdk for pandora sdk intead of embed in azurerm --- internal/services/fluidrelay/client/client.go | 2 +- .../fluid_relay_servers_resource.go | 2 +- .../fluid_relay_servers_resource_test.go | 2 +- .../2022-05-26/fluidrelayservers/client.go | 18 ++ .../2022-05-26/fluidrelayservers/constants.go | 121 ++++++++++++ .../fluidrelayservers/id_fluidrelayserver.go | 124 ++++++++++++ .../method_createorupdate_autorest.go | 68 +++++++ .../method_delete_autorest.go | 65 ++++++ .../fluidrelayservers/method_get_autorest.go | 67 +++++++ .../method_getkeys_autorest.go | 68 +++++++ .../method_listbyresourcegroup_autorest.go | 187 ++++++++++++++++++ .../method_listbysubscription_autorest.go | 187 ++++++++++++++++++ .../method_listkeys_autorest.go | 68 +++++++ .../method_regeneratekey_autorest.go | 69 +++++++ .../method_update_autorest.go | 68 +++++++ ..._customermanagedkeyencryptionproperties.go | 9 + ...ptionpropertieskeyencryptionkeyidentity.go | 9 + .../model_encryptionproperties.go | 8 + .../model_fluidrelayendpoints.go | 10 + .../model_fluidrelayserver.go | 20 ++ .../model_fluidrelayserverkeys.go | 9 + .../model_fluidrelayserverproperties.go | 12 ++ .../model_fluidrelayserverupdate.go | 15 ++ .../model_fluidrelayserverupdateproperties.go | 8 + .../model_regeneratekeyrequest.go | 8 + .../fluidrelayservers/predicates.go | 29 +++ .../2022-05-26/fluidrelayservers/version.go | 12 ++ vendor/modules.txt | 1 + 28 files changed, 1263 insertions(+), 3 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/id_fluidrelayserver.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_getkeys_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listkeys_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_update_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_encryptionproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserver.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/version.go diff --git a/internal/services/fluidrelay/client/client.go b/internal/services/fluidrelay/client/client.go index 5a62e1143694..1e50ecfde852 100644 --- a/internal/services/fluidrelay/client/client.go +++ b/internal/services/fluidrelay/client/client.go @@ -1,8 +1,8 @@ package client import ( + servers "github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/internal/common" - servers "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" ) type Client struct { diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 079beb772c82..2ab41a7d9dfd 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 521a5aecfdf8..31bbf5f94972 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/response" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/sdk/2022-05-26/fluidrelayservers" + "github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers" "github.com/hashicorp/terraform-provider-azurerm/utils" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/client.go new file mode 100644 index 000000000000..bd29abddd025 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/client.go @@ -0,0 +1,18 @@ +package fluidrelayservers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServersClient struct { + Client autorest.Client + baseUri string +} + +func NewFluidRelayServersClientWithBaseURI(endpoint string) FluidRelayServersClient { + return FluidRelayServersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/constants.go new file mode 100644 index 000000000000..1d0e44d42c6b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/constants.go @@ -0,0 +1,121 @@ +package fluidrelayservers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkIdentityType string + +const ( + CmkIdentityTypeSystemAssigned CmkIdentityType = "SystemAssigned" + CmkIdentityTypeUserAssigned CmkIdentityType = "UserAssigned" +) + +func PossibleValuesForCmkIdentityType() []string { + return []string{ + string(CmkIdentityTypeSystemAssigned), + string(CmkIdentityTypeUserAssigned), + } +} + +func parseCmkIdentityType(input string) (*CmkIdentityType, error) { + vals := map[string]CmkIdentityType{ + "systemassigned": CmkIdentityTypeSystemAssigned, + "userassigned": CmkIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CmkIdentityType(input) + return &out, nil +} + +type KeyName string + +const ( + KeyNameKeyOne KeyName = "key1" + KeyNameKeyTwo KeyName = "key2" +) + +func PossibleValuesForKeyName() []string { + return []string{ + string(KeyNameKeyOne), + string(KeyNameKeyTwo), + } +} + +func parseKeyName(input string) (*KeyName, error) { + vals := map[string]KeyName{ + "key1": KeyNameKeyOne, + "key2": KeyNameKeyTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyName(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type StorageSKU string + +const ( + StorageSKUBasic StorageSKU = "basic" + StorageSKUStandard StorageSKU = "standard" +) + +func PossibleValuesForStorageSKU() []string { + return []string{ + string(StorageSKUBasic), + string(StorageSKUStandard), + } +} + +func parseStorageSKU(input string) (*StorageSKU, error) { + vals := map[string]StorageSKU{ + "basic": StorageSKUBasic, + "standard": StorageSKUStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageSKU(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/id_fluidrelayserver.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/id_fluidrelayserver.go new file mode 100644 index 000000000000..bc41376a2926 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/id_fluidrelayserver.go @@ -0,0 +1,124 @@ +package fluidrelayservers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FluidRelayServerId{} + +// FluidRelayServerId is a struct representing the Resource ID for a Fluid Relay Server +type FluidRelayServerId struct { + SubscriptionId string + ResourceGroup string + FluidRelayServerName string +} + +// NewFluidRelayServerID returns a new FluidRelayServerId struct +func NewFluidRelayServerID(subscriptionId string, resourceGroup string, fluidRelayServerName string) FluidRelayServerId { + return FluidRelayServerId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + FluidRelayServerName: fluidRelayServerName, + } +} + +// ParseFluidRelayServerID parses 'input' into a FluidRelayServerId +func ParseFluidRelayServerID(input string) (*FluidRelayServerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayServerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseFluidRelayServerIDInsensitively parses 'input' case-insensitively into a FluidRelayServerId +// note: this method should only be used for API response data and not user input +func ParseFluidRelayServerIDInsensitively(input string) (*FluidRelayServerId, error) { + parser := resourceids.NewParserFromResourceIdType(FluidRelayServerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FluidRelayServerId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroup, ok = parsed.Parsed["resourceGroup"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroup' was not found in the resource id %q", input) + } + + if id.FluidRelayServerName, ok = parsed.Parsed["fluidRelayServerName"]; !ok { + return nil, fmt.Errorf("the segment 'fluidRelayServerName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateFluidRelayServerID checks that 'input' can be parsed as a Fluid Relay Server ID +func ValidateFluidRelayServerID(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 := ParseFluidRelayServerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fluid Relay Server ID +func (id FluidRelayServerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.FluidRelay/fluidRelayServers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.FluidRelayServerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fluid Relay Server ID +func (id FluidRelayServerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroup", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftFluidRelay", "Microsoft.FluidRelay", "Microsoft.FluidRelay"), + resourceids.StaticSegment("staticFluidRelayServers", "fluidRelayServers", "fluidRelayServers"), + resourceids.UserSpecifiedSegment("fluidRelayServerName", "fluidRelayServerValue"), + } +} + +// String returns a human-readable description of this Fluid Relay Server ID +func (id FluidRelayServerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group: %q", id.ResourceGroup), + fmt.Sprintf("Fluid Relay Server Name: %q", id.FluidRelayServerName), + } + return fmt.Sprintf("Fluid Relay Server (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go new file mode 100644 index 000000000000..3e71fc66c650 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_createorupdate_autorest.go @@ -0,0 +1,68 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServer +} + +// CreateOrUpdate ... +func (c FluidRelayServersClient) CreateOrUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServer) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c FluidRelayServersClient) preparerForCreateOrUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServer) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_delete_autorest.go new file mode 100644 index 000000000000..bb7ba2ba3c82 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_delete_autorest.go @@ -0,0 +1,65 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c FluidRelayServersClient) Delete(ctx context.Context, id FluidRelayServerId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c FluidRelayServersClient) preparerForDelete(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_get_autorest.go new file mode 100644 index 000000000000..c58a5785cd9a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_get_autorest.go @@ -0,0 +1,67 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServer +} + +// Get ... +func (c FluidRelayServersClient) Get(ctx context.Context, id FluidRelayServerId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c FluidRelayServersClient) preparerForGet(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_getkeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_getkeys_autorest.go new file mode 100644 index 000000000000..5f3be4b813ed --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_getkeys_autorest.go @@ -0,0 +1,68 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetKeysOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServerKeys +} + +// GetKeys ... +func (c FluidRelayServersClient) GetKeys(ctx context.Context, id FluidRelayServerId) (result GetKeysOperationResponse, err error) { + req, err := c.preparerForGetKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGetKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "GetKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGetKeys prepares the GetKeys request. +func (c FluidRelayServersClient) preparerForGetKeys(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/getKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGetKeys handles the response to the GetKeys request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForGetKeys(resp *http.Response) (result GetKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..8579dfa5bca6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbyresourcegroup_autorest.go @@ -0,0 +1,187 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + Model *[]FluidRelayServer + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []FluidRelayServer +} + +func (r ListByResourceGroupOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c FluidRelayServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c FluidRelayServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, FluidRelayServerOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c FluidRelayServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate FluidRelayServerOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]FluidRelayServer, 0) + + page, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c FluidRelayServersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.FluidRelay/fluidRelayServers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c FluidRelayServersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { + type page struct { + Values []FluidRelayServer `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go new file mode 100644 index 000000000000..1386b52cadc9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listbysubscription_autorest.go @@ -0,0 +1,187 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + Model *[]FluidRelayServer + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) +} + +type ListBySubscriptionCompleteResult struct { + Items []FluidRelayServer +} + +func (r ListBySubscriptionOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListBySubscription ... +func (c FluidRelayServersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscription(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListBySubscription(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListBySubscriptionComplete retrieves all of the results into a single object +func (c FluidRelayServersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, FluidRelayServerOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c FluidRelayServersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate FluidRelayServerOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { + items := make([]FluidRelayServer, 0) + + page, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListBySubscriptionCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListBySubscription prepares the ListBySubscription request. +func (c FluidRelayServersClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.FluidRelay/fluidRelayServers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. +func (c FluidRelayServersClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListBySubscription handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { + type page struct { + Values []FluidRelayServer `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { + req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListBySubscription(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listkeys_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listkeys_autorest.go new file mode 100644 index 000000000000..e50e87e63cb0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_listkeys_autorest.go @@ -0,0 +1,68 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServerKeys +} + +// ListKeys ... +func (c FluidRelayServersClient) ListKeys(ctx context.Context, id FluidRelayServerId) (result ListKeysOperationResponse, err error) { + req, err := c.preparerForListKeys(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListKeys(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "ListKeys", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListKeys prepares the ListKeys request. +func (c FluidRelayServersClient) preparerForListKeys(ctx context.Context, id FluidRelayServerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForListKeys handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go new file mode 100644 index 000000000000..aca471923ef9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_regeneratekey_autorest.go @@ -0,0 +1,69 @@ +package fluidrelayservers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeyOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServerKeys +} + +// RegenerateKey ... +func (c FluidRelayServersClient) RegenerateKey(ctx context.Context, id FluidRelayServerId, input RegenerateKeyRequest) (result RegenerateKeyOperationResponse, err error) { + req, err := c.preparerForRegenerateKey(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRegenerateKey(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "RegenerateKey", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRegenerateKey prepares the RegenerateKey request. +func (c FluidRelayServersClient) preparerForRegenerateKey(ctx context.Context, id FluidRelayServerId, input RegenerateKeyRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/regenerateKey", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRegenerateKey handles the response to the RegenerateKey request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForRegenerateKey(resp *http.Response) (result RegenerateKeyOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_update_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_update_autorest.go new file mode 100644 index 000000000000..150d7a9ed77b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/method_update_autorest.go @@ -0,0 +1,68 @@ +package fluidrelayservers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + Model *FluidRelayServer +} + +// Update ... +func (c FluidRelayServersClient) Update(ctx context.Context, id FluidRelayServerId, input FluidRelayServerUpdate) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fluidrelayservers.FluidRelayServersClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c FluidRelayServersClient) preparerForUpdate(ctx context.Context, id FluidRelayServerId, input FluidRelayServerUpdate) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c FluidRelayServersClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go new file mode 100644 index 000000000000..c901b57f9097 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionproperties.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomerManagedKeyEncryptionProperties struct { + KeyEncryptionKeyIdentity *CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity `json:"keyEncryptionKeyIdentity,omitempty"` + KeyEncryptionKeyUrl *string `json:"keyEncryptionKeyUrl,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go new file mode 100644 index 000000000000..a14936a4cb8a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_customermanagedkeyencryptionpropertieskeyencryptionkeyidentity.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity struct { + IdentityType *CmkIdentityType `json:"identityType,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_encryptionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_encryptionproperties.go new file mode 100644 index 000000000000..ebb20890ac63 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_encryptionproperties.go @@ -0,0 +1,8 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionProperties struct { + CustomerManagedKeyEncryption *CustomerManagedKeyEncryptionProperties `json:"customerManagedKeyEncryption,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go new file mode 100644 index 000000000000..7d6f78c08fbd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayendpoints.go @@ -0,0 +1,10 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayEndpoints struct { + OrdererEndpoints *[]string `json:"ordererEndpoints,omitempty"` + ServiceEndpoints *[]string `json:"serviceEndpoints,omitempty"` + StorageEndpoints *[]string `json:"storageEndpoints,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserver.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserver.go new file mode 100644 index 000000000000..2295c002065a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserver.go @@ -0,0 +1,20 @@ +package fluidrelayservers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServer struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *FluidRelayServerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go new file mode 100644 index 000000000000..d70edabd7a0e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverkeys.go @@ -0,0 +1,9 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerKeys struct { + Key1 *string `json:"key1,omitempty"` + Key2 *string `json:"key2,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go new file mode 100644 index 000000000000..1c430eab5e3c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverproperties.go @@ -0,0 +1,12 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerProperties struct { + Encryption *EncryptionProperties `json:"encryption,omitempty"` + FluidRelayEndpoints *FluidRelayEndpoints `json:"fluidRelayEndpoints,omitempty"` + FrsTenantId *string `json:"frsTenantId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Storagesku *StorageSKU `json:"storagesku,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go new file mode 100644 index 000000000000..51e0c55443ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdate.go @@ -0,0 +1,15 @@ +package fluidrelayservers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerUpdate struct { + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Properties *FluidRelayServerUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go new file mode 100644 index 000000000000..d150ca43a28c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_fluidrelayserverupdateproperties.go @@ -0,0 +1,8 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FluidRelayServerUpdateProperties struct { + Encryption *EncryptionProperties `json:"encryption,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go new file mode 100644 index 000000000000..1aad29b69943 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/model_regeneratekeyrequest.go @@ -0,0 +1,8 @@ +package fluidrelayservers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeyRequest struct { + KeyName KeyName `json:"keyName"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/predicates.go new file mode 100644 index 000000000000..e618e42269b5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/predicates.go @@ -0,0 +1,29 @@ +package fluidrelayservers + +type FluidRelayServerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FluidRelayServerOperationPredicate) Matches(input FluidRelayServer) bool { + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/version.go new file mode 100644 index 000000000000..7664a0458cc0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/version.go @@ -0,0 +1,12 @@ +package fluidrelayservers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2022-05-26" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fluidrelayservers/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index dd13ff2f4cd2..9283c75a490f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -223,6 +223,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/attestation/2020-10-01/attest github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2021-04-30/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/communication/2020-08-20/communicationservice github.com/hashicorp/go-azure-sdk/resource-manager/confidentialledger/2022-05-13/confidentialledger +github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/connections github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/managedapis # github.com/hashicorp/go-checkpoint v0.5.0 From 5f5e62048bd0301ee3c6b7f9c2d77a1361bd85d7 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Fri, 24 Jun 2022 09:55:38 +0800 Subject: [PATCH 20/30] fix website category --- website/allowed-subcategories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 3f5fc39c7795..b38792d449e7 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -40,7 +40,7 @@ Dev Test Digital Twins Disks Elastic -Fluid Relay Service +Fluid Relay HDInsight Hardware Security Module Healthcare From be0f35b639def0255f8e19a6aee0a98789076f14 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Mon, 27 Jun 2022 14:42:12 +0800 Subject: [PATCH 21/30] update go generate --- .teamcity/components/generated/services.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 5e30d3d7ee10..dc82027890cb 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -43,7 +43,7 @@ var services = mapOf( "eventgrid" to "EventGrid", "eventhub" to "EventHub", "firewall" to "Firewall", - "fluidrelay" to "Fluid Relay Service", + "fluidrelay" to "Fluid Relay", "frontdoor" to "FrontDoor", "hdinsight" to "HDInsight", "hpccache" to "HPC Cache", From 01d67fbdf16efcbf0f5f3c5846b40d4e327f309f Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 28 Jun 2022 08:05:22 +0800 Subject: [PATCH 22/30] update fluid relay markdown --- .../docs/r/fluid_relay_servers.html.markdown | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index 217f8eb30d18..14e9ff58d90f 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -3,12 +3,12 @@ subcategory: "Fluid Relay" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_fluid_relay_server" description: |- - Manages a Fuild Relay Server. + Manages a Fluid Relay Server. --- # azurerm_fluid_relay_server -Manages a Fuild Relay Server. +Manages a Fluid Relay Server. ## Example Usage @@ -33,13 +33,13 @@ resource "azurerm_fluid_relay_server" "example" { The following arguments are supported: -* `location` - (Required) The Azure Region where the Fuild Relay Server should exist. Changing this forces a new Fuild Relay Server to be created. +* `location` - (Required) The Azure Region where the Fluid Relay Server should exist. Changing this forces a new Fluid Relay Server to be created. -* `name` - (Required) The name which should be used for this Fuild Relay Server. Changing this forces a new Fuild Relay Server to be created. +* `name` - (Required) The name which should be used for this Fluid Relay Server. Changing this forces a new Fluid Relay Server to be created. -* `resource_group_name` - (Required) The name of the Resource Group where the Fuild Relay Server should exist. Changing this forces a new Fuild Relay Server to be created. +* `resource_group_name` - (Required) The name of the Resource Group where the Fluid Relay Server should exist. Changing this forces a new Fluid Relay Server to be created. -* `tags` - (Optional) A mapping of tags which should be assigned to the Fuild Relay Server. +* `tags` - (Optional) A mapping of tags which should be assigned to the Fluid Relay Server. * `identity` - (Optional) An `identity` block as defined below. @@ -55,13 +55,13 @@ An `identity` block supports the following: In addition to the Arguments listed above - the following Attributes are exported: -* `id` - The ID of the Fuild Relay Server. +* `id` - The ID of the Fluid Relay Server. * `frs_tenant_id` - The Fluid tenantId for this server. * `orderer_endpoints` - An array of the Fluid Relay Orderer endpoints. -* `principal_id` - The principal ID of the Fluid Relay Server. +* `principal_id` - The Principal ID of the Fluid Relay Server. * `storage_endpoints` - An array of the Fluid Relay storage endpoints. @@ -71,22 +71,22 @@ In addition to the Arguments listed above - the following Attributes are exporte `identity` exports the following: -* `principal_id` - The Principal ID for the Service Principal associated with the Identity of this SQL Server. +* `principal_id` - The Principal ID for the Service Principal associated with the Identity of this Fluid Relay Server. -* `tenant_id` - The Tenant ID for the Service Principal associated with the Identity of this SQL Server. +* `tenant_id` - The Tenant ID for the Service Principal associated with the Identity of this Fluid Relay Server. ## 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 Fuild Relay Server. -* `read` - (Defaults to 5 minutes) Used when retrieving the Fuild Relay Server. -* `update` - (Defaults to 10 minutes) Used when updating the Fuild Relay Server. -* `delete` - (Defaults to 10 minutes) Used when deleting the Fuild Relay Server. +* `create` - (Defaults to 30 minutes) Used when creating the Fluid Relay Server. +* `read` - (Defaults to 5 minutes) Used when retrieving the Fluid Relay Server. +* `update` - (Defaults to 10 minutes) Used when updating the Fluid Relay Server. +* `delete` - (Defaults to 10 minutes) Used when deleting the Fluid Relay Server. ## Import -Fuild Relay Servers can be imported using the `resource id`, e.g. +Fluid Relay Servers can be imported using the `resource id`, e.g. ```shell terraform import azurerm_fluid_relay_server.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1 From 032aa126180ee40d1024d96106ab66ca35040d76 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 28 Jun 2022 09:39:24 +0800 Subject: [PATCH 23/30] combine err check if --- internal/services/fluidrelay/fluid_relay_servers_resource.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 2ab41a7d9dfd..cfeb99864eda 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -191,8 +191,7 @@ func (s Server) Update() sdk.ResourceFunc { return fmt.Errorf("expanding user identities: %+v", err) } } - _, err = client.Update(ctx, *id, upd) - if err != nil { + if _, err = client.Update(ctx, *id, upd); err != nil { return fmt.Errorf("updating %s: %v", id, err) } From 4148bd25b83a90c6fcb328cf014bbb0811af15c3 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 28 Jun 2022 10:47:27 +0800 Subject: [PATCH 24/30] remove some not used properties --- .../fluidrelay/fluid_relay_servers_resource.go | 16 ---------------- website/docs/r/fluid_relay_servers.html.markdown | 6 +----- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index cfeb99864eda..857af0716e85 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -18,12 +18,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/utils" ) -type UserAssignedIdentity struct { - IdentityID string `tfschema:"identity_id"` - ClientID string `tfschema:"client_id"` - PrincipalID string `tfschema:"principal_id"` -} - type ServerModel struct { Name string `tfschema:"name"` ResourceGroup string `tfschema:"resource_group_name"` @@ -32,8 +26,6 @@ type ServerModel struct { FrsTenantId string `tfschema:"frs_tenant_id"` OrdererEndpoints []string `tfschema:"orderer_endpoints"` StorageEndpoints []string `tfschema:"storage_endpoints"` - TenantID string `tfschema:"tenant_id"` - PrincipalID string `tfschema:"principal_id"` Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"` } @@ -100,14 +92,6 @@ func (s Server) Attributes() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, }, }, - "principal_id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - "tenant_id": { - Type: pluginsdk.TypeString, - Computed: true, - }, } } diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index 14e9ff58d90f..ce854a208b90 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -61,11 +61,7 @@ In addition to the Arguments listed above - the following Attributes are exporte * `orderer_endpoints` - An array of the Fluid Relay Orderer endpoints. -* `principal_id` - The Principal ID of the Fluid Relay Server. - -* `storage_endpoints` - An array of the Fluid Relay storage endpoints. - -* `tenant_id` - The tenant ID of the Fluid Relay Server. +* `storage_endpoints` - An array of storage endpoints for this Fluid Relay Server. --- From ee0aba180d8d24eedaa548502bf4bcc2fd9f20ea Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 28 Jun 2022 17:00:33 +0800 Subject: [PATCH 25/30] add storage sku support --- .../fluid_relay_servers_resource.go | 13 ++++- .../fluid_relay_servers_resource_test.go | 54 ++++++++++++++++--- .../docs/r/fluid_relay_servers.html.markdown | 2 + 3 files changed, 61 insertions(+), 8 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 857af0716e85..7d0e1ca22c09 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -22,10 +23,11 @@ type ServerModel struct { Name string `tfschema:"name"` ResourceGroup string `tfschema:"resource_group_name"` Location string `tfschema:"location"` - Tags map[string]string `tfschema:"tags"` + StorageSKU string `tfschema:"storage_sku"` FrsTenantId string `tfschema:"frs_tenant_id"` OrdererEndpoints []string `tfschema:"orderer_endpoints"` StorageEndpoints []string `tfschema:"storage_endpoints"` + Tags map[string]string `tfschema:"tags"` Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"` } @@ -69,6 +71,12 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { "location": commonschema.Location(), "tags": commonschema.Tags(), "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), + "storage_sku": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringInSlice(fluidrelayservers.PossibleValuesForStorageSKU(), false), + }, } } @@ -139,6 +147,9 @@ func (s Server) Create() sdk.ResourceFunc { return fmt.Errorf("expanding user identities: %+v", err) } + if model.StorageSKU != "" { + serverReq.Properties.Storagesku = (*fluidrelayservers.StorageSKU)(&model.StorageSKU) + } _, err = client.CreateOrUpdate(ctx, id, serverReq) if err != nil { return fmt.Errorf("creating %v err: %+v", id, err) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 31bbf5f94972..46b8793fb341 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -58,6 +58,23 @@ func TestAccFluidRelay_basic(t *testing.T) { }) } +func TestAccFluidRelay_storageBasic(t *testing.T) { + data := acceptance.BuildTestData(t, s.ResourceType(), "test") + f := FluidRelayResource{} + + data.ResourceTest(t, f, []acceptance.TestStep{ + { + Config: f.storageBasic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + check.That(data.ResourceName).Key("frs_tenant_id").IsUUID(), + check.That(data.ResourceName).Key("orderer_endpoints.0").Exists(), + ), + }, + // data.ImportStep("storage_sku"), + }) +} + func TestAccFluidRelay_ami(t *testing.T) { data := acceptance.BuildTestData(t, s.ResourceType(), "test") f := FluidRelayResource{} @@ -147,13 +164,20 @@ resource "azurerm_resource_group" "test" { name = "acctestRG-fluidrelay-%[1]d" location = "%[2]s" } +`, data.RandomInteger, data.Locations.Primary) +} + +func (f FluidRelayResource) templateWithIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s resource "azurerm_user_assigned_identity" "test" { - name = "acctestRG-userAssignedIdentity-%[1]d" + name = "acctestRG-userAssignedIdentity-%[2]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } -`, data.RandomInteger, data.Locations.Primary) +`, f.template(data), data.RandomInteger) } func (f FluidRelayResource) basic(data acceptance.TestData) string { @@ -172,6 +196,24 @@ resource "azurerm_fluid_relay_server" "test" { `, f.template(data), data.RandomInteger, data.Locations.Primary) } +// basic storage sku only work with east asia and south-ease-asia +func (f FluidRelayResource) storageBasic(data acceptance.TestData) string { + return fmt.Sprintf(` + +%[1]s + +resource "azurerm_fluid_relay_server" "test" { + name = "acctestRG-fuildRelayServer-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = "SouthEastAsia" + storage_sku = "basic" + tags = { + foo = "bar" + } +} +`, f.template(data), data.RandomInteger) +} + func (f FluidRelayResource) userAssigned(data acceptance.TestData) string { return fmt.Sprintf(` @@ -187,7 +229,7 @@ resource "azurerm_fluid_relay_server" "test" { identity_ids = [azurerm_user_assigned_identity.test.id] } } -`, f.template(data), data.RandomInteger, data.Locations.Primary) +`, f.templateWithIdentity(data), data.RandomInteger, data.Locations.Primary) } func (f FluidRelayResource) systemAssigned(data acceptance.TestData) string { @@ -207,15 +249,13 @@ resource "azurerm_fluid_relay_server" "test" { foo = "bar" } } -`, f.template(data), data.RandomInteger, data.Locations.Primary) +`, f.templateWithIdentity(data), data.RandomInteger, data.Locations.Primary) } func (f FluidRelayResource) systemAndUserAssigned(data acceptance.TestData) string { return fmt.Sprintf(` - - %[1]s resource "azurerm_fluid_relay_server" "test" { @@ -230,7 +270,7 @@ resource "azurerm_fluid_relay_server" "test" { foo = "bar" } } -`, f.template(data), data.RandomInteger, data.Locations.Primary) +`, f.templateWithIdentity(data), data.RandomInteger, data.Locations.Primary) } func (f FluidRelayResource) requiresImport(data acceptance.TestData) string { diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index ce854a208b90..ccee378d08bf 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -43,6 +43,8 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. +* `storage_sku` - (Optional) Sku of the storage associated with the resource, Possible values are `standard` and `basic`. + --- An `identity` block supports the following: From 67b4d4d7d3dc968a1d42017227b0c3f721112228 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Tue, 28 Jun 2022 17:34:04 +0800 Subject: [PATCH 26/30] update storage sku and terrafmt --- internal/services/fluidrelay/fluid_relay_servers_resource.go | 3 +++ .../services/fluidrelay/fluid_relay_servers_resource_test.go | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 7d0e1ca22c09..255731f26ee8 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -237,6 +237,9 @@ func (s Server) Read() sdk.ResourceFunc { } } } + if val, ok := meta.ResourceData.GetOk("storage_sku"); ok { + output.StorageSKU = val.(string) + } return meta.Encode(output) }, } diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go index 46b8793fb341..e20c650d0175 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource_test.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -71,7 +71,7 @@ func TestAccFluidRelay_storageBasic(t *testing.T) { check.That(data.ResourceName).Key("orderer_endpoints.0").Exists(), ), }, - // data.ImportStep("storage_sku"), + data.ImportStep("storage_sku"), }) } @@ -200,13 +200,14 @@ resource "azurerm_fluid_relay_server" "test" { func (f FluidRelayResource) storageBasic(data acceptance.TestData) string { return fmt.Sprintf(` + %[1]s resource "azurerm_fluid_relay_server" "test" { name = "acctestRG-fuildRelayServer-%[2]d" resource_group_name = azurerm_resource_group.test.name location = "SouthEastAsia" - storage_sku = "basic" + storage_sku = "basic" tags = { foo = "bar" } From 1de2dc1c7075bee1322c00a1b71541032868f252 Mon Sep 17 00:00:00 2001 From: xuwu1 Date: Thu, 7 Jul 2022 15:43:36 +0800 Subject: [PATCH 27/30] set storage sku as force new --- internal/services/fluidrelay/fluid_relay_servers_resource.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 255731f26ee8..187400f6133b 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -75,6 +75,7 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, Computed: true, + ForceNew: true, ValidateFunc: validation.StringInSlice(fluidrelayservers.PossibleValuesForStorageSKU(), false), }, } From d48d6f870e1e87ebf53f460e2da9e5ef013dfcd7 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Thu, 7 Jul 2022 09:46:18 -0700 Subject: [PATCH 28/30] Update fluid_relay_servers_resource.go --- internal/services/fluidrelay/fluid_relay_servers_resource.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index 187400f6133b..dab577990662 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -74,6 +74,7 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { "storage_sku": { Type: pluginsdk.TypeString, Optional: true, + // todo remove computed when https://github.com/Azure/azure-rest-api-specs/issues/19700 is fixed Computed: true, ForceNew: true, ValidateFunc: validation.StringInSlice(fluidrelayservers.PossibleValuesForStorageSKU(), false), From 2ae5284740fa25f203c8dc7c77231e0c95cd03f2 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Thu, 7 Jul 2022 09:46:47 -0700 Subject: [PATCH 29/30] Update fluid_relay_servers.html.markdown --- website/docs/r/fluid_relay_servers.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/fluid_relay_servers.html.markdown b/website/docs/r/fluid_relay_servers.html.markdown index ccee378d08bf..ab147a9de8e5 100644 --- a/website/docs/r/fluid_relay_servers.html.markdown +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -43,7 +43,7 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. -* `storage_sku` - (Optional) Sku of the storage associated with the resource, Possible values are `standard` and `basic`. +* `storage_sku` - (Optional) Sku of the storage associated with the resource, Possible values are `standard` and `basic`. Changing this forces a new Fluid Relay Server to be created. --- From ebc2897a920463bb944c103629eb7084c318687f Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Thu, 7 Jul 2022 09:52:24 -0700 Subject: [PATCH 30/30] Update fluid_relay_servers_resource.go --- internal/services/fluidrelay/fluid_relay_servers_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/fluidrelay/fluid_relay_servers_resource.go b/internal/services/fluidrelay/fluid_relay_servers_resource.go index dab577990662..dde9103334b3 100644 --- a/internal/services/fluidrelay/fluid_relay_servers_resource.go +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -72,9 +72,9 @@ func (s Server) Arguments() map[string]*pluginsdk.Schema { "tags": commonschema.Tags(), "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), "storage_sku": { + // todo remove computed when https://github.com/Azure/azure-rest-api-specs/issues/19700 is fixed Type: pluginsdk.TypeString, Optional: true, - // todo remove computed when https://github.com/Azure/azure-rest-api-specs/issues/19700 is fixed Computed: true, ForceNew: true, ValidateFunc: validation.StringInSlice(fluidrelayservers.PossibleValuesForStorageSKU(), false),