From c1d98d6fb980e21fd6db924e68e816f53ee34982 Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Wed, 23 Aug 2023 11:23:59 +0800 Subject: [PATCH 1/7] support new resource for resource connector RP --- .teamcity/components/generated/services.kt | 1 + internal/clients/client.go | 5 + internal/provider/services.go | 2 + .../resourceconnector/client/client.go | 24 ++ .../resourceconnector/registration.go | 33 ++ .../resourceconnector_appliance_resource.go | 302 ++++++++++++++++++ ...sourceconnector_appliance_resource_test.go | 187 +++++++++++ .../2022-10-27/appliances/README.md | 184 +++++++++++ .../2022-10-27/appliances/client.go | 26 ++ .../2022-10-27/appliances/constants.go | 264 +++++++++++++++ .../2022-10-27/appliances/id_appliance.go | 127 ++++++++ .../2022-10-27/appliances/id_upgradegraph.go | 140 ++++++++ .../appliances/method_createorupdate.go | 74 +++++ .../2022-10-27/appliances/method_delete.go | 70 ++++ .../2022-10-27/appliances/method_get.go | 51 +++ .../appliances/method_gettelemetryconfig.go | 53 +++ .../appliances/method_getupgradegraph.go | 51 +++ .../appliances/method_listbyresourcegroup.go | 90 ++++++ .../appliances/method_listbysubscription.go | 90 ++++++ .../method_listclusterusercredential.go | 52 +++ .../2022-10-27/appliances/method_listkeys.go | 80 +++++ .../2022-10-27/appliances/method_update.go | 55 ++++ .../2022-10-27/appliances/model_appliance.go | 20 ++ .../model_appliancecredentialkubeconfig.go | 9 + ...model_appliancegettelemetryconfigresult.go | 8 + .../model_appliancelistcredentialresults.go | 9 + .../model_appliancelistkeysresults.go | 10 + .../appliances/model_applianceproperties.go | 13 + ...appliancepropertiesinfrastructureconfig.go | 8 + .../appliances/model_artifactprofile.go | 8 + .../model_hybridconnectionconfig.go | 11 + .../appliances/model_patchableappliance.go | 8 + .../2022-10-27/appliances/model_sshkey.go | 12 + .../appliances/model_supportedversion.go | 9 + .../model_supportedversioncatalogversion.go | 10 + ...odel_supportedversioncatalogversiondata.go | 11 + .../model_supportedversionmetadata.go | 8 + .../appliances/model_upgradegraph.go | 10 + .../model_upgradegraphproperties.go | 9 + .../2022-10-27/appliances/predicates.go | 32 ++ .../2022-10-27/appliances/version.go | 12 + vendor/modules.txt | 1 + website/allowed-subcategories | 1 + ...resource_connector_appliance.html.markdown | 92 ++++++ 44 files changed, 2272 insertions(+) create mode 100644 internal/services/resourceconnector/client/client.go create mode 100644 internal/services/resourceconnector/registration.go create mode 100644 internal/services/resourceconnector/resourceconnector_appliance_resource.go create mode 100644 internal/services/resourceconnector/resourceconnector_appliance_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_appliance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_upgradegraph.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_gettelemetryconfig.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_getupgradegraph.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbysubscription.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listclusterusercredential.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listkeys.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancecredentialkubeconfig.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancegettelemetryconfigresult.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistcredentialresults.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistkeysresults.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_applianceproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancepropertiesinfrastructureconfig.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_artifactprofile.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_hybridconnectionconfig.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_patchableappliance.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_sshkey.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversion.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversion.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversiondata.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversionmetadata.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraph.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraphproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/version.go create mode 100644 website/docs/r/resource_connector_appliance.html.markdown diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 3091b615091b..0c4a0113e5de 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -105,6 +105,7 @@ var services = mapOf( "redisenterprise" to "Redis Enterprise", "relay" to "Relay", "resource" to "Resources", + "resourceconnector" to "Resource Connector", "sql" to "SQL", "search" to "Search", "securitycenter" to "Security Center", diff --git a/internal/clients/client.go b/internal/clients/client.go index 2fe19fdc270f..2f69b84ed0ef 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -122,6 +122,7 @@ import ( redisenterprise "github.com/hashicorp/terraform-provider-azurerm/internal/services/redisenterprise/client" relay "github.com/hashicorp/terraform-provider-azurerm/internal/services/relay/client" resource "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/client" + resourceConnector "github.com/hashicorp/terraform-provider-azurerm/internal/services/resourceconnector/client" search "github.com/hashicorp/terraform-provider-azurerm/internal/services/search/client" securityCenter "github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter/client" sentinel "github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel/client" @@ -254,6 +255,7 @@ type Client struct { RedisEnterprise *redisenterprise.Client Relay *relay.Client Resource *resource.Client + ResourceConnector *resourceConnector.Client Search *search.Client SecurityCenter *securityCenter.Client Sentinel *sentinel.Client @@ -554,6 +556,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.Resource, err = resource.NewClient(o); err != nil { return fmt.Errorf("building clients for Resource: %+v", err) } + if client.ResourceConnector, err = resourceConnector.NewClient(o); err != nil { + return fmt.Errorf("building clients for Resource connector: %+v", err) + } if client.Search, err = search.NewClient(o); err != nil { return fmt.Errorf("building clients for Search: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index d5bb4c99babe..486b3ec06650 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -107,6 +107,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/redisenterprise" "github.com/hashicorp/terraform-provider-azurerm/internal/services/relay" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/resourceconnector" "github.com/hashicorp/terraform-provider-azurerm/internal/services/search" "github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter" "github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel" @@ -186,6 +187,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { privatednsresolver.Registration{}, recoveryservices.Registration{}, resource.Registration{}, + resourceconnector.Registration{}, sentinel.Registration{}, serviceconnector.Registration{}, servicefabricmanaged.Registration{}, diff --git a/internal/services/resourceconnector/client/client.go b/internal/services/resourceconnector/client/client.go new file mode 100644 index 000000000000..1da72a063643 --- /dev/null +++ b/internal/services/resourceconnector/client/client.go @@ -0,0 +1,24 @@ +package client + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + AppliancesClient *appliances.AppliancesClient +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + appliancesClient, err := appliances.NewAppliancesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building appliances Client: %+v", err) + } + o.Configure(appliancesClient.Client, o.Authorizers.ResourceManager) + + return &Client{ + AppliancesClient: appliancesClient, + }, nil +} diff --git a/internal/services/resourceconnector/registration.go b/internal/services/resourceconnector/registration.go new file mode 100644 index 000000000000..75120ad2d779 --- /dev/null +++ b/internal/services/resourceconnector/registration.go @@ -0,0 +1,33 @@ +package resourceconnector + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" +) + +var _ sdk.TypedServiceRegistrationWithAGitHubLabel = Registration{} + +type Registration struct{} + +func (r Registration) AssociatedGitHubLabel() string { + return "service/resource-connector" +} + +func (r Registration) Name() string { + return "Resource Connector" +} + +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + ResourceConnectorApplianceResource{}, + } +} + +func (r Registration) WebsiteCategories() []string { + return []string{ + "Resource Connector", + } +} diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource.go b/internal/services/resourceconnector/resourceconnector_appliance_resource.go new file mode 100644 index 000000000000..67da4316df89 --- /dev/null +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource.go @@ -0,0 +1,302 @@ +package resourceconnector + +import ( + "context" + "fmt" + "regexp" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +var _ sdk.Resource = ResourceConnectorApplianceResource{} + +var _ sdk.ResourceWithCustomizeDiff = ResourceConnectorApplianceResource{} + +type ResourceConnectorApplianceResource struct{} + +type ApplianceModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Distro appliances.Distro `tfschema:"distro"` + Identity []identity.ModelSystemAssigned `tfschema:"identity"` + Provider appliances.Provider `tfschema:"infrastructure_provider"` + PublicKey string `tfschema:"public_key"` + Tags map[string]string `tfschema:"tags"` + Version string `tfschema:"version"` +} + +func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 260), + validation.StringMatch(regexp.MustCompile(`[^+#%&'?/,%\\]+$`), "any of '+', '#', '%', '&', ''', '?', '/', ',', '%', '&', '\\', are not allowed"), + ), + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "distro": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(appliances.DistroAKSEdge), + }, false), + }, + + "identity": commonschema.SystemAssignedIdentityRequiredForceNew(), + + "infrastructure_provider": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(appliances.ProviderHCI), + string(appliances.ProviderSCVMM), + string(appliances.ProviderVMWare), + }, false), + }, + + "public_key": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "tags": commonschema.Tags(), + + "version": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "latest", + }, false), + }, + } +} + +func (r ResourceConnectorApplianceResource) Attributes() map[string]*schema.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r ResourceConnectorApplianceResource) ModelObject() interface{} { + return &ResourceConnectorApplianceResource{} +} + +func (r ResourceConnectorApplianceResource) ResourceType() string { + return "azurerm_resource_connector_appliance" +} + +func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 60 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model ApplianceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.ResourceConnector.AppliancesClient + subscriptionId := metadata.Client.Account.SubscriptionId + + id := appliances.NewApplianceID(subscriptionId, model.ResourceGroupName, model.Name) + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + if model.PublicKey != "" { + return fmt.Errorf("the public key can not be set when creating %s. it could be set after a deploy as an update operation", id) + } + + if model.Version != "" { + return fmt.Errorf("the version cannot be set when creating %s. it could be set from upgrade call", id) + } + + parameters := appliances.Appliance{ + Location: model.Location, + Properties: &appliances.ApplianceProperties{ + Distro: pointer.To(model.Distro), + InfrastructureConfig: &appliances.AppliancePropertiesInfrastructureConfig{ + Provider: pointer.To(model.Provider), + }, + }, + Tags: pointer.To(model.Tags), + } + + identity, err := identity.ExpandSystemAssignedFromModel(model.Identity) + if err != nil { + return fmt.Errorf("expanding SystemAssigned Identity: %+v", err) + } + + parameters.Identity = identity + + if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.ResourceConnector.AppliancesClient + + id, err := appliances.ParseApplianceID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + metadata.Logger.Infof("Decoding state for %s", *id) + var model ApplianceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + parameters := resp.Model + if parameters == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + identity, err := identity.ExpandSystemAssignedFromModel(model.Identity) + if err != nil { + return fmt.Errorf("expanding SystemAssigned Identity: %+v", err) + } + + parameters.Identity = identity + + if metadata.ResourceData.HasChange("tags") { + parameters.Tags = pointer.To(model.Tags) + } + + if parameters.Properties == nil { + parameters.Properties = &appliances.ApplianceProperties{} + } + + if metadata.ResourceData.HasChange("public_key") { + parameters.Properties.PublicKey = pointer.To(model.PublicKey) + } + + if metadata.ResourceData.HasChange("version") { + parameters.Properties.Version = pointer.To(model.Version) + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *parameters); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + return nil + }, + } +} + +func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + id, err := appliances.ParseApplianceID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + client := metadata.Client.ResourceConnector.AppliancesClient + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(*id) + } + return fmt.Errorf("retrieving %q: %+v", *id, err) + } + + if resp.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", *id) + } + + state := ApplianceModel{ + Name: pointer.From(resp.Model.Name), + ResourceGroupName: id.ResourceGroupName, + Location: location.NormalizeNilable(pointer.To(resp.Model.Location)), + Identity: identity.FlattenSystemAssignedToModel(resp.Model.Identity), + } + + state.Tags = pointer.From(resp.Model.Tags) + if v := resp.Model.Properties; v != nil { + state.Distro = pointer.From(v.Distro) + state.PublicKey = pointer.From(v.PublicKey) + state.Version = pointer.From(v.Version) + if p := v.InfrastructureConfig; p != nil { + state.Provider = pointer.From(p.Provider) + } + } + return metadata.Encode(&state) + }, + } +} + +func (r ResourceConnectorApplianceResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.ResourceConnector.AppliancesClient + id, err := appliances.ParseApplianceID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r ResourceConnectorApplianceResource) CustomizeDiff() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + rd := metadata.ResourceDiff + if rd.HasChange("public_key") { + old, _ := rd.GetChange("public_key") + if old.(string) != "" { + return fmt.Errorf("the public_key can not be updated once it is set") + } + } + return nil + }, + } +} + +func (r ResourceConnectorApplianceResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return appliances.ValidateApplianceID +} diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go b/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go new file mode 100644 index 000000000000..38ef0c07c382 --- /dev/null +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go @@ -0,0 +1,187 @@ +package resourceconnector_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type ResourceConnectorApplianceResource struct{} + +func TestAccResourceConnectorAppliance_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") + l := ResourceConnectorApplianceResource{} + + data.ResourceTest(t, l, []acceptance.TestStep{ + { + Config: l.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(l), + ), + }, + data.ImportStep(), + }) +} + +func TestAccResourceConnectorAppliance_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") + l := ResourceConnectorApplianceResource{} + + data.ResourceTest(t, l, []acceptance.TestStep{ + { + Config: l.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(l), + ), + }, + data.ImportStep(), + { + Config: l.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(l), + ), + }, + data.ImportStep(), + }) +} + +func TestAccResourceConnectorAppliance_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") + l := ResourceConnectorApplianceResource{} + + data.ResourceTest(t, l, []acceptance.TestStep{ + { + Config: l.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(l), + ), + }, + data.ImportStep(), + }) +} + +func TestAccResourceConnectorAppliance_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") + l := ResourceConnectorApplianceResource{} + data.ResourceTest(t, l, []acceptance.TestStep{ + { + Config: l.basic(data), + }, + { + Config: l.requiresImport(data), + ExpectError: acceptance.RequiresImportError("azurerm_resource_connector_appliance"), + }, + }) +} + +func (r ResourceConnectorApplianceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := appliances.ParseApplianceID(state.ID) + if err != nil { + return nil, err + } + + client := clients.ResourceConnector.AppliancesClient + resp, err := client.Get(ctx, *id) + + if err != nil { + return nil, fmt.Errorf("retrieving %q: %+v", *id, err) + } + + return pointer.To(resp.Model != nil), nil +} + +func (r ResourceConnectorApplianceResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} +resource "azurerm_resource_group" "test" { + name = "acctestRG-Appliances-%[1]d" + location = "%[2]s" +} +resource "azurerm_resource_connector_appliance" "test" { + name = "acctestAppliances-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + distro = "AKSEdge" + infrastructure_provider = "VMWare" + identity { + type = "SystemAssigned" + } +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r ResourceConnectorApplianceResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} +resource "azurerm_resource_group" "test" { + name = "acctestRG-Appliances-%[1]d" + location = "%[2]s" +} +resource "azurerm_resource_connector_appliance" "test" { + name = "acctestAppliances-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + distro = "AKSEdge" + infrastructure_provider = "VMWare" + public_key = "MIGJAoGBALXhHAjXWcYsF5oMPrYPfYwA/Jim7ErxlRM7laOhvUqFuMkEGxOGf76W4NhMoouFty7SUeio+IWgHjwUmiXDBhVsNie2Pe5XSyuSmvhRIFOoULfKUgv3qEBIHq0ylZOoaNIFN/HFALRIqejEh2MF5URi3fBxJA4tDV4tgR+KdYJ9AgMBAAE=" + identity { + type = "SystemAssigned" + } + tags = { + "hello" = "world" + } +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r ResourceConnectorApplianceResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} +resource "azurerm_resource_group" "test" { + name = "acctestRG-appliances-%[1]d" + location = "%[2]s" +} +resource "azurerm_resource_connector_appliance" "test" { + name = "acctestappliances-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + distro = "AKSEdge" + infrastructure_provider = "VMWare" + identity { + type = "SystemAssigned" + } + tags = { + "hello" = "world" + } +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r ResourceConnectorApplianceResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s +resource "azurerm_resource_connector_appliance" "import" { + name = azurerm_resource_connector_appliance.test.name + location = azurerm_resource_connector_appliance.test.location + resource_group_name = azurerm_resource_connector_appliance.test.resource_group_name + distro = azurerm_resource_connector_appliance.test.distro + infrastructure_provider = azurerm_resource_connector_appliance.test.infrastructure_provider + identity { + type = "SystemAssigned" + } +} +`, r.basic(data), data.RandomInteger) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/README.md new file mode 100644 index 000000000000..8d17fd3e3757 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/README.md @@ -0,0 +1,184 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances` Documentation + +The `appliances` SDK allows for interaction with the Azure Resource Manager Service `resourceconnector` (API Version `2022-10-27`). + +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/resourceconnector/2022-10-27/appliances" +``` + + +### Client Initialization + +```go +client := appliances.NewAppliancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppliancesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appliances.NewApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue") + +payload := appliances.Appliance{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppliancesClient.Delete` + +```go +ctx := context.TODO() +id := appliances.NewApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppliancesClient.Get` + +```go +ctx := context.TODO() +id := appliances.NewApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue") + +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: `AppliancesClient.GetTelemetryConfig` + +```go +ctx := context.TODO() +id := appliances.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetTelemetryConfig(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppliancesClient.GetUpgradeGraph` + +```go +ctx := context.TODO() +id := appliances.NewUpgradeGraphID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue", "upgradeGraphValue") + +read, err := client.GetUpgradeGraph(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppliancesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := appliances.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// 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: `AppliancesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := appliances.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `AppliancesClient.ListClusterUserCredential` + +```go +ctx := context.TODO() +id := appliances.NewApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue") + +read, err := client.ListClusterUserCredential(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppliancesClient.ListKeys` + +```go +ctx := context.TODO() +id := appliances.NewApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue") + +read, err := client.ListKeys(ctx, id, appliances.DefaultListKeysOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppliancesClient.Update` + +```go +ctx := context.TODO() +id := appliances.NewApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applianceValue") + +payload := appliances.PatchableAppliance{ + // ... +} + + +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/resourceconnector/2022-10-27/appliances/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/client.go new file mode 100644 index 000000000000..c909b4585ece --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/client.go @@ -0,0 +1,26 @@ +package appliances + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppliancesClient struct { + Client *resourcemanager.Client +} + +func NewAppliancesClientWithBaseURI(sdkApi sdkEnv.Api) (*AppliancesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "appliances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppliancesClient: %+v", err) + } + + return &AppliancesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/constants.go new file mode 100644 index 000000000000..3b8487515b5b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/constants.go @@ -0,0 +1,264 @@ +package appliances + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessProfileType string + +const ( + AccessProfileTypeClusterCustomerUser AccessProfileType = "clusterCustomerUser" + AccessProfileTypeClusterUser AccessProfileType = "clusterUser" +) + +func PossibleValuesForAccessProfileType() []string { + return []string{ + string(AccessProfileTypeClusterCustomerUser), + string(AccessProfileTypeClusterUser), + } +} + +func (s *AccessProfileType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessProfileType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccessProfileType(input string) (*AccessProfileType, error) { + vals := map[string]AccessProfileType{ + "clustercustomeruser": AccessProfileTypeClusterCustomerUser, + "clusteruser": AccessProfileTypeClusterUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessProfileType(input) + return &out, nil +} + +type Distro string + +const ( + DistroAKSEdge Distro = "AKSEdge" +) + +func PossibleValuesForDistro() []string { + return []string{ + string(DistroAKSEdge), + } +} + +func (s *Distro) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDistro(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDistro(input string) (*Distro, error) { + vals := map[string]Distro{ + "aksedge": DistroAKSEdge, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Distro(input) + return &out, nil +} + +type Provider string + +const ( + ProviderHCI Provider = "HCI" + ProviderSCVMM Provider = "SCVMM" + ProviderVMWare Provider = "VMWare" +) + +func PossibleValuesForProvider() []string { + return []string{ + string(ProviderHCI), + string(ProviderSCVMM), + string(ProviderVMWare), + } +} + +func (s *Provider) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvider(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvider(input string) (*Provider, error) { + vals := map[string]Provider{ + "hci": ProviderHCI, + "scvmm": ProviderSCVMM, + "vmware": ProviderVMWare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Provider(input) + return &out, nil +} + +type Status string + +const ( + StatusConnected Status = "Connected" + StatusConnecting Status = "Connecting" + StatusETCDSnapshotFailed Status = "ETCDSnapshotFailed" + StatusImageDeprovisioning Status = "ImageDeprovisioning" + StatusImageDownloaded Status = "ImageDownloaded" + StatusImageDownloading Status = "ImageDownloading" + StatusImagePending Status = "ImagePending" + StatusImageProvisioned Status = "ImageProvisioned" + StatusImageProvisioning Status = "ImageProvisioning" + StatusImageUnknown Status = "ImageUnknown" + StatusNone Status = "None" + StatusOffline Status = "Offline" + StatusPostUpgrade Status = "PostUpgrade" + StatusPreUpgrade Status = "PreUpgrade" + StatusPreparingForUpgrade Status = "PreparingForUpgrade" + StatusRunning Status = "Running" + StatusUpdatingCAPI Status = "UpdatingCAPI" + StatusUpdatingCloudOperator Status = "UpdatingCloudOperator" + StatusUpdatingCluster Status = "UpdatingCluster" + StatusUpgradeClusterExtensionFailedToDelete Status = "UpgradeClusterExtensionFailedToDelete" + StatusUpgradeComplete Status = "UpgradeComplete" + StatusUpgradeFailed Status = "UpgradeFailed" + StatusUpgradePrerequisitesCompleted Status = "UpgradePrerequisitesCompleted" + StatusUpgradingKVAIO Status = "UpgradingKVAIO" + StatusValidating Status = "Validating" + StatusValidatingETCDHealth Status = "ValidatingETCDHealth" + StatusValidatingImageDownload Status = "ValidatingImageDownload" + StatusValidatingImageUpload Status = "ValidatingImageUpload" + StatusValidatingSFSConnectivity Status = "ValidatingSFSConnectivity" + StatusWaitingForCloudOperator Status = "WaitingForCloudOperator" + StatusWaitingForHeartbeat Status = "WaitingForHeartbeat" + StatusWaitingForKVAIO Status = "WaitingForKVAIO" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusConnected), + string(StatusConnecting), + string(StatusETCDSnapshotFailed), + string(StatusImageDeprovisioning), + string(StatusImageDownloaded), + string(StatusImageDownloading), + string(StatusImagePending), + string(StatusImageProvisioned), + string(StatusImageProvisioning), + string(StatusImageUnknown), + string(StatusNone), + string(StatusOffline), + string(StatusPostUpgrade), + string(StatusPreUpgrade), + string(StatusPreparingForUpgrade), + string(StatusRunning), + string(StatusUpdatingCAPI), + string(StatusUpdatingCloudOperator), + string(StatusUpdatingCluster), + string(StatusUpgradeClusterExtensionFailedToDelete), + string(StatusUpgradeComplete), + string(StatusUpgradeFailed), + string(StatusUpgradePrerequisitesCompleted), + string(StatusUpgradingKVAIO), + string(StatusValidating), + string(StatusValidatingETCDHealth), + string(StatusValidatingImageDownload), + string(StatusValidatingImageUpload), + string(StatusValidatingSFSConnectivity), + string(StatusWaitingForCloudOperator), + string(StatusWaitingForHeartbeat), + string(StatusWaitingForKVAIO), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "connected": StatusConnected, + "connecting": StatusConnecting, + "etcdsnapshotfailed": StatusETCDSnapshotFailed, + "imagedeprovisioning": StatusImageDeprovisioning, + "imagedownloaded": StatusImageDownloaded, + "imagedownloading": StatusImageDownloading, + "imagepending": StatusImagePending, + "imageprovisioned": StatusImageProvisioned, + "imageprovisioning": StatusImageProvisioning, + "imageunknown": StatusImageUnknown, + "none": StatusNone, + "offline": StatusOffline, + "postupgrade": StatusPostUpgrade, + "preupgrade": StatusPreUpgrade, + "preparingforupgrade": StatusPreparingForUpgrade, + "running": StatusRunning, + "updatingcapi": StatusUpdatingCAPI, + "updatingcloudoperator": StatusUpdatingCloudOperator, + "updatingcluster": StatusUpdatingCluster, + "upgradeclusterextensionfailedtodelete": StatusUpgradeClusterExtensionFailedToDelete, + "upgradecomplete": StatusUpgradeComplete, + "upgradefailed": StatusUpgradeFailed, + "upgradeprerequisitescompleted": StatusUpgradePrerequisitesCompleted, + "upgradingkvaio": StatusUpgradingKVAIO, + "validating": StatusValidating, + "validatingetcdhealth": StatusValidatingETCDHealth, + "validatingimagedownload": StatusValidatingImageDownload, + "validatingimageupload": StatusValidatingImageUpload, + "validatingsfsconnectivity": StatusValidatingSFSConnectivity, + "waitingforcloudoperator": StatusWaitingForCloudOperator, + "waitingforheartbeat": StatusWaitingForHeartbeat, + "waitingforkvaio": StatusWaitingForKVAIO, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_appliance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_appliance.go new file mode 100644 index 000000000000..c8eb093b3a03 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_appliance.go @@ -0,0 +1,127 @@ +package appliances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = ApplianceId{} + +// ApplianceId is a struct representing the Resource ID for a Appliance +type ApplianceId struct { + SubscriptionId string + ResourceGroupName string + ApplianceName string +} + +// NewApplianceID returns a new ApplianceId struct +func NewApplianceID(subscriptionId string, resourceGroupName string, applianceName string) ApplianceId { + return ApplianceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplianceName: applianceName, + } +} + +// ParseApplianceID parses 'input' into a ApplianceId +func ParseApplianceID(input string) (*ApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(ApplianceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ApplianceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.ApplianceName, ok = parsed.Parsed["applianceName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "applianceName", *parsed) + } + + return &id, nil +} + +// ParseApplianceIDInsensitively parses 'input' case-insensitively into a ApplianceId +// note: this method should only be used for API response data and not user input +func ParseApplianceIDInsensitively(input string) (*ApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(ApplianceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ApplianceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.ApplianceName, ok = parsed.Parsed["applianceName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "applianceName", *parsed) + } + + return &id, nil +} + +// ValidateApplianceID checks that 'input' can be parsed as a Appliance ID +func ValidateApplianceID(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 := ParseApplianceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Appliance ID +func (id ApplianceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ResourceConnector/appliances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplianceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Appliance ID +func (id ApplianceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftResourceConnector", "Microsoft.ResourceConnector", "Microsoft.ResourceConnector"), + resourceids.StaticSegment("staticAppliances", "appliances", "appliances"), + resourceids.UserSpecifiedSegment("applianceName", "applianceValue"), + } +} + +// String returns a human-readable description of this Appliance ID +func (id ApplianceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Appliance Name: %q", id.ApplianceName), + } + return fmt.Sprintf("Appliance (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_upgradegraph.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_upgradegraph.go new file mode 100644 index 000000000000..02d88d9c97c1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/id_upgradegraph.go @@ -0,0 +1,140 @@ +package appliances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = UpgradeGraphId{} + +// UpgradeGraphId is a struct representing the Resource ID for a Upgrade Graph +type UpgradeGraphId struct { + SubscriptionId string + ResourceGroupName string + ApplianceName string + UpgradeGraphName string +} + +// NewUpgradeGraphID returns a new UpgradeGraphId struct +func NewUpgradeGraphID(subscriptionId string, resourceGroupName string, applianceName string, upgradeGraphName string) UpgradeGraphId { + return UpgradeGraphId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplianceName: applianceName, + UpgradeGraphName: upgradeGraphName, + } +} + +// ParseUpgradeGraphID parses 'input' into a UpgradeGraphId +func ParseUpgradeGraphID(input string) (*UpgradeGraphId, error) { + parser := resourceids.NewParserFromResourceIdType(UpgradeGraphId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := UpgradeGraphId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.ApplianceName, ok = parsed.Parsed["applianceName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "applianceName", *parsed) + } + + if id.UpgradeGraphName, ok = parsed.Parsed["upgradeGraphName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "upgradeGraphName", *parsed) + } + + return &id, nil +} + +// ParseUpgradeGraphIDInsensitively parses 'input' case-insensitively into a UpgradeGraphId +// note: this method should only be used for API response data and not user input +func ParseUpgradeGraphIDInsensitively(input string) (*UpgradeGraphId, error) { + parser := resourceids.NewParserFromResourceIdType(UpgradeGraphId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := UpgradeGraphId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.ApplianceName, ok = parsed.Parsed["applianceName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "applianceName", *parsed) + } + + if id.UpgradeGraphName, ok = parsed.Parsed["upgradeGraphName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "upgradeGraphName", *parsed) + } + + return &id, nil +} + +// ValidateUpgradeGraphID checks that 'input' can be parsed as a Upgrade Graph ID +func ValidateUpgradeGraphID(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 := ParseUpgradeGraphID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Upgrade Graph ID +func (id UpgradeGraphId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ResourceConnector/appliances/%s/upgradeGraphs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplianceName, id.UpgradeGraphName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Upgrade Graph ID +func (id UpgradeGraphId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftResourceConnector", "Microsoft.ResourceConnector", "Microsoft.ResourceConnector"), + resourceids.StaticSegment("staticAppliances", "appliances", "appliances"), + resourceids.UserSpecifiedSegment("applianceName", "applianceValue"), + resourceids.StaticSegment("staticUpgradeGraphs", "upgradeGraphs", "upgradeGraphs"), + resourceids.UserSpecifiedSegment("upgradeGraphName", "upgradeGraphValue"), + } +} + +// String returns a human-readable description of this Upgrade Graph ID +func (id UpgradeGraphId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Appliance Name: %q", id.ApplianceName), + fmt.Sprintf("Upgrade Graph Name: %q", id.UpgradeGraphName), + } + return fmt.Sprintf("Upgrade Graph (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_createorupdate.go new file mode 100644 index 000000000000..3e65ee2b9d52 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_createorupdate.go @@ -0,0 +1,74 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c AppliancesClient) CreateOrUpdate(ctx context.Context, id ApplianceId, input Appliance) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppliancesClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplianceId, input Appliance) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_delete.go new file mode 100644 index 000000000000..cd9e813db837 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_delete.go @@ -0,0 +1,70 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppliancesClient) Delete(ctx context.Context, id ApplianceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AppliancesClient) DeleteThenPoll(ctx context.Context, id ApplianceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_get.go new file mode 100644 index 000000000000..72c719318306 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_get.go @@ -0,0 +1,51 @@ +package appliances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Appliance +} + +// Get ... +func (c AppliancesClient) Get(ctx context.Context, id ApplianceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_gettelemetryconfig.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_gettelemetryconfig.go new file mode 100644 index 000000000000..b379b7ee1150 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_gettelemetryconfig.go @@ -0,0 +1,53 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTelemetryConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplianceGetTelemetryConfigResult +} + +// GetTelemetryConfig ... +func (c AppliancesClient) GetTelemetryConfig(ctx context.Context, id commonids.SubscriptionId) (result GetTelemetryConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ResourceConnector/telemetryconfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_getupgradegraph.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_getupgradegraph.go new file mode 100644 index 000000000000..8d8b3bee629b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_getupgradegraph.go @@ -0,0 +1,51 @@ +package appliances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUpgradeGraphOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UpgradeGraph +} + +// GetUpgradeGraph ... +func (c AppliancesClient) GetUpgradeGraph(ctx context.Context, id UpgradeGraphId) (result GetUpgradeGraphOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbyresourcegroup.go new file mode 100644 index 000000000000..f60ee84ed5be --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Appliance +} + +type ListByResourceGroupCompleteResult struct { + Items []Appliance +} + +// ListByResourceGroup ... +func (c AppliancesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ResourceConnector/appliances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Appliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppliancesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ApplianceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppliancesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApplianceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Appliance, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbysubscription.go new file mode 100644 index 000000000000..96e13e35442e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listbysubscription.go @@ -0,0 +1,90 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Appliance +} + +type ListBySubscriptionCompleteResult struct { + Items []Appliance +} + +// ListBySubscription ... +func (c AppliancesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ResourceConnector/appliances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Appliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AppliancesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ApplianceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppliancesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApplianceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Appliance, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listclusterusercredential.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listclusterusercredential.go new file mode 100644 index 000000000000..f78229f12866 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listclusterusercredential.go @@ -0,0 +1,52 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterUserCredentialOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplianceListCredentialResults +} + +// ListClusterUserCredential ... +func (c AppliancesClient) ListClusterUserCredential(ctx context.Context, id ApplianceId) (result ListClusterUserCredentialOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listClusterUserCredential", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listkeys.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listkeys.go new file mode 100644 index 000000000000..934aad299db0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_listkeys.go @@ -0,0 +1,80 @@ +package appliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplianceListKeysResults +} + +type ListKeysOperationOptions struct { + ArtifactType *string +} + +func DefaultListKeysOperationOptions() ListKeysOperationOptions { + return ListKeysOperationOptions{} +} + +func (o ListKeysOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListKeysOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListKeysOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ArtifactType != nil { + out.Append("artifactType", fmt.Sprintf("%v", *o.ArtifactType)) + } + return &out +} + +// ListKeys ... +func (c AppliancesClient) ListKeys(ctx context.Context, id ApplianceId, options ListKeysOperationOptions) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_update.go new file mode 100644 index 000000000000..11f8e1c5d32f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/method_update.go @@ -0,0 +1,55 @@ +package appliances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Appliance +} + +// Update ... +func (c AppliancesClient) Update(ctx context.Context, id ApplianceId, input PatchableAppliance) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliance.go new file mode 100644 index 000000000000..3bffef71c23d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliance.go @@ -0,0 +1,20 @@ +package appliances + +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 Appliance struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ApplianceProperties `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/resourceconnector/2022-10-27/appliances/model_appliancecredentialkubeconfig.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancecredentialkubeconfig.go new file mode 100644 index 000000000000..ba91ca3f35d6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancecredentialkubeconfig.go @@ -0,0 +1,9 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceCredentialKubeconfig struct { + Name *AccessProfileType `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancegettelemetryconfigresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancegettelemetryconfigresult.go new file mode 100644 index 000000000000..51784d4d3349 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancegettelemetryconfigresult.go @@ -0,0 +1,8 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceGetTelemetryConfigResult struct { + TelemetryInstrumentationKey *string `json:"telemetryInstrumentationKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistcredentialresults.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistcredentialresults.go new file mode 100644 index 000000000000..925fa8556442 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistcredentialresults.go @@ -0,0 +1,9 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceListCredentialResults struct { + HybridConnectionConfig *HybridConnectionConfig `json:"hybridConnectionConfig,omitempty"` + Kubeconfigs *[]ApplianceCredentialKubeconfig `json:"kubeconfigs,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistkeysresults.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistkeysresults.go new file mode 100644 index 000000000000..be869370361c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancelistkeysresults.go @@ -0,0 +1,10 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceListKeysResults struct { + ArtifactProfiles *map[string]ArtifactProfile `json:"artifactProfiles,omitempty"` + Kubeconfigs *[]ApplianceCredentialKubeconfig `json:"kubeconfigs,omitempty"` + SshKeys *map[string]SSHKey `json:"sshKeys,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_applianceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_applianceproperties.go new file mode 100644 index 000000000000..ea46a7b2231b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_applianceproperties.go @@ -0,0 +1,13 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceProperties struct { + Distro *Distro `json:"distro,omitempty"` + InfrastructureConfig *AppliancePropertiesInfrastructureConfig `json:"infrastructureConfig,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicKey *string `json:"publicKey,omitempty"` + Status *Status `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancepropertiesinfrastructureconfig.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancepropertiesinfrastructureconfig.go new file mode 100644 index 000000000000..1301b177d046 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_appliancepropertiesinfrastructureconfig.go @@ -0,0 +1,8 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppliancePropertiesInfrastructureConfig struct { + Provider *Provider `json:"provider,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_artifactprofile.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_artifactprofile.go new file mode 100644 index 000000000000..81f4faa9faeb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_artifactprofile.go @@ -0,0 +1,8 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArtifactProfile struct { + Endpoint *string `json:"endpoint,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_hybridconnectionconfig.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_hybridconnectionconfig.go new file mode 100644 index 000000000000..84aaa679766f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_hybridconnectionconfig.go @@ -0,0 +1,11 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionConfig struct { + ExpirationTime *int64 `json:"expirationTime,omitempty"` + HybridConnectionName *string `json:"hybridConnectionName,omitempty"` + Relay *string `json:"relay,omitempty"` + Token *string `json:"token,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_patchableappliance.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_patchableappliance.go new file mode 100644 index 000000000000..2eed58c90089 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_patchableappliance.go @@ -0,0 +1,8 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchableAppliance struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_sshkey.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_sshkey.go new file mode 100644 index 000000000000..682a1195a236 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_sshkey.go @@ -0,0 +1,12 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SSHKey struct { + Certificate *string `json:"certificate,omitempty"` + CreationTimeStamp *int64 `json:"creationTimeStamp,omitempty"` + ExpirationTimeStamp *int64 `json:"expirationTimeStamp,omitempty"` + PrivateKey *string `json:"privateKey,omitempty"` + PublicKey *string `json:"publicKey,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversion.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversion.go new file mode 100644 index 000000000000..1c4599e8f33e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversion.go @@ -0,0 +1,9 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedVersion struct { + Metadata *SupportedVersionMetadata `json:"metadata,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversion.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversion.go new file mode 100644 index 000000000000..a25fbf59ca00 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversion.go @@ -0,0 +1,10 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedVersionCatalogVersion struct { + Data *SupportedVersionCatalogVersionData `json:"data,omitempty"` + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversiondata.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversiondata.go new file mode 100644 index 000000000000..53a8fe553b44 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversioncatalogversiondata.go @@ -0,0 +1,11 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedVersionCatalogVersionData struct { + Audience *string `json:"audience,omitempty"` + Catalog *string `json:"catalog,omitempty"` + Offer *string `json:"offer,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversionmetadata.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversionmetadata.go new file mode 100644 index 000000000000..e6aab72141e9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_supportedversionmetadata.go @@ -0,0 +1,8 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedVersionMetadata struct { + CatalogVersion *SupportedVersionCatalogVersion `json:"catalogVersion,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraph.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraph.go new file mode 100644 index 000000000000..aba238b13ca8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraph.go @@ -0,0 +1,10 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeGraph struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UpgradeGraphProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraphproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraphproperties.go new file mode 100644 index 000000000000..ba33a88bc712 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/model_upgradegraphproperties.go @@ -0,0 +1,9 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeGraphProperties struct { + ApplianceVersion *string `json:"applianceVersion,omitempty"` + SupportedVersions *[]SupportedVersion `json:"supportedVersions,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/predicates.go new file mode 100644 index 000000000000..748f0086d851 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/predicates.go @@ -0,0 +1,32 @@ +package appliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ApplianceOperationPredicate) Matches(input Appliance) 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/resourceconnector/2022-10-27/appliances/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/version.go new file mode 100644 index 000000000000..d8fc28f3da58 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances/version.go @@ -0,0 +1,12 @@ +package appliances + +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-10-27" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/appliances/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4c2b36ed1a18..688513e8a396 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -802,6 +802,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/redisenterprise/2022-01-01/da github.com/hashicorp/go-azure-sdk/resource-manager/redisenterprise/2022-01-01/redisenterprise github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/hybridconnections github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces +github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-06-01/policyassignments diff --git a/website/allowed-subcategories b/website/allowed-subcategories index d0783de08aa6..83d01f1cad0a 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -88,6 +88,7 @@ Purview Recovery Services Redis Redis Enterprise +Resource Connector Search Security Center Sentinel diff --git a/website/docs/r/resource_connector_appliance.html.markdown b/website/docs/r/resource_connector_appliance.html.markdown new file mode 100644 index 000000000000..ac00b2ee9e80 --- /dev/null +++ b/website/docs/r/resource_connector_appliance.html.markdown @@ -0,0 +1,92 @@ +--- +subcategory: "Resource Connector" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_resource_connector_appliance" +description: |- + Manages an Appliance. +--- + +# azurerm_resource_connector_appliance + +Manages an Appliances. + +-> **Note:** Before using this resource, it's required to submit the request of registering the providers with Azure CLI `az provider register --namespace Microsoft.ResourceConnector`. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example" + location = "eastus" +} + +resource "azurerm_resource_connector_appliance" "example" { + name = "example-appliance" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + distro = "AKSEdge" + infrastructure_provider = "VMWare" + + identity { + type = "SystemAssigned" + } + + tags = { + "hello" = "world" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The Name which should be used for this Appliance. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) Specifies the resource group where the resource exists. Changing this forces a new resource to be created. + +* `location` - (Required) The Azure Region where the Appliance should exist. Changing this forces a new resource to be created. + +* `distro` - (Required) Specifies the resource group where the resource exists. The possible value is `AKSEdge`. + +* `identity` - (Required) An `identity` block as defined below. Changing this forces a new resource to be created. + +* `infrastructure_provider`- (Required) The infrastructure provider about the connected Appliance. Possible values are `HCI`,`SCVMM` and `VMWare`. Changing this forces a new resource to be created. + +* `public_key`- (Required) The `public_key` is an RSA public key in PKCS1 format encoded in base64. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Appliance. + +* `version` - (Optional) The version of the Appliance. Possible values is `latest`. + +-> **NOTE:** The `version` cannot be populated apart from upgrade call. + +--- + +An `identity` block supports the following: + +* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Appliance. The only possible value is `SystemAssigned`. + + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Appliance. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 60 minutes) Used when creating the Appliance. +* `read` - (Defaults to 5 minutes) Used when retrieving the Appliance. +* `update` - (Defaults to 30 minutes) Used when updating the Appliance. +* `delete` - (Defaults to 30 minutes) Used when deleting the Appliance. + +## Import + +Appliance can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_resource_connector_appliance.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/providers/Microsoft.ResourceConnector/apliances/appliancesExample +``` From 4097b881a30c04fcdf2d2e6491ebd4c6cce63e9c Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Tue, 29 Aug 2023 15:46:33 +0800 Subject: [PATCH 2/7] run make generate --- .github/labeler-issue-triage.yml | 3 +++ .github/labeler-pull-request-triage.yml | 3 +++ .teamcity/components/generated/services.kt | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 02be616bacb3..8b68c448e673 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -285,6 +285,9 @@ service/redis: service/relay: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_relay_((.|\n)*)###' +service/resource-connector: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_resource_connector_appliance((.|\n)*)###' + service/search: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_search_s((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index d02368e107e6..1210bf0a0beb 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -286,6 +286,9 @@ service/redis: service/relay: - internal/services/relay/**/* +service/resource-connector: + - internal/services/resourceconnector/**/* + service/search: - internal/services/search/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 0c4a0113e5de..50c099dad3c1 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -104,8 +104,8 @@ var services = mapOf( "redis" to "Redis", "redisenterprise" to "Redis Enterprise", "relay" to "Relay", - "resource" to "Resources", "resourceconnector" to "Resource Connector", + "resource" to "Resources", "sql" to "SQL", "search" to "Search", "securitycenter" to "Security Center", From 8a10faa9cf81ebd233dbdc14c3243f063c56ae2f Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Mon, 11 Sep 2023 10:09:44 +0800 Subject: [PATCH 3/7] update code --- .../resourceconnector_appliance_resource.go | 120 ++++++++---------- ...sourceconnector_appliance_resource_test.go | 116 ++++++++++------- ...resource_connector_appliance.html.markdown | 44 +++---- 3 files changed, 144 insertions(+), 136 deletions(-) diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource.go b/internal/services/resourceconnector/resourceconnector_appliance_resource.go index 67da4316df89..6cc1a3e3f445 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource.go +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -20,8 +21,6 @@ import ( var _ sdk.Resource = ResourceConnectorApplianceResource{} -var _ sdk.ResourceWithCustomizeDiff = ResourceConnectorApplianceResource{} - type ResourceConnectorApplianceResource struct{} type ApplianceModel struct { @@ -76,17 +75,16 @@ func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schem "public_key": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validation.StringIsNotEmpty, + ForceNew: true, + ValidateFunc: validate.Base64EncodedString, }, "tags": commonschema.Tags(), "version": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - "latest", - }, false), + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, }, } } @@ -124,16 +122,13 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - if model.PublicKey != "" { - return fmt.Errorf("the public key can not be set when creating %s. it could be set after a deploy as an update operation", id) - } - - if model.Version != "" { - return fmt.Errorf("the version cannot be set when creating %s. it could be set from upgrade call", id) + identity, err := identity.ExpandSystemAssignedFromModel(model.Identity) + if err != nil { + return err } parameters := appliances.Appliance{ - Location: model.Location, + Location: location.Normalize(model.Location), Properties: &appliances.ApplianceProperties{ Distro: pointer.To(model.Distro), InfrastructureConfig: &appliances.AppliancePropertiesInfrastructureConfig{ @@ -143,17 +138,27 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { Tags: pointer.To(model.Tags), } - identity, err := identity.ExpandSystemAssignedFromModel(model.Identity) - if err != nil { - return fmt.Errorf("expanding SystemAssigned Identity: %+v", err) - } - parameters.Identity = identity if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } + // since the public key and version could not be set during creation, update after creation + if model.PublicKey != "" || model.Version != "" { + if model.PublicKey != "" { + parameters.Properties.PublicKey = pointer.To(model.PublicKey) + } + + if model.Version != "" { + parameters.Properties.Version = pointer.To(model.Version) + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + } + metadata.SetID(id) return nil }, @@ -187,27 +192,29 @@ func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: model was nil", *id) } - identity, err := identity.ExpandSystemAssignedFromModel(model.Identity) - if err != nil { - return fmt.Errorf("expanding SystemAssigned Identity: %+v", err) - } + if metadata.ResourceData.HasChange("identity") { + identity, err := identity.ExpandSystemAssignedFromModel(model.Identity) + if err != nil { + return err + } - parameters.Identity = identity + parameters.Identity = identity + } if metadata.ResourceData.HasChange("tags") { parameters.Tags = pointer.To(model.Tags) } - if parameters.Properties == nil { - parameters.Properties = &appliances.ApplianceProperties{} - } - - if metadata.ResourceData.HasChange("public_key") { - parameters.Properties.PublicKey = pointer.To(model.PublicKey) - } - - if metadata.ResourceData.HasChange("version") { - parameters.Properties.Version = pointer.To(model.Version) + if metadata.ResourceData.HasChanges("public_key", "version") { + if parameters.Properties == nil { + parameters.Properties = &appliances.ApplianceProperties{} + } + if metadata.ResourceData.HasChange("public_key") { + parameters.Properties.PublicKey = pointer.To(model.PublicKey) + } + if metadata.ResourceData.HasChange("version") { + parameters.Properties.Version = pointer.To(model.Version) + } } if err := client.CreateOrUpdateThenPoll(ctx, *id, *parameters); err != nil { @@ -238,24 +245,24 @@ func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %q: %+v", *id, err) } - if resp.Model == nil { - return fmt.Errorf("retrieving %s: model was nil", *id) - } - state := ApplianceModel{ - Name: pointer.From(resp.Model.Name), + Name: id.ApplianceName, ResourceGroupName: id.ResourceGroupName, - Location: location.NormalizeNilable(pointer.To(resp.Model.Location)), - Identity: identity.FlattenSystemAssignedToModel(resp.Model.Identity), } - state.Tags = pointer.From(resp.Model.Tags) - if v := resp.Model.Properties; v != nil { - state.Distro = pointer.From(v.Distro) - state.PublicKey = pointer.From(v.PublicKey) - state.Version = pointer.From(v.Version) - if p := v.InfrastructureConfig; p != nil { - state.Provider = pointer.From(p.Provider) + if model := resp.Model; model != nil { + state.Location = location.Normalize(model.Location) + state.Identity = identity.FlattenSystemAssignedToModel(model.Identity) + state.Tags = pointer.From(resp.Model.Tags) + + if props := model.Properties; props != nil { + state.Distro = pointer.From(props.Distro) + state.PublicKey = pointer.From(props.PublicKey) + + state.Version = pointer.From(props.Version) + if infraConfig := props.InfrastructureConfig; infraConfig != nil { + state.Provider = pointer.From(infraConfig.Provider) + } } } return metadata.Encode(&state) @@ -282,21 +289,6 @@ func (r ResourceConnectorApplianceResource) Delete() sdk.ResourceFunc { } } -func (r ResourceConnectorApplianceResource) CustomizeDiff() sdk.ResourceFunc { - return sdk.ResourceFunc{ - Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - rd := metadata.ResourceDiff - if rd.HasChange("public_key") { - old, _ := rd.GetChange("public_key") - if old.(string) != "" { - return fmt.Errorf("the public_key can not be updated once it is set") - } - } - return nil - }, - } -} - func (r ResourceConnectorApplianceResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { return appliances.ValidateApplianceID } diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go b/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go index 38ef0c07c382..1fe899d26a80 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go @@ -2,6 +2,10 @@ package resourceconnector_test import ( "context" + cryptoRand "crypto/rand" + "crypto/rsa" + "crypto/x509" + "encoding/base64" "fmt" "testing" @@ -17,13 +21,13 @@ type ResourceConnectorApplianceResource struct{} func TestAccResourceConnectorAppliance_basic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - l := ResourceConnectorApplianceResource{} + r := ResourceConnectorApplianceResource{} - data.ResourceTest(t, l, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: l.basic(data), + Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(l), + check.That(data.ResourceName).ExistsInAzure(r), ), }, data.ImportStep(), @@ -32,20 +36,27 @@ func TestAccResourceConnectorAppliance_basic(t *testing.T) { func TestAccResourceConnectorAppliance_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - l := ResourceConnectorApplianceResource{} + r := ResourceConnectorApplianceResource{} - data.ResourceTest(t, l, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: l.basic(data), + Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(l), + check.That(data.ResourceName).ExistsInAzure(r), ), }, data.ImportStep(), { - Config: l.update(data), + Config: r.update(data), Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(l), + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), ), }, data.ImportStep(), @@ -54,13 +65,13 @@ func TestAccResourceConnectorAppliance_update(t *testing.T) { func TestAccResourceConnectorAppliance_complete(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - l := ResourceConnectorApplianceResource{} + r := ResourceConnectorApplianceResource{} - data.ResourceTest(t, l, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: l.complete(data), + Config: r.complete(data, r.generatePublicKey()), Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(l), + check.That(data.ResourceName).ExistsInAzure(r), ), }, data.ImportStep(), @@ -69,13 +80,13 @@ func TestAccResourceConnectorAppliance_complete(t *testing.T) { func TestAccResourceConnectorAppliance_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - l := ResourceConnectorApplianceResource{} - data.ResourceTest(t, l, []acceptance.TestStep{ + r := ResourceConnectorApplianceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: l.basic(data), + Config: r.basic(data), }, { - Config: l.requiresImport(data), + Config: r.requiresImport(data, r.generatePublicKey()), ExpectError: acceptance.RequiresImportError("azurerm_resource_connector_appliance"), }, }) @@ -99,15 +110,11 @@ func (r ResourceConnectorApplianceResource) Exists(ctx context.Context, clients func (r ResourceConnectorApplianceResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` -provider "azurerm" { - features {} -} -resource "azurerm_resource_group" "test" { - name = "acctestRG-Appliances-%[1]d" - location = "%[2]s" -} + +%s + resource "azurerm_resource_connector_appliance" "test" { - name = "acctestAppliances-%[1]d" + name = "acctestrcapplicance-%[2]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name distro = "AKSEdge" @@ -116,25 +123,20 @@ resource "azurerm_resource_connector_appliance" "test" { type = "SystemAssigned" } } -`, data.RandomInteger, data.Locations.Primary) +`, r.template(data), data.RandomInteger) } func (r ResourceConnectorApplianceResource) update(data acceptance.TestData) string { return fmt.Sprintf(` -provider "azurerm" { - features {} -} -resource "azurerm_resource_group" "test" { - name = "acctestRG-Appliances-%[1]d" - location = "%[2]s" -} + +%s + resource "azurerm_resource_connector_appliance" "test" { - name = "acctestAppliances-%[1]d" + name = "acctestrcapplicance-%[2]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name distro = "AKSEdge" infrastructure_provider = "VMWare" - public_key = "MIGJAoGBALXhHAjXWcYsF5oMPrYPfYwA/Jim7ErxlRM7laOhvUqFuMkEGxOGf76W4NhMoouFty7SUeio+IWgHjwUmiXDBhVsNie2Pe5XSyuSmvhRIFOoULfKUgv3qEBIHq0ylZOoaNIFN/HFALRIqejEh2MF5URi3fBxJA4tDV4tgR+KdYJ9AgMBAAE=" identity { type = "SystemAssigned" } @@ -142,24 +144,21 @@ resource "azurerm_resource_connector_appliance" "test" { "hello" = "world" } } -`, data.RandomInteger, data.Locations.Primary) +`, r.template(data), data.RandomInteger) } -func (r ResourceConnectorApplianceResource) complete(data acceptance.TestData) string { +func (r ResourceConnectorApplianceResource) complete(data acceptance.TestData, publicKey string) string { return fmt.Sprintf(` -provider "azurerm" { - features {} -} -resource "azurerm_resource_group" "test" { - name = "acctestRG-appliances-%[1]d" - location = "%[2]s" -} + +%s + resource "azurerm_resource_connector_appliance" "test" { - name = "acctestappliances-%[1]d" + name = "acctestrcapplicance-%[2]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name distro = "AKSEdge" infrastructure_provider = "VMWare" + public_key = "%[3]s" identity { type = "SystemAssigned" } @@ -167,10 +166,10 @@ resource "azurerm_resource_connector_appliance" "test" { "hello" = "world" } } -`, data.RandomInteger, data.Locations.Primary) +`, r.template(data), data.RandomInteger, publicKey) } -func (r ResourceConnectorApplianceResource) requiresImport(data acceptance.TestData) string { +func (r ResourceConnectorApplianceResource) requiresImport(data acceptance.TestData, publicKey string) string { return fmt.Sprintf(` %[1]s resource "azurerm_resource_connector_appliance" "import" { @@ -185,3 +184,24 @@ resource "azurerm_resource_connector_appliance" "import" { } `, r.basic(data), data.RandomInteger) } + +func (r ResourceConnectorApplianceResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestrg-appliances-%[1]d" + location = "%[2]s" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r ResourceConnectorApplianceResource) generatePublicKey() string { + privateKey, err := rsa.GenerateKey(cryptoRand.Reader, 4096) + if err != nil { + return "" + } + return base64.StdEncoding.EncodeToString(x509.MarshalPKCS1PublicKey(&privateKey.PublicKey)) +} diff --git a/website/docs/r/resource_connector_appliance.html.markdown b/website/docs/r/resource_connector_appliance.html.markdown index ac00b2ee9e80..c46b2b77680a 100644 --- a/website/docs/r/resource_connector_appliance.html.markdown +++ b/website/docs/r/resource_connector_appliance.html.markdown @@ -3,21 +3,19 @@ subcategory: "Resource Connector" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_resource_connector_appliance" description: |- - Manages an Appliance. + Manages a Resource Connector Appliance. --- # azurerm_resource_connector_appliance -Manages an Appliances. - --> **Note:** Before using this resource, it's required to submit the request of registering the providers with Azure CLI `az provider register --namespace Microsoft.ResourceConnector`. +Manages a Resource Connector Appliance. ## Example Usage ```hcl resource "azurerm_resource_group" "example" { - name = "example" - location = "eastus" + name = "example-resources" + location = "West Europe" } resource "azurerm_resource_connector_appliance" "example" { @@ -41,52 +39,50 @@ resource "azurerm_resource_connector_appliance" "example" { The following arguments are supported: -* `name` - (Required) The Name which should be used for this Appliance. Changing this forces a new resource to be created. +* `name` - (Required) The Name which should be used for this Resource Connector Appliance. Changing this forces a new resource to be created. -* `resource_group_name` - (Required) Specifies the resource group where the resource exists. Changing this forces a new resource to be created. +* `resource_group_name` - (Required) Specifies the resource group where the Resource Connector Appliance exists. Changing this forces a new resource to be created. -* `location` - (Required) The Azure Region where the Appliance should exist. Changing this forces a new resource to be created. +* `location` - (Required) The Azure Region where the Resource Connector Appliance should exist. Changing this forces a new resource to be created. -* `distro` - (Required) Specifies the resource group where the resource exists. The possible value is `AKSEdge`. +* `distro` - (Required) Specifies a supported Fabric/Infrastructure for this Resource Connector Appliance. The possible value is `AKSEdge`. * `identity` - (Required) An `identity` block as defined below. Changing this forces a new resource to be created. -* `infrastructure_provider`- (Required) The infrastructure provider about the connected Appliance. Possible values are `HCI`,`SCVMM` and `VMWare`. Changing this forces a new resource to be created. - -* `public_key`- (Required) The `public_key` is an RSA public key in PKCS1 format encoded in base64. +* `infrastructure_provider`- (Required) The infrastructure provider about the connected Resource Connector Appliance. Possible values are `HCI`,`SCVMM` and `VMWare`. Changing this forces a new resource to be created. -* `tags` - (Optional) A mapping of tags which should be assigned to the Appliance. +* `public_key`- (Optional) The `public_key` is an RSA public key in PKCS1 format encoded in base64. Changing this forces a new resource to be created. -* `version` - (Optional) The version of the Appliance. Possible values is `latest`. +* `tags` - (Optional) A mapping of tags which should be assigned to the Resource Connector Appliance. --> **NOTE:** The `version` cannot be populated apart from upgrade call. +* `version` - (Optional) The version of the Resource Connector Appliance. --- An `identity` block supports the following: -* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Appliance. The only possible value is `SystemAssigned`. +* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Resource Connector Appliance. The only possible value is `SystemAssigned`. ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: -* `id` - The ID of the Appliance. +* `id` - The ID of the Resource Connector Appliance. ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: -* `create` - (Defaults to 60 minutes) Used when creating the Appliance. -* `read` - (Defaults to 5 minutes) Used when retrieving the Appliance. -* `update` - (Defaults to 30 minutes) Used when updating the Appliance. -* `delete` - (Defaults to 30 minutes) Used when deleting the Appliance. +* `create` - (Defaults to 60 minutes) Used when creating the Resource Connector Appliance. +* `read` - (Defaults to 5 minutes) Used when retrieving the Resource Connector Appliance. +* `update` - (Defaults to 30 minutes) Used when updating the Resource Connector Appliance. +* `delete` - (Defaults to 30 minutes) Used when deleting the Resource Connector Appliance. ## Import -Appliance can be imported using the `resource id`, e.g. +Resource Connector Appliance can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_resource_connector_appliance.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/providers/Microsoft.ResourceConnector/apliances/appliancesExample +terraform import azurerm_resource_connector_appliance.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/providers/Microsoft.ResourceConnector/appliances/appliancesExample ``` From c3521232185d91dc5b76037be6de2151d840f5fb Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Mon, 11 Sep 2023 13:32:14 +0800 Subject: [PATCH 4/7] update code --- .../resourceconnector_appliance_resource_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go b/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go index 1fe899d26a80..c09e608edfb2 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go @@ -86,7 +86,7 @@ func TestAccResourceConnectorAppliance_requiresImport(t *testing.T) { Config: r.basic(data), }, { - Config: r.requiresImport(data, r.generatePublicKey()), + Config: r.requiresImport(data), ExpectError: acceptance.RequiresImportError("azurerm_resource_connector_appliance"), }, }) @@ -169,7 +169,7 @@ resource "azurerm_resource_connector_appliance" "test" { `, r.template(data), data.RandomInteger, publicKey) } -func (r ResourceConnectorApplianceResource) requiresImport(data acceptance.TestData, publicKey string) string { +func (r ResourceConnectorApplianceResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %[1]s resource "azurerm_resource_connector_appliance" "import" { From 4ed6e20675c992e7d6a581e3515ffc91a91b128f Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Tue, 12 Sep 2023 10:19:00 +0800 Subject: [PATCH 5/7] remove version --- .../resourceconnector_appliance_resource.go | 21 +++---------------- ...resource_connector_appliance.html.markdown | 2 -- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource.go b/internal/services/resourceconnector/resourceconnector_appliance_resource.go index 6cc1a3e3f445..489d74f1b702 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource.go +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource.go @@ -32,7 +32,6 @@ type ApplianceModel struct { Provider appliances.Provider `tfschema:"infrastructure_provider"` PublicKey string `tfschema:"public_key"` Tags map[string]string `tfschema:"tags"` - Version string `tfschema:"version"` } func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schema { @@ -80,12 +79,6 @@ func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schem }, "tags": commonschema.Tags(), - - "version": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringIsNotEmpty, - }, } } @@ -144,16 +137,12 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { return fmt.Errorf("creating %s: %+v", id, err) } - // since the public key and version could not be set during creation, update after creation - if model.PublicKey != "" || model.Version != "" { + // since the public key could not be set during creation, update after creation + if model.PublicKey != "" { if model.PublicKey != "" { parameters.Properties.PublicKey = pointer.To(model.PublicKey) } - if model.Version != "" { - parameters.Properties.Version = pointer.To(model.Version) - } - if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -205,16 +194,13 @@ func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { parameters.Tags = pointer.To(model.Tags) } - if metadata.ResourceData.HasChanges("public_key", "version") { + if metadata.ResourceData.HasChanges("public_key") { if parameters.Properties == nil { parameters.Properties = &appliances.ApplianceProperties{} } if metadata.ResourceData.HasChange("public_key") { parameters.Properties.PublicKey = pointer.To(model.PublicKey) } - if metadata.ResourceData.HasChange("version") { - parameters.Properties.Version = pointer.To(model.Version) - } } if err := client.CreateOrUpdateThenPoll(ctx, *id, *parameters); err != nil { @@ -259,7 +245,6 @@ func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { state.Distro = pointer.From(props.Distro) state.PublicKey = pointer.From(props.PublicKey) - state.Version = pointer.From(props.Version) if infraConfig := props.InfrastructureConfig; infraConfig != nil { state.Provider = pointer.From(infraConfig.Provider) } diff --git a/website/docs/r/resource_connector_appliance.html.markdown b/website/docs/r/resource_connector_appliance.html.markdown index c46b2b77680a..4a711cf6c000 100644 --- a/website/docs/r/resource_connector_appliance.html.markdown +++ b/website/docs/r/resource_connector_appliance.html.markdown @@ -55,8 +55,6 @@ The following arguments are supported: * `tags` - (Optional) A mapping of tags which should be assigned to the Resource Connector Appliance. -* `version` - (Optional) The version of the Resource Connector Appliance. - --- An `identity` block supports the following: From 469e45173bee451e6074db8684a118a2ce5a8eee Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Tue, 12 Sep 2023 11:55:01 +0800 Subject: [PATCH 6/7] update code --- .../resourceconnector_appliance_resource.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource.go b/internal/services/resourceconnector/resourceconnector_appliance_resource.go index 489d74f1b702..795057e5de95 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource.go +++ b/internal/services/resourceconnector/resourceconnector_appliance_resource.go @@ -139,9 +139,7 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { // since the public key could not be set during creation, update after creation if model.PublicKey != "" { - if model.PublicKey != "" { - parameters.Properties.PublicKey = pointer.To(model.PublicKey) - } + parameters.Properties.PublicKey = pointer.To(model.PublicKey) if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { return fmt.Errorf("creating %s: %+v", id, err) @@ -198,9 +196,7 @@ func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { if parameters.Properties == nil { parameters.Properties = &appliances.ApplianceProperties{} } - if metadata.ResourceData.HasChange("public_key") { - parameters.Properties.PublicKey = pointer.To(model.PublicKey) - } + parameters.Properties.PublicKey = pointer.To(model.PublicKey) } if err := client.CreateOrUpdateThenPoll(ctx, *id, *parameters); err != nil { From 59eff66335b05a15a3b691d30c32d4ae09fef752 Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Tue, 19 Sep 2023 14:15:53 +0800 Subject: [PATCH 7/7] update code --- .github/labeler-issue-triage.yml | 6 +- .github/labeler-pull-request-triage.yml | 6 +- .teamcity/components/generated/services.kt | 2 +- internal/clients/client.go | 10 +-- internal/provider/services.go | 4 +- ...arc_resource_bridge_appliance_resource.go} | 59 ++++++------- ...esource_bridge_appliance_resource_test.go} | 66 +++++++------- .../client/client.go | 0 .../registration.go | 10 +-- website/allowed-subcategories | 2 +- ...rc_resource_bridge_appliance.html.markdown | 86 +++++++++++++++++++ ...resource_connector_appliance.html.markdown | 86 ------------------- 12 files changed, 169 insertions(+), 168 deletions(-) rename internal/services/{resourceconnector/resourceconnector_appliance_resource.go => arcresourcebridge/arc_resource_bridge_appliance_resource.go} (81%) rename internal/services/{resourceconnector/resourceconnector_appliance_resource_test.go => arcresourcebridge/arc_resource_bridge_appliance_resource_test.go} (64%) rename internal/services/{resourceconnector => arcresourcebridge}/client/client.go (100%) rename internal/services/{resourceconnector => arcresourcebridge}/registration.go (76%) create mode 100644 website/docs/r/arc_resource_bridge_appliance.html.markdown delete mode 100644 website/docs/r/resource_connector_appliance.html.markdown diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index 8b68c448e673..a868ee29ee24 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -30,6 +30,9 @@ service/app-service: service/application-insights: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_application_insights((.|\n)*)###' +service/arc-resource-bridge: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_arc_resource_bridge_appliance((.|\n)*)###' + service/attestation: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_attestation_provider((.|\n)*)###' @@ -285,9 +288,6 @@ service/redis: service/relay: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_relay_((.|\n)*)###' -service/resource-connector: - - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_resource_connector_appliance((.|\n)*)###' - service/search: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_search_s((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 1210bf0a0beb..63360164cadd 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -28,6 +28,9 @@ service/app-service: service/application-insights: - internal/services/applicationinsights/**/* +service/arc-resource-bridge: + - internal/services/arcresourcebridge/**/* + service/attestation: - internal/services/attestation/**/* @@ -286,9 +289,6 @@ service/redis: service/relay: - internal/services/relay/**/* -service/resource-connector: - - internal/services/resourceconnector/**/* - service/search: - internal/services/search/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 50c099dad3c1..00d9e83827a3 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -10,6 +10,7 @@ var services = mapOf( "appconfiguration" to "App Configuration", "appservice" to "AppService", "applicationinsights" to "Application Insights", + "arcresourcebridge" to "Arc Resource Bridge", "arckubernetes" to "ArcKubernetes", "attestation" to "Attestation", "authorization" to "Authorization", @@ -104,7 +105,6 @@ var services = mapOf( "redis" to "Redis", "redisenterprise" to "Redis Enterprise", "relay" to "Relay", - "resourceconnector" to "Resource Connector", "resource" to "Resources", "sql" to "SQL", "search" to "Search", diff --git a/internal/clients/client.go b/internal/clients/client.go index 2f69b84ed0ef..42a84a9bfece 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -30,6 +30,7 @@ import ( applicationInsights "github.com/hashicorp/terraform-provider-azurerm/internal/services/applicationinsights/client" appService "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/client" arckubernetes "github.com/hashicorp/terraform-provider-azurerm/internal/services/arckubernetes/client" + arcResourceBridge "github.com/hashicorp/terraform-provider-azurerm/internal/services/arcresourcebridge/client" attestation "github.com/hashicorp/terraform-provider-azurerm/internal/services/attestation/client" authorization "github.com/hashicorp/terraform-provider-azurerm/internal/services/authorization/client" automanage "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage/client" @@ -122,7 +123,6 @@ import ( redisenterprise "github.com/hashicorp/terraform-provider-azurerm/internal/services/redisenterprise/client" relay "github.com/hashicorp/terraform-provider-azurerm/internal/services/relay/client" resource "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/client" - resourceConnector "github.com/hashicorp/terraform-provider-azurerm/internal/services/resourceconnector/client" search "github.com/hashicorp/terraform-provider-azurerm/internal/services/search/client" securityCenter "github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter/client" sentinel "github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel/client" @@ -163,6 +163,7 @@ type Client struct { AppPlatform *appPlatform.Client AppService *appService.Client ArcKubernetes *arckubernetes.Client + ArcResourceBridge *arcResourceBridge.Client Attestation *attestation.Client Authorization *authorization.Client Automanage *automanage.Client @@ -255,7 +256,6 @@ type Client struct { RedisEnterprise *redisenterprise.Client Relay *relay.Client Resource *resource.Client - ResourceConnector *resourceConnector.Client Search *search.Client SecurityCenter *securityCenter.Client Sentinel *sentinel.Client @@ -316,6 +316,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.ArcKubernetes, err = arckubernetes.NewClient(o); err != nil { return fmt.Errorf("building clients for ArcKubernetes: %+v", err) } + if client.ArcResourceBridge, err = arcResourceBridge.NewClient(o); err != nil { + return fmt.Errorf("building clients for Arc Resource Bridge: %+v", err) + } if client.Attestation, err = attestation.NewClient(o); err != nil { return fmt.Errorf("building clients for Attestation: %+v", err) } @@ -556,9 +559,6 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.Resource, err = resource.NewClient(o); err != nil { return fmt.Errorf("building clients for Resource: %+v", err) } - if client.ResourceConnector, err = resourceConnector.NewClient(o); err != nil { - return fmt.Errorf("building clients for Resource connector: %+v", err) - } if client.Search, err = search.NewClient(o); err != nil { return fmt.Errorf("building clients for Search: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index 486b3ec06650..251ee20d930b 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/applicationinsights" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice" "github.com/hashicorp/terraform-provider-azurerm/internal/services/arckubernetes" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/arcresourcebridge" "github.com/hashicorp/terraform-provider-azurerm/internal/services/attestation" "github.com/hashicorp/terraform-provider-azurerm/internal/services/authorization" "github.com/hashicorp/terraform-provider-azurerm/internal/services/automanage" @@ -107,7 +108,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/redisenterprise" "github.com/hashicorp/terraform-provider-azurerm/internal/services/relay" "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/resourceconnector" "github.com/hashicorp/terraform-provider-azurerm/internal/services/search" "github.com/hashicorp/terraform-provider-azurerm/internal/services/securitycenter" "github.com/hashicorp/terraform-provider-azurerm/internal/services/sentinel" @@ -140,6 +140,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { applicationinsights.Registration{}, appservice.Registration{}, arckubernetes.Registration{}, + arcresourcebridge.Registration{}, authorization.Registration{}, automanage.Registration{}, automation.Registration{}, @@ -187,7 +188,6 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { privatednsresolver.Registration{}, recoveryservices.Registration{}, resource.Registration{}, - resourceconnector.Registration{}, sentinel.Registration{}, serviceconnector.Registration{}, servicefabricmanaged.Registration{}, diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource.go b/internal/services/arcresourcebridge/arc_resource_bridge_appliance_resource.go similarity index 81% rename from internal/services/resourceconnector/resourceconnector_appliance_resource.go rename to internal/services/arcresourcebridge/arc_resource_bridge_appliance_resource.go index 795057e5de95..997d31885379 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource.go +++ b/internal/services/arcresourcebridge/arc_resource_bridge_appliance_resource.go @@ -1,4 +1,4 @@ -package resourceconnector +package arcresourcebridge import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/resourceconnector/2022-10-27/appliances" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" @@ -19,9 +20,9 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) -var _ sdk.Resource = ResourceConnectorApplianceResource{} +var _ sdk.Resource = ArcResourceBridgeApplianceResource{} -type ResourceConnectorApplianceResource struct{} +type ArcResourceBridgeApplianceResource struct{} type ApplianceModel struct { Name string `tfschema:"name"` @@ -30,11 +31,11 @@ type ApplianceModel struct { Distro appliances.Distro `tfschema:"distro"` Identity []identity.ModelSystemAssigned `tfschema:"identity"` Provider appliances.Provider `tfschema:"infrastructure_provider"` - PublicKey string `tfschema:"public_key"` - Tags map[string]string `tfschema:"tags"` + PublicKeyBase64 string `tfschema:"public_key_base64"` + Tags map[string]interface{} `tfschema:"tags"` } -func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schema { +func (r ArcResourceBridgeApplianceResource) Arguments() map[string]*schema.Schema { return map[string]*schema.Schema{ "name": { Type: pluginsdk.TypeString, @@ -71,7 +72,7 @@ func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schem }, false), }, - "public_key": { + "public_key_base64": { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, @@ -82,19 +83,19 @@ func (r ResourceConnectorApplianceResource) Arguments() map[string]*schema.Schem } } -func (r ResourceConnectorApplianceResource) Attributes() map[string]*schema.Schema { +func (r ArcResourceBridgeApplianceResource) Attributes() map[string]*schema.Schema { return map[string]*pluginsdk.Schema{} } -func (r ResourceConnectorApplianceResource) ModelObject() interface{} { - return &ResourceConnectorApplianceResource{} +func (r ArcResourceBridgeApplianceResource) ModelObject() interface{} { + return &ArcResourceBridgeApplianceResource{} } -func (r ResourceConnectorApplianceResource) ResourceType() string { - return "azurerm_resource_connector_appliance" +func (r ArcResourceBridgeApplianceResource) ResourceType() string { + return "azurerm_arc_resource_bridge_appliance" } -func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { +func (r ArcResourceBridgeApplianceResource) Create() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { @@ -103,7 +104,7 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { return fmt.Errorf("decoding: %+v", err) } - client := metadata.Client.ResourceConnector.AppliancesClient + client := metadata.Client.ArcResourceBridge.AppliancesClient subscriptionId := metadata.Client.Account.SubscriptionId id := appliances.NewApplianceID(subscriptionId, model.ResourceGroupName, model.Name) @@ -128,7 +129,7 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { Provider: pointer.To(model.Provider), }, }, - Tags: pointer.To(model.Tags), + Tags: tags.Expand(model.Tags), } parameters.Identity = identity @@ -138,8 +139,8 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { } // since the public key could not be set during creation, update after creation - if model.PublicKey != "" { - parameters.Properties.PublicKey = pointer.To(model.PublicKey) + if model.PublicKeyBase64 != "" { + parameters.Properties.PublicKey = pointer.To(model.PublicKeyBase64) if err := client.CreateOrUpdateThenPoll(ctx, id, parameters); err != nil { return fmt.Errorf("creating %s: %+v", id, err) @@ -152,11 +153,11 @@ func (r ResourceConnectorApplianceResource) Create() sdk.ResourceFunc { } } -func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { +func (r ArcResourceBridgeApplianceResource) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 30 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.ResourceConnector.AppliancesClient + client := metadata.Client.ArcResourceBridge.AppliancesClient id, err := appliances.ParseApplianceID(metadata.ResourceData.Id()) if err != nil { @@ -189,14 +190,14 @@ func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { } if metadata.ResourceData.HasChange("tags") { - parameters.Tags = pointer.To(model.Tags) + parameters.Tags = tags.Expand(model.Tags) } - if metadata.ResourceData.HasChanges("public_key") { + if metadata.ResourceData.HasChanges("public_key_base64") { if parameters.Properties == nil { parameters.Properties = &appliances.ApplianceProperties{} } - parameters.Properties.PublicKey = pointer.To(model.PublicKey) + parameters.Properties.PublicKey = pointer.To(model.PublicKeyBase64) } if err := client.CreateOrUpdateThenPoll(ctx, *id, *parameters); err != nil { @@ -208,7 +209,7 @@ func (r ResourceConnectorApplianceResource) Update() sdk.ResourceFunc { } } -func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { +func (r ArcResourceBridgeApplianceResource) Read() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 5 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { @@ -217,7 +218,7 @@ func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { return err } - client := metadata.Client.ResourceConnector.AppliancesClient + client := metadata.Client.ArcResourceBridge.AppliancesClient resp, err := client.Get(ctx, *id) if err != nil { @@ -235,11 +236,11 @@ func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { state.Location = location.Normalize(model.Location) state.Identity = identity.FlattenSystemAssignedToModel(model.Identity) - state.Tags = pointer.From(resp.Model.Tags) + state.Tags = tags.Flatten(model.Tags) if props := model.Properties; props != nil { state.Distro = pointer.From(props.Distro) - state.PublicKey = pointer.From(props.PublicKey) + state.PublicKeyBase64 = pointer.From(props.PublicKey) if infraConfig := props.InfrastructureConfig; infraConfig != nil { state.Provider = pointer.From(infraConfig.Provider) @@ -251,11 +252,11 @@ func (r ResourceConnectorApplianceResource) Read() sdk.ResourceFunc { } } -func (r ResourceConnectorApplianceResource) Delete() sdk.ResourceFunc { +func (r ArcResourceBridgeApplianceResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ Timeout: 30 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { - client := metadata.Client.ResourceConnector.AppliancesClient + client := metadata.Client.ArcResourceBridge.AppliancesClient id, err := appliances.ParseApplianceID(metadata.ResourceData.Id()) if err != nil { return err @@ -270,6 +271,6 @@ func (r ResourceConnectorApplianceResource) Delete() sdk.ResourceFunc { } } -func (r ResourceConnectorApplianceResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { +func (r ArcResourceBridgeApplianceResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { return appliances.ValidateApplianceID } diff --git a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go b/internal/services/arcresourcebridge/arc_resource_bridge_appliance_resource_test.go similarity index 64% rename from internal/services/resourceconnector/resourceconnector_appliance_resource_test.go rename to internal/services/arcresourcebridge/arc_resource_bridge_appliance_resource_test.go index c09e608edfb2..e332808c1952 100644 --- a/internal/services/resourceconnector/resourceconnector_appliance_resource_test.go +++ b/internal/services/arcresourcebridge/arc_resource_bridge_appliance_resource_test.go @@ -1,4 +1,4 @@ -package resourceconnector_test +package arcresourcebridge_test import ( "context" @@ -17,11 +17,11 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) -type ResourceConnectorApplianceResource struct{} +type ArcResourceBridgeApplianceResource struct{} -func TestAccResourceConnectorAppliance_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - r := ResourceConnectorApplianceResource{} +func TestAccArcResourceBridgeAppliance_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_arc_resource_bridge_appliance", "test") + r := ArcResourceBridgeApplianceResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { @@ -34,9 +34,9 @@ func TestAccResourceConnectorAppliance_basic(t *testing.T) { }) } -func TestAccResourceConnectorAppliance_update(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - r := ResourceConnectorApplianceResource{} +func TestAccArcResourceBridgeAppliance_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_arc_resource_bridge_appliance", "test") + r := ArcResourceBridgeApplianceResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { @@ -63,9 +63,9 @@ func TestAccResourceConnectorAppliance_update(t *testing.T) { }) } -func TestAccResourceConnectorAppliance_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - r := ResourceConnectorApplianceResource{} +func TestAccArcResourceBridgeAppliance_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_arc_resource_bridge_appliance", "test") + r := ArcResourceBridgeApplianceResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { @@ -78,27 +78,27 @@ func TestAccResourceConnectorAppliance_complete(t *testing.T) { }) } -func TestAccResourceConnectorAppliance_requiresImport(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_resource_connector_appliance", "test") - r := ResourceConnectorApplianceResource{} +func TestAccArcResourceBridgeAppliance_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_arc_resource_bridge_appliance", "test") + r := ArcResourceBridgeApplianceResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.basic(data), }, { Config: r.requiresImport(data), - ExpectError: acceptance.RequiresImportError("azurerm_resource_connector_appliance"), + ExpectError: acceptance.RequiresImportError("azurerm_arc_resource_bridge_appliance"), }, }) } -func (r ResourceConnectorApplianceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { +func (r ArcResourceBridgeApplianceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := appliances.ParseApplianceID(state.ID) if err != nil { return nil, err } - client := clients.ResourceConnector.AppliancesClient + client := clients.ArcResourceBridge.AppliancesClient resp, err := client.Get(ctx, *id) if err != nil { @@ -108,12 +108,12 @@ func (r ResourceConnectorApplianceResource) Exists(ctx context.Context, clients return pointer.To(resp.Model != nil), nil } -func (r ResourceConnectorApplianceResource) basic(data acceptance.TestData) string { +func (r ArcResourceBridgeApplianceResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` %s -resource "azurerm_resource_connector_appliance" "test" { +resource "azurerm_arc_resource_bridge_appliance" "test" { name = "acctestrcapplicance-%[2]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -126,12 +126,12 @@ resource "azurerm_resource_connector_appliance" "test" { `, r.template(data), data.RandomInteger) } -func (r ResourceConnectorApplianceResource) update(data acceptance.TestData) string { +func (r ArcResourceBridgeApplianceResource) update(data acceptance.TestData) string { return fmt.Sprintf(` %s -resource "azurerm_resource_connector_appliance" "test" { +resource "azurerm_arc_resource_bridge_appliance" "test" { name = "acctestrcapplicance-%[2]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -147,18 +147,18 @@ resource "azurerm_resource_connector_appliance" "test" { `, r.template(data), data.RandomInteger) } -func (r ResourceConnectorApplianceResource) complete(data acceptance.TestData, publicKey string) string { +func (r ArcResourceBridgeApplianceResource) complete(data acceptance.TestData, publicKey string) string { return fmt.Sprintf(` %s -resource "azurerm_resource_connector_appliance" "test" { +resource "azurerm_arc_resource_bridge_appliance" "test" { name = "acctestrcapplicance-%[2]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name distro = "AKSEdge" infrastructure_provider = "VMWare" - public_key = "%[3]s" + public_key_base64 = "%[3]s" identity { type = "SystemAssigned" } @@ -169,15 +169,15 @@ resource "azurerm_resource_connector_appliance" "test" { `, r.template(data), data.RandomInteger, publicKey) } -func (r ResourceConnectorApplianceResource) requiresImport(data acceptance.TestData) string { +func (r ArcResourceBridgeApplianceResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %[1]s -resource "azurerm_resource_connector_appliance" "import" { - name = azurerm_resource_connector_appliance.test.name - location = azurerm_resource_connector_appliance.test.location - resource_group_name = azurerm_resource_connector_appliance.test.resource_group_name - distro = azurerm_resource_connector_appliance.test.distro - infrastructure_provider = azurerm_resource_connector_appliance.test.infrastructure_provider +resource "azurerm_arc_resource_bridge_appliance" "import" { + name = azurerm_arc_resource_bridge_appliance.test.name + location = azurerm_arc_resource_bridge_appliance.test.location + resource_group_name = azurerm_arc_resource_bridge_appliance.test.resource_group_name + distro = azurerm_arc_resource_bridge_appliance.test.distro + infrastructure_provider = azurerm_arc_resource_bridge_appliance.test.infrastructure_provider identity { type = "SystemAssigned" } @@ -185,7 +185,7 @@ resource "azurerm_resource_connector_appliance" "import" { `, r.basic(data), data.RandomInteger) } -func (r ResourceConnectorApplianceResource) template(data acceptance.TestData) string { +func (r ArcResourceBridgeApplianceResource) template(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -198,7 +198,7 @@ resource "azurerm_resource_group" "test" { `, data.RandomInteger, data.Locations.Primary) } -func (r ResourceConnectorApplianceResource) generatePublicKey() string { +func (r ArcResourceBridgeApplianceResource) generatePublicKey() string { privateKey, err := rsa.GenerateKey(cryptoRand.Reader, 4096) if err != nil { return "" diff --git a/internal/services/resourceconnector/client/client.go b/internal/services/arcresourcebridge/client/client.go similarity index 100% rename from internal/services/resourceconnector/client/client.go rename to internal/services/arcresourcebridge/client/client.go diff --git a/internal/services/resourceconnector/registration.go b/internal/services/arcresourcebridge/registration.go similarity index 76% rename from internal/services/resourceconnector/registration.go rename to internal/services/arcresourcebridge/registration.go index 75120ad2d779..fef3dfe3f895 100644 --- a/internal/services/resourceconnector/registration.go +++ b/internal/services/arcresourcebridge/registration.go @@ -1,4 +1,4 @@ -package resourceconnector +package arcresourcebridge import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" @@ -9,11 +9,11 @@ var _ sdk.TypedServiceRegistrationWithAGitHubLabel = Registration{} type Registration struct{} func (r Registration) AssociatedGitHubLabel() string { - return "service/resource-connector" + return "service/arc-resource-bridge" } func (r Registration) Name() string { - return "Resource Connector" + return "Arc Resource Bridge" } func (r Registration) DataSources() []sdk.DataSource { @@ -22,12 +22,12 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ - ResourceConnectorApplianceResource{}, + ArcResourceBridgeApplianceResource{}, } } func (r Registration) WebsiteCategories() []string { return []string{ - "Resource Connector", + "Arc Resource Bridge", } } diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 83d01f1cad0a..cb7312f079d1 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -6,6 +6,7 @@ Analysis Services App Configuration App Service (Web Apps) Application Insights +Arc Resource Bridge ArcKubernetes Attestation Authorization @@ -88,7 +89,6 @@ Purview Recovery Services Redis Redis Enterprise -Resource Connector Search Security Center Sentinel diff --git a/website/docs/r/arc_resource_bridge_appliance.html.markdown b/website/docs/r/arc_resource_bridge_appliance.html.markdown new file mode 100644 index 000000000000..fe3c3bee875c --- /dev/null +++ b/website/docs/r/arc_resource_bridge_appliance.html.markdown @@ -0,0 +1,86 @@ +--- +subcategory: "Arc Resource Bridge" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_arc_resource_bridge_appliance" +description: |- + Manages an Arc Resource Bridge Appliance. +--- + +# azurerm_arc_resource_bridge_appliance + +Manages an Arc Resource Bridge Appliance. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_arc_resource_bridge_appliance" "example" { + name = "example-appliance" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + distro = "AKSEdge" + infrastructure_provider = "VMWare" + + identity { + type = "SystemAssigned" + } + + tags = { + "hello" = "world" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The Name which should be used for this Arc Resource Bridge Appliance. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) Specifies the resource group where the Arc Resource Bridge Appliance exists. Changing this forces a new resource to be created. + +* `location` - (Required) The Azure Region where the Arc Resource Bridge Appliance should exist. Changing this forces a new resource to be created. + +* `distro` - (Required) Specifies a supported Fabric/Infrastructure for this Arc Resource Bridge Appliance. The possible value is `AKSEdge`. + +* `identity` - (Required) An `identity` block as defined below. Changing this forces a new resource to be created. + +* `infrastructure_provider`- (Required) The infrastructure provider about the connected Arc Resource Bridge Appliance. Possible values are `HCI`,`SCVMM` and `VMWare`. Changing this forces a new resource to be created. + +* `public_key_base64`- (Optional) The `public_key_base64` is an RSA public key in PKCS1 format encoded in base64. Changing this forces a new resource to be created. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Arc Resource Bridge Appliance. + +--- + +An `identity` block supports the following: + +* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Arc Resource Bridge Appliance. The only possible value is `SystemAssigned`. + + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Arc Resource Bridge Appliance. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 60 minutes) Used when creating the Arc Resource Bridge Appliance. +* `read` - (Defaults to 5 minutes) Used when retrieving the Arc Resource Bridge Appliance. +* `update` - (Defaults to 30 minutes) Used when updating the Arc Resource Bridge Appliance. +* `delete` - (Defaults to 30 minutes) Used when deleting the Arc Resource Bridge Appliance. + +## Import + +Arc Resource Bridge Appliance can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_arc_resource_bridge_appliance.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/providers/Microsoft.ResourceConnector/appliances/appliancesExample +``` diff --git a/website/docs/r/resource_connector_appliance.html.markdown b/website/docs/r/resource_connector_appliance.html.markdown deleted file mode 100644 index 4a711cf6c000..000000000000 --- a/website/docs/r/resource_connector_appliance.html.markdown +++ /dev/null @@ -1,86 +0,0 @@ ---- -subcategory: "Resource Connector" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_resource_connector_appliance" -description: |- - Manages a Resource Connector Appliance. ---- - -# azurerm_resource_connector_appliance - -Manages a Resource Connector Appliance. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West Europe" -} - -resource "azurerm_resource_connector_appliance" "example" { - name = "example-appliance" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - distro = "AKSEdge" - infrastructure_provider = "VMWare" - - identity { - type = "SystemAssigned" - } - - tags = { - "hello" = "world" - } -} -``` - -## Arguments Reference - -The following arguments are supported: - -* `name` - (Required) The Name which should be used for this Resource Connector Appliance. Changing this forces a new resource to be created. - -* `resource_group_name` - (Required) Specifies the resource group where the Resource Connector Appliance exists. Changing this forces a new resource to be created. - -* `location` - (Required) The Azure Region where the Resource Connector Appliance should exist. Changing this forces a new resource to be created. - -* `distro` - (Required) Specifies a supported Fabric/Infrastructure for this Resource Connector Appliance. The possible value is `AKSEdge`. - -* `identity` - (Required) An `identity` block as defined below. Changing this forces a new resource to be created. - -* `infrastructure_provider`- (Required) The infrastructure provider about the connected Resource Connector Appliance. Possible values are `HCI`,`SCVMM` and `VMWare`. Changing this forces a new resource to be created. - -* `public_key`- (Optional) The `public_key` is an RSA public key in PKCS1 format encoded in base64. Changing this forces a new resource to be created. - -* `tags` - (Optional) A mapping of tags which should be assigned to the Resource Connector Appliance. - ---- - -An `identity` block supports the following: - -* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this Resource Connector Appliance. The only possible value is `SystemAssigned`. - - -## Attributes Reference - -In addition to the Arguments listed above - the following Attributes are exported: - -* `id` - The ID of the Resource Connector Appliance. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: - -* `create` - (Defaults to 60 minutes) Used when creating the Resource Connector Appliance. -* `read` - (Defaults to 5 minutes) Used when retrieving the Resource Connector Appliance. -* `update` - (Defaults to 30 minutes) Used when updating the Resource Connector Appliance. -* `delete` - (Defaults to 30 minutes) Used when deleting the Resource Connector Appliance. - -## Import - -Resource Connector Appliance can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_resource_connector_appliance.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/providers/Microsoft.ResourceConnector/appliances/appliancesExample -```