From c364888e1c1942a1f57183969bd3b518494c801b Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Tue, 7 Feb 2023 11:25:01 +0800 Subject: [PATCH 01/11] New Resource: `azurerm_mobile_network_service`; New DataSource: `azurerm_mobile_network_service` --- .../services/mobilenetwork/client/client.go | 6 + internal/services/mobilenetwork/helpers.go | 44 ++ .../mobile_network_service_data_source.go | 295 +++++++ ...mobile_network_service_data_source_test.go | 61 ++ .../mobile_network_service_resource.go | 741 ++++++++++++++++++ .../mobile_network_service_resource_test.go | 386 +++++++++ .../services/mobilenetwork/registration.go | 2 + .../2022-11-01/service/README.md | 86 ++ .../2022-11-01/service/client.go | 18 + .../2022-11-01/service/constants.go | 164 ++++ .../2022-11-01/service/id_service.go | 137 ++++ .../service/method_createorupdate_autorest.go | 79 ++ .../service/method_delete_autorest.go | 78 ++ .../2022-11-01/service/method_get_autorest.go | 68 ++ .../service/method_updatetags_autorest.go | 69 ++ .../2022-11-01/service/model_ambr.go | 9 + .../service/model_pccruleconfiguration.go | 12 + .../service/model_pccruleqospolicy.go | 13 + .../2022-11-01/service/model_qospolicy.go | 12 + .../2022-11-01/service/model_service.go | 18 + .../service/model_servicedataflowtemplate.go | 12 + .../service/model_servicepropertiesformat.go | 11 + .../2022-11-01/service/model_tagsobject.go | 8 + .../2022-11-01/service/version.go | 12 + vendor/modules.txt | 1 + .../d/mobile_network_service.html.markdown | 129 +++ .../r/mobile_network_service.html.markdown | 199 +++++ 27 files changed, 2670 insertions(+) create mode 100644 internal/services/mobilenetwork/helpers.go create mode 100644 internal/services/mobilenetwork/mobile_network_service_data_source.go create mode 100644 internal/services/mobilenetwork/mobile_network_service_data_source_test.go create mode 100644 internal/services/mobilenetwork/mobile_network_service_resource.go create mode 100644 internal/services/mobilenetwork/mobile_network_service_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/id_service.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_createorupdate_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_delete_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_get_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_updatetags_autorest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_ambr.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleconfiguration.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleqospolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_qospolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_service.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicedataflowtemplate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicepropertiesformat.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_tagsobject.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/version.go create mode 100644 website/docs/d/mobile_network_service.html.markdown create mode 100644 website/docs/r/mobile_network_service.html.markdown diff --git a/internal/services/mobilenetwork/client/client.go b/internal/services/mobilenetwork/client/client.go index ee94c25b74f8..7a6bb645d624 100644 --- a/internal/services/mobilenetwork/client/client.go +++ b/internal/services/mobilenetwork/client/client.go @@ -2,18 +2,24 @@ package client import ( "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { MobileNetworkClient *mobilenetwork.MobileNetworkClient + ServiceClient *service.ServiceClient } func NewClient(o *common.ClientOptions) *Client { mobileNetworkClient := mobilenetwork.NewMobileNetworkClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&mobileNetworkClient.Client, o.ResourceManagerAuthorizer) + serviceClient := service.NewServiceClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&serviceClient.Client, o.ResourceManagerAuthorizer) + return &Client{ MobileNetworkClient: &mobileNetworkClient, + ServiceClient: &serviceClient, } } diff --git a/internal/services/mobilenetwork/helpers.go b/internal/services/mobilenetwork/helpers.go new file mode 100644 index 000000000000..4f78c590946a --- /dev/null +++ b/internal/services/mobilenetwork/helpers.go @@ -0,0 +1,44 @@ +package mobilenetwork + +import ( + "context" + "fmt" + "net/http" + "strconv" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +// a workaround for that some child resources may still exist for seconds before it fully deleted. +// it will cause the error "Can not delete resource before nested resources are deleted." +func resourceMobileNetworkChildWaitForDeletion(ctx context.Context, id string, getFunction func() (*http.Response, error)) error { + deadline, _ := ctx.Deadline() + stateConf := &pluginsdk.StateChangeConf{ + Pending: []string{"200"}, + Target: []string{"404"}, + Refresh: func() (interface{}, string, error) { + resp, err := getFunction() + if err != nil { + if response.WasNotFound(resp) { + return resp, strconv.Itoa(resp.StatusCode), nil + } + + return nil, strconv.Itoa(resp.StatusCode), fmt.Errorf("polling for %s: %+v", id, err) + } + + return resp, strconv.Itoa(resp.StatusCode), nil + }, + MinTimeout: 10 * time.Second, + PollInterval: 10 * time.Second, + ContinuousTargetOccurence: 6, + Timeout: time.Until(deadline), + } + + if _, err := stateConf.WaitForStateContext(ctx); err != nil { + return fmt.Errorf("waiting for deleting %s: %+v", id, err) + } + + return nil +} diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source.go b/internal/services/mobilenetwork/mobile_network_service_data_source.go new file mode 100644 index 000000000000..de315a54eafd --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_service_data_source.go @@ -0,0 +1,295 @@ +package mobilenetwork + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type MobileNetworkServiceDataSource struct{} + +var _ sdk.DataSource = MobileNetworkServiceDataSource{} + +func (r MobileNetworkServiceDataSource) ResourceType() string { + return "azurerm_mobile_network_service" +} + +func (r MobileNetworkServiceDataSource) ModelObject() interface{} { + return &ServiceModel{} +} + +func (r MobileNetworkServiceDataSource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return service.ValidateServiceID +} + +func (r MobileNetworkServiceDataSource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "mobile_network_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: mobilenetwork.ValidateMobileNetworkID, + }, + } +} + +func (r MobileNetworkServiceDataSource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + + "location": commonschema.LocationComputed(), + + "pcc_rules": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "rule_name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "rule_precedence": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + + "rule_qos_policy": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "allocation_and_retention_priority_level": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + + "qos_indicator": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + + "guaranteed_bit_rate": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "downlink": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "uplink": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "maximum_bit_rate": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "downlink": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "uplink": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "preemption_capability": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "preemption_vulnerability": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "service_data_flow_templates": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "direction": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "ports": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "protocol": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "remote_ip_list": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "template_name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "traffic_control_enabled": { + Type: pluginsdk.TypeBool, + Computed: true, + }, + }, + }, + }, + + "service_precedence": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + + "service_qos_policy": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "allocation_and_retention_priority_level": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + + "qos_indicator": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + + "maximum_bit_rate": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "downlink": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "uplink": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "preemption_capability": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "preemption_vulnerability": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "tags": commonschema.TagsDataSource(), + } +} + +func (r MobileNetworkServiceDataSource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var metaModel ServiceModel + if err := metadata.Decode(&metaModel); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.MobileNetwork.ServiceClient + mobileNetworkId, err := mobilenetwork.ParseMobileNetworkID(metaModel.MobileNetworkMobileNetworkId) + if err != nil { + return err + } + + id := service.NewServiceID(mobileNetworkId.SubscriptionId, mobileNetworkId.ResourceGroupName, mobileNetworkId.MobileNetworkName, metaModel.Name) + + 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 := ServiceModel{ + Name: id.ServiceName, + MobileNetworkMobileNetworkId: mobilenetwork.NewMobileNetworkID(id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName).ID(), + Location: location.Normalize(model.Location), + } + + properties := &model.Properties + + state.PccRules = flattenPccRuleConfigurationModel(properties.PccRules) + + state.ServicePrecedence = properties.ServicePrecedence + + state.ServiceQosPolicy = flattenQosPolicyModel(properties.ServiceQosPolicy) + + if model.Tags != nil { + state.Tags = *model.Tags + } + + metadata.SetID(id) + + return metadata.Encode(&state) + }, + } +} diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source_test.go b/internal/services/mobilenetwork/mobile_network_service_data_source_test.go new file mode 100644 index 000000000000..4641ed4ee963 --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_service_data_source_test.go @@ -0,0 +1,61 @@ +package mobilenetwork_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" +) + +type MobileNetworkServiceDataSource struct{} + +func TestAccMobileNetworkServiceDataSource_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + d := MobileNetworkServiceDataSource{} + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: d.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key(`location`).Exists(), + check.That(data.ResourceName).Key(`service_precedence`).HasValue("0"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_name`).HasValue("default-rule"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_precedence`).HasValue("1"), + check.That(data.ResourceName).Key(`pcc_rules.0.traffic_control_enabled`).HasValue("true"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.allocation_and_retention_priority_level`).HasValue("9"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.qos_indicator`).HasValue("9"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.preemption_capability`).HasValue("NotPreempt"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.preemption_vulnerability`).HasValue("Preemptable"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.guaranteed_bit_rate.0.downlink`).HasValue("100 Mbps"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.guaranteed_bit_rate.0.uplink`).HasValue("10 Mbps"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.maximum_bit_rate.0.downlink`).HasValue("1 Gbps"), + check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.maximum_bit_rate.0.uplink`).HasValue("100 Mbps"), + check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.direction`).HasValue("Uplink"), + check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.template_name`).HasValue("IP-to-server"), + check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.protocol.0`).HasValue("ip"), + check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.remote_ip_list.0`).HasValue("10.3.4.0/24"), + check.That(data.ResourceName).Key(`service_qos_policy.0.allocation_and_retention_priority_level`).HasValue("9"), + check.That(data.ResourceName).Key(`service_qos_policy.0.qos_indicator`).HasValue("9"), + check.That(data.ResourceName).Key(`service_qos_policy.0.preemption_capability`).HasValue("NotPreempt"), + check.That(data.ResourceName).Key(`service_qos_policy.0.preemption_vulnerability`).HasValue("Preemptable"), + check.That(data.ResourceName).Key(`service_qos_policy.0.maximum_bit_rate.0.downlink`).HasValue("1 Gbps"), + check.That(data.ResourceName).Key(`service_qos_policy.0.maximum_bit_rate.0.uplink`).HasValue("100 Mbps"), + check.That(data.ResourceName).Key("tags.%").HasValue("1"), + ), + }, + }) +} + +func (r MobileNetworkServiceDataSource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +data "azurerm_mobile_network_service" "test" { + name = azurerm_mobile_network_service.test.name + mobile_network_id = azurerm_mobile_network_service.test.mobile_network_id +} +`, MobileNetworkServiceResource{}.complete(data)) +} diff --git a/internal/services/mobilenetwork/mobile_network_service_resource.go b/internal/services/mobilenetwork/mobile_network_service_resource.go new file mode 100644 index 000000000000..b448fe317297 --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_service_resource.go @@ -0,0 +1,741 @@ +package mobilenetwork + +import ( + "context" + "fmt" + "net/http" + "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/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +type ServiceModel struct { + Name string `tfschema:"name"` + MobileNetworkMobileNetworkId string `tfschema:"mobile_network_id"` + Location string `tfschema:"location"` + PccRules []PccRuleConfigurationModel `tfschema:"pcc_rules"` + ServicePrecedence int64 `tfschema:"service_precedence"` + ServiceQosPolicy []QosPolicyModel `tfschema:"service_qos_policy"` + Tags map[string]string `tfschema:"tags"` +} + +type PccRuleConfigurationModel struct { + RuleName string `tfschema:"rule_name"` + RulePrecedence int64 `tfschema:"rule_precedence"` + RuleQosPolicy []PccRuleQosPolicyModel `tfschema:"rule_qos_policy"` + ServiceDataFlowTemplates []ServiceDataFlowTemplateModel `tfschema:"service_data_flow_templates"` + TrafficControlEnabled bool `tfschema:"traffic_control_enabled"` +} + +type PccRuleQosPolicyModel struct { + AllocationAndRetentionPriorityLevel int64 `tfschema:"allocation_and_retention_priority_level"` + QosIdentifier int64 `tfschema:"qos_indicator"` + GuaranteedBitRate []maxBitRateModel `tfschema:"guaranteed_bit_rate"` + MaximumBitRate []maxBitRateModel `tfschema:"maximum_bit_rate"` + PreemptionCapability string `tfschema:"preemption_capability"` + PreemptionVulnerability string `tfschema:"preemption_vulnerability"` +} + +type maxBitRateModel struct { + Downlink string `tfschema:"downlink"` + Uplink string `tfschema:"uplink"` +} + +type ServiceDataFlowTemplateModel struct { + Direction string `tfschema:"direction"` + Ports []string `tfschema:"ports"` + Protocol []string `tfschema:"protocol"` + RemoteIPList []string `tfschema:"remote_ip_list"` + TemplateName string `tfschema:"template_name"` +} + +type QosPolicyModel struct { + AllocationAndRetentionPriorityLevel int64 `tfschema:"allocation_and_retention_priority_level"` + QosIdentifier int64 `tfschema:"qos_indicator"` + MaximumBitRate []maxBitRateModel `tfschema:"maximum_bit_rate"` + PreemptionCapability string `tfschema:"preemption_capability"` + PreemptionVulnerability string `tfschema:"preemption_vulnerability"` +} + +type MobileNetworkServiceResource struct{} + +var _ sdk.ResourceWithUpdate = MobileNetworkServiceResource{} + +func (r MobileNetworkServiceResource) ResourceType() string { + return "azurerm_mobile_network_service" +} + +func (r MobileNetworkServiceResource) ModelObject() interface{} { + return &ServiceModel{} +} + +func (r MobileNetworkServiceResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return service.ValidateServiceID +} + +func (r MobileNetworkServiceResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "mobile_network_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: mobilenetwork.ValidateMobileNetworkID, + }, + + "location": commonschema.Location(), + + "pcc_rules": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "rule_name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 64), + }, + + "rule_precedence": { + Type: pluginsdk.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(0, 255), + }, + + "rule_qos_policy": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "allocation_and_retention_priority_level": { + Type: pluginsdk.TypeInt, + Optional: true, + }, + + "qos_indicator": { + Type: pluginsdk.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "guaranteed_bit_rate": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "downlink": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^([1-9]\d*|0)(\.\d+)?\s(Kbps|Mbps|Gbps|Tbps)$`), + "The value must be a number followed by Kbps, Mbps, Gbps or Tbps.", + )}, + + "uplink": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^([1-9]\d*|0)(\.\d+)?\s(Kbps|Mbps|Gbps|Tbps)$`), + "The value must be a number followed by Kbps, Mbps, Gbps or Tbps.", + )}, + }, + }, + }, + + "maximum_bit_rate": { + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "downlink": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^([1-9]\d*|0)(\.\d+)?\s(Kbps|Mbps|Gbps|Tbps)$`), + "The value must be a number followed by Kbps, Mbps, Gbps or Tbps.", + )}, + + "uplink": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^([1-9]\d*|0)(\.\d+)?\s(Kbps|Mbps|Gbps|Tbps)$`), + "The value must be a number followed by Kbps, Mbps, Gbps or Tbps.", + )}, + }, + }, + }, + + "preemption_capability": { + Type: pluginsdk.TypeString, + Optional: true, + Default: string(service.PreemptionCapabilityNotPreempt), + ValidateFunc: validation.StringInSlice([]string{ + string(service.PreemptionCapabilityNotPreempt), + string(service.PreemptionCapabilityMayPreempt), + }, false), + }, + + "preemption_vulnerability": { + Type: pluginsdk.TypeString, + Optional: true, + Default: string(service.PreemptionVulnerabilityPreemptable), + ValidateFunc: validation.StringInSlice([]string{ + string(service.PreemptionVulnerabilityNotPreemptable), + string(service.PreemptionVulnerabilityPreemptable), + }, false), + }, + }, + }, + }, + + "service_data_flow_templates": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "direction": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(service.SdfDirectionUplink), + string(service.SdfDirectionDownlink), + string(service.SdfDirectionBidirectional), + }, false), + }, + + "ports": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "protocol": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "remote_ip_list": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "template_name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + }, + }, + }, + + "traffic_control_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + }, + }, + }, + + "service_precedence": { + Type: pluginsdk.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(0, 255), + }, + + "service_qos_policy": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "allocation_and_retention_priority_level": { + Type: pluginsdk.TypeInt, + Optional: true, + Default: 9, + ValidateFunc: validation.IntBetween(1, 127), + }, + + "qos_indicator": { + Type: pluginsdk.TypeInt, + Optional: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "maximum_bit_rate": { + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "downlink": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^\d+(\\.\\d+)?\s(bps|Kbps|Mbps|Gbps|Tbps)$`), + "The value must be a number followed by bps, Kbps, Mbps, Gbps or Tbps.", + )}, + + "uplink": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^\d+(\\.\\d+)?\s(bps|Kbps|Mbps|Gbps|Tbps)$`), + "The value must be a number followed by bps, Kbps, Mbps, Gbps or Tbps.", + )}, + }, + }, + }, + + "preemption_capability": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(service.PreemptionCapabilityNotPreempt), + string(service.PreemptionCapabilityMayPreempt), + }, false), + }, + + "preemption_vulnerability": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(service.PreemptionVulnerabilityNotPreemptable), + string(service.PreemptionVulnerabilityPreemptable), + }, false), + }, + }, + }, + }, + + "tags": commonschema.Tags(), + } +} + +func (r MobileNetworkServiceResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r MobileNetworkServiceResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 180 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model ServiceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.MobileNetwork.ServiceClient + mobileNetworkId, err := mobilenetwork.ParseMobileNetworkID(model.MobileNetworkMobileNetworkId) + if err != nil { + return err + } + + id := service.NewServiceID(mobileNetworkId.SubscriptionId, mobileNetworkId.ResourceGroupName, mobileNetworkId.MobileNetworkName, 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 := &service.Service{ + Location: location.Normalize(model.Location), + Properties: service.ServicePropertiesFormat{ + ServicePrecedence: model.ServicePrecedence, + PccRules: expandPccRuleConfigurationModel(model.PccRules), + ServiceQosPolicy: expandQosPolicyModel(model.ServiceQosPolicy), + }, + Tags: &model.Tags, + } + + if err := client.CreateOrUpdateThenPoll(ctx, id, *properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r MobileNetworkServiceResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 180 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MobileNetwork.ServiceClient + + id, err := service.ParseServiceID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model ServiceModel + 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("pcc_rules") { + properties.Properties.PccRules = expandPccRuleConfigurationModel(model.PccRules) + } + + if metadata.ResourceData.HasChange("service_precedence") { + properties.Properties.ServicePrecedence = model.ServicePrecedence + } + + if metadata.ResourceData.HasChange("service_qos_policy") { + properties.Properties.ServiceQosPolicy = expandQosPolicyModel(model.ServiceQosPolicy) + } + + properties.SystemData = nil + + 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 MobileNetworkServiceResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MobileNetwork.ServiceClient + + id, err := service.ParseServiceID(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 := ServiceModel{ + Name: id.ServiceName, + MobileNetworkMobileNetworkId: mobilenetwork.NewMobileNetworkID(id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName).ID(), + Location: location.Normalize(model.Location), + } + + properties := &model.Properties + + state.PccRules = flattenPccRuleConfigurationModel(properties.PccRules) + + state.ServicePrecedence = properties.ServicePrecedence + + state.ServiceQosPolicy = flattenQosPolicyModel(properties.ServiceQosPolicy) + + if model.Tags != nil { + state.Tags = *model.Tags + } + + return metadata.Encode(&state) + }, + } +} + +func (r MobileNetworkServiceResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 180 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MobileNetwork.ServiceClient + + id, err := service.ParseServiceID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + if err := resourceMobileNetworkChildWaitForDeletion(ctx, id.ID(), func() (*http.Response, error) { + resp, err := client.Get(ctx, *id) + return resp.HttpResponse, err + }); err != nil { + return err + } + + return nil + }, + } +} + +func expandPccRuleConfigurationModel(inputList []PccRuleConfigurationModel) []service.PccRuleConfiguration { + var outputList []service.PccRuleConfiguration + for _, v := range inputList { + input := v + output := service.PccRuleConfiguration{ + RuleName: input.RuleName, + RulePrecedence: input.RulePrecedence, + } + + trafficControlValue := service.TrafficControlPermissionBlocked + if input.TrafficControlEnabled { + trafficControlValue = service.TrafficControlPermissionEnabled + } + output.TrafficControl = &trafficControlValue + + output.RuleQosPolicy = expandPccRuleQosPolicyModel(input.RuleQosPolicy) + + output.ServiceDataFlowTemplates = expandServiceDataFlowTemplateModel(input.ServiceDataFlowTemplates) + + outputList = append(outputList, output) + } + + return outputList +} + +func expandPccRuleQosPolicyModel(inputList []PccRuleQosPolicyModel) *service.PccRuleQosPolicy { + if len(inputList) == 0 { + return nil + } + + input := &inputList[0] + cap := service.PreemptionCapability(input.PreemptionCapability) + vulnerability := service.PreemptionVulnerability(input.PreemptionVulnerability) + output := service.PccRuleQosPolicy{ + AllocationAndRetentionPriorityLevel: &input.AllocationAndRetentionPriorityLevel, + Fiveqi: &input.QosIdentifier, + PreemptionCapability: &cap, + PreemptionVulnerability: &vulnerability, + } + + output.GuaranteedBitRate = expandMaxBitRateModel(input.GuaranteedBitRate) + + if v := expandMaxBitRateModel(input.MaximumBitRate); v != nil { + output.MaximumBitRate = *v + } + + return &output +} + +func expandServiceDataFlowTemplateModel(inputList []ServiceDataFlowTemplateModel) []service.ServiceDataFlowTemplate { + outputList := make([]service.ServiceDataFlowTemplate, 0) + for _, v := range inputList { + input := v + output := service.ServiceDataFlowTemplate{ + Direction: service.SdfDirection(input.Direction), + Ports: &input.Ports, + Protocol: input.Protocol, + RemoteIPList: input.RemoteIPList, + TemplateName: input.TemplateName, + } + + outputList = append(outputList, output) + } + + return outputList +} + +func expandQosPolicyModel(inputList []QosPolicyModel) *service.QosPolicy { + if len(inputList) == 0 { + return nil + } + + input := &inputList[0] + cap := service.PreemptionCapability(input.PreemptionCapability) + vulnerability := service.PreemptionVulnerability(input.PreemptionVulnerability) + output := service.QosPolicy{ + AllocationAndRetentionPriorityLevel: &input.AllocationAndRetentionPriorityLevel, + Fiveqi: &input.QosIdentifier, + PreemptionCapability: &cap, + PreemptionVulnerability: &vulnerability, + } + + if v := expandMaxBitRateModel(input.MaximumBitRate); v != nil { + output.MaximumBitRate = *v + } + + return &output +} + +func flattenPccRuleConfigurationModel(inputList []service.PccRuleConfiguration) []PccRuleConfigurationModel { + var outputList []PccRuleConfigurationModel + + for _, input := range inputList { + output := PccRuleConfigurationModel{ + RuleName: input.RuleName, + RulePrecedence: input.RulePrecedence, + } + + output.RuleQosPolicy = flattenPccRuleQosPolicyModel(input.RuleQosPolicy) + + output.ServiceDataFlowTemplates = flattenServiceDataFlowTemplateModel(&input.ServiceDataFlowTemplates) + + if input.TrafficControl != nil { + output.TrafficControlEnabled = *input.TrafficControl == service.TrafficControlPermissionEnabled + } + + outputList = append(outputList, output) + } + + return outputList +} + +func flattenPccRuleQosPolicyModel(input *service.PccRuleQosPolicy) []PccRuleQosPolicyModel { + var outputList []PccRuleQosPolicyModel + if input == nil { + return outputList + } + + output := PccRuleQosPolicyModel{} + + if input.AllocationAndRetentionPriorityLevel != nil { + output.AllocationAndRetentionPriorityLevel = *input.AllocationAndRetentionPriorityLevel + } + + if input.Fiveqi != nil { + output.QosIdentifier = *input.Fiveqi + } + + output.GuaranteedBitRate = flattenMaxBitRateModel(input.GuaranteedBitRate) + + output.MaximumBitRate = flattenMaxBitRateModel(&input.MaximumBitRate) + + if input.PreemptionCapability != nil { + output.PreemptionCapability = string(*input.PreemptionCapability) + } + + if input.PreemptionVulnerability != nil { + output.PreemptionVulnerability = string(*input.PreemptionVulnerability) + } + + return append(outputList, output) +} + +func flattenServiceDataFlowTemplateModel(inputList *[]service.ServiceDataFlowTemplate) []ServiceDataFlowTemplateModel { + var outputList []ServiceDataFlowTemplateModel + if inputList == nil { + return outputList + } + + for _, input := range *inputList { + output := ServiceDataFlowTemplateModel{ + Direction: string(input.Direction), + Protocol: input.Protocol, + RemoteIPList: input.RemoteIPList, + TemplateName: input.TemplateName, + } + + if input.Ports != nil { + output.Ports = *input.Ports + } + + outputList = append(outputList, output) + } + + return outputList +} + +func flattenQosPolicyModel(input *service.QosPolicy) []QosPolicyModel { + var outputList []QosPolicyModel + if input == nil { + return outputList + } + + output := QosPolicyModel{} + + if input.AllocationAndRetentionPriorityLevel != nil { + output.AllocationAndRetentionPriorityLevel = *input.AllocationAndRetentionPriorityLevel + } + + if input.Fiveqi != nil { + output.QosIdentifier = *input.Fiveqi + } + + output.MaximumBitRate = flattenMaxBitRateModel(&input.MaximumBitRate) + + if input.PreemptionCapability != nil { + output.PreemptionCapability = string(*input.PreemptionCapability) + } + + if input.PreemptionVulnerability != nil { + output.PreemptionVulnerability = string(*input.PreemptionVulnerability) + } + + return append(outputList, output) +} + +// make it return a pointer because some property accept nil value +func expandMaxBitRateModel(inputList []maxBitRateModel) *service.Ambr { + if len(inputList) == 0 { + return nil + } + + input := &inputList[0] + output := service.Ambr{ + Downlink: input.Downlink, + Uplink: input.Uplink, + } + + return &output +} + +func flattenMaxBitRateModel(input *service.Ambr) []maxBitRateModel { + var outputList []maxBitRateModel + if input == nil { + return outputList + } + + output := maxBitRateModel{ + Downlink: input.Downlink, + Uplink: input.Uplink, + } + + return append(outputList, output) +} diff --git a/internal/services/mobilenetwork/mobile_network_service_resource_test.go b/internal/services/mobilenetwork/mobile_network_service_resource_test.go new file mode 100644 index 000000000000..582c9ba18439 --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_service_resource_test.go @@ -0,0 +1,386 @@ +package mobilenetwork_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service" + "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 MobileNetworkServiceResource struct{} + +func TestAccMobileNetworkService_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkServiceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMobileNetworkService_withQosPolicy(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkServiceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.withQosPolicy(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMobileNetworkService_withServiceQosPolicy(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkServiceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.withServiceQosPolicy(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMobileNetworkService_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkServiceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccMobileNetworkService_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkServiceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMobileNetworkService_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_service", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkServiceResource{} + 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 MobileNetworkServiceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := service.ParseServiceID(state.ID) + if err != nil { + return nil, err + } + + client := clients.MobileNetwork.ServiceClient + 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 MobileNetworkServiceResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_service" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + service_precedence = 0 + + pcc_rules { + rule_name = "default-rule" + rule_precedence = 1 + traffic_control_enabled = true + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + + } +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} + +func (r MobileNetworkServiceResource) withQosPolicy(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_service" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + service_precedence = 0 + + pcc_rules { + rule_name = "default-rule" + rule_precedence = 1 + traffic_control_enabled = true + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + + rule_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + + maximum_bit_rate { + downlink = "1 Gbps" + uplink = "500 Mbps" + } + } + } +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} + +func (r MobileNetworkServiceResource) withServiceQosPolicy(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_service" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + service_precedence = 0 + + pcc_rules { + rule_name = "default-rule" + rule_precedence = 1 + traffic_control_enabled = true + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + } + + service_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + maximum_bit_rate { + downlink = "1 Gbps" + uplink = "100 Mbps" + } + } + +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} + +func (r MobileNetworkServiceResource) requiresImport(data acceptance.TestData) string { + config := r.basic(data) + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_service" "import" { + name = azurerm_mobile_network_service.test.name + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + service_precedence = 0 + + pcc_rules { + rule_name = "default-rule" + rule_precedence = 1 + traffic_control_enabled = true + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + } +} +`, config, data.Locations.Primary) +} + +func (r MobileNetworkServiceResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_service" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + service_precedence = 0 + pcc_rules { + rule_name = "default-rule" + rule_precedence = 1 + traffic_control_enabled = true + rule_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + guaranteed_bit_rate { + downlink = "100 Mbps" + uplink = "10 Mbps" + } + maximum_bit_rate { + downlink = "1 Gbps" + uplink = "100 Mbps" + } + } + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + } + service_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + maximum_bit_rate { + downlink = "1 Gbps" + uplink = "100 Mbps" + } + } + tags = { + key = "value" + } + +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} + +func (r MobileNetworkServiceResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_service" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + service_precedence = 0 + pcc_rules { + rule_name = "default-rule-2" + rule_precedence = 1 + traffic_control_enabled = false + rule_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "MayPreempt" + preemption_vulnerability = "NotPreemptable" + guaranteed_bit_rate { + downlink = "200 Mbps" + uplink = "20 Mbps" + } + maximum_bit_rate { + downlink = "2 Gbps" + uplink = "200 Mbps" + } + } + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + } + + service_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + maximum_bit_rate { + downlink = "2 Gbps" + uplink = "200 Mbps" + } + } + tags = { + key = "update" + } + +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/mobilenetwork/registration.go b/internal/services/mobilenetwork/registration.go index b3176fc95e8d..430aa7696951 100644 --- a/internal/services/mobilenetwork/registration.go +++ b/internal/services/mobilenetwork/registration.go @@ -42,12 +42,14 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { func (r Registration) DataSources() []sdk.DataSource { return []sdk.DataSource{ MobileNetworkDataSource{}, + MobileNetworkServiceDataSource{}, } } // Resources returns a list of Resources supported by this Service func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ + MobileNetworkServiceResource{}, MobileNetworkResource{}, } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/README.md new file mode 100644 index 000000000000..de4a2e78c17b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service` Documentation + +The `service` SDK allows for interaction with the Azure Resource Manager Service `mobilenetwork` (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/mobilenetwork/2022-11-01/service" +``` + + +### Client Initialization + +```go +client := service.NewServiceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServiceClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +payload := service.Service{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceClient.Delete` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceClient.Get` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +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: `ServiceClient.UpdateTags` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "serviceValue") + +payload := service.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/mobilenetwork/2022-11-01/service/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/client.go new file mode 100644 index 000000000000..c0efa2f4308f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/client.go @@ -0,0 +1,18 @@ +package service + +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 ServiceClient struct { + Client autorest.Client + baseUri string +} + +func NewServiceClientWithBaseURI(endpoint string) ServiceClient { + return ServiceClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/constants.go new file mode 100644 index 000000000000..5d64a5f582e0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/constants.go @@ -0,0 +1,164 @@ +package service + +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 PreemptionCapability string + +const ( + PreemptionCapabilityMayPreempt PreemptionCapability = "MayPreempt" + PreemptionCapabilityNotPreempt PreemptionCapability = "NotPreempt" +) + +func PossibleValuesForPreemptionCapability() []string { + return []string{ + string(PreemptionCapabilityMayPreempt), + string(PreemptionCapabilityNotPreempt), + } +} + +func parsePreemptionCapability(input string) (*PreemptionCapability, error) { + vals := map[string]PreemptionCapability{ + "maypreempt": PreemptionCapabilityMayPreempt, + "notpreempt": PreemptionCapabilityNotPreempt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionCapability(input) + return &out, nil +} + +type PreemptionVulnerability string + +const ( + PreemptionVulnerabilityNotPreemptable PreemptionVulnerability = "NotPreemptable" + PreemptionVulnerabilityPreemptable PreemptionVulnerability = "Preemptable" +) + +func PossibleValuesForPreemptionVulnerability() []string { + return []string{ + string(PreemptionVulnerabilityNotPreemptable), + string(PreemptionVulnerabilityPreemptable), + } +} + +func parsePreemptionVulnerability(input string) (*PreemptionVulnerability, error) { + vals := map[string]PreemptionVulnerability{ + "notpreemptable": PreemptionVulnerabilityNotPreemptable, + "preemptable": PreemptionVulnerabilityPreemptable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreemptionVulnerability(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleted), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleted": ProvisioningStateDeleted, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SdfDirection string + +const ( + SdfDirectionBidirectional SdfDirection = "Bidirectional" + SdfDirectionDownlink SdfDirection = "Downlink" + SdfDirectionUplink SdfDirection = "Uplink" +) + +func PossibleValuesForSdfDirection() []string { + return []string{ + string(SdfDirectionBidirectional), + string(SdfDirectionDownlink), + string(SdfDirectionUplink), + } +} + +func parseSdfDirection(input string) (*SdfDirection, error) { + vals := map[string]SdfDirection{ + "bidirectional": SdfDirectionBidirectional, + "downlink": SdfDirectionDownlink, + "uplink": SdfDirectionUplink, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SdfDirection(input) + return &out, nil +} + +type TrafficControlPermission string + +const ( + TrafficControlPermissionBlocked TrafficControlPermission = "Blocked" + TrafficControlPermissionEnabled TrafficControlPermission = "Enabled" +) + +func PossibleValuesForTrafficControlPermission() []string { + return []string{ + string(TrafficControlPermissionBlocked), + string(TrafficControlPermissionEnabled), + } +} + +func parseTrafficControlPermission(input string) (*TrafficControlPermission, error) { + vals := map[string]TrafficControlPermission{ + "blocked": TrafficControlPermissionBlocked, + "enabled": TrafficControlPermissionEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrafficControlPermission(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/id_service.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/id_service.go new file mode 100644 index 000000000000..05fbfbf82100 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/id_service.go @@ -0,0 +1,137 @@ +package service + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, mobileNetworkName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + 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.MobileNetworkName, ok = parsed.Parsed["mobileNetworkName"]; !ok { + return nil, fmt.Errorf("the segment 'mobileNetworkName' was not found in the resource id %q", input) + } + + if id.ServiceName, ok = parsed.Parsed["serviceName"]; !ok { + return nil, fmt.Errorf("the segment 'serviceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + 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.MobileNetworkName, ok = parsed.Parsed["mobileNetworkName"]; !ok { + return nil, fmt.Errorf("the segment 'mobileNetworkName' was not found in the resource id %q", input) + } + + if id.ServiceName, ok = parsed.Parsed["serviceName"]; !ok { + return nil, fmt.Errorf("the segment 'serviceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftMobileNetwork", "Microsoft.MobileNetwork", "Microsoft.MobileNetwork"), + resourceids.StaticSegment("staticMobileNetworks", "mobileNetworks", "mobileNetworks"), + resourceids.UserSpecifiedSegment("mobileNetworkName", "mobileNetworkValue"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Mobile Network Name: %q", id.MobileNetworkName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_createorupdate_autorest.go new file mode 100644 index 000000000000..9f3891483db3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_createorupdate_autorest.go @@ -0,0 +1,79 @@ +package service + +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 ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input Service) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input Service) 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 ServiceClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input Service) (*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 ServiceClient) 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/mobilenetwork/2022-11-01/service/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_delete_autorest.go new file mode 100644 index 000000000000..d7941cd7187b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_delete_autorest.go @@ -0,0 +1,78 @@ +package service + +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 ServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) 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 ServiceClient) preparerForDelete(ctx context.Context, id ServiceId) (*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 ServiceClient) 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/mobilenetwork/2022-11-01/service/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_get_autorest.go new file mode 100644 index 000000000000..7d7f11ef63bf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_get_autorest.go @@ -0,0 +1,68 @@ +package service + +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 *Service +} + +// Get ... +func (c ServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ServiceClient) preparerForGet(ctx context.Context, id ServiceId) (*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 ServiceClient) 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/mobilenetwork/2022-11-01/service/method_updatetags_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_updatetags_autorest.go new file mode 100644 index 000000000000..2b62b5c90296 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/method_updatetags_autorest.go @@ -0,0 +1,69 @@ +package service + +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 *Service +} + +// UpdateTags ... +func (c ServiceClient) UpdateTags(ctx context.Context, id ServiceId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + req, err := c.preparerForUpdateTags(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "UpdateTags", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "UpdateTags", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdateTags(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "service.ServiceClient", "UpdateTags", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdateTags prepares the UpdateTags request. +func (c ServiceClient) preparerForUpdateTags(ctx context.Context, id ServiceId, 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 ServiceClient) 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/mobilenetwork/2022-11-01/service/model_ambr.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_ambr.go new file mode 100644 index 000000000000..bb1e9df80767 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_ambr.go @@ -0,0 +1,9 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ambr struct { + Downlink string `json:"downlink"` + Uplink string `json:"uplink"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleconfiguration.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleconfiguration.go new file mode 100644 index 000000000000..f15a71d7979e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleconfiguration.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PccRuleConfiguration struct { + RuleName string `json:"ruleName"` + RulePrecedence int64 `json:"rulePrecedence"` + RuleQosPolicy *PccRuleQosPolicy `json:"ruleQosPolicy,omitempty"` + ServiceDataFlowTemplates []ServiceDataFlowTemplate `json:"serviceDataFlowTemplates"` + TrafficControl *TrafficControlPermission `json:"trafficControl,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleqospolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleqospolicy.go new file mode 100644 index 000000000000..e059d65446ef --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_pccruleqospolicy.go @@ -0,0 +1,13 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PccRuleQosPolicy struct { + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + GuaranteedBitRate *Ambr `json:"guaranteedBitRate,omitempty"` + MaximumBitRate Ambr `json:"maximumBitRate"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_qospolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_qospolicy.go new file mode 100644 index 000000000000..7dd7b8335096 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_qospolicy.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosPolicy struct { + AllocationAndRetentionPriorityLevel *int64 `json:"allocationAndRetentionPriorityLevel,omitempty"` + Fiveqi *int64 `json:"5qi,omitempty"` + MaximumBitRate Ambr `json:"maximumBitRate"` + PreemptionCapability *PreemptionCapability `json:"preemptionCapability,omitempty"` + PreemptionVulnerability *PreemptionVulnerability `json:"preemptionVulnerability,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_service.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_service.go new file mode 100644 index 000000000000..dca0696c0027 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_service.go @@ -0,0 +1,18 @@ +package service + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Service struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ServicePropertiesFormat `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicedataflowtemplate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicedataflowtemplate.go new file mode 100644 index 000000000000..be719de33023 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicedataflowtemplate.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDataFlowTemplate struct { + Direction SdfDirection `json:"direction"` + Ports *[]string `json:"ports,omitempty"` + Protocol []string `json:"protocol"` + RemoteIPList []string `json:"remoteIpList"` + TemplateName string `json:"templateName"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicepropertiesformat.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicepropertiesformat.go new file mode 100644 index 000000000000..aa890a8678d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_servicepropertiesformat.go @@ -0,0 +1,11 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServicePropertiesFormat struct { + PccRules []PccRuleConfiguration `json:"pccRules"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServicePrecedence int64 `json:"servicePrecedence"` + ServiceQosPolicy *QosPolicy `json:"serviceQosPolicy,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_tagsobject.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_tagsobject.go new file mode 100644 index 000000000000..b88d791c2678 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/model_tagsobject.go @@ -0,0 +1,8 @@ +package service + +// 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/mobilenetwork/2022-11-01/service/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/version.go new file mode 100644 index 000000000000..eab1ed2588f1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service/version.go @@ -0,0 +1,12 @@ +package service + +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/service/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1b40286e5d16..55a709be0043 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -379,6 +379,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingend github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingpoliciesandstreaminglocators github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2021-01-01/resource github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork +github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/serverfailover github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/servers github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/capacitypools diff --git a/website/docs/d/mobile_network_service.html.markdown b/website/docs/d/mobile_network_service.html.markdown new file mode 100644 index 000000000000..f035c161d8f1 --- /dev/null +++ b/website/docs/d/mobile_network_service.html.markdown @@ -0,0 +1,129 @@ +--- +subcategory: "Mobile Network" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_mobile_network_service" +description: |- + Get information about a Mobile Network Service. +--- + +# azurerm_mobile_network_service + +Get information about a Mobile Network Service. + +## Example Usage + +```hcl +data "azurerm_mobile_network" "example" { + name = "example-mn" + resource_group_name = "example-rg" +} + +resource "azurerm_mobile_network_service" "example" { + name = "example-mns" + mobile_network_id = data.azurerm_mobile_network.example.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Mobile Network Service. Changing this forces a new Mobile Network Service to be created. + +* `mobile_network_id` - (Required) Specifies the ID of the Mobile Network Service. Changing this forces a new Mobile Network Service to be created. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Mobile Network Service. + +* `location` - The Azure Region where the Mobile Network Service should exist. + +* `service_precedence` - A precedence value that is used to decide between services when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all services configured in the mobile network. + +* `pcc_rules` - A `pcc_rules` block as defined below. The set of PCC Rules that make up this service. + +* `service_qos_policy` - A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rules`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. + +* `tags` - A mapping of tags which should be assigned to the Mobile Network Service. + +--- + +A `pcc_rules` block supports the following: + +* `rule_name` - The name of the rule. This must be unique within the parent service. + +* `rule_precedence` - A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. + +* `rule_qos_policy` - A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. + +* `service_data_flow_templates` - A `service_data_flow_templates` block as defined below. The set of service data flow templates to use for this PCC rule. + +* `traffic_control_enabled` - Determines whether flows that match this data flow policy rule are permitted. + +--- + +A `rule_qos_policy` block supports the following: + +* `allocation_and_retention_priority_level` - QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +* `qos_indicator` - The QoS Indicator (5QI for 5G network /QCI for 4G net work) value identifies a set of QoS characteristics that control QoS forwarding treatment for QoS flows or EPS bearers. + +* `guaranteed_bit_rate` - A `guaranteed_bit_rate` block as defined below. The Guaranteed Bit Rate (GBR) for all service data flows that use this PCC Rule. If it's not specified, there will be no GBR set for the PCC Rule that uses this QoS definition. + +* `maximum_bit_rate` - A `maximum_bit_rate` block as defined below. The Maximum Bit Rate (MBR) for all service data flows that use this PCC Rule or Service. + +* `preemption_capability` - The Preemption Capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +* `preemption_vulnerability` - The Preemption Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +--- + +A `guaranteed_bit_rate` block supports the following: + +* `downlink` - Downlink bit rate. + +* `uplink` - Uplink bit rate. + +--- + +A `service_data_flow_templates` block supports the following: + +* `template_name` - The name of the data flow template. This must be unique within the parent data flow policy rule. + +* `direction` - The direction of this flow. Possible values are `Uplink`, `Downlink` and `Bidirectional`. + +* `protocol` - A list of the allowed protocol(s) for this flow. If you want this flow to be able to use any protocol within the internet protocol suite, use the value `ip`. If you only want to allow a selection of protocols, you must use the corresponding IANA Assigned Internet Protocol Number for each protocol, as described in https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml. For example, for UDP, you must use 17. If you use the value `ip` then you must leave the field `port` unspecified. + +* `remote_ip_list` - The remote IP address(es) to which UEs will connect for this flow. If you want to allow connections on any IP address, use the value `any`. Otherwise, you must provide each of the remote IP addresses to which the packet core instance will connect for this flow. You must provide each IP address in CIDR notation, including the netmask (for example, `192.0.2.54/24`). + +* `ports` - The port(s) to which UEs will connect for this flow. You can specify zero or more ports or port ranges. If you specify one or more ports or port ranges then you must specify a value other than `ip` in the `protocol` field. If it is not specified then connections will be allowed on all ports. Port ranges must be specified as -. For example: [`8080`, `8082-8085`]. + +--- + +A `service_qos_policy` block supports the following: + +* `allocation_and_retention_priority_level` - QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. If this field is not specified then `qos_indicator` is used to derive the ARP value. Defaults to `9`. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +* `qos_indicator` - The QoS Indicator (5QI for 5G network /QCI for 4G net work) value identifies a set of QoS characteristics that control QoS forwarding treatment for QoS flows or EPS bearers. + +* `maximum_bit_rate` - A `maximum_bit_rate` block as defined below. The Maximum Bit Rate (MBR) for all service data flows that use this PCC Rule or Service. + +* `preemption_capability` - The Preemption Capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +* `preemption_vulnerability` - The Preemption Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Possible values are `NotPreemptable` and `Preemptable`. Defaults to `Preemptable`. + +--- + +A `maximum_bit_rate` block supports the following: + +* `downlink` - Downlink bit rate. + +* `uplink` - Uplink bit rate. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the Mobile Network Service. diff --git a/website/docs/r/mobile_network_service.html.markdown b/website/docs/r/mobile_network_service.html.markdown new file mode 100644 index 000000000000..e6d2b7ad830c --- /dev/null +++ b/website/docs/r/mobile_network_service.html.markdown @@ -0,0 +1,199 @@ +--- +subcategory: "Mobile Network" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_mobile_network_service" +description: |- + Manages a Mobile Network Service. +--- + +# azurerm_mobile_network_service + +Manages a Mobile Network Service. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "east us" +} + +resource "azurerm_mobile_network" "example" { + name = "example-mn" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.test.name + mobile_country_code = "001" + mobile_network_code = "01" +} + +resource "azurerm_mobile_network_service" "example" { + name = "example-mns" + mobile_network_id = azurerm_mobile_network.example.id + location = azurerm_resource_group.example.location + service_precedence = 0 + + pcc_rules { + rule_name = "default-rule" + rule_precedence = 1 + traffic_control_enabled = true + + rule_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + + guaranteed_bit_rate { + downlink = "100 Mbps" + uplink = "10 Mbps" + } + + maximum_bit_rate { + downlink = "1 Gbps" + uplink = "100 Mbps" + } + } + + service_data_flow_templates { + direction = "Uplink" + template_name = "IP-to-server" + ports = [] + protocol = ["ip"] + remote_ip_list = ["10.3.4.0/24"] + } + } + + service_qos_policy { + allocation_and_retention_priority_level = 9 + qos_indicator = 9 + preemption_capability = "NotPreempt" + preemption_vulnerability = "Preemptable" + maximum_bit_rate { + downlink = "1 Gbps" + uplink = "100 Mbps" + } + } + + tags = { + key = "value" + } + +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Mobile Network Service. Changing this forces a new Mobile Network Service to be created. + +* `mobile_network_id` - (Required) Specifies the ID of the Mobile Network Service. Changing this forces a new Mobile Network Service to be created. + +* `location` - (Required) Specifies the Azure Region where the Mobile Network Service should exist. Changing this forces a new Mobile Network Service to be created. + +* `service_precedence` - (Required) A precedence value that is used to decide between services when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all services configured in the mobile network. Must be between `0` and `255`. + +* `pcc_rules` - (Required) A `pcc_rules` block as defined below. The set of PCC Rules that make up this service. + +* `service_qos_policy` - (Optional) A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rules`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Mobile Network Service. + +--- + +A `pcc_rules` block supports the following: + +* `rule_name` - (Required) Specifies the name of the rule. This must be unique within the parent service. You must not use any of the following reserved strings - `default`, `requested` or `service`. + +* `rule_precedence` - (Required) A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. Must be between `0` and `255`. + +* `rule_qos_policy` - (Optional) A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. + +* `service_data_flow_templates` - (Required) A `service_data_flow_templates` block as defined below. The set of service data flow templates to use for this PCC rule. + +* `traffic_control_enabled` - (Optional) Determines whether flows that match this data flow policy rule are permitted. Defaults to `true`. + +--- + +A `rule_qos_policy` block supports the following: + +* `allocation_and_retention_priority_level` - (Optional) QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. If this field is not specified then `qos_indicator` is used to derive the ARP value. Defaults to `9`. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +* `qos_indicator` - (Optional) The QoS Indicator (5QI for 5G network /QCI for 4G net work) value identifies a set of QoS characteristics that control QoS forwarding treatment for QoS flows or EPS bearers. Recommended values: 5-9; 69-70; 79-80. Must be between `1` and `127`. Defaults to `9`. + +* `guaranteed_bit_rate` - (Optional) A `guaranteed_bit_rate` block as defined below. The Guaranteed Bit Rate (GBR) for all service data flows that use this PCC Rule. If it's not specified, there will be no GBR set for the PCC Rule that uses this QoS definition. + +* `maximum_bit_rate` - (Required) A `maximum_bit_rate` block as defined below. The Maximum Bit Rate (MBR) for all service data flows that use this PCC Rule or Service. + +* `preemption_capability` - (Optional) The Preemption Capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Possible values are `NotPreempt` and `MayPreempt`, Defaults to `NotPreempt`. + +* `preemption_vulnerability` - (Optional) The Preemption Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Possible values are `NotPreemptable` and `Preemptable`. Defaults to `Preemptable`. + +--- + +A `guaranteed_bit_rate` block supports the following: + +* `downlink` - (Required) Downlink bit rate. Must be a number followed by `Kbps`, `Mbps`, `Gbps` or `Tbps`. + +* `uplink` - (Required) Uplink bit rate. Must be a number followed by `Kbps`, `Mbps`, `Gbps` or `Tbps`. + +--- + +A `service_data_flow_templates` block supports the following: + +* `template_name` - (Required) Specifies the name of the data flow template. This must be unique within the parent data flow policy rule. You must not use any of the following reserved strings - `default`, `requested` or `service`. + +* `direction` - (Required) Specifies the direction of this flow. Possible values are `Uplink`, `Downlink` and `Bidirectional`. + +* `protocol` - (Required) A list of the allowed protocol(s) for this flow. If you want this flow to be able to use any protocol within the internet protocol suite, use the value `ip`. If you only want to allow a selection of protocols, you must use the corresponding IANA Assigned Internet Protocol Number for each protocol, as described in https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml. For example, for UDP, you must use 17. If you use the value `ip` then you must leave the field `port` unspecified. + +* `remote_ip_list` - (Required) Specifies the remote IP address(es) to which UEs will connect for this flow. If you want to allow connections on any IP address, use the value `any`. Otherwise, you must provide each of the remote IP addresses to which the packet core instance will connect for this flow. You must provide each IP address in CIDR notation, including the netmask (for example, `192.0.2.54/24`). + +* `ports` - (Optional) The port(s) to which UEs will connect for this flow. You can specify zero or more ports or port ranges. If you specify one or more ports or port ranges then you must specify a value other than `ip` in the `protocol` field. If it is not specified then connections will be allowed on all ports. Port ranges must be specified as -. For example: [`8080`, `8082-8085`]. + +--- + +A `service_qos_policy` block supports the following: + +* `allocation_and_retention_priority_level` - (Optional) QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. If this field is not specified then `qos_indicator` is used to derive the ARP value. Defaults to `9`. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. + +* `qos_indicator` - (Optional) The QoS Indicator (5QI for 5G network /QCI for 4G net work) value identifies a set of QoS characteristics that control QoS forwarding treatment for QoS flows or EPS bearers. Recommended values: 5-9; 69-70; 79-80. Must be between `1` and `127`. Defaults to `9`. + +* `maximum_bit_rate` - (Required) A `maximum_bit_rate` block as defined below. The Maximum Bit Rate (MBR) for all service data flows that use this PCC Rule or Service. + +* `preemption_capability` - (Optional) The Preemption Capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Possible values are `NotPreempt` and `MayPreempt`, Defaults to `NotPreempt`. + +* `preemption_vulnerability` - (Optional) The Preemption Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Possible values are `NotPreemptable` and `Preemptable`. Defaults to `Preemptable`. + +--- + +A `maximum_bit_rate` block supports the following: + +* `downlink` - (Required) Downlink bit rate. Must be a number followed by `bps`, `Kbps`, `Mbps`, `Gbps` or `Tbps`. + +* `uplink` - (Required) Uplink bit rate. Must be a number followed by `bps`, `Kbps`, `Mbps`, `Gbps` or `Tbps`. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Mobile Network Service. + + + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 180 minutes) Used when creating the Mobile Network Service. +* `read` - (Defaults to 5 minutes) Used when retrieving the Mobile Network Service. +* `update` - (Defaults to 180 minutes) Used when updating the Mobile Network Service. +* `delete` - (Defaults to 180 minutes) Used when deleting the Mobile Network Service. + +## Import + +Mobile Network Service can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_mobile_network_service.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetwork1/services/service1 +``` From 63c102d3ca6915959d05115893593945f010f26e Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Wed, 8 Feb 2023 09:41:20 +0800 Subject: [PATCH 02/11] rename properties --- .../mobile_network_service_data_source.go | 12 ++-- ...mobile_network_service_data_source_test.go | 30 ++++----- .../mobile_network_service_resource.go | 26 ++++---- .../mobile_network_service_resource_test.go | 66 +++++++++---------- website/allowed-subcategories | 2 +- .../d/mobile_network_service.html.markdown | 18 ++--- .../r/mobile_network_service.html.markdown | 30 ++++----- 7 files changed, 92 insertions(+), 92 deletions(-) diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source.go b/internal/services/mobilenetwork/mobile_network_service_data_source.go index de315a54eafd..5b7298a3a929 100644 --- a/internal/services/mobilenetwork/mobile_network_service_data_source.go +++ b/internal/services/mobilenetwork/mobile_network_service_data_source.go @@ -54,22 +54,22 @@ func (r MobileNetworkServiceDataSource) Attributes() map[string]*pluginsdk.Schem "location": commonschema.LocationComputed(), - "pcc_rules": { + "pcc_rule": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "rule_name": { + "name": { Type: pluginsdk.TypeString, Computed: true, }, - "rule_precedence": { + "precedence": { Type: pluginsdk.TypeInt, Computed: true, }, - "rule_qos_policy": { + "qos_policy": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -133,7 +133,7 @@ func (r MobileNetworkServiceDataSource) Attributes() map[string]*pluginsdk.Schem }, }, - "service_data_flow_templates": { + "service_data_flow_template": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -167,7 +167,7 @@ func (r MobileNetworkServiceDataSource) Attributes() map[string]*pluginsdk.Schem }, }, - "template_name": { + "name": { Type: pluginsdk.TypeString, Computed: true, }, diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source_test.go b/internal/services/mobilenetwork/mobile_network_service_data_source_test.go index 4641ed4ee963..9c4d632f5bc6 100644 --- a/internal/services/mobilenetwork/mobile_network_service_data_source_test.go +++ b/internal/services/mobilenetwork/mobile_network_service_data_source_test.go @@ -22,21 +22,21 @@ func TestAccMobileNetworkServiceDataSource_complete(t *testing.T) { Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).Key(`location`).Exists(), check.That(data.ResourceName).Key(`service_precedence`).HasValue("0"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_name`).HasValue("default-rule"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_precedence`).HasValue("1"), - check.That(data.ResourceName).Key(`pcc_rules.0.traffic_control_enabled`).HasValue("true"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.allocation_and_retention_priority_level`).HasValue("9"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.qos_indicator`).HasValue("9"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.preemption_capability`).HasValue("NotPreempt"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.preemption_vulnerability`).HasValue("Preemptable"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.guaranteed_bit_rate.0.downlink`).HasValue("100 Mbps"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.guaranteed_bit_rate.0.uplink`).HasValue("10 Mbps"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.maximum_bit_rate.0.downlink`).HasValue("1 Gbps"), - check.That(data.ResourceName).Key(`pcc_rules.0.rule_qos_policy.0.maximum_bit_rate.0.uplink`).HasValue("100 Mbps"), - check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.direction`).HasValue("Uplink"), - check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.template_name`).HasValue("IP-to-server"), - check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.protocol.0`).HasValue("ip"), - check.That(data.ResourceName).Key(`pcc_rules.0.service_data_flow_templates.0.remote_ip_list.0`).HasValue("10.3.4.0/24"), + check.That(data.ResourceName).Key(`pcc_rule.0.name`).HasValue("default-rule"), + check.That(data.ResourceName).Key(`pcc_rule.0.precedence`).HasValue("1"), + check.That(data.ResourceName).Key(`pcc_rule.0.traffic_control_enabled`).HasValue("true"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.allocation_and_retention_priority_level`).HasValue("9"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.qos_indicator`).HasValue("9"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.preemption_capability`).HasValue("NotPreempt"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.preemption_vulnerability`).HasValue("Preemptable"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.guaranteed_bit_rate.0.downlink`).HasValue("100 Mbps"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.guaranteed_bit_rate.0.uplink`).HasValue("10 Mbps"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.maximum_bit_rate.0.downlink`).HasValue("1 Gbps"), + check.That(data.ResourceName).Key(`pcc_rule.0.qos_policy.0.maximum_bit_rate.0.uplink`).HasValue("100 Mbps"), + check.That(data.ResourceName).Key(`pcc_rule.0.service_data_flow_template.0.direction`).HasValue("Uplink"), + check.That(data.ResourceName).Key(`pcc_rule.0.service_data_flow_template.0.name`).HasValue("IP-to-server"), + check.That(data.ResourceName).Key(`pcc_rule.0.service_data_flow_template.0.protocol.0`).HasValue("ip"), + check.That(data.ResourceName).Key(`pcc_rule.0.service_data_flow_template.0.remote_ip_list.0`).HasValue("10.3.4.0/24"), check.That(data.ResourceName).Key(`service_qos_policy.0.allocation_and_retention_priority_level`).HasValue("9"), check.That(data.ResourceName).Key(`service_qos_policy.0.qos_indicator`).HasValue("9"), check.That(data.ResourceName).Key(`service_qos_policy.0.preemption_capability`).HasValue("NotPreempt"), diff --git a/internal/services/mobilenetwork/mobile_network_service_resource.go b/internal/services/mobilenetwork/mobile_network_service_resource.go index b448fe317297..ea5e23527a97 100644 --- a/internal/services/mobilenetwork/mobile_network_service_resource.go +++ b/internal/services/mobilenetwork/mobile_network_service_resource.go @@ -21,17 +21,17 @@ type ServiceModel struct { Name string `tfschema:"name"` MobileNetworkMobileNetworkId string `tfschema:"mobile_network_id"` Location string `tfschema:"location"` - PccRules []PccRuleConfigurationModel `tfschema:"pcc_rules"` + PccRules []PccRuleConfigurationModel `tfschema:"pcc_rule"` ServicePrecedence int64 `tfschema:"service_precedence"` ServiceQosPolicy []QosPolicyModel `tfschema:"service_qos_policy"` Tags map[string]string `tfschema:"tags"` } type PccRuleConfigurationModel struct { - RuleName string `tfschema:"rule_name"` - RulePrecedence int64 `tfschema:"rule_precedence"` - RuleQosPolicy []PccRuleQosPolicyModel `tfschema:"rule_qos_policy"` - ServiceDataFlowTemplates []ServiceDataFlowTemplateModel `tfschema:"service_data_flow_templates"` + RuleName string `tfschema:"name"` + RulePrecedence int64 `tfschema:"precedence"` + RuleQosPolicy []PccRuleQosPolicyModel `tfschema:"qos_policy"` + ServiceDataFlowTemplates []ServiceDataFlowTemplateModel `tfschema:"service_data_flow_template"` TrafficControlEnabled bool `tfschema:"traffic_control_enabled"` } @@ -54,7 +54,7 @@ type ServiceDataFlowTemplateModel struct { Ports []string `tfschema:"ports"` Protocol []string `tfschema:"protocol"` RemoteIPList []string `tfschema:"remote_ip_list"` - TemplateName string `tfschema:"template_name"` + TemplateName string `tfschema:"name"` } type QosPolicyModel struct { @@ -99,24 +99,24 @@ func (r MobileNetworkServiceResource) Arguments() map[string]*pluginsdk.Schema { "location": commonschema.Location(), - "pcc_rules": { + "pcc_rule": { Type: pluginsdk.TypeList, Required: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "rule_name": { + "name": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 64), }, - "rule_precedence": { + "precedence": { Type: pluginsdk.TypeInt, Required: true, ValidateFunc: validation.IntBetween(0, 255), }, - "rule_qos_policy": { + "qos_policy": { Type: pluginsdk.TypeList, Optional: true, MaxItems: 1, @@ -206,7 +206,7 @@ func (r MobileNetworkServiceResource) Arguments() map[string]*pluginsdk.Schema { }, }, - "service_data_flow_templates": { + "service_data_flow_template": { Type: pluginsdk.TypeList, Required: true, Elem: &pluginsdk.Resource{ @@ -245,7 +245,7 @@ func (r MobileNetworkServiceResource) Arguments() map[string]*pluginsdk.Schema { }, }, - "template_name": { + "name": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringIsNotEmpty, @@ -413,7 +413,7 @@ func (r MobileNetworkServiceResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: properties was nil", id) } - if metadata.ResourceData.HasChange("pcc_rules") { + if metadata.ResourceData.HasChange("pcc_rule") { properties.Properties.PccRules = expandPccRuleConfigurationModel(model.PccRules) } diff --git a/internal/services/mobilenetwork/mobile_network_service_resource_test.go b/internal/services/mobilenetwork/mobile_network_service_resource_test.go index 582c9ba18439..537c839a3377 100644 --- a/internal/services/mobilenetwork/mobile_network_service_resource_test.go +++ b/internal/services/mobilenetwork/mobile_network_service_resource_test.go @@ -152,14 +152,14 @@ resource "azurerm_mobile_network_service" "test" { location = "%s" service_precedence = 0 - pcc_rules { - rule_name = "default-rule" - rule_precedence = 1 + pcc_rule { + name = "default-rule" + precedence = 1 traffic_control_enabled = true - service_data_flow_templates { + service_data_flow_template { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] @@ -180,20 +180,20 @@ resource "azurerm_mobile_network_service" "test" { location = "%s" service_precedence = 0 - pcc_rules { - rule_name = "default-rule" - rule_precedence = 1 + pcc_rule { + name = "default-rule" + precedence = 1 traffic_control_enabled = true - service_data_flow_templates { + service_data_flow_template { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] } - rule_qos_policy { + qos_policy { allocation_and_retention_priority_level = 9 qos_indicator = 9 preemption_capability = "NotPreempt" @@ -219,14 +219,14 @@ resource "azurerm_mobile_network_service" "test" { location = "%s" service_precedence = 0 - pcc_rules { - rule_name = "default-rule" - rule_precedence = 1 + pcc_rule { + name = "default-rule" + precedence = 1 traffic_control_enabled = true - service_data_flow_templates { + service_data_flow_template { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] @@ -259,14 +259,14 @@ resource "azurerm_mobile_network_service" "import" { location = "%s" service_precedence = 0 - pcc_rules { - rule_name = "default-rule" - rule_precedence = 1 + pcc_rule { + name = "default-rule" + precedence = 1 traffic_control_enabled = true - service_data_flow_templates { + service_data_flow_template { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] @@ -285,11 +285,11 @@ resource "azurerm_mobile_network_service" "test" { mobile_network_id = azurerm_mobile_network.test.id location = "%s" service_precedence = 0 - pcc_rules { - rule_name = "default-rule" - rule_precedence = 1 + pcc_rule { + name = "default-rule" + precedence = 1 traffic_control_enabled = true - rule_qos_policy { + qos_policy { allocation_and_retention_priority_level = 9 qos_indicator = 9 preemption_capability = "NotPreempt" @@ -304,9 +304,9 @@ resource "azurerm_mobile_network_service" "test" { } } - service_data_flow_templates { + service_data_flow_template { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] @@ -339,11 +339,11 @@ resource "azurerm_mobile_network_service" "test" { mobile_network_id = azurerm_mobile_network.test.id location = "%s" service_precedence = 0 - pcc_rules { - rule_name = "default-rule-2" - rule_precedence = 1 + pcc_rule { + name = "default-rule-2" + precedence = 1 traffic_control_enabled = false - rule_qos_policy { + qos_policy { allocation_and_retention_priority_level = 9 qos_indicator = 9 preemption_capability = "MayPreempt" @@ -358,9 +358,9 @@ resource "azurerm_mobile_network_service" "test" { } } - service_data_flow_templates { + service_data_flow_template { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] diff --git a/website/allowed-subcategories b/website/allowed-subcategories index 464ada76ec44..f719f7c85ada 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -93,4 +93,4 @@ Template Time Series Insights VMware (AVS) Video Analyzer -Web PubSub \ No newline at end of file +Web PubSub diff --git a/website/docs/d/mobile_network_service.html.markdown b/website/docs/d/mobile_network_service.html.markdown index f035c161d8f1..db25f27a077b 100644 --- a/website/docs/d/mobile_network_service.html.markdown +++ b/website/docs/d/mobile_network_service.html.markdown @@ -42,23 +42,23 @@ In addition to the Arguments listed above - the following Attributes are exporte * `service_precedence` - A precedence value that is used to decide between services when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all services configured in the mobile network. -* `pcc_rules` - A `pcc_rules` block as defined below. The set of PCC Rules that make up this service. +* `pcc_rule` - A `pcc_rule` block as defined below. The set of PCC Rules that make up this service. -* `service_qos_policy` - A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rules`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. +* `service_qos_policy` - A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rule`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. * `tags` - A mapping of tags which should be assigned to the Mobile Network Service. --- -A `pcc_rules` block supports the following: +A `pcc_rule` block supports the following: -* `rule_name` - The name of the rule. This must be unique within the parent service. +* `name` - The name of the rule. This must be unique within the parent service. -* `rule_precedence` - A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. +* `precedence` - A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. -* `rule_qos_policy` - A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. +* `qos_policy` - A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. -* `service_data_flow_templates` - A `service_data_flow_templates` block as defined below. The set of service data flow templates to use for this PCC rule. +* `service_data_flow_template` - A `service_data_flow_template` block as defined below. The set of service data flow templates to use for this PCC rule. * `traffic_control_enabled` - Determines whether flows that match this data flow policy rule are permitted. @@ -88,9 +88,9 @@ A `guaranteed_bit_rate` block supports the following: --- -A `service_data_flow_templates` block supports the following: +A `service_data_flow_template` block supports the following: -* `template_name` - The name of the data flow template. This must be unique within the parent data flow policy rule. +* `name` - The name of the data flow template. This must be unique within the parent data flow policy rule. * `direction` - The direction of this flow. Possible values are `Uplink`, `Downlink` and `Bidirectional`. diff --git a/website/docs/r/mobile_network_service.html.markdown b/website/docs/r/mobile_network_service.html.markdown index e6d2b7ad830c..42157e12bfd6 100644 --- a/website/docs/r/mobile_network_service.html.markdown +++ b/website/docs/r/mobile_network_service.html.markdown @@ -32,12 +32,12 @@ resource "azurerm_mobile_network_service" "example" { location = azurerm_resource_group.example.location service_precedence = 0 - pcc_rules { - rule_name = "default-rule" - rule_precedence = 1 + pcc_rule { + name = "default-rule" + precedence = 1 traffic_control_enabled = true - rule_qos_policy { + qos_policy { allocation_and_retention_priority_level = 9 qos_indicator = 9 preemption_capability = "NotPreempt" @@ -56,7 +56,7 @@ resource "azurerm_mobile_network_service" "example" { service_data_flow_templates { direction = "Uplink" - template_name = "IP-to-server" + name = "IP-to-server" ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] @@ -93,29 +93,29 @@ The following arguments are supported: * `service_precedence` - (Required) A precedence value that is used to decide between services when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all services configured in the mobile network. Must be between `0` and `255`. -* `pcc_rules` - (Required) A `pcc_rules` block as defined below. The set of PCC Rules that make up this service. +* `pcc_rule` - (Required) A `pcc_rule` block as defined below. The set of PCC Rules that make up this service. -* `service_qos_policy` - (Optional) A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rules`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. +* `service_qos_policy` - (Optional) A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rule`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. * `tags` - (Optional) A mapping of tags which should be assigned to the Mobile Network Service. --- -A `pcc_rules` block supports the following: +A `pcc_rule` block supports the following: -* `rule_name` - (Required) Specifies the name of the rule. This must be unique within the parent service. You must not use any of the following reserved strings - `default`, `requested` or `service`. +* `name` - (Required) Specifies the name of the rule. This must be unique within the parent service. You must not use any of the following reserved strings - `default`, `requested` or `service`. -* `rule_precedence` - (Required) A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. Must be between `0` and `255`. +* `precedence` - (Required) A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. Must be between `0` and `255`. -* `rule_qos_policy` - (Optional) A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. +* `qos_policy` - (Optional) A `qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. -* `service_data_flow_templates` - (Required) A `service_data_flow_templates` block as defined below. The set of service data flow templates to use for this PCC rule. +* `service_data_flow_template` - (Required) A `service_data_flow_template` block as defined below. The set of service data flow templates to use for this PCC rule. * `traffic_control_enabled` - (Optional) Determines whether flows that match this data flow policy rule are permitted. Defaults to `true`. --- -A `rule_qos_policy` block supports the following: +A `qos_policy` block supports the following: * `allocation_and_retention_priority_level` - (Optional) QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. If this field is not specified then `qos_indicator` is used to derive the ARP value. Defaults to `9`. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. @@ -139,9 +139,9 @@ A `guaranteed_bit_rate` block supports the following: --- -A `service_data_flow_templates` block supports the following: +A `service_data_flow_template` block supports the following: -* `template_name` - (Required) Specifies the name of the data flow template. This must be unique within the parent data flow policy rule. You must not use any of the following reserved strings - `default`, `requested` or `service`. +* `name` - (Required) Specifies the name of the data flow template. This must be unique within the parent data flow policy rule. You must not use any of the following reserved strings - `default`, `requested` or `service`. * `direction` - (Required) Specifies the direction of this flow. Possible values are `Uplink`, `Downlink` and `Bidirectional`. From 62b25254abd58004c92e086c9c0fc1b90926c044 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Wed, 8 Feb 2023 10:32:50 +0800 Subject: [PATCH 03/11] make generate --- website/allowed-subcategories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/allowed-subcategories b/website/allowed-subcategories index f719f7c85ada..464ada76ec44 100644 --- a/website/allowed-subcategories +++ b/website/allowed-subcategories @@ -93,4 +93,4 @@ Template Time Series Insights VMware (AVS) Video Analyzer -Web PubSub +Web PubSub \ No newline at end of file From 9201ecd655c2ab19f9d33fdebe69d5b9bb1ebaf7 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Thu, 9 Feb 2023 22:24:08 +0800 Subject: [PATCH 04/11] remove unused forcenew --- .../mobilenetwork/mobile_network_service_data_source.go | 2 -- website/docs/d/mobile_network_service.html.markdown | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source.go b/internal/services/mobilenetwork/mobile_network_service_data_source.go index 5b7298a3a929..9a54db2d083b 100644 --- a/internal/services/mobilenetwork/mobile_network_service_data_source.go +++ b/internal/services/mobilenetwork/mobile_network_service_data_source.go @@ -36,14 +36,12 @@ func (r MobileNetworkServiceDataSource) Arguments() map[string]*pluginsdk.Schema "name": { Type: pluginsdk.TypeString, Required: true, - ForceNew: true, ValidateFunc: validation.StringIsNotEmpty, }, "mobile_network_id": { Type: pluginsdk.TypeString, Required: true, - ForceNew: true, ValidateFunc: mobilenetwork.ValidateMobileNetworkID, }, } diff --git a/website/docs/d/mobile_network_service.html.markdown b/website/docs/d/mobile_network_service.html.markdown index db25f27a077b..db6246bffdee 100644 --- a/website/docs/d/mobile_network_service.html.markdown +++ b/website/docs/d/mobile_network_service.html.markdown @@ -28,9 +28,9 @@ resource "azurerm_mobile_network_service" "example" { The following arguments are supported: -* `name` - (Required) Specifies the name which should be used for this Mobile Network Service. Changing this forces a new Mobile Network Service to be created. +* `name` - (Required) Specifies the name which should be used for this Mobile Network Service. -* `mobile_network_id` - (Required) Specifies the ID of the Mobile Network Service. Changing this forces a new Mobile Network Service to be created. +* `mobile_network_id` - (Required) Specifies the ID of the Mobile Network Service. ## Attributes Reference From a7965f42b18e3fa43f076349d1579aea7d5dfc96 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Fri, 10 Feb 2023 10:07:22 +0800 Subject: [PATCH 05/11] doc enhancement --- .../mobile_network_service_resource.go | 44 +++++++++---------- .../mobile_network_service_resource_test.go | 1 - .../d/mobile_network_service.html.markdown | 8 ++-- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/internal/services/mobilenetwork/mobile_network_service_resource.go b/internal/services/mobilenetwork/mobile_network_service_resource.go index ea5e23527a97..b03b42f55c76 100644 --- a/internal/services/mobilenetwork/mobile_network_service_resource.go +++ b/internal/services/mobilenetwork/mobile_network_service_resource.go @@ -36,15 +36,15 @@ type PccRuleConfigurationModel struct { } type PccRuleQosPolicyModel struct { - AllocationAndRetentionPriorityLevel int64 `tfschema:"allocation_and_retention_priority_level"` - QosIdentifier int64 `tfschema:"qos_indicator"` - GuaranteedBitRate []maxBitRateModel `tfschema:"guaranteed_bit_rate"` - MaximumBitRate []maxBitRateModel `tfschema:"maximum_bit_rate"` - PreemptionCapability string `tfschema:"preemption_capability"` - PreemptionVulnerability string `tfschema:"preemption_vulnerability"` + AllocationAndRetentionPriorityLevel int64 `tfschema:"allocation_and_retention_priority_level"` + QosIdentifier int64 `tfschema:"qos_indicator"` + GuaranteedBitRate []BitRateModel `tfschema:"guaranteed_bit_rate"` + MaximumBitRate []BitRateModel `tfschema:"maximum_bit_rate"` + PreemptionCapability string `tfschema:"preemption_capability"` + PreemptionVulnerability string `tfschema:"preemption_vulnerability"` } -type maxBitRateModel struct { +type BitRateModel struct { Downlink string `tfschema:"downlink"` Uplink string `tfschema:"uplink"` } @@ -58,11 +58,11 @@ type ServiceDataFlowTemplateModel struct { } type QosPolicyModel struct { - AllocationAndRetentionPriorityLevel int64 `tfschema:"allocation_and_retention_priority_level"` - QosIdentifier int64 `tfschema:"qos_indicator"` - MaximumBitRate []maxBitRateModel `tfschema:"maximum_bit_rate"` - PreemptionCapability string `tfschema:"preemption_capability"` - PreemptionVulnerability string `tfschema:"preemption_vulnerability"` + AllocationAndRetentionPriorityLevel int64 `tfschema:"allocation_and_retention_priority_level"` + QosIdentifier int64 `tfschema:"qos_indicator"` + MaximumBitRate []BitRateModel `tfschema:"maximum_bit_rate"` + PreemptionCapability string `tfschema:"preemption_capability"` + PreemptionVulnerability string `tfschema:"preemption_vulnerability"` } type MobileNetworkServiceResource struct{} @@ -555,9 +555,9 @@ func expandPccRuleQosPolicyModel(inputList []PccRuleQosPolicyModel) *service.Pcc PreemptionVulnerability: &vulnerability, } - output.GuaranteedBitRate = expandMaxBitRateModel(input.GuaranteedBitRate) + output.GuaranteedBitRate = expandBitRateModel(input.GuaranteedBitRate) - if v := expandMaxBitRateModel(input.MaximumBitRate); v != nil { + if v := expandBitRateModel(input.MaximumBitRate); v != nil { output.MaximumBitRate = *v } @@ -597,7 +597,7 @@ func expandQosPolicyModel(inputList []QosPolicyModel) *service.QosPolicy { PreemptionVulnerability: &vulnerability, } - if v := expandMaxBitRateModel(input.MaximumBitRate); v != nil { + if v := expandBitRateModel(input.MaximumBitRate); v != nil { output.MaximumBitRate = *v } @@ -643,9 +643,9 @@ func flattenPccRuleQosPolicyModel(input *service.PccRuleQosPolicy) []PccRuleQosP output.QosIdentifier = *input.Fiveqi } - output.GuaranteedBitRate = flattenMaxBitRateModel(input.GuaranteedBitRate) + output.GuaranteedBitRate = flattenBitRateModel(input.GuaranteedBitRate) - output.MaximumBitRate = flattenMaxBitRateModel(&input.MaximumBitRate) + output.MaximumBitRate = flattenBitRateModel(&input.MaximumBitRate) if input.PreemptionCapability != nil { output.PreemptionCapability = string(*input.PreemptionCapability) @@ -698,7 +698,7 @@ func flattenQosPolicyModel(input *service.QosPolicy) []QosPolicyModel { output.QosIdentifier = *input.Fiveqi } - output.MaximumBitRate = flattenMaxBitRateModel(&input.MaximumBitRate) + output.MaximumBitRate = flattenBitRateModel(&input.MaximumBitRate) if input.PreemptionCapability != nil { output.PreemptionCapability = string(*input.PreemptionCapability) @@ -712,7 +712,7 @@ func flattenQosPolicyModel(input *service.QosPolicy) []QosPolicyModel { } // make it return a pointer because some property accept nil value -func expandMaxBitRateModel(inputList []maxBitRateModel) *service.Ambr { +func expandBitRateModel(inputList []BitRateModel) *service.Ambr { if len(inputList) == 0 { return nil } @@ -726,13 +726,13 @@ func expandMaxBitRateModel(inputList []maxBitRateModel) *service.Ambr { return &output } -func flattenMaxBitRateModel(input *service.Ambr) []maxBitRateModel { - var outputList []maxBitRateModel +func flattenBitRateModel(input *service.Ambr) []BitRateModel { + var outputList []BitRateModel if input == nil { return outputList } - output := maxBitRateModel{ + output := BitRateModel{ Downlink: input.Downlink, Uplink: input.Uplink, } diff --git a/internal/services/mobilenetwork/mobile_network_service_resource_test.go b/internal/services/mobilenetwork/mobile_network_service_resource_test.go index 537c839a3377..d5205ebc0b6c 100644 --- a/internal/services/mobilenetwork/mobile_network_service_resource_test.go +++ b/internal/services/mobilenetwork/mobile_network_service_resource_test.go @@ -160,7 +160,6 @@ resource "azurerm_mobile_network_service" "test" { service_data_flow_template { direction = "Uplink" name = "IP-to-server" - ports = [] protocol = ["ip"] remote_ip_list = ["10.3.4.0/24"] } diff --git a/website/docs/d/mobile_network_service.html.markdown b/website/docs/d/mobile_network_service.html.markdown index db6246bffdee..350ab0d8a81a 100644 --- a/website/docs/d/mobile_network_service.html.markdown +++ b/website/docs/d/mobile_network_service.html.markdown @@ -94,11 +94,11 @@ A `service_data_flow_template` block supports the following: * `direction` - The direction of this flow. Possible values are `Uplink`, `Downlink` and `Bidirectional`. -* `protocol` - A list of the allowed protocol(s) for this flow. If you want this flow to be able to use any protocol within the internet protocol suite, use the value `ip`. If you only want to allow a selection of protocols, you must use the corresponding IANA Assigned Internet Protocol Number for each protocol, as described in https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml. For example, for UDP, you must use 17. If you use the value `ip` then you must leave the field `port` unspecified. +* `protocol` - A list of the allowed protocol(s) for this flow. -* `remote_ip_list` - The remote IP address(es) to which UEs will connect for this flow. If you want to allow connections on any IP address, use the value `any`. Otherwise, you must provide each of the remote IP addresses to which the packet core instance will connect for this flow. You must provide each IP address in CIDR notation, including the netmask (for example, `192.0.2.54/24`). +* `remote_ip_list` - The remote IP address(es) to which UEs will connect for this flow. -* `ports` - The port(s) to which UEs will connect for this flow. You can specify zero or more ports or port ranges. If you specify one or more ports or port ranges then you must specify a value other than `ip` in the `protocol` field. If it is not specified then connections will be allowed on all ports. Port ranges must be specified as -. For example: [`8080`, `8082-8085`]. +* `ports` - The port(s) to which UEs will connect for this flow. You can specify zero or more ports or port ranges. --- @@ -112,7 +112,7 @@ A `service_qos_policy` block supports the following: * `preemption_capability` - The Preemption Capability of a QoS Flow controls whether it can preempt another QoS Flow with a lower priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. -* `preemption_vulnerability` - The Preemption Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. Possible values are `NotPreemptable` and `Preemptable`. Defaults to `Preemptable`. +* `preemption_vulnerability` - The Preemption Vulnerability of a QoS Flow controls whether it can be preempted by QoS Flow with a higher priority level. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. --- From 642e2b2e6295038893dd5f6d10b02cd2779c1303 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Mon, 13 Feb 2023 10:25:14 +0800 Subject: [PATCH 06/11] refresh vendor --- vendor/modules.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/modules.txt b/vendor/modules.txt index 470eef36f343..cd1ee460f6de 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -388,6 +388,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingend github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingpoliciesandstreaminglocators github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2021-01-01/resource github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork +github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/site github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/serverfailover github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/servers From a83858bcaa67563a54fad98bfb392c6450df7948 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Mon, 13 Feb 2023 10:26:17 +0800 Subject: [PATCH 07/11] update code --- .../mobile_network_service_data_source.go | 7 +++--- .../mobile_network_service_resource.go | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source.go b/internal/services/mobilenetwork/mobile_network_service_data_source.go index 9a54db2d083b..4b17c3453476 100644 --- a/internal/services/mobilenetwork/mobile_network_service_data_source.go +++ b/internal/services/mobilenetwork/mobile_network_service_data_source.go @@ -262,18 +262,19 @@ func (r MobileNetworkServiceDataSource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", id, err) } - model := resp.Model - if model == nil { + if resp.Model == nil { return fmt.Errorf("retrieving %s: model was nil", id) } + model := *resp.Model + state := ServiceModel{ Name: id.ServiceName, MobileNetworkMobileNetworkId: mobilenetwork.NewMobileNetworkID(id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName).ID(), Location: location.Normalize(model.Location), } - properties := &model.Properties + properties := model.Properties state.PccRules = flattenPccRuleConfigurationModel(properties.PccRules) diff --git a/internal/services/mobilenetwork/mobile_network_service_resource.go b/internal/services/mobilenetwork/mobile_network_service_resource.go index b03b42f55c76..05679d3cb70a 100644 --- a/internal/services/mobilenetwork/mobile_network_service_resource.go +++ b/internal/services/mobilenetwork/mobile_network_service_resource.go @@ -408,11 +408,12 @@ func (r MobileNetworkServiceResource) Update() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", *id, err) } - properties := resp.Model - if properties == nil { + if resp.Model == nil { return fmt.Errorf("retrieving %s: properties was nil", id) } + properties := *resp.Model + if metadata.ResourceData.HasChange("pcc_rule") { properties.Properties.PccRules = expandPccRuleConfigurationModel(model.PccRules) } @@ -431,7 +432,7 @@ func (r MobileNetworkServiceResource) Update() sdk.ResourceFunc { properties.Tags = &model.Tags } - if err := client.CreateOrUpdateThenPoll(ctx, *id, *properties); err != nil { + if err := client.CreateOrUpdateThenPoll(ctx, *id, properties); err != nil { return fmt.Errorf("updating %s: %+v", *id, err) } @@ -460,18 +461,19 @@ func (r MobileNetworkServiceResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", *id, err) } - model := resp.Model - if model == nil { + if resp.Model == nil { return fmt.Errorf("retrieving %s: model was nil", id) } + model := *resp.Model + state := ServiceModel{ Name: id.ServiceName, MobileNetworkMobileNetworkId: mobilenetwork.NewMobileNetworkID(id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName).ID(), Location: location.Normalize(model.Location), } - properties := &model.Properties + properties := model.Properties state.PccRules = flattenPccRuleConfigurationModel(properties.PccRules) @@ -546,12 +548,12 @@ func expandPccRuleQosPolicyModel(inputList []PccRuleQosPolicyModel) *service.Pcc } input := &inputList[0] - cap := service.PreemptionCapability(input.PreemptionCapability) + capability := service.PreemptionCapability(input.PreemptionCapability) vulnerability := service.PreemptionVulnerability(input.PreemptionVulnerability) output := service.PccRuleQosPolicy{ AllocationAndRetentionPriorityLevel: &input.AllocationAndRetentionPriorityLevel, Fiveqi: &input.QosIdentifier, - PreemptionCapability: &cap, + PreemptionCapability: &capability, PreemptionVulnerability: &vulnerability, } @@ -588,12 +590,12 @@ func expandQosPolicyModel(inputList []QosPolicyModel) *service.QosPolicy { } input := &inputList[0] - cap := service.PreemptionCapability(input.PreemptionCapability) + capability := service.PreemptionCapability(input.PreemptionCapability) vulnerability := service.PreemptionVulnerability(input.PreemptionVulnerability) output := service.QosPolicy{ AllocationAndRetentionPriorityLevel: &input.AllocationAndRetentionPriorityLevel, Fiveqi: &input.QosIdentifier, - PreemptionCapability: &cap, + PreemptionCapability: &capability, PreemptionVulnerability: &vulnerability, } From 1cc667843111f7d3d589114b793e1740d8cda4f9 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Mon, 13 Feb 2023 14:05:31 +0800 Subject: [PATCH 08/11] doc update --- .../docs/d/mobile_network_service.html.markdown | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/website/docs/d/mobile_network_service.html.markdown b/website/docs/d/mobile_network_service.html.markdown index 350ab0d8a81a..fd52d85a2a6b 100644 --- a/website/docs/d/mobile_network_service.html.markdown +++ b/website/docs/d/mobile_network_service.html.markdown @@ -40,11 +40,11 @@ In addition to the Arguments listed above - the following Attributes are exporte * `location` - The Azure Region where the Mobile Network Service should exist. -* `service_precedence` - A precedence value that is used to decide between services when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all services configured in the mobile network. +* `service_precedence` - A precedence value that is used to decide between services when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. * `pcc_rule` - A `pcc_rule` block as defined below. The set of PCC Rules that make up this service. -* `service_qos_policy` - A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. This can be overridden for particular flows using the ruleQosPolicy field in a `pcc_rule`. If this field is not specified then the `sim_policy` of User Equipment (UE) will define the QoS settings. +* `service_qos_policy` - A `service_qos_policy` block as defined below. The QoS policy to use for packets matching this service. * `tags` - A mapping of tags which should be assigned to the Mobile Network Service. @@ -54,9 +54,9 @@ A `pcc_rule` block supports the following: * `name` - The name of the rule. This must be unique within the parent service. -* `precedence` - A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. This value should be unique among all data flow policy rules configured in the mobile network. +* `precedence` - A precedence value that is used to decide between data flow policy rules when identifying the QoS values to use for a particular SIM. A lower value means a higher priority. -* `qos_policy` - A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. If this field is not specified then the Service will define the QoS settings. +* `qos_policy` - A `rule_qos_policy` block as defined below. The QoS policy to use for packets matching this rule. * `service_data_flow_template` - A `service_data_flow_template` block as defined below. The set of service data flow templates to use for this PCC rule. @@ -66,11 +66,11 @@ A `pcc_rule` block supports the following: A `rule_qos_policy` block supports the following: -* `allocation_and_retention_priority_level` - QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. +* `allocation_and_retention_priority_level` - QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority. * `qos_indicator` - The QoS Indicator (5QI for 5G network /QCI for 4G net work) value identifies a set of QoS characteristics that control QoS forwarding treatment for QoS flows or EPS bearers. -* `guaranteed_bit_rate` - A `guaranteed_bit_rate` block as defined below. The Guaranteed Bit Rate (GBR) for all service data flows that use this PCC Rule. If it's not specified, there will be no GBR set for the PCC Rule that uses this QoS definition. +* `guaranteed_bit_rate` - A `guaranteed_bit_rate` block as defined below. The Guaranteed Bit Rate (GBR) for all service data flows that use this PCC Rule. * `maximum_bit_rate` - A `maximum_bit_rate` block as defined below. The Maximum Bit Rate (MBR) for all service data flows that use this PCC Rule or Service. @@ -104,7 +104,7 @@ A `service_data_flow_template` block supports the following: A `service_qos_policy` block supports the following: -* `allocation_and_retention_priority_level` - QoS Flow allocation and retention priority (ARP) level. Flows with higher priority preempt flows with lower priority, if the settings of `preemption_capability` and `preemption_vulnerability` allow it. 1 is the highest level of priority. If this field is not specified then `qos_indicator` is used to derive the ARP value. Defaults to `9`. See 3GPP TS23.501 section 5.7.2.2 for a full description of the ARP parameters. +* `allocation_and_retention_priority_level` - QoS Flow allocation and retention priority (ARP) level. * `qos_indicator` - The QoS Indicator (5QI for 5G network /QCI for 4G net work) value identifies a set of QoS characteristics that control QoS forwarding treatment for QoS flows or EPS bearers. From fb2eb489dc089caab9e118d0abd0d9f7e1d64c87 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Wed, 15 Feb 2023 10:08:09 +0800 Subject: [PATCH 09/11] update code --- .../services/mobilenetwork/mobile_network_service_resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/mobilenetwork/mobile_network_service_resource.go b/internal/services/mobilenetwork/mobile_network_service_resource.go index 05679d3cb70a..9d35c1d1612a 100644 --- a/internal/services/mobilenetwork/mobile_network_service_resource.go +++ b/internal/services/mobilenetwork/mobile_network_service_resource.go @@ -367,7 +367,7 @@ func (r MobileNetworkServiceResource) Create() sdk.ResourceFunc { return metadata.ResourceRequiresImport(r.ResourceType(), id) } - properties := &service.Service{ + properties := service.Service{ Location: location.Normalize(model.Location), Properties: service.ServicePropertiesFormat{ ServicePrecedence: model.ServicePrecedence, @@ -377,7 +377,7 @@ func (r MobileNetworkServiceResource) Create() sdk.ResourceFunc { Tags: &model.Tags, } - if err := client.CreateOrUpdateThenPoll(ctx, id, *properties); err != nil { + if err := client.CreateOrUpdateThenPoll(ctx, id, properties); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } From 5a1029d71cae60db45e6a4dfce4040812098ea1e Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Wed, 15 Feb 2023 19:54:28 +0800 Subject: [PATCH 10/11] refresh vendor --- vendor/modules.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/vendor/modules.txt b/vendor/modules.txt index a25ebe3235a4..b7e0cac144fb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -378,6 +378,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingend github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingpoliciesandstreaminglocators github.com/hashicorp/go-azure-sdk/resource-manager/mixedreality/2021-01-01/resource github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork +github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/service github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/simgroup github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/site github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice From 8cfaf3ddc279a88ed0b31e1a1a6667022cf657d3 Mon Sep 17 00:00:00 2001 From: ziyeqf Date: Thu, 16 Feb 2023 09:44:25 +0800 Subject: [PATCH 11/11] update code --- .../mobilenetwork/mobile_network_service_data_source.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/services/mobilenetwork/mobile_network_service_data_source.go b/internal/services/mobilenetwork/mobile_network_service_data_source.go index 4b17c3453476..543975cccc53 100644 --- a/internal/services/mobilenetwork/mobile_network_service_data_source.go +++ b/internal/services/mobilenetwork/mobile_network_service_data_source.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/mobilenetwork" @@ -255,10 +254,6 @@ func (r MobileNetworkServiceDataSource) Read() sdk.ResourceFunc { 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) }