From 0ad671c0ead067cfb116f961194e84378c50f036 Mon Sep 17 00:00:00 2001 From: Zhenhua Hu Date: Fri, 14 Oct 2022 09:03:29 +0800 Subject: [PATCH 1/4] add code --- internal/clients/client.go | 3 + internal/provider/services.go | 2 + .../services/networkfunction/client/client.go | 19 + ...nction_azure_traffic_collector_resource.go | 400 ++++++++++++++++++ ...n_azure_traffic_collector_resource_test.go | 175 ++++++++ .../services/networkfunction/registration.go | 51 +++ ...tion_azure_traffic_collector.html.markdown | 99 +++++ 7 files changed, 749 insertions(+) create mode 100644 internal/services/networkfunction/client/client.go create mode 100644 internal/services/networkfunction/network_function_azure_traffic_collector_resource.go create mode 100644 internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go create mode 100644 internal/services/networkfunction/registration.go create mode 100644 website/docs/r/network_function_azure_traffic_collector.html.markdown diff --git a/internal/clients/client.go b/internal/clients/client.go index 136ea8cf58e0..dd9d7149fa0d 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -83,6 +83,7 @@ import ( mysql "github.com/hashicorp/terraform-provider-azurerm/internal/services/mysql/client" netapp "github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/client" network "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/client" + networkfunction "github.com/hashicorp/terraform-provider-azurerm/internal/services/networkfunction/client" nginx "github.com/hashicorp/terraform-provider-azurerm/internal/services/nginx/client" notificationhub "github.com/hashicorp/terraform-provider-azurerm/internal/services/notificationhub/client" orbital "github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital/client" @@ -200,6 +201,7 @@ type Client struct { MySQL *mysql.Client NetApp *netapp.Client Network *network.Client + NetworkFunction *networkfunction.Client Nginx *nginx2.Client NotificationHubs *notificationhub.Client Orbital *orbital.Client @@ -321,6 +323,7 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.MySQL = mysql.NewClient(o) client.NetApp = netapp.NewClient(o) client.Network = network.NewClient(o) + client.NetworkFunction = networkfunction.NewClient(o) client.Nginx = nginx.NewClient(o) client.NotificationHubs = notificationhub.NewClient(o) client.Orbital = orbital.NewClient(o) diff --git a/internal/provider/services.go b/internal/provider/services.go index 98fdd366c444..a9e4c5b6c539 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -77,6 +77,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/mysql" "github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/networkfunction" "github.com/hashicorp/terraform-provider-azurerm/internal/services/nginx" "github.com/hashicorp/terraform-provider-azurerm/internal/services/notificationhub" "github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital" @@ -139,6 +140,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { loganalytics.Registration{}, monitor.Registration{}, mssql.Registration{}, + networkfunction.Registration{}, nginx.Registration{}, policy.Registration{}, recoveryservices.Registration{}, diff --git a/internal/services/networkfunction/client/client.go b/internal/services/networkfunction/client/client.go new file mode 100644 index 000000000000..672f0e261509 --- /dev/null +++ b/internal/services/networkfunction/client/client.go @@ -0,0 +1,19 @@ +package client + +import ( + "github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors" + "github.com/hashicorp/terraform-provider-azurerm/internal/common" +) + +type Client struct { + AzureTrafficCollectorsClient *azuretrafficcollectors.AzureTrafficCollectorsClient +} + +func NewClient(o *common.ClientOptions) *Client { + azureTrafficCollectorsClient := azuretrafficcollectors.NewAzureTrafficCollectorsClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&azureTrafficCollectorsClient.Client, o.ResourceManagerAuthorizer) + + return &Client{ + AzureTrafficCollectorsClient: &azureTrafficCollectorsClient, + } +} diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go new file mode 100644 index 000000000000..295fb90521db --- /dev/null +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go @@ -0,0 +1,400 @@ +package networkfunction + +import ( + "context" + "encoding/json" + "fmt" + "regexp" + "time" + + "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" + tagsHelper "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type NetworkFunctionAzureTrafficCollectorModel struct { + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` + VirtualHub []ResourceReferenceModel `tfschema:"virtual_hub"` + CollectorPolicies []ResourceReferenceModel `tfschema:"collector_policies"` + SystemData []SystemDataModel `tfschema:"system_data"` +} + +type ResourceReferenceModel struct { + Id string `tfschema:"id"` +} + +type SystemDataModel struct { + CreatedAt string `tfschema:"created_at"` + CreatedBy string `tfschema:"created_by"` + CreatedByType azuretrafficcollectors.CreatedByType `tfschema:"created_by_type"` + LastModifiedBy string `tfschema:"last_modified_by"` + LastModifiedByType azuretrafficcollectors.CreatedByType `tfschema:"last_modified_by_type"` +} + +type NetworkFunctionAzureTrafficCollectorResource struct{} + +var _ sdk.ResourceWithUpdate = NetworkFunctionAzureTrafficCollectorResource{} + +func (r NetworkFunctionAzureTrafficCollectorResource) ResourceType() string { + return "azurerm_network_function_azure_traffic_collector" +} + +func (r NetworkFunctionAzureTrafficCollectorResource) ModelObject() interface{} { + return &NetworkFunctionAzureTrafficCollectorModel{} +} + +func (r NetworkFunctionAzureTrafficCollectorResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return azuretrafficcollectors.ValidateAzureTrafficCollectorID +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.LocationWithoutForceNew(), + + "tags": commonschema.Tags(), + + "virtual_hub": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "id": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + } +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "collector_policies": { + Type: pluginsdk.TypeList, + Computed: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "system_data": { + Type: pluginsdk.TypeList, + Computed: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "created_at": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "created_by": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "created_by_type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "last_modified_by": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "last_modified_by_type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + } +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model NetworkFunctionAzureTrafficCollectorModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.NetworkFunction.AzureTrafficCollectorsClient + subscriptionId := metadata.Client.Account.SubscriptionId + id := azuretrafficcollectors.NewAzureTrafficCollectorID(subscriptionId, model.ResourceGroupName, model.Name) + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %+v", id, err) + } + + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + properties := &azuretrafficcollectors.AzureTrafficCollector{ + Location: location.Normalize(model.Location), + Properties: &azuretrafficcollectors.AzureTrafficCollectorPropertiesFormat{}, + Tags: &model.Tags, + } + + virtualHubValue, err := expandResourceReferenceModel(model.VirtualHub) + if err != nil { + return err + } + + properties.Properties.VirtualHub = virtualHubValue + + if err := client.CreateOrUpdateThenPoll(ctx, id, *properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.NetworkFunction.AzureTrafficCollectorsClient + + id, err := azuretrafficcollectors.ParseAzureTrafficCollectorID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model NetworkFunctionAzureTrafficCollectorModel + 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) + } + + properties := resp.Model + if properties == nil { + return fmt.Errorf("retrieving %s: properties was nil", id) + } + + if metadata.ResourceData.HasChange("location") { + properties.Location = location.Normalize(model.Location) + } + + if metadata.ResourceData.HasChange("virtual_hub") { + virtualHubValue, err := expandResourceReferenceModel(model.VirtualHub) + if err != nil { + return err + } + + properties.Properties.VirtualHub = virtualHubValue + } + + if metadata.ResourceData.HasChange("tags") { + properties.Tags = &model.Tags + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *properties); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.NetworkFunction.AzureTrafficCollectorsClient + + id, err := azuretrafficcollectors.ParseAzureTrafficCollectorID(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("retrieving %s: %+v", *id, err) + } + + model := resp.Model + if model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) + } + + state := NetworkFunctionAzureTrafficCollectorModel{ + Name: id.AzureTrafficCollectorName, + ResourceGroupName: id.ResourceGroupName, + Location: location.Normalize(model.Location), + } + + if properties := model.Properties; properties != nil { + collectorPoliciesValue, err := flattenResourceReferenceModel(properties.CollectorPolicies) + if err != nil { + return err + } + + state.CollectorPolicies = collectorPoliciesValue + + virtualHubValue, err := flattenResourceReferenceModel(properties.VirtualHub) + if err != nil { + return err + } + + state.VirtualHub = virtualHubValue + } + systemDataValue, err := flattenSystemDataModel(model.SystemData) + if err != nil { + return err + } + + state.SystemData = systemDataValue + if model.Tags != nil { + state.Tags = *model.Tags + } + + return metadata.Encode(&state) + }, + } +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.NetworkFunction.AzureTrafficCollectorsClient + + id, err := azuretrafficcollectors.ParseAzureTrafficCollectorID(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 expandResourceReferenceModel(inputList []ResourceReferenceModel) (*azuretrafficcollectors.ResourceReference, error) { + if len(inputList) == 0 { + return nil, nil + } + + input := &inputList[0] + output := azuretrafficcollectors.ResourceReference{} + + return &output, nil +} + +func flattenResourceReferenceModel(inputList *[]azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { + var outputList []ResourceReferenceModel + if inputList == nil { + return outputList, nil + } + + for _, input := range *inputList { + output := ResourceReferenceModel{} + + if input.Id != nil { + output.Id = *input.Id + } + + outputList = append(outputList, output) + } + + return outputList, nil +} + +func flattenSystemDataModel(input *azuretrafficcollectors.SystemData) ([]SystemDataModel, error) { + var outputList []SystemDataModel + if input == nil { + return outputList, nil + } + + output := SystemDataModel{} + + if input.CreatedAt != nil { + output.CreatedAt = *input.CreatedAt + } + + if input.CreatedBy != nil { + output.CreatedBy = *input.CreatedBy + } + + if input.CreatedByType != nil { + output.CreatedByType = *input.CreatedByType + } + + if input.LastModifiedBy != nil { + output.LastModifiedBy = *input.LastModifiedBy + } + + if input.LastModifiedByType != nil { + output.LastModifiedByType = *input.LastModifiedByType + } + + return append(outputList, output), nil +} + +func flattenResourceReferenceModel(input *azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { + var outputList []ResourceReferenceModel + if input == nil { + return outputList, nil + } + + output := ResourceReferenceModel{} + + if input.Id != nil { + output.Id = *input.Id + } + + return append(outputList, output), nil +} diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go new file mode 100644 index 000000000000..48987bff6eb2 --- /dev/null +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go @@ -0,0 +1,175 @@ +package networkfunction_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "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 NetworkFunctionAzureTrafficCollectorResource struct{} + +func TestAccNetworkFunctionAzureTrafficCollector_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_network_function_azure_traffic_collector", "test") + r := NetworkFunctionAzureTrafficCollectorResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccNetworkFunctionAzureTrafficCollector_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_network_function_azure_traffic_collector", "test") + r := NetworkFunctionAzureTrafficCollectorResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccNetworkFunctionAzureTrafficCollector_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_network_function_azure_traffic_collector", "test") + r := NetworkFunctionAzureTrafficCollectorResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccNetworkFunctionAzureTrafficCollector_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_network_function_azure_traffic_collector", "test") + r := NetworkFunctionAzureTrafficCollectorResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func (r NetworkFunctionAzureTrafficCollectorResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := azuretrafficcollectors.ParseAzureTrafficCollectorID(state.ID) + if err != nil { + return nil, err + } + + client := clients.NetworkFunction.AzureTrafficCollectorsClient + resp, err := client.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(resp.Model != nil), nil +} + +func (r NetworkFunctionAzureTrafficCollectorResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} +`, data.RandomInteger, data.Locations.Primary) +} + +func (r NetworkFunctionAzureTrafficCollectorResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_network_function_azure_traffic_collector" "test" { + name = "acctest-nfatc-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r NetworkFunctionAzureTrafficCollectorResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` + %s + +resource "azurerm_network_function_azure_traffic_collector" "import" { + name = azurerm_network_function_azure_traffic_collector.test.name + resource_group_name = azurerm_resource_group.test.name + location = "%s" +} +`, config, data.Locations.Primary) +} + +func (r NetworkFunctionAzureTrafficCollectorResource) complete(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_network_function_azure_traffic_collector" "test" { + name = "acctest-nfatc-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + virtual_hub { + + } + tags = { + key = "value" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} + +func (r NetworkFunctionAzureTrafficCollectorResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` + %s + +resource "azurerm_network_function_azure_traffic_collector" "test" { + name = "acctest-nfatc-%d" + resource_group_name = azurerm_resource_group.test.name + location = "%s" + virtual_hub { + + } + tags = { + key = "value" + } +} +`, template, data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/networkfunction/registration.go b/internal/services/networkfunction/registration.go new file mode 100644 index 000000000000..f2578f418e21 --- /dev/null +++ b/internal/services/networkfunction/registration.go @@ -0,0 +1,51 @@ +package networkfunction + +import ( + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type Registration struct{} + +var ( + _ sdk.TypedServiceRegistrationWithAGitHubLabel = Registration{} + _ sdk.UntypedServiceRegistrationWithAGitHubLabel = Registration{} +) + +func (r Registration) AssociatedGitHubLabel() string { + return "service/network-function" +} + +// Name is the name of this Service +func (r Registration) Name() string { + return "Network Function" +} + +// WebsiteCategories returns a list of categories which can be used for the sidebar +func (r Registration) WebsiteCategories() []string { + return []string{ + "Network Function", + } +} + +// SupportedDataSources returns the supported Data Sources supported by this Service +func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { + return map[string]*pluginsdk.Resource{} +} + +// SupportedResources returns the supported Resources supported by this Service +func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { + return map[string]*pluginsdk.Resource{} +} + +// DataSources returns a list of Data Sources supported by this Service +func (r Registration) DataSources() []sdk.DataSource { + return []sdk.DataSource{} +} + +// Resources returns a list of Resources supported by this Service +func (r Registration) Resources() []sdk.Resource { + return []sdk.Resource{ + NetworkFunctionAzureTrafficCollectorResource{}, + } +} diff --git a/website/docs/r/network_function_azure_traffic_collector.html.markdown b/website/docs/r/network_function_azure_traffic_collector.html.markdown new file mode 100644 index 000000000000..05a80d6db6a1 --- /dev/null +++ b/website/docs/r/network_function_azure_traffic_collector.html.markdown @@ -0,0 +1,99 @@ +--- +subcategory: "Network Function" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_network_function_azure_traffic_collector" +description: |- + Manages a Network Function Azure Traffic Collectors. +--- + +# azurerm_network_function_azure_traffic_collector + +Manages a Network Function Azure Traffic Collectors. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_network_function_azure_traffic_collector" "example" { + name = "example-nfatc" + resource_group_name = azurerm_resource_group.example.name + location = "West Europe" + virtual_hub { + + } + tags = { + key = "value" + } +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Network Function Azure Traffic Collectors. Changing this forces a new Network Function Azure Traffic Collectors to be created. + +* `resource_group_name` - (Required) Specifies the name of the Resource Group where the Network Function Azure Traffic Collectors should exist. Changing this forces a new Network Function Azure Traffic Collectors to be created. + +* `location` - (Required) Specifies the Azure Region where the Network Function Azure Traffic Collectors should exist. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Network Function Azure Traffic Collectors. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Network Function Azure Traffic Collectors. + +* `collector_policies` - A `collector_policies` block as defined below. + +* `system_data` - A `system_data` block as defined below. + +* `virtual_hub` - A `virtual_hub` block as defined below. + +--- + +A `collector_policies` block exports the following: + +* `id` - Resource ID. + +--- + +A `system_data` block exports the following: + +* `created_at` - The timestamp of resource creation (UTC). + +* `created_by` - The identity that created the resource. + +* `created_by_type` - The type of identity that created the resource. + +* `last_modified_by` - The identity that last modified the resource. + +* `last_modified_by_type` - The type of identity that last modified the resource. + +--- + +A `virtual_hub` block exports the following: + +* `id` - Resource ID. + +## 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 Network Function Azure Traffic Collectors. +* `read` - (Defaults to 5 minutes) Used when retrieving the Network Function Azure Traffic Collectors. +* `update` - (Defaults to 30 minutes) Used when updating the Network Function Azure Traffic Collectors. +* `delete` - (Defaults to 30 minutes) Used when deleting the Network Function Azure Traffic Collectors. + +## Import + +Network Function Azure Traffic Collectors can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_network_function_azure_traffic_collector.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/azureTrafficCollector1 +``` From 6b024eb417e68994ec7da960e6a441e8c37a7c0f Mon Sep 17 00:00:00 2001 From: Zhenhua Hu Date: Fri, 14 Oct 2022 10:16:25 +0800 Subject: [PATCH 2/4] add code --- .github/labeler-pull-request-triage.yml | 3 + .teamcity/components/generated/services.kt | 1 + .teamcity/components/settings.kt | 3 + ...nction_azure_traffic_collector_resource.go | 143 ++------------ ...n_azure_traffic_collector_resource_test.go | 8 +- .../azuretrafficcollectors/README.md | 120 +++++++++++ .../azuretrafficcollectors/client.go | 18 ++ .../azuretrafficcollectors/constants.go | 74 +++++++ .../id_azuretrafficcollector.go | 124 ++++++++++++ .../method_byresourcegrouplist_autorest.go | 187 ++++++++++++++++++ .../method_bysubscriptionlist_autorest.go | 187 ++++++++++++++++++ .../method_createorupdate_autorest.go | 79 ++++++++ .../method_delete_autorest.go | 78 ++++++++ .../method_get_autorest.go | 68 +++++++ .../method_updatetags_autorest.go | 69 +++++++ .../model_azuretrafficcollector.go | 15 ++ ...l_azuretrafficcollectorpropertiesformat.go | 10 + .../model_resourcereference.go | 8 + .../model_systemdata.go | 30 +++ .../model_tagsobject.go | 8 + .../azuretrafficcollectors/predicates.go | 34 ++++ .../azuretrafficcollectors/version.go | 12 ++ vendor/modules.txt | 1 + website/allowed-subcategories | 1 + ...tion_azure_traffic_collector.html.markdown | 46 ++--- 25 files changed, 1158 insertions(+), 169 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollector.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollectorpropertiesformat.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_resourcereference.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_systemdata.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_tagsobject.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/version.go diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 689bf5610edd..31c893d58c78 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -207,6 +207,9 @@ service/mysql: service/netapp: - internal/services/netapp/**/* +service/network-function: + - internal/services/networkfunction/**/* + service/nginx: - internal/services/nginx/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index ab5a660ff22b..591eaeefa0dd 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -76,6 +76,7 @@ var services = mapOf( "mysql" to "MySQL", "netapp" to "NetApp", "network" to "Network", + "networkfunction" to "Network Function", "nginx" to "Nginx", "notificationhub" to "Notification Hub", "orbital" to "Orbital", diff --git a/.teamcity/components/settings.kt b/.teamcity/components/settings.kt index 88be5b1b33e0..288db554d6da 100644 --- a/.teamcity/components/settings.kt +++ b/.teamcity/components/settings.kt @@ -96,6 +96,9 @@ var serviceTestConfigurationOverrides = mapOf( // netapp has a max of 10 accounts per subscription so lets limit it to 3 to account for broken ones, run Monday, Wednesday, Friday "netapp" to testConfiguration(parallelism = 3, daysOfWeek = "2,4,6"), + // Network Function is only available in certain locations + "networkfunction" to testConfiguration(locationOverride = LocationConfiguration("westus2", "eastus2", "westeurope", false)), + "policy" to testConfiguration(useAltSubscription = true), // redisenterprise is costly - Monday, Wednesday, Friday diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go index 295fb90521db..4ddec0187137 100644 --- a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go @@ -2,26 +2,17 @@ package networkfunction import ( "context" - "encoding/json" "fmt" "regexp" "time" "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" - tagsHelper "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors" - "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" - azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" - "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type NetworkFunctionAzureTrafficCollectorModel struct { @@ -31,21 +22,12 @@ type NetworkFunctionAzureTrafficCollectorModel struct { Tags map[string]string `tfschema:"tags"` VirtualHub []ResourceReferenceModel `tfschema:"virtual_hub"` CollectorPolicies []ResourceReferenceModel `tfschema:"collector_policies"` - SystemData []SystemDataModel `tfschema:"system_data"` } type ResourceReferenceModel struct { Id string `tfschema:"id"` } -type SystemDataModel struct { - CreatedAt string `tfschema:"created_at"` - CreatedBy string `tfschema:"created_by"` - CreatedByType azuretrafficcollectors.CreatedByType `tfschema:"created_by_type"` - LastModifiedBy string `tfschema:"last_modified_by"` - LastModifiedByType azuretrafficcollectors.CreatedByType `tfschema:"last_modified_by_type"` -} - type NetworkFunctionAzureTrafficCollectorResource struct{} var _ sdk.ResourceWithUpdate = NetworkFunctionAzureTrafficCollectorResource{} @@ -65,32 +47,20 @@ func (r NetworkFunctionAzureTrafficCollectorResource) IDValidationFunc() plugins func (r NetworkFunctionAzureTrafficCollectorResource) Arguments() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile("^[a-zA-Z0-9]([-._a-zA-Z0-9]{0,78}[a-zA-Z0-9_])?$"), + "The name can contain only letters, numbers, periods (.), hyphens (-),and underscores (_), up to 80 characters, and it must begin with a letter or number and end with a letter, number or underscore.", + ), }, "resource_group_name": commonschema.ResourceGroupName(), - "location": commonschema.LocationWithoutForceNew(), + "location": commonschema.Location(), "tags": commonschema.Tags(), - - "virtual_hub": { - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "id": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - }, - }, - }, } } @@ -99,7 +69,6 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Attributes() map[string]*p "collector_policies": { Type: pluginsdk.TypeList, Computed: true, - MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "id": { @@ -110,33 +79,12 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Attributes() map[string]*p }, }, - "system_data": { + "virtual_hub": { Type: pluginsdk.TypeList, Computed: true, - MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "created_at": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "created_by": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "created_by_type": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "last_modified_by": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "last_modified_by_type": { + "id": { Type: pluginsdk.TypeString, Computed: true, }, @@ -173,13 +121,6 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Create() sdk.ResourceFunc Tags: &model.Tags, } - virtualHubValue, err := expandResourceReferenceModel(model.VirtualHub) - if err != nil { - return err - } - - properties.Properties.VirtualHub = virtualHubValue - if err := client.CreateOrUpdateThenPoll(ctx, id, *properties); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -216,18 +157,7 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Update() sdk.ResourceFunc return fmt.Errorf("retrieving %s: properties was nil", id) } - if metadata.ResourceData.HasChange("location") { - properties.Location = location.Normalize(model.Location) - } - - if metadata.ResourceData.HasChange("virtual_hub") { - virtualHubValue, err := expandResourceReferenceModel(model.VirtualHub) - if err != nil { - return err - } - - properties.Properties.VirtualHub = virtualHubValue - } + properties.SystemData = nil if metadata.ResourceData.HasChange("tags") { properties.Tags = &model.Tags @@ -274,7 +204,7 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Read() sdk.ResourceFunc { } if properties := model.Properties; properties != nil { - collectorPoliciesValue, err := flattenResourceReferenceModel(properties.CollectorPolicies) + collectorPoliciesValue, err := flattenResourceReferenceModelArray(properties.CollectorPolicies) if err != nil { return err } @@ -288,12 +218,7 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Read() sdk.ResourceFunc { state.VirtualHub = virtualHubValue } - systemDataValue, err := flattenSystemDataModel(model.SystemData) - if err != nil { - return err - } - state.SystemData = systemDataValue if model.Tags != nil { state.Tags = *model.Tags } @@ -323,18 +248,7 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Delete() sdk.ResourceFunc } } -func expandResourceReferenceModel(inputList []ResourceReferenceModel) (*azuretrafficcollectors.ResourceReference, error) { - if len(inputList) == 0 { - return nil, nil - } - - input := &inputList[0] - output := azuretrafficcollectors.ResourceReference{} - - return &output, nil -} - -func flattenResourceReferenceModel(inputList *[]azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { +func flattenResourceReferenceModelArray(inputList *[]azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { var outputList []ResourceReferenceModel if inputList == nil { return outputList, nil @@ -353,37 +267,6 @@ func flattenResourceReferenceModel(inputList *[]azuretrafficcollectors.ResourceR return outputList, nil } -func flattenSystemDataModel(input *azuretrafficcollectors.SystemData) ([]SystemDataModel, error) { - var outputList []SystemDataModel - if input == nil { - return outputList, nil - } - - output := SystemDataModel{} - - if input.CreatedAt != nil { - output.CreatedAt = *input.CreatedAt - } - - if input.CreatedBy != nil { - output.CreatedBy = *input.CreatedBy - } - - if input.CreatedByType != nil { - output.CreatedByType = *input.CreatedByType - } - - if input.LastModifiedBy != nil { - output.LastModifiedBy = *input.LastModifiedBy - } - - if input.LastModifiedByType != nil { - output.LastModifiedByType = *input.LastModifiedByType - } - - return append(outputList, output), nil -} - func flattenResourceReferenceModel(input *azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { var outputList []ResourceReferenceModel if input == nil { diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go index 48987bff6eb2..fed071012fdd 100644 --- a/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go @@ -145,9 +145,6 @@ resource "azurerm_network_function_azure_traffic_collector" "test" { name = "acctest-nfatc-%d" resource_group_name = azurerm_resource_group.test.name location = "%s" - virtual_hub { - - } tags = { key = "value" } @@ -164,11 +161,8 @@ resource "azurerm_network_function_azure_traffic_collector" "test" { name = "acctest-nfatc-%d" resource_group_name = azurerm_resource_group.test.name location = "%s" - virtual_hub { - - } tags = { - key = "value" + key = "value2" } } `, template, data.RandomInteger, data.Locations.Primary) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/README.md new file mode 100644 index 000000000000..001699a3db1e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/README.md @@ -0,0 +1,120 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors` Documentation + +The `azuretrafficcollectors` SDK allows for interaction with the Azure Resource Manager Service `networkfunction` (API Version `2022-11-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/networkfunction/2022-11-01/azuretrafficcollectors" +``` + + +### Client Initialization + +```go +client := azuretrafficcollectors.NewAzureTrafficCollectorsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AzureTrafficCollectorsClient.ByResourceGroupList` + +```go +ctx := context.TODO() +id := azuretrafficcollectors.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ByResourceGroupList(ctx, id)` can be used to do batched pagination +items, err := client.ByResourceGroupListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AzureTrafficCollectorsClient.BySubscriptionList` + +```go +ctx := context.TODO() +id := azuretrafficcollectors.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.BySubscriptionList(ctx, id)` can be used to do batched pagination +items, err := client.BySubscriptionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AzureTrafficCollectorsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := azuretrafficcollectors.NewAzureTrafficCollectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureTrafficCollectorValue") + +payload := azuretrafficcollectors.AzureTrafficCollector{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureTrafficCollectorsClient.Delete` + +```go +ctx := context.TODO() +id := azuretrafficcollectors.NewAzureTrafficCollectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureTrafficCollectorValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureTrafficCollectorsClient.Get` + +```go +ctx := context.TODO() +id := azuretrafficcollectors.NewAzureTrafficCollectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureTrafficCollectorValue") + +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: `AzureTrafficCollectorsClient.UpdateTags` + +```go +ctx := context.TODO() +id := azuretrafficcollectors.NewAzureTrafficCollectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureTrafficCollectorValue") + +payload := azuretrafficcollectors.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(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/networkfunction/2022-11-01/azuretrafficcollectors/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go new file mode 100644 index 000000000000..d6f564f5ff84 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go @@ -0,0 +1,18 @@ +package azuretrafficcollectors + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureTrafficCollectorsClient struct { + Client autorest.Client + baseUri string +} + +func NewAzureTrafficCollectorsClientWithBaseURI(endpoint string) AzureTrafficCollectorsClient { + return AzureTrafficCollectorsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go new file mode 100644 index 000000000000..5d8e770b07f6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go @@ -0,0 +1,74 @@ +package azuretrafficcollectors + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "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/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go new file mode 100644 index 000000000000..99a1d4fc50a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go @@ -0,0 +1,124 @@ +package azuretrafficcollectors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = AzureTrafficCollectorId{} + +// AzureTrafficCollectorId is a struct representing the Resource ID for a Azure Traffic Collector +type AzureTrafficCollectorId struct { + SubscriptionId string + ResourceGroupName string + AzureTrafficCollectorName string +} + +// NewAzureTrafficCollectorID returns a new AzureTrafficCollectorId struct +func NewAzureTrafficCollectorID(subscriptionId string, resourceGroupName string, azureTrafficCollectorName string) AzureTrafficCollectorId { + return AzureTrafficCollectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AzureTrafficCollectorName: azureTrafficCollectorName, + } +} + +// ParseAzureTrafficCollectorID parses 'input' into a AzureTrafficCollectorId +func ParseAzureTrafficCollectorID(input string) (*AzureTrafficCollectorId, error) { + parser := resourceids.NewParserFromResourceIdType(AzureTrafficCollectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AzureTrafficCollectorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.AzureTrafficCollectorName, ok = parsed.Parsed["azureTrafficCollectorName"]; !ok { + return nil, fmt.Errorf("the segment 'azureTrafficCollectorName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseAzureTrafficCollectorIDInsensitively parses 'input' case-insensitively into a AzureTrafficCollectorId +// note: this method should only be used for API response data and not user input +func ParseAzureTrafficCollectorIDInsensitively(input string) (*AzureTrafficCollectorId, error) { + parser := resourceids.NewParserFromResourceIdType(AzureTrafficCollectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := AzureTrafficCollectorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.AzureTrafficCollectorName, ok = parsed.Parsed["azureTrafficCollectorName"]; !ok { + return nil, fmt.Errorf("the segment 'azureTrafficCollectorName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateAzureTrafficCollectorID checks that 'input' can be parsed as a Azure Traffic Collector ID +func ValidateAzureTrafficCollectorID(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 := ParseAzureTrafficCollectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Azure Traffic Collector ID +func (id AzureTrafficCollectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AzureTrafficCollectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Azure Traffic Collector ID +func (id AzureTrafficCollectorId) 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("staticMicrosoftNetworkFunction", "Microsoft.NetworkFunction", "Microsoft.NetworkFunction"), + resourceids.StaticSegment("staticAzureTrafficCollectors", "azureTrafficCollectors", "azureTrafficCollectors"), + resourceids.UserSpecifiedSegment("azureTrafficCollectorName", "azureTrafficCollectorValue"), + } +} + +// String returns a human-readable description of this Azure Traffic Collector ID +func (id AzureTrafficCollectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Azure Traffic Collector Name: %q", id.AzureTrafficCollectorName), + } + return fmt.Sprintf("Azure Traffic Collector (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go new file mode 100644 index 000000000000..2297517c8b4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go @@ -0,0 +1,187 @@ +package azuretrafficcollectors + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ByResourceGroupListOperationResponse struct { + HttpResponse *http.Response + Model *[]AzureTrafficCollector + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ByResourceGroupListOperationResponse, error) +} + +type ByResourceGroupListCompleteResult struct { + Items []AzureTrafficCollector +} + +func (r ByResourceGroupListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ByResourceGroupListOperationResponse) LoadMore(ctx context.Context) (resp ByResourceGroupListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ByResourceGroupList ... +func (c AzureTrafficCollectorsClient) ByResourceGroupList(ctx context.Context, id commonids.ResourceGroupId) (resp ByResourceGroupListOperationResponse, err error) { + req, err := c.preparerForByResourceGroupList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForByResourceGroupList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForByResourceGroupList prepares the ByResourceGroupList request. +func (c AzureTrafficCollectorsClient) preparerForByResourceGroupList(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForByResourceGroupListWithNextLink prepares the ByResourceGroupList request with the given nextLink token. +func (c AzureTrafficCollectorsClient) preparerForByResourceGroupListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForByResourceGroupList handles the response to the ByResourceGroupList request. The method always +// closes the http.Response Body. +func (c AzureTrafficCollectorsClient) responderForByResourceGroupList(resp *http.Response) (result ByResourceGroupListOperationResponse, err error) { + type page struct { + Values []AzureTrafficCollector `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ByResourceGroupListOperationResponse, err error) { + req, err := c.preparerForByResourceGroupListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForByResourceGroupList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ByResourceGroupListComplete retrieves all of the results into a single object +func (c AzureTrafficCollectorsClient) ByResourceGroupListComplete(ctx context.Context, id commonids.ResourceGroupId) (ByResourceGroupListCompleteResult, error) { + return c.ByResourceGroupListCompleteMatchingPredicate(ctx, id, AzureTrafficCollectorOperationPredicate{}) +} + +// ByResourceGroupListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c AzureTrafficCollectorsClient) ByResourceGroupListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AzureTrafficCollectorOperationPredicate) (resp ByResourceGroupListCompleteResult, err error) { + items := make([]AzureTrafficCollector, 0) + + page, err := c.ByResourceGroupList(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ByResourceGroupListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go new file mode 100644 index 000000000000..0cc51cd683b2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go @@ -0,0 +1,187 @@ +package azuretrafficcollectors + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BySubscriptionListOperationResponse struct { + HttpResponse *http.Response + Model *[]AzureTrafficCollector + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (BySubscriptionListOperationResponse, error) +} + +type BySubscriptionListCompleteResult struct { + Items []AzureTrafficCollector +} + +func (r BySubscriptionListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r BySubscriptionListOperationResponse) LoadMore(ctx context.Context) (resp BySubscriptionListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// BySubscriptionList ... +func (c AzureTrafficCollectorsClient) BySubscriptionList(ctx context.Context, id commonids.SubscriptionId) (resp BySubscriptionListOperationResponse, err error) { + req, err := c.preparerForBySubscriptionList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForBySubscriptionList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForBySubscriptionList prepares the BySubscriptionList request. +func (c AzureTrafficCollectorsClient) preparerForBySubscriptionList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForBySubscriptionListWithNextLink prepares the BySubscriptionList request with the given nextLink token. +func (c AzureTrafficCollectorsClient) preparerForBySubscriptionListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForBySubscriptionList handles the response to the BySubscriptionList request. The method always +// closes the http.Response Body. +func (c AzureTrafficCollectorsClient) responderForBySubscriptionList(resp *http.Response) (result BySubscriptionListOperationResponse, err error) { + type page struct { + Values []AzureTrafficCollector `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result BySubscriptionListOperationResponse, err error) { + req, err := c.preparerForBySubscriptionListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForBySubscriptionList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// BySubscriptionListComplete retrieves all of the results into a single object +func (c AzureTrafficCollectorsClient) BySubscriptionListComplete(ctx context.Context, id commonids.SubscriptionId) (BySubscriptionListCompleteResult, error) { + return c.BySubscriptionListCompleteMatchingPredicate(ctx, id, AzureTrafficCollectorOperationPredicate{}) +} + +// BySubscriptionListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c AzureTrafficCollectorsClient) BySubscriptionListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AzureTrafficCollectorOperationPredicate) (resp BySubscriptionListCompleteResult, err error) { + items := make([]AzureTrafficCollector, 0) + + page, err := c.BySubscriptionList(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := BySubscriptionListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go new file mode 100644 index 000000000000..8ca0bd6980d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go @@ -0,0 +1,79 @@ +package azuretrafficcollectors + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// 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 polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c AzureTrafficCollectorsClient) CreateOrUpdate(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AzureTrafficCollectorsClient) CreateOrUpdateThenPoll(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c AzureTrafficCollectorsClient) preparerForCreateOrUpdate(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c AzureTrafficCollectorsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go new file mode 100644 index 000000000000..db94c546646b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go @@ -0,0 +1,78 @@ +package azuretrafficcollectors + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// 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 polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c AzureTrafficCollectorsClient) Delete(ctx context.Context, id AzureTrafficCollectorId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AzureTrafficCollectorsClient) DeleteThenPoll(ctx context.Context, id AzureTrafficCollectorId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c AzureTrafficCollectorsClient) preparerForDelete(ctx context.Context, id AzureTrafficCollectorId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c AzureTrafficCollectorsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go new file mode 100644 index 000000000000..79419e75be97 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go @@ -0,0 +1,68 @@ +package azuretrafficcollectors + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *AzureTrafficCollector +} + +// Get ... +func (c AzureTrafficCollectorsClient) Get(ctx context.Context, id AzureTrafficCollectorId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c AzureTrafficCollectorsClient) preparerForGet(ctx context.Context, id AzureTrafficCollectorId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c AzureTrafficCollectorsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go new file mode 100644 index 000000000000..b15435300eea --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go @@ -0,0 +1,69 @@ +package azuretrafficcollectors + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + Model *AzureTrafficCollector +} + +// UpdateTags ... +func (c AzureTrafficCollectorsClient) UpdateTags(ctx context.Context, id AzureTrafficCollectorId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + req, err := c.preparerForUpdateTags(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "UpdateTags", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "UpdateTags", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdateTags(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "UpdateTags", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdateTags prepares the UpdateTags request. +func (c AzureTrafficCollectorsClient) preparerForUpdateTags(ctx context.Context, id AzureTrafficCollectorId, input TagsObject) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdateTags handles the response to the UpdateTags request. The method always +// closes the http.Response Body. +func (c AzureTrafficCollectorsClient) responderForUpdateTags(resp *http.Response) (result UpdateTagsOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollector.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollector.go new file mode 100644 index 000000000000..39a7a273a6a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollector.go @@ -0,0 +1,15 @@ +package azuretrafficcollectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureTrafficCollector struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AzureTrafficCollectorPropertiesFormat `json:"properties,omitempty"` + 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/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollectorpropertiesformat.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollectorpropertiesformat.go new file mode 100644 index 000000000000..fd2260e1a741 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_azuretrafficcollectorpropertiesformat.go @@ -0,0 +1,10 @@ +package azuretrafficcollectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureTrafficCollectorPropertiesFormat struct { + CollectorPolicies *[]ResourceReference `json:"collectorPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub *ResourceReference `json:"virtualHub,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_resourcereference.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_resourcereference.go new file mode 100644 index 000000000000..7097e3ea2a44 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_resourcereference.go @@ -0,0 +1,8 @@ +package azuretrafficcollectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_systemdata.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_systemdata.go new file mode 100644 index 000000000000..9065c216d592 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_systemdata.go @@ -0,0 +1,30 @@ +package azuretrafficcollectors + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_tagsobject.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_tagsobject.go new file mode 100644 index 000000000000..e47a735e083f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/model_tagsobject.go @@ -0,0 +1,8 @@ +package azuretrafficcollectors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go new file mode 100644 index 000000000000..6c29157210e3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go @@ -0,0 +1,34 @@ +package azuretrafficcollectors + +type AzureTrafficCollectorOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p AzureTrafficCollectorOperationPredicate) Matches(input AzureTrafficCollector) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + 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/networkfunction/2022-11-01/azuretrafficcollectors/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/version.go new file mode 100644 index 000000000000..114ccc2f415e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/version.go @@ -0,0 +1,12 @@ +package azuretrafficcollectors + +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-11-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/azuretrafficcollectors/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 656269ecf81c..088a978040ae 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -283,6 +283,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshotpol github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshots github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumes github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumesreplication +github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01 github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01/nginxcertificate github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01/nginxconfiguration diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 75d88848949d..e8104678d434 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -66,6 +66,7 @@ Mixed Reality Monitor NetApp Network +Network Function Nginx Orbital Policy diff --git a/website/docs/r/network_function_azure_traffic_collector.html.markdown b/website/docs/r/network_function_azure_traffic_collector.html.markdown index 05a80d6db6a1..d2490d9143c7 100644 --- a/website/docs/r/network_function_azure_traffic_collector.html.markdown +++ b/website/docs/r/network_function_azure_traffic_collector.html.markdown @@ -3,28 +3,26 @@ subcategory: "Network Function" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_network_function_azure_traffic_collector" description: |- - Manages a Network Function Azure Traffic Collectors. + Manages a Network Function Azure Traffic Collector. --- # azurerm_network_function_azure_traffic_collector -Manages a Network Function Azure Traffic Collectors. +Manages a Network Function Azure Traffic Collector. ## Example Usage ```hcl resource "azurerm_resource_group" "example" { name = "example-resources" - location = "West Europe" + location = "West US" } resource "azurerm_network_function_azure_traffic_collector" "example" { name = "example-nfatc" resource_group_name = azurerm_resource_group.example.name - location = "West Europe" - virtual_hub { + location = "West US" - } tags = { key = "value" } @@ -35,24 +33,22 @@ resource "azurerm_network_function_azure_traffic_collector" "example" { The following arguments are supported: -* `name` - (Required) Specifies the name which should be used for this Network Function Azure Traffic Collectors. Changing this forces a new Network Function Azure Traffic Collectors to be created. +* `name` - (Required) Specifies the name which should be used for this Network Function Azure Traffic Collector. It can contain only letters, numbers, periods (.), hyphens (-),and underscores (_), up to 80 characters, and it must begin with a letter or number and end with a letter, number or underscore. Changing this forces a new Network Function Azure Traffic Collector to be created. -* `resource_group_name` - (Required) Specifies the name of the Resource Group where the Network Function Azure Traffic Collectors should exist. Changing this forces a new Network Function Azure Traffic Collectors to be created. +* `resource_group_name` - (Required) Specifies the name of the Resource Group where the Network Function Azure Traffic Collector should exist. Changing this forces a new Network Function Azure Traffic Collector to be created. -* `location` - (Required) Specifies the Azure Region where the Network Function Azure Traffic Collectors should exist. +* `location` - (Required) Specifies the Azure Region where the Network Function Azure Traffic Collector should exist. Changing this forces a new Network Function Azure Traffic Collector to be created. -* `tags` - (Optional) A mapping of tags which should be assigned to the Network Function Azure Traffic Collectors. +* `tags` - (Optional) A mapping of tags which should be assigned to the Network Function Azure Traffic Collector. ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: -* `id` - The ID of the Network Function Azure Traffic Collectors. +* `id` - The ID of the Network Function Azure Traffic Collector. * `collector_policies` - A `collector_policies` block as defined below. -* `system_data` - A `system_data` block as defined below. - * `virtual_hub` - A `virtual_hub` block as defined below. --- @@ -63,20 +59,6 @@ A `collector_policies` block exports the following: --- -A `system_data` block exports the following: - -* `created_at` - The timestamp of resource creation (UTC). - -* `created_by` - The identity that created the resource. - -* `created_by_type` - The type of identity that created the resource. - -* `last_modified_by` - The identity that last modified the resource. - -* `last_modified_by_type` - The type of identity that last modified the resource. - ---- - A `virtual_hub` block exports the following: * `id` - Resource ID. @@ -85,14 +67,14 @@ A `virtual_hub` block exports the following: 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 Network Function Azure Traffic Collectors. -* `read` - (Defaults to 5 minutes) Used when retrieving the Network Function Azure Traffic Collectors. -* `update` - (Defaults to 30 minutes) Used when updating the Network Function Azure Traffic Collectors. -* `delete` - (Defaults to 30 minutes) Used when deleting the Network Function Azure Traffic Collectors. +* `create` - (Defaults to 30 minutes) Used when creating the Network Function Azure Traffic Collector. +* `read` - (Defaults to 5 minutes) Used when retrieving the Network Function Azure Traffic Collector. +* `update` - (Defaults to 30 minutes) Used when updating the Network Function Azure Traffic Collector. +* `delete` - (Defaults to 30 minutes) Used when deleting the Network Function Azure Traffic Collector. ## Import -Network Function Azure Traffic Collectors can be imported using the `resource id`, e.g. +Network Function Azure Traffic Collector can be imported using the `resource id`, e.g. ```shell terraform import azurerm_network_function_azure_traffic_collector.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/azureTrafficCollector1 From a805aeb8545bb9c1438cfba76cdee134e3917042 Mon Sep 17 00:00:00 2001 From: Zhenhua Hu Date: Thu, 20 Oct 2022 11:10:44 +0800 Subject: [PATCH 3/4] add code --- .../network_function_azure_traffic_collector_resource.go | 4 ++-- .../r/network_function_azure_traffic_collector.html.markdown | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go index 4ddec0187137..b00b829c7fa8 100644 --- a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go @@ -21,7 +21,7 @@ type NetworkFunctionAzureTrafficCollectorModel struct { Location string `tfschema:"location"` Tags map[string]string `tfschema:"tags"` VirtualHub []ResourceReferenceModel `tfschema:"virtual_hub"` - CollectorPolicies []ResourceReferenceModel `tfschema:"collector_policies"` + CollectorPolicies []ResourceReferenceModel `tfschema:"collector_policy"` } type ResourceReferenceModel struct { @@ -66,7 +66,7 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Arguments() map[string]*pl func (r NetworkFunctionAzureTrafficCollectorResource) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ - "collector_policies": { + "collector_policy": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ diff --git a/website/docs/r/network_function_azure_traffic_collector.html.markdown b/website/docs/r/network_function_azure_traffic_collector.html.markdown index d2490d9143c7..a7387e8a8031 100644 --- a/website/docs/r/network_function_azure_traffic_collector.html.markdown +++ b/website/docs/r/network_function_azure_traffic_collector.html.markdown @@ -47,13 +47,13 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of the Network Function Azure Traffic Collector. -* `collector_policies` - A `collector_policies` block as defined below. +* `collector_policy` - A `collector_policy` block as defined below. * `virtual_hub` - A `virtual_hub` block as defined below. --- -A `collector_policies` block exports the following: +A `collector_policy` block exports the following: * `id` - Resource ID. From f1750c3de20c0bc06d11fd1c91a0b70ceeb0ee36 Mon Sep 17 00:00:00 2001 From: Zhenhua Hu Date: Sun, 25 Jun 2023 14:38:58 +0800 Subject: [PATCH 4/4] fix build --- .github/labeler-pull-request-triage.yml | 3 + .teamcity/components/generated/services.kt | 1 + internal/clients/client.go | 5 + internal/provider/services.go | 2 + .../services/networkfunction/client/client.go | 14 +- ...nction_azure_traffic_collector_resource.go | 98 +++------ ...n_azure_traffic_collector_resource_test.go | 3 +- .../azuretrafficcollectors/client.go | 22 ++- .../azuretrafficcollectors/constants.go | 32 ++- .../id_azuretrafficcollector.go | 15 +- .../method_byresourcegrouplist.go | 90 +++++++++ .../method_byresourcegrouplist_autorest.go | 187 ------------------ .../method_bysubscriptionlist.go | 90 +++++++++ .../method_bysubscriptionlist_autorest.go | 187 ------------------ .../method_createorupdate.go | 74 +++++++ .../method_createorupdate_autorest.go | 79 -------- .../azuretrafficcollectors/method_delete.go | 71 +++++++ .../method_delete_autorest.go | 78 -------- .../azuretrafficcollectors/method_get.go | 51 +++++ .../method_get_autorest.go | 68 ------- .../method_updatetags.go | 55 ++++++ .../method_updatetags_autorest.go | 69 ------- .../azuretrafficcollectors/predicates.go | 3 + vendor/modules.txt | 1 + website/allowed-subcategories | 1 + ...tion_azure_traffic_collector.html.markdown | 18 +- 26 files changed, 544 insertions(+), 773 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go diff --git a/.github/labeler-pull-request-triage.yml b/.github/labeler-pull-request-triage.yml index 988a2529cfb6..0c9992c2b236 100644 --- a/.github/labeler-pull-request-triage.yml +++ b/.github/labeler-pull-request-triage.yml @@ -225,6 +225,9 @@ service/netapp: service/network: - internal/services/network/**/* +service/network-function: + - internal/services/networkfunction/**/* + service/nginx: - internal/services/nginx/**/* diff --git a/.teamcity/components/generated/services.kt b/.teamcity/components/generated/services.kt index 0748a8a51de8..8aa45b624fb7 100644 --- a/.teamcity/components/generated/services.kt +++ b/.teamcity/components/generated/services.kt @@ -83,6 +83,7 @@ var services = mapOf( "mysql" to "MySQL", "netapp" to "NetApp", "network" to "Network", + "networkfunction" to "Network Function", "newrelic" to "New Relic", "nginx" to "Nginx", "notificationhub" to "Notification Hub", diff --git a/internal/clients/client.go b/internal/clients/client.go index 2838786dde6d..554d7cd90cf3 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -97,6 +97,7 @@ import ( mysql "github.com/hashicorp/terraform-provider-azurerm/internal/services/mysql/client" netapp "github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/client" network "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/client" + networkfunction "github.com/hashicorp/terraform-provider-azurerm/internal/services/networkfunction/client" newrelic "github.com/hashicorp/terraform-provider-azurerm/internal/services/newrelic/client" nginx "github.com/hashicorp/terraform-provider-azurerm/internal/services/nginx/client" notificationhub "github.com/hashicorp/terraform-provider-azurerm/internal/services/notificationhub/client" @@ -225,6 +226,7 @@ type Client struct { MySQL *mysql.Client NetApp *netapp.Client Network *network.Client + NetworkFunction *networkfunction.Client NewRelic *newrelic.Client Nginx *nginx2.Client NotificationHubs *notificationhub.Client @@ -417,6 +419,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.Network, err = network.NewClient(o); err != nil { return fmt.Errorf("building clients for Network: %+v", err) } + if client.NetworkFunction, err = networkfunction.NewClient(o); err != nil { + return fmt.Errorf("building clients for NetworkFunction: %+v", err) + } if client.NewRelic, err = newrelic.NewClient(o); err != nil { return fmt.Errorf("building clients for NewRelic: %+v", err) } diff --git a/internal/provider/services.go b/internal/provider/services.go index ef74bf3ae5dd..16ba83349c93 100644 --- a/internal/provider/services.go +++ b/internal/provider/services.go @@ -84,6 +84,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/mysql" "github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/networkfunction" "github.com/hashicorp/terraform-provider-azurerm/internal/services/newrelic" "github.com/hashicorp/terraform-provider-azurerm/internal/services/nginx" "github.com/hashicorp/terraform-provider-azurerm/internal/services/notificationhub" @@ -167,6 +168,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration { mysql.Registration{}, network.Registration{}, netapp.Registration{}, + networkfunction.Registration{}, newrelic.Registration{}, nginx.Registration{}, policy.Registration{}, diff --git a/internal/services/networkfunction/client/client.go b/internal/services/networkfunction/client/client.go index 672f0e261509..7e5a0593af2e 100644 --- a/internal/services/networkfunction/client/client.go +++ b/internal/services/networkfunction/client/client.go @@ -9,11 +9,15 @@ type Client struct { AzureTrafficCollectorsClient *azuretrafficcollectors.AzureTrafficCollectorsClient } -func NewClient(o *common.ClientOptions) *Client { - azureTrafficCollectorsClient := azuretrafficcollectors.NewAzureTrafficCollectorsClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&azureTrafficCollectorsClient.Client, o.ResourceManagerAuthorizer) +func NewClient(o *common.ClientOptions) (*Client, error) { + azureTrafficCollectorsClient, err := azuretrafficcollectors.NewAzureTrafficCollectorsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, err + } + + o.Configure(azureTrafficCollectorsClient.Client, o.Authorizers.ResourceManager) return &Client{ - AzureTrafficCollectorsClient: &azureTrafficCollectorsClient, - } + AzureTrafficCollectorsClient: azureTrafficCollectorsClient, + }, nil } diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go index b00b829c7fa8..3a7508ae01f2 100644 --- a/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource.go @@ -16,16 +16,12 @@ import ( ) type NetworkFunctionAzureTrafficCollectorModel struct { - Name string `tfschema:"name"` - ResourceGroupName string `tfschema:"resource_group_name"` - Location string `tfschema:"location"` - Tags map[string]string `tfschema:"tags"` - VirtualHub []ResourceReferenceModel `tfschema:"virtual_hub"` - CollectorPolicies []ResourceReferenceModel `tfschema:"collector_policy"` -} - -type ResourceReferenceModel struct { - Id string `tfschema:"id"` + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + Location string `tfschema:"location"` + Tags map[string]string `tfschema:"tags"` + CollectorPolicies []string `tfschema:"collector_policy_ids"` + VirtualHub []string `tfschema:"virtual_hub_id"` } type NetworkFunctionAzureTrafficCollectorResource struct{} @@ -66,29 +62,19 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Arguments() map[string]*pl func (r NetworkFunctionAzureTrafficCollectorResource) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ - "collector_policy": { + "collector_policy_ids": { Type: pluginsdk.TypeList, Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, }, }, - "virtual_hub": { + "virtual_hub_id": { Type: pluginsdk.TypeList, Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, }, }, } @@ -157,8 +143,6 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Update() sdk.ResourceFunc return fmt.Errorf("retrieving %s: properties was nil", id) } - properties.SystemData = nil - if metadata.ResourceData.HasChange("tags") { properties.Tags = &model.Tags } @@ -192,35 +176,21 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", *id, err) } - model := resp.Model - if model == nil { - return fmt.Errorf("retrieving %s: model was nil", id) - } - state := NetworkFunctionAzureTrafficCollectorModel{ Name: id.AzureTrafficCollectorName, ResourceGroupName: id.ResourceGroupName, - Location: location.Normalize(model.Location), } - if properties := model.Properties; properties != nil { - collectorPoliciesValue, err := flattenResourceReferenceModelArray(properties.CollectorPolicies) - if err != nil { - return err + if model := resp.Model; model != nil { + state.Location = location.Normalize(model.Location) + if properties := model.Properties; properties != nil { + state.CollectorPolicies = flattenCollectorPolicyModelArray(properties.CollectorPolicies) + state.VirtualHub = flattenVirtualHubModel(properties.VirtualHub) } - state.CollectorPolicies = collectorPoliciesValue - - virtualHubValue, err := flattenResourceReferenceModel(properties.VirtualHub) - if err != nil { - return err + if model.Tags != nil { + state.Tags = *model.Tags } - - state.VirtualHub = virtualHubValue - } - - if model.Tags != nil { - state.Tags = *model.Tags } return metadata.Encode(&state) @@ -248,36 +218,26 @@ func (r NetworkFunctionAzureTrafficCollectorResource) Delete() sdk.ResourceFunc } } -func flattenResourceReferenceModelArray(inputList *[]azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { - var outputList []ResourceReferenceModel +func flattenCollectorPolicyModelArray(inputList *[]azuretrafficcollectors.ResourceReference) []string { + var outputList []string if inputList == nil { - return outputList, nil + return outputList } for _, input := range *inputList { - output := ResourceReferenceModel{} - if input.Id != nil { - output.Id = *input.Id + outputList = append(outputList, *input.Id) } - - outputList = append(outputList, output) } - return outputList, nil + return outputList } -func flattenResourceReferenceModel(input *azuretrafficcollectors.ResourceReference) ([]ResourceReferenceModel, error) { - var outputList []ResourceReferenceModel - if input == nil { - return outputList, nil - } - - output := ResourceReferenceModel{} - - if input.Id != nil { - output.Id = *input.Id +func flattenVirtualHubModel(input *azuretrafficcollectors.ResourceReference) []string { + var outputList []string + if input != nil && input.Id != nil { + outputList = append(outputList, *input.Id) } - return append(outputList, output), nil + return outputList } diff --git a/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go b/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go index fed071012fdd..8d6915cfd173 100644 --- a/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go +++ b/internal/services/networkfunction/network_function_azure_traffic_collector_resource_test.go @@ -5,9 +5,8 @@ import ( "fmt" "testing" - "github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors" - "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors" "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" diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go index d6f564f5ff84..2d2ddd610b9b 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/client.go @@ -1,18 +1,26 @@ package azuretrafficcollectors -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AzureTrafficCollectorsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAzureTrafficCollectorsClientWithBaseURI(endpoint string) AzureTrafficCollectorsClient { - return AzureTrafficCollectorsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAzureTrafficCollectorsClientWithBaseURI(api environments.Api) (*AzureTrafficCollectorsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "azuretrafficcollectors", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AzureTrafficCollectorsClient: %+v", err) } + + return &AzureTrafficCollectorsClient{ + Client: client, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go index 5d8e770b07f6..d3d909feb7ad 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/constants.go @@ -1,6 +1,10 @@ package azuretrafficcollectors -import "strings" +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. @@ -23,6 +27,19 @@ func PossibleValuesForCreatedByType() []string { } } +func (s *CreatedByType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreatedByType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCreatedByType(input string) (*CreatedByType, error) { vals := map[string]CreatedByType{ "application": CreatedByTypeApplication, @@ -57,6 +74,19 @@ func PossibleValuesForProvisioningState() []string { } } +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{ "deleting": ProvisioningStateDeleting, diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go index 99a1d4fc50a5..3d0cf730c133 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/id_azuretrafficcollector.go @@ -7,6 +7,9 @@ import ( "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 = AzureTrafficCollectorId{} // AzureTrafficCollectorId is a struct representing the Resource ID for a Azure Traffic Collector @@ -37,15 +40,15 @@ func ParseAzureTrafficCollectorID(input string) (*AzureTrafficCollectorId, error id := AzureTrafficCollectorId{} if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) } if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) } if id.AzureTrafficCollectorName, ok = parsed.Parsed["azureTrafficCollectorName"]; !ok { - return nil, fmt.Errorf("the segment 'azureTrafficCollectorName' was not found in the resource id %q", input) + return nil, resourceids.NewSegmentNotSpecifiedError(id, "azureTrafficCollectorName", *parsed) } return &id, nil @@ -64,15 +67,15 @@ func ParseAzureTrafficCollectorIDInsensitively(input string) (*AzureTrafficColle id := AzureTrafficCollectorId{} if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) } if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) } if id.AzureTrafficCollectorName, ok = parsed.Parsed["azureTrafficCollectorName"]; !ok { - return nil, fmt.Errorf("the segment 'azureTrafficCollectorName' was not found in the resource id %q", input) + return nil, resourceids.NewSegmentNotSpecifiedError(id, "azureTrafficCollectorName", *parsed) } return &id, nil diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist.go new file mode 100644 index 000000000000..d39f0be51e40 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist.go @@ -0,0 +1,90 @@ +package azuretrafficcollectors + +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 ByResourceGroupListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureTrafficCollector +} + +type ByResourceGroupListCompleteResult struct { + Items []AzureTrafficCollector +} + +// ByResourceGroupList ... +func (c AzureTrafficCollectorsClient) ByResourceGroupList(ctx context.Context, id commonids.ResourceGroupId) (result ByResourceGroupListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors", 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 *[]AzureTrafficCollector `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ByResourceGroupListComplete retrieves all the results into a single object +func (c AzureTrafficCollectorsClient) ByResourceGroupListComplete(ctx context.Context, id commonids.ResourceGroupId) (ByResourceGroupListCompleteResult, error) { + return c.ByResourceGroupListCompleteMatchingPredicate(ctx, id, AzureTrafficCollectorOperationPredicate{}) +} + +// ByResourceGroupListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureTrafficCollectorsClient) ByResourceGroupListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AzureTrafficCollectorOperationPredicate) (result ByResourceGroupListCompleteResult, err error) { + items := make([]AzureTrafficCollector, 0) + + resp, err := c.ByResourceGroupList(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 = ByResourceGroupListCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go deleted file mode 100644 index 2297517c8b4a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_byresourcegrouplist_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package azuretrafficcollectors - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ByResourceGroupListOperationResponse struct { - HttpResponse *http.Response - Model *[]AzureTrafficCollector - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ByResourceGroupListOperationResponse, error) -} - -type ByResourceGroupListCompleteResult struct { - Items []AzureTrafficCollector -} - -func (r ByResourceGroupListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ByResourceGroupListOperationResponse) LoadMore(ctx context.Context) (resp ByResourceGroupListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ByResourceGroupList ... -func (c AzureTrafficCollectorsClient) ByResourceGroupList(ctx context.Context, id commonids.ResourceGroupId) (resp ByResourceGroupListOperationResponse, err error) { - req, err := c.preparerForByResourceGroupList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForByResourceGroupList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForByResourceGroupList prepares the ByResourceGroupList request. -func (c AzureTrafficCollectorsClient) preparerForByResourceGroupList(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForByResourceGroupListWithNextLink prepares the ByResourceGroupList request with the given nextLink token. -func (c AzureTrafficCollectorsClient) preparerForByResourceGroupListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForByResourceGroupList handles the response to the ByResourceGroupList request. The method always -// closes the http.Response Body. -func (c AzureTrafficCollectorsClient) responderForByResourceGroupList(resp *http.Response) (result ByResourceGroupListOperationResponse, err error) { - type page struct { - Values []AzureTrafficCollector `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ByResourceGroupListOperationResponse, err error) { - req, err := c.preparerForByResourceGroupListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForByResourceGroupList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "ByResourceGroupList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ByResourceGroupListComplete retrieves all of the results into a single object -func (c AzureTrafficCollectorsClient) ByResourceGroupListComplete(ctx context.Context, id commonids.ResourceGroupId) (ByResourceGroupListCompleteResult, error) { - return c.ByResourceGroupListCompleteMatchingPredicate(ctx, id, AzureTrafficCollectorOperationPredicate{}) -} - -// ByResourceGroupListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AzureTrafficCollectorsClient) ByResourceGroupListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AzureTrafficCollectorOperationPredicate) (resp ByResourceGroupListCompleteResult, err error) { - items := make([]AzureTrafficCollector, 0) - - page, err := c.ByResourceGroupList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ByResourceGroupListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist.go new file mode 100644 index 000000000000..93f078624162 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist.go @@ -0,0 +1,90 @@ +package azuretrafficcollectors + +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 BySubscriptionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureTrafficCollector +} + +type BySubscriptionListCompleteResult struct { + Items []AzureTrafficCollector +} + +// BySubscriptionList ... +func (c AzureTrafficCollectorsClient) BySubscriptionList(ctx context.Context, id commonids.SubscriptionId) (result BySubscriptionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors", 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 *[]AzureTrafficCollector `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// BySubscriptionListComplete retrieves all the results into a single object +func (c AzureTrafficCollectorsClient) BySubscriptionListComplete(ctx context.Context, id commonids.SubscriptionId) (BySubscriptionListCompleteResult, error) { + return c.BySubscriptionListCompleteMatchingPredicate(ctx, id, AzureTrafficCollectorOperationPredicate{}) +} + +// BySubscriptionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureTrafficCollectorsClient) BySubscriptionListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AzureTrafficCollectorOperationPredicate) (result BySubscriptionListCompleteResult, err error) { + items := make([]AzureTrafficCollector, 0) + + resp, err := c.BySubscriptionList(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 = BySubscriptionListCompleteResult{ + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go deleted file mode 100644 index 0cc51cd683b2..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_bysubscriptionlist_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package azuretrafficcollectors - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BySubscriptionListOperationResponse struct { - HttpResponse *http.Response - Model *[]AzureTrafficCollector - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (BySubscriptionListOperationResponse, error) -} - -type BySubscriptionListCompleteResult struct { - Items []AzureTrafficCollector -} - -func (r BySubscriptionListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r BySubscriptionListOperationResponse) LoadMore(ctx context.Context) (resp BySubscriptionListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// BySubscriptionList ... -func (c AzureTrafficCollectorsClient) BySubscriptionList(ctx context.Context, id commonids.SubscriptionId) (resp BySubscriptionListOperationResponse, err error) { - req, err := c.preparerForBySubscriptionList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForBySubscriptionList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForBySubscriptionList prepares the BySubscriptionList request. -func (c AzureTrafficCollectorsClient) preparerForBySubscriptionList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.NetworkFunction/azureTrafficCollectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForBySubscriptionListWithNextLink prepares the BySubscriptionList request with the given nextLink token. -func (c AzureTrafficCollectorsClient) preparerForBySubscriptionListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForBySubscriptionList handles the response to the BySubscriptionList request. The method always -// closes the http.Response Body. -func (c AzureTrafficCollectorsClient) responderForBySubscriptionList(resp *http.Response) (result BySubscriptionListOperationResponse, err error) { - type page struct { - Values []AzureTrafficCollector `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result BySubscriptionListOperationResponse, err error) { - req, err := c.preparerForBySubscriptionListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForBySubscriptionList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "BySubscriptionList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// BySubscriptionListComplete retrieves all of the results into a single object -func (c AzureTrafficCollectorsClient) BySubscriptionListComplete(ctx context.Context, id commonids.SubscriptionId) (BySubscriptionListCompleteResult, error) { - return c.BySubscriptionListCompleteMatchingPredicate(ctx, id, AzureTrafficCollectorOperationPredicate{}) -} - -// BySubscriptionListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AzureTrafficCollectorsClient) BySubscriptionListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AzureTrafficCollectorOperationPredicate) (resp BySubscriptionListCompleteResult, err error) { - items := make([]AzureTrafficCollector, 0) - - page, err := c.BySubscriptionList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := BySubscriptionListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate.go new file mode 100644 index 000000000000..099f4e612b95 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate.go @@ -0,0 +1,74 @@ +package azuretrafficcollectors + +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 AzureTrafficCollectorsClient) CreateOrUpdate(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AzureTrafficCollectorsClient) CreateOrUpdateThenPoll(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) 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/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go deleted file mode 100644 index 8ca0bd6980d1..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package azuretrafficcollectors - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AzureTrafficCollectorsClient) CreateOrUpdate(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AzureTrafficCollectorsClient) CreateOrUpdateThenPoll(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AzureTrafficCollectorsClient) preparerForCreateOrUpdate(ctx context.Context, id AzureTrafficCollectorId, input AzureTrafficCollector) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AzureTrafficCollectorsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete.go new file mode 100644 index 000000000000..b66167c237d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete.go @@ -0,0 +1,71 @@ +package azuretrafficcollectors + +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 AzureTrafficCollectorsClient) Delete(ctx context.Context, id AzureTrafficCollectorId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AzureTrafficCollectorsClient) DeleteThenPoll(ctx context.Context, id AzureTrafficCollectorId) 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/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go deleted file mode 100644 index db94c546646b..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package azuretrafficcollectors - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c AzureTrafficCollectorsClient) Delete(ctx context.Context, id AzureTrafficCollectorId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AzureTrafficCollectorsClient) DeleteThenPoll(ctx context.Context, id AzureTrafficCollectorId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c AzureTrafficCollectorsClient) preparerForDelete(ctx context.Context, id AzureTrafficCollectorId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c AzureTrafficCollectorsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get.go new file mode 100644 index 000000000000..a41ab0866534 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get.go @@ -0,0 +1,51 @@ +package azuretrafficcollectors + +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 *AzureTrafficCollector +} + +// Get ... +func (c AzureTrafficCollectorsClient) Get(ctx context.Context, id AzureTrafficCollectorId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go deleted file mode 100644 index 79419e75be97..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package azuretrafficcollectors - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AzureTrafficCollector -} - -// Get ... -func (c AzureTrafficCollectorsClient) Get(ctx context.Context, id AzureTrafficCollectorId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AzureTrafficCollectorsClient) preparerForGet(ctx context.Context, id AzureTrafficCollectorId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AzureTrafficCollectorsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags.go new file mode 100644 index 000000000000..94643a2fe842 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags.go @@ -0,0 +1,55 @@ +package azuretrafficcollectors + +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 UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureTrafficCollector +} + +// UpdateTags ... +func (c AzureTrafficCollectorsClient) UpdateTags(ctx context.Context, id AzureTrafficCollectorId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go deleted file mode 100644 index b15435300eea..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/method_updatetags_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package azuretrafficcollectors - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateTagsOperationResponse struct { - HttpResponse *http.Response - Model *AzureTrafficCollector -} - -// UpdateTags ... -func (c AzureTrafficCollectorsClient) UpdateTags(ctx context.Context, id AzureTrafficCollectorId, input TagsObject) (result UpdateTagsOperationResponse, err error) { - req, err := c.preparerForUpdateTags(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "UpdateTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "UpdateTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azuretrafficcollectors.AzureTrafficCollectorsClient", "UpdateTags", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateTags prepares the UpdateTags request. -func (c AzureTrafficCollectorsClient) preparerForUpdateTags(ctx context.Context, id AzureTrafficCollectorId, input TagsObject) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateTags handles the response to the UpdateTags request. The method always -// closes the http.Response Body. -func (c AzureTrafficCollectorsClient) responderForUpdateTags(resp *http.Response) (result UpdateTagsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go index 6c29157210e3..b1576b905221 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors/predicates.go @@ -1,5 +1,8 @@ package azuretrafficcollectors +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + type AzureTrafficCollectorOperationPredicate struct { Etag *string Id *string diff --git a/vendor/modules.txt b/vendor/modules.txt index 6f90e28113ea..203cf2e9735c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -477,6 +477,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-09-01/routetable github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-09-01/scopeconnections github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-09-01/securityadminconfigurations github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-09-01/staticmembers +github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/azuretrafficcollectors github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2022-07-01/monitors github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01 github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2022-08-01/nginxcertificate diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 0d9faa1a2c0a..55d1d670da63 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -72,6 +72,7 @@ Mobile Network Monitor NetApp Network +Network Function New Relic Nginx Orbital diff --git a/website/docs/r/network_function_azure_traffic_collector.html.markdown b/website/docs/r/network_function_azure_traffic_collector.html.markdown index a7387e8a8031..e2ac1b1fb736 100644 --- a/website/docs/r/network_function_azure_traffic_collector.html.markdown +++ b/website/docs/r/network_function_azure_traffic_collector.html.markdown @@ -33,7 +33,7 @@ resource "azurerm_network_function_azure_traffic_collector" "example" { The following arguments are supported: -* `name` - (Required) Specifies the name which should be used for this Network Function Azure Traffic Collector. It can contain only letters, numbers, periods (.), hyphens (-),and underscores (_), up to 80 characters, and it must begin with a letter or number and end with a letter, number or underscore. Changing this forces a new Network Function Azure Traffic Collector to be created. +* `name` - (Required) Specifies the name which should be used for this Network Function Azure Traffic Collector. Changing this forces a new Network Function Azure Traffic Collector to be created. * `resource_group_name` - (Required) Specifies the name of the Resource Group where the Network Function Azure Traffic Collector should exist. Changing this forces a new Network Function Azure Traffic Collector to be created. @@ -47,21 +47,9 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of the Network Function Azure Traffic Collector. -* `collector_policy` - A `collector_policy` block as defined below. +* `collector_policy_ids` - The list of Resource IDs of collector policies. -* `virtual_hub` - A `virtual_hub` block as defined below. - ---- - -A `collector_policy` block exports the following: - -* `id` - Resource ID. - ---- - -A `virtual_hub` block exports the following: - -* `id` - Resource ID. +* `virtual_hub_id` - The Resource ID of virtual hub. ## Timeouts