diff --git a/internal/services/mobilenetwork/client/client.go b/internal/services/mobilenetwork/client/client.go index 9de9d92de42e..fe08a2549a5f 100644 --- a/internal/services/mobilenetwork/client/client.go +++ b/internal/services/mobilenetwork/client/client.go @@ -3,11 +3,13 @@ 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/site" + "github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { MobileNetworkClient *mobilenetwork.MobileNetworkClient + SliceClient *slice.SliceClient SiteClient *site.SiteClient } @@ -18,8 +20,12 @@ func NewClient(o *common.ClientOptions) *Client { siteClient := site.NewSiteClientWithBaseURI(o.ResourceManagerEndpoint) o.ConfigureClient(&siteClient.Client, o.ResourceManagerAuthorizer) + sliceClient := slice.NewSliceClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&sliceClient.Client, o.ResourceManagerAuthorizer) + return &Client{ MobileNetworkClient: &mobileNetworkClient, SiteClient: &siteClient, + SliceClient: &sliceClient, } } diff --git a/internal/services/mobilenetwork/mobile_network_slice_data_source.go b/internal/services/mobilenetwork/mobile_network_slice_data_source.go new file mode 100644 index 000000000000..cab5aba4771a --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_slice_data_source.go @@ -0,0 +1,137 @@ +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/slice" + "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 SliceDataSource struct{} + +var _ sdk.DataSource = SliceDataSource{} + +func (r SliceDataSource) ResourceType() string { + return "azurerm_mobile_network_slice" +} + +func (r SliceDataSource) ModelObject() interface{} { + return &SliceModel{} +} + +func (r SliceDataSource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return slice.ValidateSliceID +} + +func (r SliceDataSource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "mobile_network_id": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: mobilenetwork.ValidateMobileNetworkID, + }, + } +} + +func (r SliceDataSource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + + "description": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "location": commonschema.LocationComputed(), + + "single_network_slice_selection_assistance_information": { + Type: pluginsdk.TypeList, + Computed: true, + + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "slice_differentiator": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "slice_service_type": { + Type: pluginsdk.TypeInt, + Computed: true, + }, + }, + }, + }, + + "tags": commonschema.TagsDataSource(), + } +} + +func (r SliceDataSource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var metaModel SliceModel + if err := metadata.Decode(&metaModel); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.MobileNetwork.SliceClient + mobileNetworkId, err := mobilenetwork.ParseMobileNetworkID(metaModel.MobileNetworkMobileNetworkId) + if err != nil { + return err + } + + id := slice.NewSliceID(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) + } + + if resp.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) + } + + model := *resp.Model + + state := SliceModel{ + Name: id.SliceName, + MobileNetworkMobileNetworkId: mobilenetwork.NewMobileNetworkID(id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName).ID(), + Location: location.Normalize(model.Location), + } + + properties := model.Properties + if properties.Description != nil { + state.Description = *properties.Description + } + + state.Snssai = flattenSnssaiModel(properties.Snssai) + + if resp.Model.Tags != nil { + state.Tags = *model.Tags + } + + metadata.SetID(id) + + return metadata.Encode(&state) + }, + } +} diff --git a/internal/services/mobilenetwork/mobile_network_slice_data_source_test.go b/internal/services/mobilenetwork/mobile_network_slice_data_source_test.go new file mode 100644 index 000000000000..9ed68f0ff30f --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_slice_data_source_test.go @@ -0,0 +1,42 @@ +package mobilenetwork_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" +) + +type MobileNetworkSliceDataSource struct{} + +func TestAccMobileNetworkSliceDataSource_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_slice", "test") + + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + d := MobileNetworkSliceDataSource{} + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: d.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key(`location`).Exists(), + check.That(data.ResourceName).Key(`description`).HasValue("my favorite slice"), + check.That(data.ResourceName).Key(`single_network_slice_selection_assistance_information.0.slice_service_type`).HasValue("1"), + check.That(data.ResourceName).Key("tags.%").HasValue("1"), + ), + }, + }) +} + +func (r MobileNetworkSliceDataSource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +data "azurerm_mobile_network_slice" "test" { + name = azurerm_mobile_network_slice.test.name + mobile_network_id = azurerm_mobile_network_slice.test.mobile_network_id +} +`, MobileNetworkSliceResource{}.complete(data)) +} diff --git a/internal/services/mobilenetwork/mobile_network_slice_resource.go b/internal/services/mobilenetwork/mobile_network_slice_resource.go new file mode 100644 index 000000000000..655ce8fbb1a2 --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_slice_resource.go @@ -0,0 +1,309 @@ +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/slice" + "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 SliceModel struct { + Name string `tfschema:"name"` + MobileNetworkMobileNetworkId string `tfschema:"mobile_network_id"` + Description string `tfschema:"description"` + Location string `tfschema:"location"` + Snssai []SnssaiModel `tfschema:"single_network_slice_selection_assistance_information"` + Tags map[string]string `tfschema:"tags"` +} + +type SnssaiModel struct { + Sd string `tfschema:"slice_differentiator"` + Sst int64 `tfschema:"slice_service_type"` +} + +type SliceResource struct{} + +var _ sdk.ResourceWithUpdate = SliceResource{} + +func (r SliceResource) ResourceType() string { + return "azurerm_mobile_network_slice" +} + +func (r SliceResource) ModelObject() interface{} { + return &SliceModel{} +} + +func (r SliceResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return slice.ValidateSliceID +} + +func (r SliceResource) 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, + }, + + "description": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "location": commonschema.Location(), + + "single_network_slice_selection_assistance_information": { + Type: pluginsdk.TypeList, + Required: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "slice_differentiator": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch( + regexp.MustCompile(`^[A-Fa-f0-9]{6}$`), + "Slice Differentiator must be a 6 digit hex string", + ), + }, + + "slice_service_type": { + Type: pluginsdk.TypeInt, + Required: true, + ValidateFunc: validation.IntBetween(0, 255), + }, + }, + }, + }, + + "tags": commonschema.Tags(), + } +} + +func (r SliceResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r SliceResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 180 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model SliceModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.MobileNetwork.SliceClient + mobileNetworkId, err := mobilenetwork.ParseMobileNetworkID(model.MobileNetworkMobileNetworkId) + if err != nil { + return err + } + + id := slice.NewSliceID(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 := slice.Slice{ + Location: location.Normalize(model.Location), + Properties: slice.SlicePropertiesFormat{}, + Tags: &model.Tags, + } + + if model.Description != "" { + properties.Properties.Description = &model.Description + } + + properties.Properties.Snssai = expandSnssaiModel(model.Snssai) + + if err := client.CreateOrUpdateThenPoll(ctx, id, properties); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r SliceResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 180 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MobileNetwork.SliceClient + + id, err := slice.ParseSliceID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model SliceModel + 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) + } + + if resp.Model == nil { + return fmt.Errorf("retrieving %s: properties were nil", id) + } + + updateModel := resp.Model + + if metadata.ResourceData.HasChange("description") { + if model.Description != "" { + updateModel.Properties.Description = &model.Description + } else { + updateModel.Properties.Description = nil + } + } + + if metadata.ResourceData.HasChange("snssai") { + updateModel.Properties.Snssai = expandSnssaiModel(model.Snssai) + } + + updateModel.SystemData = nil + + if metadata.ResourceData.HasChange("tags") { + updateModel.Tags = &model.Tags + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *updateModel); err != nil { + return fmt.Errorf("updating %s: %+v", *id, err) + } + + return nil + }, + } +} + +func (r SliceResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MobileNetwork.SliceClient + + id, err := slice.ParseSliceID(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) + } + + if resp.Model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) + } + + model := *resp.Model + + state := SliceModel{ + Name: id.SliceName, + MobileNetworkMobileNetworkId: mobilenetwork.NewMobileNetworkID(id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName).ID(), + Location: location.Normalize(model.Location), + } + + properties := model.Properties + if properties.Description != nil { + state.Description = *properties.Description + } + + state.Snssai = flattenSnssaiModel(properties.Snssai) + if model.Tags != nil { + state.Tags = *model.Tags + } + + return metadata.Encode(&state) + }, + } +} + +func (r SliceResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 180 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MobileNetwork.SliceClient + + id, err := slice.ParseSliceID(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 expandSnssaiModel(inputList []SnssaiModel) slice.Snssai { + output := slice.Snssai{} + if len(inputList) == 0 { + return output + } + input := inputList[0] + + output.Sst = input.Sst + + if input.Sd != "" { + output.Sd = &input.Sd + } + + return output +} + +func flattenSnssaiModel(input slice.Snssai) []SnssaiModel { + var outputList []SnssaiModel + + output := SnssaiModel{ + Sst: input.Sst, + } + + if input.Sd != nil { + output.Sd = *input.Sd + } + + return append(outputList, output) +} diff --git a/internal/services/mobilenetwork/mobile_network_slice_resource_test.go b/internal/services/mobilenetwork/mobile_network_slice_resource_test.go new file mode 100644 index 000000000000..ca942c133531 --- /dev/null +++ b/internal/services/mobilenetwork/mobile_network_slice_resource_test.go @@ -0,0 +1,181 @@ +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/slice" + "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 MobileNetworkSliceResource struct{} + +func TestAccMobileNetworkSlice_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_slice", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkSliceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMobileNetworkSlice_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_slice", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkSliceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func TestAccMobileNetworkSlice_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_slice", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkSliceResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMobileNetworkSlice_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_mobile_network_slice", "test") + // Limited regional availability for Mobile Network + data.Locations.Primary = "eastus" + + r := MobileNetworkSliceResource{} + 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 MobileNetworkSliceResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := slice.ParseSliceID(state.ID) + if err != nil { + return nil, err + } + + client := clients.MobileNetwork.SliceClient + 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 MobileNetworkSliceResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_slice" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + single_network_slice_selection_assistance_information { + slice_service_type = 1 + } +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} + +func (r MobileNetworkSliceResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_slice" "import" { + name = azurerm_mobile_network_slice.test.name + mobile_network_id = azurerm_mobile_network_slice.test.mobile_network_id + + location = "%s" + single_network_slice_selection_assistance_information { + slice_service_type = 1 + } +} +`, r.basic(data), data.Locations.Primary) +} + +func (r MobileNetworkSliceResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` + %s + +resource "azurerm_mobile_network_slice" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + description = "my favorite slice" + single_network_slice_selection_assistance_information { + slice_service_type = 1 + } + tags = { + key = "value" + } + +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} + +func (r MobileNetworkSliceResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_mobile_network_slice" "test" { + name = "acctest-mns-%d" + mobile_network_id = azurerm_mobile_network.test.id + location = "%s" + description = "my favorite slice2" + single_network_slice_selection_assistance_information { + slice_service_type = 1 + } + + tags = { + key = "value" + } + +} +`, MobileNetworkResource{}.basic(data), data.RandomInteger, data.Locations.Primary) +} diff --git a/internal/services/mobilenetwork/registration.go b/internal/services/mobilenetwork/registration.go index 2d0e9b577ac0..18b0475e5ff0 100644 --- a/internal/services/mobilenetwork/registration.go +++ b/internal/services/mobilenetwork/registration.go @@ -43,12 +43,14 @@ func (r Registration) DataSources() []sdk.DataSource { return []sdk.DataSource{ MobileNetworkDataSource{}, SiteDataSource{}, + SliceDataSource{}, } } // Resources returns a list of Resources supported by this Service func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ + SliceResource{}, MobileNetworkResource{}, SiteResource{}, } diff --git a/internal/services/mobilenetwork/testdata/rsa_bundle.pfx b/internal/services/mobilenetwork/testdata/rsa_bundle.pfx new file mode 100644 index 000000000000..3b7526983809 Binary files /dev/null and b/internal/services/mobilenetwork/testdata/rsa_bundle.pfx differ diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/README.md new file mode 100644 index 000000000000..d90754b37bd1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice` Documentation + +The `slice` 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/slice" +``` + + +### Client Initialization + +```go +client := slice.NewSliceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SliceClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +payload := slice.Slice{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SliceClient.Delete` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SliceClient.Get` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +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: `SliceClient.UpdateTags` + +```go +ctx := context.TODO() +id := slice.NewSliceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "mobileNetworkValue", "sliceValue") + +payload := slice.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/slice/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/client.go new file mode 100644 index 000000000000..524b7f437cec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/client.go @@ -0,0 +1,18 @@ +package slice + +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 SliceClient struct { + Client autorest.Client + baseUri string +} + +func NewSliceClientWithBaseURI(endpoint string) SliceClient { + return SliceClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/constants.go new file mode 100644 index 000000000000..b0340c1fc2b9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/constants.go @@ -0,0 +1,49 @@ +package slice + +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 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/id_slice.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/id_slice.go new file mode 100644 index 000000000000..d22553e4bbfc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/id_slice.go @@ -0,0 +1,137 @@ +package slice + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = SliceId{} + +// SliceId is a struct representing the Resource ID for a Slice +type SliceId struct { + SubscriptionId string + ResourceGroupName string + MobileNetworkName string + SliceName string +} + +// NewSliceID returns a new SliceId struct +func NewSliceID(subscriptionId string, resourceGroupName string, mobileNetworkName string, sliceName string) SliceId { + return SliceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MobileNetworkName: mobileNetworkName, + SliceName: sliceName, + } +} + +// ParseSliceID parses 'input' into a SliceId +func ParseSliceID(input string) (*SliceId, error) { + parser := resourceids.NewParserFromResourceIdType(SliceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := SliceId{} + + 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.SliceName, ok = parsed.Parsed["sliceName"]; !ok { + return nil, fmt.Errorf("the segment 'sliceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseSliceIDInsensitively parses 'input' case-insensitively into a SliceId +// note: this method should only be used for API response data and not user input +func ParseSliceIDInsensitively(input string) (*SliceId, error) { + parser := resourceids.NewParserFromResourceIdType(SliceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := SliceId{} + + 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.SliceName, ok = parsed.Parsed["sliceName"]; !ok { + return nil, fmt.Errorf("the segment 'sliceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateSliceID checks that 'input' can be parsed as a Slice ID +func ValidateSliceID(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 := ParseSliceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slice ID +func (id SliceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MobileNetwork/mobileNetworks/%s/slices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MobileNetworkName, id.SliceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slice ID +func (id SliceId) 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("staticSlices", "slices", "slices"), + resourceids.UserSpecifiedSegment("sliceName", "sliceValue"), + } +} + +// String returns a human-readable description of this Slice ID +func (id SliceId) 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("Slice Name: %q", id.SliceName), + } + return fmt.Sprintf("Slice (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_createorupdate_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_createorupdate_autorest.go new file mode 100644 index 000000000000..e9384e1b14f4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_createorupdate_autorest.go @@ -0,0 +1,79 @@ +package slice + +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 SliceClient) CreateOrUpdate(ctx context.Context, id SliceId, input Slice) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SliceClient) CreateOrUpdateThenPoll(ctx context.Context, id SliceId, input Slice) 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 SliceClient) preparerForCreateOrUpdate(ctx context.Context, id SliceId, input Slice) (*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 SliceClient) 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/slice/method_delete_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_delete_autorest.go new file mode 100644 index 000000000000..bf386c58b1ba --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_delete_autorest.go @@ -0,0 +1,78 @@ +package slice + +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 SliceClient) Delete(ctx context.Context, id SliceId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SliceClient) DeleteThenPoll(ctx context.Context, id SliceId) 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 SliceClient) preparerForDelete(ctx context.Context, id SliceId) (*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 SliceClient) 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/slice/method_get_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_get_autorest.go new file mode 100644 index 000000000000..b2160e45a2f4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_get_autorest.go @@ -0,0 +1,68 @@ +package slice + +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 *Slice +} + +// Get ... +func (c SliceClient) Get(ctx context.Context, id SliceId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c SliceClient) preparerForGet(ctx context.Context, id SliceId) (*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 SliceClient) 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/slice/method_updatetags_autorest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_updatetags_autorest.go new file mode 100644 index 000000000000..cb933c9852d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/method_updatetags_autorest.go @@ -0,0 +1,69 @@ +package slice + +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 *Slice +} + +// UpdateTags ... +func (c SliceClient) UpdateTags(ctx context.Context, id SliceId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + req, err := c.preparerForUpdateTags(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "UpdateTags", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "UpdateTags", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdateTags(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "slice.SliceClient", "UpdateTags", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdateTags prepares the UpdateTags request. +func (c SliceClient) preparerForUpdateTags(ctx context.Context, id SliceId, 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 SliceClient) 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/slice/model_slice.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_slice.go new file mode 100644 index 000000000000..2ea70e266090 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_slice.go @@ -0,0 +1,18 @@ +package slice + +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 Slice struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties SlicePropertiesFormat `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/slice/model_slicepropertiesformat.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_slicepropertiesformat.go new file mode 100644 index 000000000000..9af74336fee4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_slicepropertiesformat.go @@ -0,0 +1,10 @@ +package slice + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlicePropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Snssai Snssai `json:"snssai"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_snssai.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_snssai.go new file mode 100644 index 000000000000..d52cf0ef4ff6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_snssai.go @@ -0,0 +1,9 @@ +package slice + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snssai struct { + Sd *string `json:"sd,omitempty"` + Sst int64 `json:"sst"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_tagsobject.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_tagsobject.go new file mode 100644 index 000000000000..a6e5718ffcda --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/model_tagsobject.go @@ -0,0 +1,8 @@ +package slice + +// 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/slice/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/version.go new file mode 100644 index 000000000000..0c450fcd1efe --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice/version.go @@ -0,0 +1,12 @@ +package slice + +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/slice/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ca050664108c..92edc3861b61 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -391,6 +391,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/streamingpol 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/site +github.com/hashicorp/go-azure-sdk/resource-manager/mobilenetwork/2022-11-01/slice 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_slice.html.markdown b/website/docs/d/mobile_network_slice.html.markdown new file mode 100644 index 000000000000..555d58f051e5 --- /dev/null +++ b/website/docs/d/mobile_network_slice.html.markdown @@ -0,0 +1,63 @@ +--- +subcategory: "Mobile Network" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_mobile_network_slice" +description: |- + Get information about a Mobile Network Slice. +--- + +# azurerm_mobile_network_slice + +Get information about a Mobile Network Slice. + +## Example Usage + +```hcl +data "azurerm_mobile_network" "example" { + name = "example-mn" + resource_group_name = "example-rg" +} + +data "azurerm_mobile_network_slice" "example" { + name = "example-mns" + mobile_network_id = data.azurerm_mobile_network.test.id +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Mobile Network Slice. + +* `mobile_network_id` - (Required) The ID of Mobile Network which the Mobile Network Slice belongs to. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Mobile Network Slice. + +* `location` - The Azure Region where the Mobile Network Slice exists. + +* `single_network_slice_selection_assistance_information` - A `single_network_slice_selection_assistance_information` block as defined below. Single-network slice selection assistance information (S-NSSAI). + +* `description` - A description of this Mobile Network Slice. + +* `tags` - A mapping of tags which are assigned to the Mobile Network Slice. + +--- + +A `single_network_slice_selection_assistance_information` block supports the following: + +* `slice_differentiator` - Slice differentiator (SD). + +* `slice_service_type` - Slice/service type (SST). + + +## 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 Slice. + diff --git a/website/docs/r/mobile_network_slice.html.markdown b/website/docs/r/mobile_network_slice.html.markdown new file mode 100644 index 000000000000..42c4fae5b2ac --- /dev/null +++ b/website/docs/r/mobile_network_slice.html.markdown @@ -0,0 +1,94 @@ +--- +subcategory: "Mobile Network" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_mobile_network_slice" +description: |- + Manages a Mobile Network Slice. +--- + +# azurerm_mobile_network_slice + +Manages a Mobile Network Slice. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_mobile_network" "example" { + name = "example-mn" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + mobile_country_code = "001" + mobile_network_code = "01" +} + + +resource "azurerm_mobile_network_slice" "example" { + name = "example-mns" + mobile_network_id = azurerm_mobile_network.test.id + location = azurerm_resource_group.example.location + description = "an example slice" + + single_network_slice_selection_assistance_information { + slice_service_type = 1 + } + + tags = { + key = "value" + } + +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name which should be used for this Mobile Network Slice. Changing this forces a new Mobile Network Slice to be created. + +* `mobile_network_id` - (Required) The ID of Mobile Network which the Mobile Network Slice belongs to. Changing this forces a new Mobile Network Slice to be created. + +* `location` - (Required) Specifies the Azure Region where the Mobile Network Slice should exist. Changing this forces a new Mobile Network Slice to be created. + +* `single_network_slice_selection_assistance_information` - (Required) A `single_network_slice_selection_assistance_information` block as defined below. Single-network slice selection assistance information (S-NSSAI). Unique at the scope of a mobile network. + +* `description` - (Optional) A description for this Mobile Network Slice. + +* `tags` - (Optional) A mapping of tags which should be assigned to the Mobile Network Slice. + +--- + +A `single_network_slice_selection_assistance_information` block supports the following: + +* `slice_differentiator` - (Optional) Slice differentiator (SD). Must be a 6 digit hex string. + +* `slice_service_type` - (Required) Slice/service type (SST). Must be between `0` and `255`. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Mobile Network Slice. + + + +## 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 Slice. +* `read` - (Defaults to 5 minutes) Used when retrieving the Mobile Network Slice. +* `update` - (Defaults to 180 minutes) Used when updating the Mobile Network Slice. +* `delete` - (Defaults to 180 minutes) Used when deleting the Mobile Network Slice. + +## Import + +Mobile Network Slice can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_mobile_network_slice.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.MobileNetwork/mobileNetworks/mobileNetwork1/slices/slice1 +```