diff --git a/.github/labeler-issue-triage.yml b/.github/labeler-issue-triage.yml index aac8e90bff0a..f46d4568f968 100644 --- a/.github/labeler-issue-triage.yml +++ b/.github/labeler-issue-triage.yml @@ -114,6 +114,9 @@ service/databricks: service/datadog: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_datadog_monitor((.|\n)*)###' +service/dev-center: + - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_dev_center((.|\n)*)###' + service/devtestlabs: - '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_dev_test_((.|\n)*)###' diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 31af6fda50f3..bb6a4aa0650c 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -115,6 +115,9 @@ service/databricks: service/datadog: - internal/services/datadog/**/* +service/dev-center: + - internal/services/devcenter/**/* + service/devtestlabs: - internal/services/devtestlabs/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index f567623fed9c..345efa5d02bd 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -44,6 +44,7 @@ var services = mapOf( "databoxedge" to "Databox Edge", "datadog" to "Datadog", "desktopvirtualization" to "Desktop Virtualization", + "devcenter" to "Dev Center", "devtestlabs" to "Dev Test", "digitaltwins" to "Digital Twins", "disks" to "Disks", diff --git a/internal/clients/client.go b/internal/clients/client.go index e281e1130d43..7ca4f572ca7e 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -62,6 +62,7 @@ import ( dataprotection "github.com/hashicorp/terraform-provider-azurerm/internal/services/dataprotection/client" datashare "github.com/hashicorp/terraform-provider-azurerm/internal/services/datashare/client" desktopvirtualization "github.com/hashicorp/terraform-provider-azurerm/internal/services/desktopvirtualization/client" + devcenter "github.com/hashicorp/terraform-provider-azurerm/internal/services/devcenter/client" devtestlabs "github.com/hashicorp/terraform-provider-azurerm/internal/services/devtestlabs/client" digitaltwins "github.com/hashicorp/terraform-provider-azurerm/internal/services/digitaltwins/client" disks "github.com/hashicorp/terraform-provider-azurerm/internal/services/disks/client" @@ -196,6 +197,7 @@ type Client struct { DataProtection *dataprotection.Client DataShare *datashare.Client DesktopVirtualization *desktopvirtualization.Client + DevCenter *devcenter.Client DevTestLabs *devtestlabs.Client DigitalTwins *digitaltwins.Client Disks *disks.Client @@ -406,6 +408,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.DesktopVirtualization, err = desktopvirtualization.NewClient(o); err != nil { return fmt.Errorf("building clients for DesktopVirtualization: %+v", err) } + if client.DevCenter, err = devcenter.NewClient(o); err != nil { + return fmt.Errorf("building clients for DevCenter: %+v", err) + } if client.DevTestLabs, err = devtestlabs.NewClient(o); err != nil { return fmt.Errorf("building clients for DevTestLabs: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index fedff05e4e4e..db3d5f5846ac 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -45,6 +45,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/dataprotection" "github.com/hashicorp/terraform-provider-azurerm/internal/services/datashare" "github.com/hashicorp/terraform-provider-azurerm/internal/services/desktopvirtualization" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/devcenter" "github.com/hashicorp/terraform-provider-azurerm/internal/services/devtestlabs" "github.com/hashicorp/terraform-provider-azurerm/internal/services/digitaltwins" "github.com/hashicorp/terraform-provider-azurerm/internal/services/disks" @@ -159,6 +160,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { databoxedge.Registration{}, databricks.Registration{}, datafactory.Registration{}, + devcenter.Registration{}, digitaltwins.Registration{}, disks.Registration{}, domainservices.Registration{}, diff --git a/internal/services/devcenter/client/client.go b/internal/services/devcenter/client/client.go new file mode 100644 index 000000000000..1596bc6cd41e --- /dev/null +++ b/internal/services/devcenter/client/client.go @@ -0,0 +1,26 @@ +package client + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + DevCenterClient *devcenters.DevCentersClient + AttachedNetworkConnectionsClient *attachednetworkconnections.AttachedNetworkConnectionsClient +} + +func NewClient(o *common.ClientOptions) (*Client, error) { + devCenterClient, err := devcenters.NewDevCentersClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Devcenter client: %+v", err) + } + o.Configure(devCenterClient.Client, o.Authorizers.ResourceManager) + + return &Client{ + DevCenterClient: devCenterClient, + }, nil +} diff --git a/internal/services/devcenter/dev_center_resource.go b/internal/services/devcenter/dev_center_resource.go new file mode 100644 index 000000000000..802ed33d3aa4 --- /dev/null +++ b/internal/services/devcenter/dev_center_resource.go @@ -0,0 +1,207 @@ +package devcenter + +import ( + "context" + "fmt" + "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-sdk/resource-manager/devcenter/2023-04-01/devcenters" + "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" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type DevCenterResource struct{} + +type DevCenterModel struct { + Name string `tfschema:"name"` + ResourceGroup string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` +} + +var _ sdk.ResourceWithUpdate = DevCenterResource{} + +func (r DevCenterResource) Arguments() map[string]*schema.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), + + "tags": commonschema.Tags(), + } +} + +func (r DevCenterResource) Attributes() map[string]*schema.Schema { + return map[string]*schema.Schema{} +} + +func (r DevCenterResource) ModelObject() interface{} { + return &DevCenterModel{} +} + +func (r DevCenterResource) ResourceType() string { + return "azurerm_dev_center" +} + +func (r DevCenterResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.DevCenter.DevCenterClient + subscriptionId := metadata.Client.Account.SubscriptionId + + var model DevCenterModel + if err := metadata.Decode(&model); err != nil { + return err + } + + id := devcenters.NewDevCenterID(subscriptionId, model.ResourceGroup, model.Name) + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + devCenterIdentity, err := identity.ExpandSystemAndUserAssignedMap(metadata.ResourceData.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + + devCenter := devcenters.DevCenter{ + Id: utils.String(id.ID()), + Identity: devCenterIdentity, + Location: model.Location, + Name: utils.String(model.Name), + Tags: pointer.To(model.Tags), + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, devCenter); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r DevCenterResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.DevCenter.DevCenterClient + id, err := devcenters.ParseDevCenterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("reading %s: %+v", *id, err) + } + + if model := resp.Model; model != nil { + state := DevCenterModel{ + Name: id.DevCenterName, + ResourceGroup: id.ResourceGroupName, + Location: model.Location, + } + if model.Tags != nil { + state.Tags = pointer.From(model.Tags) + } + devCenterIdentity, err := identity.FlattenSystemAndUserAssignedMap(model.Identity) + if err != nil { + return fmt.Errorf("flattening `identity`: %+v", err) + } + if err := metadata.ResourceData.Set("identity", devCenterIdentity); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } + + return metadata.Encode(&state) + } + return nil + }, + } +} + +func (r DevCenterResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.DevCenter.DevCenterClient + id, err := devcenters.ParseDevCenterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + metadata.Logger.Infof("deleting %s", *id) + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r DevCenterResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return devcenters.ValidateDevCenterID +} + +func (r DevCenterResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.DevCenter.DevCenterClient + id, err := devcenters.ParseDevCenterID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var state DevCenterModel + if err := metadata.Decode(&state); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + devCenterIdentity, err := identity.ExpandSystemAndUserAssignedMap(metadata.ResourceData.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + + if metadata.ResourceData.HasChangesExcept("name", "resource_group_name", "location") { + devCenter := devcenters.DevCenterUpdate{ + Identity: devCenterIdentity, + Tags: pointer.To(state.Tags), + } + + if err := client.UpdateThenPoll(ctx, *id, devCenter); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + } + return nil + }, + } +} diff --git a/internal/services/devcenter/dev_center_resource_test.go b/internal/services/devcenter/dev_center_resource_test.go new file mode 100644 index 000000000000..7fc26c510a5d --- /dev/null +++ b/internal/services/devcenter/dev_center_resource_test.go @@ -0,0 +1,122 @@ +package devcenter_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters" + "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" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type DevCenterResource struct{} + +func TestAccDevCenter_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dev_center", "test") + r := DevCenterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccDevCenter_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_dev_center", "test") + r := DevCenterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r DevCenterResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := devcenters.ParseDevCenterID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.DevCenter.DevCenterClient.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + return utils.Bool(true), nil +} + +func (r DevCenterResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%[1]s + +resource "azurerm_dev_center" "test" { + name = "testdevcenter-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + identity { + type = "SystemAssigned" + } +} +`, template, data.RandomIntOfLength(8)) +} + +func (r DevCenterResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%[1]s + +resource "azurerm_user_assigned_identity" "test" { + name = "testuserassignedidentity-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_dev_center" "test" { + name = "testdevcenter-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } +} +`, template, data.RandomIntOfLength(8)) +} + +func (r DevCenterResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRg-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/devcenter/registration.go b/internal/services/devcenter/registration.go new file mode 100644 index 000000000000..1883c8f87de1 --- /dev/null +++ b/internal/services/devcenter/registration.go @@ -0,0 +1,31 @@ +package devcenter + +import "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + +type Registration struct{} + +func (r Registration) AssociatedGitHubLabel() string { + return "service/dev-center" +} + +func (r Registration) WebsiteCategories() []string { + return []string{ + "Dev Center", + } +} + +func (r Registration) Name() string { + return "Dev Center" +} + +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + DevCenterResource{}, + } +} + +var _ sdk.TypedServiceRegistration = Registration{} diff --git a/internal/services/paloalto/local_rulestack_data_source_test.go b/internal/services/paloalto/local_rulestack_data_source_test.go index aa7cb48cd9fd..a56016e691c9 100644 --- a/internal/services/paloalto/local_rulestack_data_source_test.go +++ b/internal/services/paloalto/local_rulestack_data_source_test.go @@ -29,7 +29,7 @@ func (d LocalRulestackDataSource) basic(data acceptance.TestData) string { return fmt.Sprintf(` %s -data "azurerm_palo_alto_local_rulestack" "test"{ +data "azurerm_palo_alto_local_rulestack" "test" { name = azurerm_palo_alto_local_rulestack.test.name resource_group_name = azurerm_palo_alto_local_rulestack.test.resource_group_name } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/README.md new file mode 100644 index 000000000000..3675658dbbb6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections` Documentation + +The `attachednetworkconnections` SDK allows for interaction with the Azure Resource Manager Service `devcenter` (API Version `2023-04-01`). + +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/devcenter/2023-04-01/attachednetworkconnections" +``` + + +### Client Initialization + +```go +client := attachednetworkconnections.NewAttachedNetworkConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AttachedNetworkConnectionsClient.AttachedNetworksListByDevCenter` + +```go +ctx := context.TODO() +id := attachednetworkconnections.NewDevCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "devCenterValue") + +// alternatively `client.AttachedNetworksListByDevCenter(ctx, id, attachednetworkconnections.DefaultAttachedNetworksListByDevCenterOperationOptions())` can be used to do batched pagination +items, err := client.AttachedNetworksListByDevCenterComplete(ctx, id, attachednetworkconnections.DefaultAttachedNetworksListByDevCenterOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AttachedNetworkConnectionsClient.AttachedNetworksListByProject` + +```go +ctx := context.TODO() +id := attachednetworkconnections.NewProjectID("12345678-1234-9876-4563-123456789012", "example-resource-group", "projectValue") + +// alternatively `client.AttachedNetworksListByProject(ctx, id, attachednetworkconnections.DefaultAttachedNetworksListByProjectOperationOptions())` can be used to do batched pagination +items, err := client.AttachedNetworksListByProjectComplete(ctx, id, attachednetworkconnections.DefaultAttachedNetworksListByProjectOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/client.go new file mode 100644 index 000000000000..c047bb519e24 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/client.go @@ -0,0 +1,26 @@ +package attachednetworkconnections + +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 AttachedNetworkConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewAttachedNetworkConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*AttachedNetworkConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "attachednetworkconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AttachedNetworkConnectionsClient: %+v", err) + } + + return &AttachedNetworkConnectionsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/constants.go new file mode 100644 index 000000000000..187bed9c3dda --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/constants.go @@ -0,0 +1,187 @@ +package attachednetworkconnections + +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 DomainJoinType string + +const ( + DomainJoinTypeAzureADJoin DomainJoinType = "AzureADJoin" + DomainJoinTypeHybridAzureADJoin DomainJoinType = "HybridAzureADJoin" +) + +func PossibleValuesForDomainJoinType() []string { + return []string{ + string(DomainJoinTypeAzureADJoin), + string(DomainJoinTypeHybridAzureADJoin), + } +} + +func (s *DomainJoinType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainJoinType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainJoinType(input string) (*DomainJoinType, error) { + vals := map[string]DomainJoinType{ + "azureadjoin": DomainJoinTypeAzureADJoin, + "hybridazureadjoin": DomainJoinTypeHybridAzureADJoin, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainJoinType(input) + return &out, nil +} + +type HealthCheckStatus string + +const ( + HealthCheckStatusFailed HealthCheckStatus = "Failed" + HealthCheckStatusPassed HealthCheckStatus = "Passed" + HealthCheckStatusPending HealthCheckStatus = "Pending" + HealthCheckStatusRunning HealthCheckStatus = "Running" + HealthCheckStatusUnknown HealthCheckStatus = "Unknown" + HealthCheckStatusWarning HealthCheckStatus = "Warning" +) + +func PossibleValuesForHealthCheckStatus() []string { + return []string{ + string(HealthCheckStatusFailed), + string(HealthCheckStatusPassed), + string(HealthCheckStatusPending), + string(HealthCheckStatusRunning), + string(HealthCheckStatusUnknown), + string(HealthCheckStatusWarning), + } +} + +func (s *HealthCheckStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthCheckStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthCheckStatus(input string) (*HealthCheckStatus, error) { + vals := map[string]HealthCheckStatus{ + "failed": HealthCheckStatusFailed, + "passed": HealthCheckStatusPassed, + "pending": HealthCheckStatusPending, + "running": HealthCheckStatusRunning, + "unknown": HealthCheckStatusUnknown, + "warning": HealthCheckStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthCheckStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMovingResources ProvisioningState = "MovingResources" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateRolloutInProgress ProvisioningState = "RolloutInProgress" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateStorageProvisioningFailed ProvisioningState = "StorageProvisioningFailed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateTransientFailure ProvisioningState = "TransientFailure" + ProvisioningStateUpdated ProvisioningState = "Updated" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreated), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMovingResources), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateRolloutInProgress), + string(ProvisioningStateRunning), + string(ProvisioningStateStorageProvisioningFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateTransientFailure), + string(ProvisioningStateUpdated), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "created": ProvisioningStateCreated, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "movingresources": ProvisioningStateMovingResources, + "notspecified": ProvisioningStateNotSpecified, + "rolloutinprogress": ProvisioningStateRolloutInProgress, + "running": ProvisioningStateRunning, + "storageprovisioningfailed": ProvisioningStateStorageProvisioningFailed, + "succeeded": ProvisioningStateSucceeded, + "transientfailure": ProvisioningStateTransientFailure, + "updated": ProvisioningStateUpdated, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/id_devcenter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/id_devcenter.go new file mode 100644 index 000000000000..d10f31983598 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/id_devcenter.go @@ -0,0 +1,127 @@ +package attachednetworkconnections + +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 = DevCenterId{} + +// DevCenterId is a struct representing the Resource ID for a Dev Center +type DevCenterId struct { + SubscriptionId string + ResourceGroupName string + DevCenterName string +} + +// NewDevCenterID returns a new DevCenterId struct +func NewDevCenterID(subscriptionId string, resourceGroupName string, devCenterName string) DevCenterId { + return DevCenterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DevCenterName: devCenterName, + } +} + +// ParseDevCenterID parses 'input' into a DevCenterId +func ParseDevCenterID(input string) (*DevCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(DevCenterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DevCenterId{} + + 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.DevCenterName, ok = parsed.Parsed["devCenterName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "devCenterName", *parsed) + } + + return &id, nil +} + +// ParseDevCenterIDInsensitively parses 'input' case-insensitively into a DevCenterId +// note: this method should only be used for API response data and not user input +func ParseDevCenterIDInsensitively(input string) (*DevCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(DevCenterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DevCenterId{} + + 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.DevCenterName, ok = parsed.Parsed["devCenterName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "devCenterName", *parsed) + } + + return &id, nil +} + +// ValidateDevCenterID checks that 'input' can be parsed as a Dev Center ID +func ValidateDevCenterID(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 := ParseDevCenterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dev Center ID +func (id DevCenterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevCenter/devCenters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DevCenterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dev Center ID +func (id DevCenterId) 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("staticMicrosoftDevCenter", "Microsoft.DevCenter", "Microsoft.DevCenter"), + resourceids.StaticSegment("staticDevCenters", "devCenters", "devCenters"), + resourceids.UserSpecifiedSegment("devCenterName", "devCenterValue"), + } +} + +// String returns a human-readable description of this Dev Center ID +func (id DevCenterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Dev Center Name: %q", id.DevCenterName), + } + return fmt.Sprintf("Dev Center (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/id_project.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/id_project.go new file mode 100644 index 000000000000..6077761c94db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/id_project.go @@ -0,0 +1,127 @@ +package attachednetworkconnections + +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 = ProjectId{} + +// ProjectId is a struct representing the Resource ID for a Project +type ProjectId struct { + SubscriptionId string + ResourceGroupName string + ProjectName string +} + +// NewProjectID returns a new ProjectId struct +func NewProjectID(subscriptionId string, resourceGroupName string, projectName string) ProjectId { + return ProjectId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ProjectName: projectName, + } +} + +// ParseProjectID parses 'input' into a ProjectId +func ParseProjectID(input string) (*ProjectId, error) { + parser := resourceids.NewParserFromResourceIdType(ProjectId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProjectId{} + + 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.ProjectName, ok = parsed.Parsed["projectName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "projectName", *parsed) + } + + return &id, nil +} + +// ParseProjectIDInsensitively parses 'input' case-insensitively into a ProjectId +// note: this method should only be used for API response data and not user input +func ParseProjectIDInsensitively(input string) (*ProjectId, error) { + parser := resourceids.NewParserFromResourceIdType(ProjectId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ProjectId{} + + 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.ProjectName, ok = parsed.Parsed["projectName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "projectName", *parsed) + } + + return &id, nil +} + +// ValidateProjectID checks that 'input' can be parsed as a Project ID +func ValidateProjectID(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 := ParseProjectID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Project ID +func (id ProjectId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevCenter/projects/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ProjectName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Project ID +func (id ProjectId) 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("staticMicrosoftDevCenter", "Microsoft.DevCenter", "Microsoft.DevCenter"), + resourceids.StaticSegment("staticProjects", "projects", "projects"), + resourceids.UserSpecifiedSegment("projectName", "projectValue"), + } +} + +// String returns a human-readable description of this Project ID +func (id ProjectId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Project Name: %q", id.ProjectName), + } + return fmt.Sprintf("Project (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/method_attachednetworkslistbydevcenter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/method_attachednetworkslistbydevcenter.go new file mode 100644 index 000000000000..fcc9c676b943 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/method_attachednetworkslistbydevcenter.go @@ -0,0 +1,117 @@ +package attachednetworkconnections + +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 AttachedNetworksListByDevCenterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AttachedNetworkConnection +} + +type AttachedNetworksListByDevCenterCompleteResult struct { + Items []AttachedNetworkConnection +} + +type AttachedNetworksListByDevCenterOperationOptions struct { + Top *int64 +} + +func DefaultAttachedNetworksListByDevCenterOperationOptions() AttachedNetworksListByDevCenterOperationOptions { + return AttachedNetworksListByDevCenterOperationOptions{} +} + +func (o AttachedNetworksListByDevCenterOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AttachedNetworksListByDevCenterOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AttachedNetworksListByDevCenterOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// AttachedNetworksListByDevCenter ... +func (c AttachedNetworkConnectionsClient) AttachedNetworksListByDevCenter(ctx context.Context, id DevCenterId, options AttachedNetworksListByDevCenterOperationOptions) (result AttachedNetworksListByDevCenterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/attachednetworks", id.ID()), + OptionsObject: options, + } + + 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 *[]AttachedNetworkConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AttachedNetworksListByDevCenterComplete retrieves all the results into a single object +func (c AttachedNetworkConnectionsClient) AttachedNetworksListByDevCenterComplete(ctx context.Context, id DevCenterId, options AttachedNetworksListByDevCenterOperationOptions) (AttachedNetworksListByDevCenterCompleteResult, error) { + return c.AttachedNetworksListByDevCenterCompleteMatchingPredicate(ctx, id, options, AttachedNetworkConnectionOperationPredicate{}) +} + +// AttachedNetworksListByDevCenterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AttachedNetworkConnectionsClient) AttachedNetworksListByDevCenterCompleteMatchingPredicate(ctx context.Context, id DevCenterId, options AttachedNetworksListByDevCenterOperationOptions, predicate AttachedNetworkConnectionOperationPredicate) (result AttachedNetworksListByDevCenterCompleteResult, err error) { + items := make([]AttachedNetworkConnection, 0) + + resp, err := c.AttachedNetworksListByDevCenter(ctx, id, options) + 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 = AttachedNetworksListByDevCenterCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/method_attachednetworkslistbyproject.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/method_attachednetworkslistbyproject.go new file mode 100644 index 000000000000..d6754e5a12b7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/method_attachednetworkslistbyproject.go @@ -0,0 +1,117 @@ +package attachednetworkconnections + +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 AttachedNetworksListByProjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AttachedNetworkConnection +} + +type AttachedNetworksListByProjectCompleteResult struct { + Items []AttachedNetworkConnection +} + +type AttachedNetworksListByProjectOperationOptions struct { + Top *int64 +} + +func DefaultAttachedNetworksListByProjectOperationOptions() AttachedNetworksListByProjectOperationOptions { + return AttachedNetworksListByProjectOperationOptions{} +} + +func (o AttachedNetworksListByProjectOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AttachedNetworksListByProjectOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AttachedNetworksListByProjectOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// AttachedNetworksListByProject ... +func (c AttachedNetworkConnectionsClient) AttachedNetworksListByProject(ctx context.Context, id ProjectId, options AttachedNetworksListByProjectOperationOptions) (result AttachedNetworksListByProjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/attachednetworks", id.ID()), + OptionsObject: options, + } + + 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 *[]AttachedNetworkConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AttachedNetworksListByProjectComplete retrieves all the results into a single object +func (c AttachedNetworkConnectionsClient) AttachedNetworksListByProjectComplete(ctx context.Context, id ProjectId, options AttachedNetworksListByProjectOperationOptions) (AttachedNetworksListByProjectCompleteResult, error) { + return c.AttachedNetworksListByProjectCompleteMatchingPredicate(ctx, id, options, AttachedNetworkConnectionOperationPredicate{}) +} + +// AttachedNetworksListByProjectCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AttachedNetworkConnectionsClient) AttachedNetworksListByProjectCompleteMatchingPredicate(ctx context.Context, id ProjectId, options AttachedNetworksListByProjectOperationOptions, predicate AttachedNetworkConnectionOperationPredicate) (result AttachedNetworksListByProjectCompleteResult, err error) { + items := make([]AttachedNetworkConnection, 0) + + resp, err := c.AttachedNetworksListByProject(ctx, id, options) + 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 = AttachedNetworksListByProjectCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/model_attachednetworkconnection.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/model_attachednetworkconnection.go new file mode 100644 index 000000000000..ba8b52ae22d3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/model_attachednetworkconnection.go @@ -0,0 +1,16 @@ +package attachednetworkconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedNetworkConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AttachedNetworkConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/model_attachednetworkconnectionproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/model_attachednetworkconnectionproperties.go new file mode 100644 index 000000000000..c8557609bfff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/model_attachednetworkconnectionproperties.go @@ -0,0 +1,12 @@ +package attachednetworkconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedNetworkConnectionProperties struct { + DomainJoinType *DomainJoinType `json:"domainJoinType,omitempty"` + HealthCheckStatus *HealthCheckStatus `json:"healthCheckStatus,omitempty"` + NetworkConnectionId string `json:"networkConnectionId"` + NetworkConnectionLocation *string `json:"networkConnectionLocation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/predicates.go new file mode 100644 index 000000000000..591ae8641715 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/predicates.go @@ -0,0 +1,27 @@ +package attachednetworkconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AttachedNetworkConnectionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AttachedNetworkConnectionOperationPredicate) Matches(input AttachedNetworkConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/version.go new file mode 100644 index 000000000000..14f4bd4f6341 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections/version.go @@ -0,0 +1,12 @@ +package attachednetworkconnections + +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 = "2023-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/attachednetworkconnections/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/README.md new file mode 100644 index 000000000000..9159a33391ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters` Documentation + +The `devcenters` SDK allows for interaction with the Azure Resource Manager Service `devcenter` (API Version `2023-04-01`). + +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/devcenter/2023-04-01/devcenters" +``` + + +### Client Initialization + +```go +client := devcenters.NewDevCentersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DevCentersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := devcenters.NewDevCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "devCenterValue") + +payload := devcenters.DevCenter{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DevCentersClient.Delete` + +```go +ctx := context.TODO() +id := devcenters.NewDevCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "devCenterValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DevCentersClient.Get` + +```go +ctx := context.TODO() +id := devcenters.NewDevCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "devCenterValue") + +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: `DevCentersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := devcenters.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, devcenters.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, devcenters.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DevCentersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := devcenters.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, devcenters.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, devcenters.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DevCentersClient.Update` + +```go +ctx := context.TODO() +id := devcenters.NewDevCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "devCenterValue") + +payload := devcenters.DevCenterUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/client.go new file mode 100644 index 000000000000..166e4043995c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/client.go @@ -0,0 +1,26 @@ +package devcenters + +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 DevCentersClient struct { + Client *resourcemanager.Client +} + +func NewDevCentersClientWithBaseURI(sdkApi sdkEnv.Api) (*DevCentersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "devcenters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DevCentersClient: %+v", err) + } + + return &DevCentersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/constants.go new file mode 100644 index 000000000000..6ea812ee151d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/constants.go @@ -0,0 +1,93 @@ +package devcenters + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMovingResources ProvisioningState = "MovingResources" + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + ProvisioningStateRolloutInProgress ProvisioningState = "RolloutInProgress" + ProvisioningStateRunning ProvisioningState = "Running" + ProvisioningStateStorageProvisioningFailed ProvisioningState = "StorageProvisioningFailed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateTransientFailure ProvisioningState = "TransientFailure" + ProvisioningStateUpdated ProvisioningState = "Updated" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreated), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateMovingResources), + string(ProvisioningStateNotSpecified), + string(ProvisioningStateRolloutInProgress), + string(ProvisioningStateRunning), + string(ProvisioningStateStorageProvisioningFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateTransientFailure), + string(ProvisioningStateUpdated), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "created": ProvisioningStateCreated, + "creating": ProvisioningStateCreating, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "movingresources": ProvisioningStateMovingResources, + "notspecified": ProvisioningStateNotSpecified, + "rolloutinprogress": ProvisioningStateRolloutInProgress, + "running": ProvisioningStateRunning, + "storageprovisioningfailed": ProvisioningStateStorageProvisioningFailed, + "succeeded": ProvisioningStateSucceeded, + "transientfailure": ProvisioningStateTransientFailure, + "updated": ProvisioningStateUpdated, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/id_devcenter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/id_devcenter.go new file mode 100644 index 000000000000..1eb7247b57e2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/id_devcenter.go @@ -0,0 +1,127 @@ +package devcenters + +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 = DevCenterId{} + +// DevCenterId is a struct representing the Resource ID for a Dev Center +type DevCenterId struct { + SubscriptionId string + ResourceGroupName string + DevCenterName string +} + +// NewDevCenterID returns a new DevCenterId struct +func NewDevCenterID(subscriptionId string, resourceGroupName string, devCenterName string) DevCenterId { + return DevCenterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DevCenterName: devCenterName, + } +} + +// ParseDevCenterID parses 'input' into a DevCenterId +func ParseDevCenterID(input string) (*DevCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(DevCenterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DevCenterId{} + + 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.DevCenterName, ok = parsed.Parsed["devCenterName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "devCenterName", *parsed) + } + + return &id, nil +} + +// ParseDevCenterIDInsensitively parses 'input' case-insensitively into a DevCenterId +// note: this method should only be used for API response data and not user input +func ParseDevCenterIDInsensitively(input string) (*DevCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(DevCenterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DevCenterId{} + + 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.DevCenterName, ok = parsed.Parsed["devCenterName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "devCenterName", *parsed) + } + + return &id, nil +} + +// ValidateDevCenterID checks that 'input' can be parsed as a Dev Center ID +func ValidateDevCenterID(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 := ParseDevCenterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dev Center ID +func (id DevCenterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevCenter/devCenters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DevCenterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dev Center ID +func (id DevCenterId) 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("staticMicrosoftDevCenter", "Microsoft.DevCenter", "Microsoft.DevCenter"), + resourceids.StaticSegment("staticDevCenters", "devCenters", "devCenters"), + resourceids.UserSpecifiedSegment("devCenterName", "devCenterValue"), + } +} + +// String returns a human-readable description of this Dev Center ID +func (id DevCenterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Dev Center Name: %q", id.DevCenterName), + } + return fmt.Sprintf("Dev Center (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_createorupdate.go new file mode 100644 index 000000000000..b77d4fccf476 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_createorupdate.go @@ -0,0 +1,74 @@ +package devcenters + +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 DevCentersClient) CreateOrUpdate(ctx context.Context, id DevCenterId, input DevCenter) (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 DevCentersClient) CreateOrUpdateThenPoll(ctx context.Context, id DevCenterId, input DevCenter) 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/devcenter/2023-04-01/devcenters/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_delete.go new file mode 100644 index 000000000000..c4d8c92ccded --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_delete.go @@ -0,0 +1,71 @@ +package devcenters + +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 DevCentersClient) Delete(ctx context.Context, id DevCenterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 DevCentersClient) DeleteThenPoll(ctx context.Context, id DevCenterId) 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/devcenter/2023-04-01/devcenters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_get.go new file mode 100644 index 000000000000..6ef097bb2b91 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_get.go @@ -0,0 +1,51 @@ +package devcenters + +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 *DevCenter +} + +// Get ... +func (c DevCentersClient) Get(ctx context.Context, id DevCenterId) (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/devcenter/2023-04-01/devcenters/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_listbyresourcegroup.go new file mode 100644 index 000000000000..6bad130ee3c9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_listbyresourcegroup.go @@ -0,0 +1,118 @@ +package devcenters + +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 *[]DevCenter +} + +type ListByResourceGroupCompleteResult struct { + Items []DevCenter +} + +type ListByResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByResourceGroup ... +func (c DevCentersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (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.DevCenter/devCenters", id.ID()), + OptionsObject: options, + } + + 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 *[]DevCenter `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 DevCentersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, DevCenterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DevCentersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate DevCenterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DevCenter, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + 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/devcenter/2023-04-01/devcenters/method_listbysubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_listbysubscription.go new file mode 100644 index 000000000000..80045ba514f3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_listbysubscription.go @@ -0,0 +1,118 @@ +package devcenters + +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 *[]DevCenter +} + +type ListBySubscriptionCompleteResult struct { + Items []DevCenter +} + +type ListBySubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListBySubscription ... +func (c DevCentersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (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.DevCenter/devCenters", id.ID()), + OptionsObject: options, + } + + 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 *[]DevCenter `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 DevCentersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, DevCenterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DevCentersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate DevCenterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DevCenter, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + 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/devcenter/2023-04-01/devcenters/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_update.go new file mode 100644 index 000000000000..163aa35e16d5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/method_update.go @@ -0,0 +1,74 @@ +package devcenters + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c DevCentersClient) Update(ctx context.Context, id DevCenterId, input DevCenterUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c DevCentersClient) UpdateThenPoll(ctx context.Context, id DevCenterId, input DevCenterUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenter.go new file mode 100644 index 000000000000..a6ca99f8955b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenter.go @@ -0,0 +1,20 @@ +package devcenters + +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 DevCenter struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DevCenterProperties `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/devcenter/2023-04-01/devcenters/model_devcenterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenterproperties.go new file mode 100644 index 000000000000..03fd772de97e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenterproperties.go @@ -0,0 +1,9 @@ +package devcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DevCenterProperties struct { + DevCenterUri *string `json:"devCenterUri,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenterupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenterupdate.go new file mode 100644 index 000000000000..45bba691c993 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/model_devcenterupdate.go @@ -0,0 +1,14 @@ +package devcenters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DevCenterUpdate struct { + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/predicates.go new file mode 100644 index 000000000000..ff0eefcdfd6c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/predicates.go @@ -0,0 +1,32 @@ +package devcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DevCenterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DevCenterOperationPredicate) Matches(input DevCenter) 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/devcenter/2023-04-01/devcenters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/version.go new file mode 100644 index 000000000000..e84d0c95c4b3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters/version.go @@ -0,0 +1,12 @@ +package devcenters + +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 = "2023-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/devcenters/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index e6c279be364a..082129d539f2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -411,6 +411,8 @@ github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02 github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/scalingplan github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/sessionhost github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/workspace +github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/attachednetworkconnections +github.com/hashicorp/go-azure-sdk/resource-manager/devcenter/2023-04-01/devcenters github.com/hashicorp/go-azure-sdk/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate github.com/hashicorp/go-azure-sdk/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2022-10-01/deviceupdates diff --git a/website/allowed-subcategories b/website/allowed-subcategories index b1dfd82be850..89cd7a82e828 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -43,6 +43,7 @@ Databox Edge Databricks Datadog Desktop Virtualization +Dev Center Dev Test Digital Twins Disks diff --git a/website/docs/r/dev_center.html.markdown b/website/docs/r/dev_center.html.markdown new file mode 100644 index 000000000000..f470a02598a2 --- /dev/null +++ b/website/docs/r/dev_center.html.markdown @@ -0,0 +1,80 @@ +--- +subcategory: "Dev Center" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_dev_center" +description: |- + Manages a Dev Center resource. +--- + +# azurerm_dev_center + +Manages a Dev Center. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "rg-example" + location = "West Europe" +} + +resource "azurerm_dev_center" "example" { + name = "example-devcenter" + resource_group_name = azurerm_resource_group.example.name + location = "westeurope" + identity { + type = "SystemAssigned" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Dev Center. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group where the Dev Center exists. Changing this forces a new resource to be created. + +* `location` - (Required) The location where the Dev Center exists. Changing this forces a new resource to be created. + +* `identity` - (Optional) A `identity` block as defined below. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +--- + +A `identity` block supports the following: + +* `type` - (Required) The type of identity used for the Dev Center. Possible values are `SystemAssigned` `UserAssigned` and `SystemAssigned, UserAssigned`. + +* `identity_ids` - (Optional) A list of User Assigned Identity IDs to be associated with the Dev Center. + +* `principal_id` - (Optional) The Principal ID of the Dev Center. + +* `tenant_id` - (Optional) The Tenant ID of the Dev Center. + +--- + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Dev Center. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Dev Center. +* `read` - (Defaults to 5 minutes) Used when retrieving the Dev Center. +* `update` - (Defaults to 30 minutes) Used when updating the Dev Center. +* `delete` - (Defaults to 30 minutes) Used when deleting the Dev Center. + +## Import + +Dev Center can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_dev_center.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DevCenter/devCenters/devCenter1 +```