diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 1cfc96510486..dc82027890cb 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", "frontdoor" to "FrontDoor", "hdinsight" to "HDInsight", "hpccache" to "HPC Cache", 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 93092db6aa7e..673dea056898 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" @@ -122,6 +123,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { disks.Registration{}, domainservices.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..1e50ecfde852 --- /dev/null +++ b/internal/services/fluidrelay/client/client.go @@ -0,0 +1,19 @@ +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" +) + +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..dde9103334b3 --- /dev/null +++ b/internal/services/fluidrelay/fluid_relay_servers_resource.go @@ -0,0 +1,272 @@ +package fluidrelay + +import ( + "context" + "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/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/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" +) + +type ServerModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + 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"` +} + +func (s *ServerModel) flattenIdentity(input *identity.SystemAndUserAssignedMap) error { + if input == nil { + return nil + } + config := identity.SystemAndUserAssignedMap{ + Type: input.Type, + PrincipalId: input.PrincipalId, + TenantId: input.TenantId, + IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), + } + for k, v := range input.IdentityIds { + config.IdentityIds[k] = identity.UserAssignedIdentityDetails{ + ClientId: v.ClientId, + PrincipalId: v.PrincipalId, + } + } + model, err := identity.FlattenSystemAndUserAssignedMapToModel(&config) + if err != nil { + return err + } + s.Identity = *model + return nil +} + +type Server struct{} + +var _ sdk.ResourceWithUpdate = (*Server)(nil) + +func (s Server) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.FluidRelayServerName, + }, + "resource_group_name": commonschema.ResourceGroupName(), + "location": commonschema.Location(), + "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, + Computed: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(fluidrelayservers.PossibleValuesForStorageSKU(), false), + }, + } +} + +func (s Server) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "frs_tenant_id": { + 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, + }, + }, + } +} + +func (s Server) ModelObject() interface{} { + return &ServerModel{} +} + +func (s Server) ResourceType() string { + return "azurerm_fluid_relay_server" +} + +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 ServerModel + if err = meta.Decode(&model); err != nil { + return err + } + + subscriptionID := meta.Client.Account.SubscriptionId + id := fluidrelayservers.NewFluidRelayServerID(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.String(model.Name), + } + if model.Tags != nil { + serverReq.Tags = &model.Tags + } + serverReq.Properties = &fluidrelayservers.FluidRelayServerProperties{} + serverReq.Identity, err = identity.ExpandSystemAndUserAssignedMapFromModel(model.Identity) + if err != nil { + 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) + } + meta.SetID(id) + + return nil + }, + } +} + +func (s Server) 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.ParseFluidRelayServerID(meta.ResourceData.Id()) + if err != nil { + return err + } + + var model ServerModel + if err = meta.Decode(&model); err != nil { + return fmt.Errorf("decoding err: %+v", err) + } + + var upd fluidrelayservers.FluidRelayServerUpdate + if meta.ResourceData.HasChange("tags") { + upd.Tags = &model.Tags + } + if meta.ResourceData.HasChange("identity") { + upd.Identity, err = identity.ExpandSystemAndUserAssignedMapFromModel(model.Identity) + if err != nil { + return fmt.Errorf("expanding user identities: %+v", err) + } + } + if _, err = client.Update(ctx, *id, upd); err != nil { + return fmt.Errorf("updating %s: %v", id, err) + } + + return nil + }, + } +} + +func (s Server) 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 + } + + server, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %v", id, err) + } + + model := server.Model + + output := &ServerModel{ + Name: id.FluidRelayServerName, + ResourceGroup: id.ResourceGroup, + Location: location.Normalize(model.Location), + } + if err = output.flattenIdentity(model.Identity); err != nil { + return fmt.Errorf("flattening `identity`: %v", err) + } + if server.Model.Tags != nil { + output.Tags = *server.Model.Tags + } + if prop := model.Properties; prop != nil { + if prop.FrsTenantId != nil { + output.FrsTenantId = *prop.FrsTenantId + } + if points := prop.FluidRelayEndpoints; points != nil { + if points.OrdererEndpoints != nil { + output.OrdererEndpoints = *points.OrdererEndpoints + } + if points.StorageEndpoints != nil { + output.StorageEndpoints = *points.StorageEndpoints + } + } + } + if val, ok := meta.ResourceData.GetOk("storage_sku"); ok { + output.StorageSKU = val.(string) + } + return meta.Encode(output) + }, + } +} + +func (s Server) 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: %v", id, err) + } + return nil + }, + } +} + +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..e20c650d0175 --- /dev/null +++ b/internal/services/fluidrelay/fluid_relay_servers_resource_test.go @@ -0,0 +1,304 @@ +package fluidrelay_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "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" + "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.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %v", id, err) + } + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return utils.Bool(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), + check.That(data.ResourceName).Key("frs_tenant_id").IsUUID(), + check.That(data.ResourceName).Key("orderer_endpoints.0").Exists(), + ), + }, + data.ImportStep(), + }) +} + +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{} + + 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( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), + { + Config: f.systemAssigned(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), + { + Config: f.systemAndUserAssigned(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), + }) +} + +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 TestAccFluidRelayServer_update(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.ImportStep(), + { + Config: f.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + data.ImportStep(), + { + Config: f.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(f), + ), + }, + }) +} + +func (f FluidRelayResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +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-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +`, f.template(data), data.RandomInteger) +} + +func (f FluidRelayResource) basic(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" + tags = { + foo = "bar" + } +} +`, 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(` + + +%[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.templateWithIdentity(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" + } +} +`, 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" { + 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 = "bar" + } +} +`, f.templateWithIdentity(data), 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)) +} + +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" + tags = { + foo = "bar2" + } +} +`, f.template(data), data.RandomInteger, data.Locations.Primary) +} 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..eed09cfe0595 --- /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("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) + } +} + +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/00000000-0000-0000-0000-000000000000/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + + { + // missing FluidRelayServerName + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/", + Error: true, + }, + + { + // missing value for FluidRelayServerName + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1", + Expected: &FluidRelayServersId{ + SubscriptionId: "00000000-0000-0000-0000-000000000000", + ResourceGroup: "rg1", + FluidRelayServerName: "server1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RG1/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/SERVER1", + 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..1dc2cd1f83d7 --- /dev/null +++ b/internal/services/fluidrelay/registration.go @@ -0,0 +1,29 @@ +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{ + Server{}, + } +} + +func (r Registration) WebsiteCategories() []string { + return []string{ + "Fluid Relay", + } +} + +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..84a7525948ab --- /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/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1 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..f0de817b98a8 --- /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/00000000-0000-0000-0000-000000000000/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Valid: false, + }, + + { + // missing FluidRelayServerName + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/", + Valid: false, + }, + + { + // missing value for FluidRelayServerName + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.FluidRelay/fluidRelayServers/server1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RG1/PROVIDERS/MICROSOFT.FLUIDRELAY/FLUIDRELAYSERVERS/SERVER1", + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/README.md new file mode 100644 index 000000000000..1890f15a0c97 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers/README.md @@ -0,0 +1,181 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers` Documentation + +The `fluidrelayservers` SDK allows for interaction with the Azure Resource Manager Service `fluidrelay` (API Version `2022-05-26`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers" +``` + + +### Client Initialization + +```go +client := fluidrelayservers.NewFluidRelayServersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FluidRelayServersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +payload := fluidrelayservers.FluidRelayServer{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FluidRelayServersClient.Delete` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FluidRelayServersClient.Get` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FluidRelayServersClient.GetKeys` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +read, err := client.GetKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FluidRelayServersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewResourceGroupID() + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FluidRelayServersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewSubscriptionID() + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FluidRelayServersClient.ListKeys` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FluidRelayServersClient.RegenerateKey` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +payload := fluidrelayservers.RegenerateKeyRequest{ + // ... +} + + +read, err := client.RegenerateKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FluidRelayServersClient.Update` + +```go +ctx := context.TODO() +id := fluidrelayservers.NewFluidRelayServerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "fluidRelayServerValue") + +payload := fluidrelayservers.FluidRelayServerUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/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 edf0301b6461..1479a95d3659 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -234,6 +234,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2017-04-01/eventhubs github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2018-01-01-preview/eventhubsclusters github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2018-01-01-preview/networkrulesets github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2021-01-01-preview/namespaces +github.com/hashicorp/go-azure-sdk/resource-manager/fluidrelay/2022-05-26/fluidrelayservers github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2021-11-30/dedicatedhsms github.com/hashicorp/go-azure-sdk/resource-manager/iotcentral/2021-11-01-preview/apps github.com/hashicorp/go-azure-sdk/resource-manager/loadtestservice/2021-12-01-preview/loadtests diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 51d664b4bd6e..b38792d449e7 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -40,6 +40,7 @@ Dev Test Digital Twins Disks Elastic +Fluid Relay 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 new file mode 100644 index 000000000000..ab147a9de8e5 --- /dev/null +++ b/website/docs/r/fluid_relay_servers.html.markdown @@ -0,0 +1,91 @@ +--- +subcategory: "Fluid Relay" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_fluid_relay_server" +description: |- + Manages a Fluid Relay Server. +--- + +# azurerm_fluid_relay_server + +Manages a Fluid 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 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 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 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 Fluid Relay Server. + +* `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`. Changing this forces a new Fluid Relay Server to be created. + +--- + +An `identity` block supports the following: + +* `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 Fluid Relay Service. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `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. + +* `storage_endpoints` - An array of storage endpoints for this Fluid Relay Server. + +--- + +`identity` exports the following: + +* `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 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 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 + +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 +```