diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/CHANGELOG.md b/sdk/resourcemanager/voiceservices/armvoiceservices/CHANGELOG.md new file mode 100644 index 000000000000..e52665c72716 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-02-27) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/LICENSE.txt b/sdk/resourcemanager/voiceservices/armvoiceservices/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/README.md b/sdk/resourcemanager/voiceservices/armvoiceservices/README.md new file mode 100644 index 000000000000..d52770fd1d93 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/README.md @@ -0,0 +1,77 @@ +# Azure VoiceServices Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices) + +The `armvoiceservices` module provides operations for working with Azure VoiceServices. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/voiceservices/armvoiceservices) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure VoiceServices module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure VoiceServices. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure VoiceServices modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armvoiceservices.NewTestLinesClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armvoiceservices.NewTestLinesClient(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `VoiceServices` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/autorest.md b/sdk/resourcemanager/voiceservices/armvoiceservices/autorest.md new file mode 100644 index 000000000000..34d37ae2f07f --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +tag: package-2022-12-01-preview +``` \ No newline at end of file diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/build.go b/sdk/resourcemanager/voiceservices/armvoiceservices/build.go new file mode 100644 index 000000000000..a7d37ada2b55 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/voiceservices/armvoiceservices + +package armvoiceservices diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/ci.yml b/sdk/resourcemanager/voiceservices/armvoiceservices/ci.yml new file mode 100644 index 000000000000..66666b955640 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/voiceservices/armvoiceservices/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/voiceservices/armvoiceservices/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/voiceservices/armvoiceservices' diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/communicationsgateways_client.go b/sdk/resourcemanager/voiceservices/armvoiceservices/communicationsgateways_client.go new file mode 100644 index 000000000000..e6545e63be22 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/communicationsgateways_client.go @@ -0,0 +1,433 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// CommunicationsGatewaysClient contains the methods for the CommunicationsGateways group. +// Don't use this type directly, use NewCommunicationsGatewaysClient() instead. +type CommunicationsGatewaysClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewCommunicationsGatewaysClient creates a new instance of CommunicationsGatewaysClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewCommunicationsGatewaysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommunicationsGatewaysClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &CommunicationsGatewaysClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a CommunicationsGateway +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - resource - Resource create parameters. +// - options - CommunicationsGatewaysClientBeginCreateOrUpdateOptions contains the optional parameters for the CommunicationsGatewaysClient.BeginCreateOrUpdate +// method. +func (client *CommunicationsGatewaysClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communicationsGatewayName string, resource CommunicationsGateway, options *CommunicationsGatewaysClientBeginCreateOrUpdateOptions) (*runtime.Poller[CommunicationsGatewaysClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, communicationsGatewayName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommunicationsGatewaysClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[CommunicationsGatewaysClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a CommunicationsGateway +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +func (client *CommunicationsGatewaysClient) createOrUpdate(ctx context.Context, resourceGroupName string, communicationsGatewayName string, resource CommunicationsGateway, options *CommunicationsGatewaysClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, communicationsGatewayName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CommunicationsGatewaysClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, resource CommunicationsGateway, options *CommunicationsGatewaysClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a CommunicationsGateway +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - options - CommunicationsGatewaysClientBeginDeleteOptions contains the optional parameters for the CommunicationsGatewaysClient.BeginDelete +// method. +func (client *CommunicationsGatewaysClient) BeginDelete(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *CommunicationsGatewaysClientBeginDeleteOptions) (*runtime.Poller[CommunicationsGatewaysClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communicationsGatewayName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CommunicationsGatewaysClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[CommunicationsGatewaysClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a CommunicationsGateway +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +func (client *CommunicationsGatewaysClient) deleteOperation(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *CommunicationsGatewaysClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, communicationsGatewayName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CommunicationsGatewaysClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *CommunicationsGatewaysClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a CommunicationsGateway +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - options - CommunicationsGatewaysClientGetOptions contains the optional parameters for the CommunicationsGatewaysClient.Get +// method. +func (client *CommunicationsGatewaysClient) Get(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *CommunicationsGatewaysClientGetOptions) (CommunicationsGatewaysClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, communicationsGatewayName, options) + if err != nil { + return CommunicationsGatewaysClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CommunicationsGatewaysClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CommunicationsGatewaysClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CommunicationsGatewaysClient) getCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *CommunicationsGatewaysClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CommunicationsGatewaysClient) getHandleResponse(resp *http.Response) (CommunicationsGatewaysClientGetResponse, error) { + result := CommunicationsGatewaysClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunicationsGateway); err != nil { + return CommunicationsGatewaysClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List CommunicationsGateway resources by resource group +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - CommunicationsGatewaysClientListByResourceGroupOptions contains the optional parameters for the CommunicationsGatewaysClient.NewListByResourceGroupPager +// method. +func (client *CommunicationsGatewaysClient) NewListByResourceGroupPager(resourceGroupName string, options *CommunicationsGatewaysClientListByResourceGroupOptions) *runtime.Pager[CommunicationsGatewaysClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunicationsGatewaysClientListByResourceGroupResponse]{ + More: func(page CommunicationsGatewaysClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunicationsGatewaysClientListByResourceGroupResponse) (CommunicationsGatewaysClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CommunicationsGatewaysClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CommunicationsGatewaysClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CommunicationsGatewaysClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CommunicationsGatewaysClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CommunicationsGatewaysClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CommunicationsGatewaysClient) listByResourceGroupHandleResponse(resp *http.Response) (CommunicationsGatewaysClientListByResourceGroupResponse, error) { + result := CommunicationsGatewaysClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunicationsGatewayListResult); err != nil { + return CommunicationsGatewaysClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List CommunicationsGateway resources by subscription ID +// +// Generated from API version 2022-12-01-preview +// - options - CommunicationsGatewaysClientListBySubscriptionOptions contains the optional parameters for the CommunicationsGatewaysClient.NewListBySubscriptionPager +// method. +func (client *CommunicationsGatewaysClient) NewListBySubscriptionPager(options *CommunicationsGatewaysClientListBySubscriptionOptions) *runtime.Pager[CommunicationsGatewaysClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunicationsGatewaysClientListBySubscriptionResponse]{ + More: func(page CommunicationsGatewaysClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunicationsGatewaysClientListBySubscriptionResponse) (CommunicationsGatewaysClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CommunicationsGatewaysClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CommunicationsGatewaysClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CommunicationsGatewaysClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CommunicationsGatewaysClient) listBySubscriptionCreateRequest(ctx context.Context, options *CommunicationsGatewaysClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.VoiceServices/communicationsGateways" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *CommunicationsGatewaysClient) listBySubscriptionHandleResponse(resp *http.Response) (CommunicationsGatewaysClientListBySubscriptionResponse, error) { + result := CommunicationsGatewaysClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunicationsGatewayListResult); err != nil { + return CommunicationsGatewaysClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Update a CommunicationsGateway +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - properties - The resource properties to be updated. +// - options - CommunicationsGatewaysClientUpdateOptions contains the optional parameters for the CommunicationsGatewaysClient.Update +// method. +func (client *CommunicationsGatewaysClient) Update(ctx context.Context, resourceGroupName string, communicationsGatewayName string, properties CommunicationsGatewayUpdate, options *CommunicationsGatewaysClientUpdateOptions) (CommunicationsGatewaysClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, communicationsGatewayName, properties, options) + if err != nil { + return CommunicationsGatewaysClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CommunicationsGatewaysClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CommunicationsGatewaysClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *CommunicationsGatewaysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, properties CommunicationsGatewayUpdate, options *CommunicationsGatewaysClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// updateHandleResponse handles the Update response. +func (client *CommunicationsGatewaysClient) updateHandleResponse(resp *http.Response) (CommunicationsGatewaysClientUpdateResponse, error) { + result := CommunicationsGatewaysClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunicationsGateway); err != nil { + return CommunicationsGatewaysClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/communicationsgateways_client_example_test.go b/sdk/resourcemanager/voiceservices/armvoiceservices/communicationsgateways_client_example_test.go new file mode 100644 index 000000000000..3adcca69dbfe --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/communicationsgateways_client_example_test.go @@ -0,0 +1,335 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/CommunicationsGateways_ListBySubscription.json +func ExampleCommunicationsGatewaysClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewCommunicationsGatewaysClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CommunicationsGatewayListResult = armvoiceservices.CommunicationsGatewayListResult{ + // Value: []*armvoiceservices.CommunicationsGateway{ + // { + // Name: to.Ptr("myname"), + // Type: to.Ptr("Microsoft.VoiceService/communicationsGateways"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateways/myname"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.CommunicationsGatewayProperties{ + // Codecs: []*armvoiceservices.TeamsCodecs{ + // to.Ptr(armvoiceservices.TeamsCodecsPCMA)}, + // Connectivity: to.Ptr(armvoiceservices.ConnectivityPublicAddress), + // E911Type: to.Ptr(armvoiceservices.E911TypeStandard), + // Platforms: []*armvoiceservices.CommunicationsPlatform{ + // to.Ptr(armvoiceservices.CommunicationsPlatformOperatorConnect)}, + // ServiceLocations: []*armvoiceservices.ServiceRegionProperties{ + // { + // Name: to.Ptr("useast"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.1")}, + // }, + // }, + // { + // Name: to.Ptr("useast2"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.2")}, + // }, + // }}, + // Status: to.Ptr(armvoiceservices.StatusChangePending), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/CommunicationsGateways_ListByResourceGroup.json +func ExampleCommunicationsGatewaysClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewCommunicationsGatewaysClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("testrg", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.CommunicationsGatewayListResult = armvoiceservices.CommunicationsGatewayListResult{ + // Value: []*armvoiceservices.CommunicationsGateway{ + // { + // Name: to.Ptr("myname"), + // Type: to.Ptr("Microsoft.VoiceService/communicationsGateways"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateways/myname"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.CommunicationsGatewayProperties{ + // Codecs: []*armvoiceservices.TeamsCodecs{ + // to.Ptr(armvoiceservices.TeamsCodecsPCMA)}, + // Connectivity: to.Ptr(armvoiceservices.ConnectivityPublicAddress), + // E911Type: to.Ptr(armvoiceservices.E911TypeStandard), + // Platforms: []*armvoiceservices.CommunicationsPlatform{ + // to.Ptr(armvoiceservices.CommunicationsPlatformOperatorConnect)}, + // ServiceLocations: []*armvoiceservices.ServiceRegionProperties{ + // { + // Name: to.Ptr("useast"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.1")}, + // }, + // }, + // { + // Name: to.Ptr("useast2"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.2")}, + // }, + // }}, + // Status: to.Ptr(armvoiceservices.StatusChangePending), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/CommunicationsGateways_Get.json +func ExampleCommunicationsGatewaysClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewCommunicationsGatewaysClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "testrg", "myname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CommunicationsGateway = armvoiceservices.CommunicationsGateway{ + // Name: to.Ptr("myname"), + // Type: to.Ptr("Microsoft.VoiceService/communicationsGateways"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateways/myname"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.CommunicationsGatewayProperties{ + // Codecs: []*armvoiceservices.TeamsCodecs{ + // to.Ptr(armvoiceservices.TeamsCodecsPCMA)}, + // Connectivity: to.Ptr(armvoiceservices.ConnectivityPublicAddress), + // E911Type: to.Ptr(armvoiceservices.E911TypeStandard), + // Platforms: []*armvoiceservices.CommunicationsPlatform{ + // to.Ptr(armvoiceservices.CommunicationsPlatformOperatorConnect)}, + // ServiceLocations: []*armvoiceservices.ServiceRegionProperties{ + // { + // Name: to.Ptr("useast"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.1")}, + // }, + // }, + // { + // Name: to.Ptr("useast2"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.2")}, + // }, + // }}, + // Status: to.Ptr(armvoiceservices.StatusChangePending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/CommunicationsGateways_CreateOrUpdate.json +func ExampleCommunicationsGatewaysClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewCommunicationsGatewaysClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "testrg", "myname", armvoiceservices.CommunicationsGateway{ + Location: to.Ptr("useast"), + Properties: &armvoiceservices.CommunicationsGatewayProperties{ + Codecs: []*armvoiceservices.TeamsCodecs{ + to.Ptr(armvoiceservices.TeamsCodecsPCMA)}, + Connectivity: to.Ptr(armvoiceservices.ConnectivityPublicAddress), + E911Type: to.Ptr(armvoiceservices.E911TypeStandard), + Platforms: []*armvoiceservices.CommunicationsPlatform{ + to.Ptr(armvoiceservices.CommunicationsPlatformOperatorConnect)}, + ServiceLocations: []*armvoiceservices.ServiceRegionProperties{ + { + Name: to.Ptr("useast"), + PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + OperatorAddresses: []*string{ + to.Ptr("198.51.100.1")}, + }, + }, + { + Name: to.Ptr("useast2"), + PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + OperatorAddresses: []*string{ + to.Ptr("198.51.100.2")}, + }, + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CommunicationsGateway = armvoiceservices.CommunicationsGateway{ + // Name: to.Ptr("myname"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.CommunicationsGatewayProperties{ + // Codecs: []*armvoiceservices.TeamsCodecs{ + // to.Ptr(armvoiceservices.TeamsCodecsPCMA)}, + // Connectivity: to.Ptr(armvoiceservices.ConnectivityPublicAddress), + // E911Type: to.Ptr(armvoiceservices.E911TypeStandard), + // Platforms: []*armvoiceservices.CommunicationsPlatform{ + // to.Ptr(armvoiceservices.CommunicationsPlatformOperatorConnect)}, + // ServiceLocations: []*armvoiceservices.ServiceRegionProperties{ + // { + // Name: to.Ptr("useast"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.1")}, + // }, + // }, + // { + // Name: to.Ptr("useast2"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.2")}, + // }, + // }}, + // Status: to.Ptr(armvoiceservices.StatusChangePending), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/CommunicationsGateways_Delete.json +func ExampleCommunicationsGatewaysClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewCommunicationsGatewaysClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, "testrg", "myname", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/CommunicationsGateways_Update.json +func ExampleCommunicationsGatewaysClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewCommunicationsGatewaysClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Update(ctx, "testrg", "myname", armvoiceservices.CommunicationsGatewayUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CommunicationsGateway = armvoiceservices.CommunicationsGateway{ + // Name: to.Ptr("myname"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.CommunicationsGatewayProperties{ + // Codecs: []*armvoiceservices.TeamsCodecs{ + // to.Ptr(armvoiceservices.TeamsCodecsPCMA)}, + // Connectivity: to.Ptr(armvoiceservices.ConnectivityPublicAddress), + // E911Type: to.Ptr(armvoiceservices.E911TypeStandard), + // Platforms: []*armvoiceservices.CommunicationsPlatform{ + // to.Ptr(armvoiceservices.CommunicationsPlatformOperatorConnect)}, + // ServiceLocations: []*armvoiceservices.ServiceRegionProperties{ + // { + // Name: to.Ptr("useast"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.1")}, + // }, + // }, + // { + // Name: to.Ptr("useast2"), + // PrimaryRegionProperties: &armvoiceservices.PrimaryRegionProperties{ + // OperatorAddresses: []*string{ + // to.Ptr("198.51.100.2")}, + // }, + // }}, + // Status: to.Ptr(armvoiceservices.StatusChangePending), + // }, + // } +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/constants.go b/sdk/resourcemanager/voiceservices/armvoiceservices/constants.go new file mode 100644 index 000000000000..54cd81d3100c --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/constants.go @@ -0,0 +1,195 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +const ( + moduleName = "armvoiceservices" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CommunicationsPlatform - Available platform types. +type CommunicationsPlatform string + +const ( + CommunicationsPlatformOperatorConnect CommunicationsPlatform = "OperatorConnect" + CommunicationsPlatformTeamsPhoneMobile CommunicationsPlatform = "TeamsPhoneMobile" +) + +// PossibleCommunicationsPlatformValues returns the possible values for the CommunicationsPlatform const type. +func PossibleCommunicationsPlatformValues() []CommunicationsPlatform { + return []CommunicationsPlatform{ + CommunicationsPlatformOperatorConnect, + CommunicationsPlatformTeamsPhoneMobile, + } +} + +// Connectivity - How this deployment connects back to the operator network +type Connectivity string + +const ( + // ConnectivityPublicAddress - This deployment connects to the operator network using a Public IP address, e.g. when using + // MAPS + ConnectivityPublicAddress Connectivity = "PublicAddress" +) + +// PossibleConnectivityValues returns the possible values for the Connectivity const type. +func PossibleConnectivityValues() []Connectivity { + return []Connectivity{ + ConnectivityPublicAddress, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// E911Type - The method for terminating emergency calls to the PSTN. +type E911Type string + +const ( + // E911TypeDirectToEsrp - Emergency calls are routed directly to the ESRP + E911TypeDirectToEsrp E911Type = "DirectToEsrp" + // E911TypeStandard - Emergency calls are not handled different from other calls + E911TypeStandard E911Type = "Standard" +) + +// PossibleE911TypeValues returns the possible values for the E911Type const type. +func PossibleE911TypeValues() []E911Type { + return []E911Type{ + E911TypeDirectToEsrp, + E911TypeStandard, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - Provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} + +// Status - The status of the current CommunicationsGateway resource. +type Status string + +const ( + // StatusChangePending - The resource has been created or updated, but the CommunicationsGateway service has not yet been + // updated to reflect the changes. + StatusChangePending Status = "ChangePending" + // StatusComplete - The CommunicationsGateway service is up and running with the parameters specified in the resource. + StatusComplete Status = "Complete" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusChangePending, + StatusComplete, + } +} + +// TeamsCodecs - The voice codecs expected for communication with Teams. +type TeamsCodecs string + +const ( + TeamsCodecsG722 TeamsCodecs = "G722" + TeamsCodecsG7222 TeamsCodecs = "G722_2" + TeamsCodecsPCMA TeamsCodecs = "PCMA" + TeamsCodecsPCMU TeamsCodecs = "PCMU" + TeamsCodecsSILK16 TeamsCodecs = "SILK_16" + TeamsCodecsSILK8 TeamsCodecs = "SILK_8" +) + +// PossibleTeamsCodecsValues returns the possible values for the TeamsCodecs const type. +func PossibleTeamsCodecsValues() []TeamsCodecs { + return []TeamsCodecs{ + TeamsCodecsG722, + TeamsCodecsG7222, + TeamsCodecsPCMA, + TeamsCodecsPCMU, + TeamsCodecsSILK16, + TeamsCodecsSILK8, + } +} + +// TestLinePurpose - The purpose of the TestLine resource. +type TestLinePurpose string + +const ( + TestLinePurposeManual TestLinePurpose = "Manual" + TestLinePurposeAutomated TestLinePurpose = "Automated" +) + +// PossibleTestLinePurposeValues returns the possible values for the TestLinePurpose const type. +func PossibleTestLinePurposeValues() []TestLinePurpose { + return []TestLinePurpose{ + TestLinePurposeManual, + TestLinePurposeAutomated, + } +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/contacts_client.go b/sdk/resourcemanager/voiceservices/armvoiceservices/contacts_client.go new file mode 100644 index 000000000000..451a824af9e1 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/contacts_client.go @@ -0,0 +1,395 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ContactsClient contains the methods for the Contacts group. +// Don't use this type directly, use NewContactsClient() instead. +type ContactsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewContactsClient creates a new instance of ContactsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewContactsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContactsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ContactsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Contact +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - contactName - Unique identifier for this contact +// - resource - Resource create parameters. +// - options - ContactsClientBeginCreateOrUpdateOptions contains the optional parameters for the ContactsClient.BeginCreateOrUpdate +// method. +func (client *ContactsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, resource Contact, options *ContactsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ContactsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, communicationsGatewayName, contactName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ContactsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ContactsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a Contact +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +func (client *ContactsClient) createOrUpdate(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, resource Contact, options *ContactsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, communicationsGatewayName, contactName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ContactsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, resource Contact, options *ContactsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a Contact +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - contactName - Unique identifier for this contact +// - options - ContactsClientBeginDeleteOptions contains the optional parameters for the ContactsClient.BeginDelete method. +func (client *ContactsClient) BeginDelete(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, options *ContactsClientBeginDeleteOptions) (*runtime.Poller[ContactsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communicationsGatewayName, contactName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ContactsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ContactsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a Contact +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +func (client *ContactsClient) deleteOperation(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, options *ContactsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, communicationsGatewayName, contactName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ContactsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, options *ContactsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Contact +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - contactName - Unique identifier for this contact +// - options - ContactsClientGetOptions contains the optional parameters for the ContactsClient.Get method. +func (client *ContactsClient) Get(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, options *ContactsClientGetOptions) (ContactsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, communicationsGatewayName, contactName, options) + if err != nil { + return ContactsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ContactsClient) getCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, options *ContactsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContactsClient) getHandleResponse(resp *http.Response) (ContactsClientGetResponse, error) { + result := ContactsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Contact); err != nil { + return ContactsClientGetResponse{}, err + } + return result, nil +} + +// NewListByCommunicationsGatewayPager - List Contact resources by CommunicationsGateway +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - options - ContactsClientListByCommunicationsGatewayOptions contains the optional parameters for the ContactsClient.NewListByCommunicationsGatewayPager +// method. +func (client *ContactsClient) NewListByCommunicationsGatewayPager(resourceGroupName string, communicationsGatewayName string, options *ContactsClientListByCommunicationsGatewayOptions) *runtime.Pager[ContactsClientListByCommunicationsGatewayResponse] { + return runtime.NewPager(runtime.PagingHandler[ContactsClientListByCommunicationsGatewayResponse]{ + More: func(page ContactsClientListByCommunicationsGatewayResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ContactsClientListByCommunicationsGatewayResponse) (ContactsClientListByCommunicationsGatewayResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByCommunicationsGatewayCreateRequest(ctx, resourceGroupName, communicationsGatewayName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ContactsClientListByCommunicationsGatewayResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactsClientListByCommunicationsGatewayResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactsClientListByCommunicationsGatewayResponse{}, runtime.NewResponseError(resp) + } + return client.listByCommunicationsGatewayHandleResponse(resp) + }, + }) +} + +// listByCommunicationsGatewayCreateRequest creates the ListByCommunicationsGateway request. +func (client *ContactsClient) listByCommunicationsGatewayCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *ContactsClientListByCommunicationsGatewayOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/contacts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCommunicationsGatewayHandleResponse handles the ListByCommunicationsGateway response. +func (client *ContactsClient) listByCommunicationsGatewayHandleResponse(resp *http.Response) (ContactsClientListByCommunicationsGatewayResponse, error) { + result := ContactsClientListByCommunicationsGatewayResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContactListResult); err != nil { + return ContactsClientListByCommunicationsGatewayResponse{}, err + } + return result, nil +} + +// Update - Update a Contact +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - contactName - Unique identifier for this contact +// - properties - The resource properties to be updated. +// - options - ContactsClientUpdateOptions contains the optional parameters for the ContactsClient.Update method. +func (client *ContactsClient) Update(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, properties ContactUpdate, options *ContactsClientUpdateOptions) (ContactsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, communicationsGatewayName, contactName, properties, options) + if err != nil { + return ContactsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContactsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContactsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ContactsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, contactName string, properties ContactUpdate, options *ContactsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/contacts/{contactName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if contactName == "" { + return nil, errors.New("parameter contactName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contactName}", url.PathEscape(contactName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// updateHandleResponse handles the Update response. +func (client *ContactsClient) updateHandleResponse(resp *http.Response) (ContactsClientUpdateResponse, error) { + result := ContactsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Contact); err != nil { + return ContactsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/contacts_client_example_test.go b/sdk/resourcemanager/voiceservices/armvoiceservices/contacts_client_example_test.go new file mode 100644 index 000000000000..5a24aa4d0622 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/contacts_client_example_test.go @@ -0,0 +1,188 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/Contacts_ListByCommunicationsGateway.json +func ExampleContactsClient_NewListByCommunicationsGatewayPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewContactsClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByCommunicationsGatewayPager("testrg", "myname", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ContactListResult = armvoiceservices.ContactListResult{ + // Value: []*armvoiceservices.Contact{ + // { + // Name: to.Ptr("myline"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/Contacts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/Contacts/name2"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.ContactProperties{ + // ContactName: to.Ptr("John Smith"), + // Email: to.Ptr("johnsmith@example.com"), + // PhoneNumber: to.Ptr("+1-555-1234"), + // Role: to.Ptr("Network Manager"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/Contacts_Get.json +func ExampleContactsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewContactsClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "testrg", "myname", "name2", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Contact = armvoiceservices.Contact{ + // Name: to.Ptr("name2"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/contacts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/Contacts/name2"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.ContactProperties{ + // ContactName: to.Ptr("John Smith"), + // Email: to.Ptr("johnsmith@example.com"), + // PhoneNumber: to.Ptr("+1-555-1234"), + // Role: to.Ptr("Network Manager"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/Contacts_CreateOrUpdate.json +func ExampleContactsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewContactsClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "testrg", "myname", "name2", armvoiceservices.Contact{ + Location: to.Ptr("useast"), + Properties: &armvoiceservices.ContactProperties{ + ContactName: to.Ptr("John Smith"), + Email: to.Ptr("johnsmith@example.com"), + PhoneNumber: to.Ptr("+1-555-1234"), + Role: to.Ptr("Network Manager"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Contact = armvoiceservices.Contact{ + // Name: to.Ptr("name2"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/contacts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/contacts/name2"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.ContactProperties{ + // ContactName: to.Ptr("John Smith"), + // Email: to.Ptr("johnsmith@example.com"), + // PhoneNumber: to.Ptr("+1-555-1234"), + // Role: to.Ptr("Network Manager"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/Contacts_Delete.json +func ExampleContactsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewContactsClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, "testrg", "myname", "myline", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/Contacts_Update.json +func ExampleContactsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewContactsClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Update(ctx, "testrg", "myname", "name2", armvoiceservices.ContactUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Contact = armvoiceservices.Contact{ + // Name: to.Ptr("name2"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/contacts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/Contacts/name2"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.ContactProperties{ + // ContactName: to.Ptr("John Smith"), + // Email: to.Ptr("johnsmith@example.com"), + // PhoneNumber: to.Ptr("+1-555-1234"), + // Role: to.Ptr("Network Manager"), + // }, + // } +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/go.mod b/sdk/resourcemanager/voiceservices/armvoiceservices/go.mod new file mode 100644 index 000000000000..d0a48e7e22e8 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect + github.com/golang-jwt/jwt/v4 v4.4.2 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/go.sum b/sdk/resourcemanager/voiceservices/armvoiceservices/go.sum new file mode 100644 index 000000000000..67cfef6bdf6e --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= +github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= +github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/models.go b/sdk/resourcemanager/voiceservices/armvoiceservices/models.go new file mode 100644 index 000000000000..db75522fad06 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/models.go @@ -0,0 +1,373 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import "time" + +// CommunicationsGateway - A CommunicationsGateway resource +type CommunicationsGateway struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // The resource-specific properties for this resource. + Properties *CommunicationsGatewayProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CommunicationsGatewayListResult - The response of a CommunicationsGateway list operation. +type CommunicationsGatewayListResult struct { + // REQUIRED; The CommunicationsGateway items on this page + Value []*CommunicationsGateway `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// CommunicationsGatewayProperties - Details of the CommunicationsGateway resource. +type CommunicationsGatewayProperties struct { + // REQUIRED; Voice codecs to support + Codecs []*TeamsCodecs `json:"codecs,omitempty"` + + // REQUIRED; How to connect back to the operator network, e.g. MAPS + Connectivity *Connectivity `json:"connectivity,omitempty"` + + // REQUIRED; How to handle 911 calls + E911Type *E911Type `json:"e911Type,omitempty"` + + // REQUIRED; What platforms to support + Platforms []*CommunicationsPlatform `json:"platforms,omitempty"` + + // REQUIRED; The regions in which to deploy the resources needed for Teams Calling + ServiceLocations []*ServiceRegionProperties `json:"serviceLocations,omitempty"` + + // Details of API bridge functionality, if required + APIBridge any `json:"apiBridge,omitempty"` + + // READ-ONLY; Resource provisioning state. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The current status of the deployment. + Status *Status `json:"status,omitempty" azure:"ro"` +} + +// CommunicationsGatewayUpdate - The type used for update operations of the CommunicationsGateway. +type CommunicationsGatewayUpdate struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// CommunicationsGatewaysClientBeginCreateOrUpdateOptions contains the optional parameters for the CommunicationsGatewaysClient.BeginCreateOrUpdate +// method. +type CommunicationsGatewaysClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CommunicationsGatewaysClientBeginDeleteOptions contains the optional parameters for the CommunicationsGatewaysClient.BeginDelete +// method. +type CommunicationsGatewaysClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CommunicationsGatewaysClientGetOptions contains the optional parameters for the CommunicationsGatewaysClient.Get method. +type CommunicationsGatewaysClientGetOptions struct { + // placeholder for future optional parameters +} + +// CommunicationsGatewaysClientListByResourceGroupOptions contains the optional parameters for the CommunicationsGatewaysClient.NewListByResourceGroupPager +// method. +type CommunicationsGatewaysClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CommunicationsGatewaysClientListBySubscriptionOptions contains the optional parameters for the CommunicationsGatewaysClient.NewListBySubscriptionPager +// method. +type CommunicationsGatewaysClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// CommunicationsGatewaysClientUpdateOptions contains the optional parameters for the CommunicationsGatewaysClient.Update +// method. +type CommunicationsGatewaysClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// Contact - A Contact resource +type Contact struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // The resource-specific properties for this resource. + Properties *ContactProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ContactListResult - The response of a Contact list operation. +type ContactListResult struct { + // REQUIRED; The Contact items on this page + Value []*Contact `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// ContactProperties - Details of the Contact resource. +type ContactProperties struct { + // REQUIRED; Full name of contact + ContactName *string `json:"contactName,omitempty"` + + // REQUIRED; Email address of contact + Email *string `json:"email,omitempty"` + + // REQUIRED; Telephone number of contact + PhoneNumber *string `json:"phoneNumber,omitempty"` + + // REQUIRED; Job title of contact + Role *string `json:"role,omitempty"` + + // READ-ONLY; Resource provisioning state. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// ContactUpdate - The type used for update operations of the Contact. +type ContactUpdate struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// ContactsClientBeginCreateOrUpdateOptions contains the optional parameters for the ContactsClient.BeginCreateOrUpdate method. +type ContactsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ContactsClientBeginDeleteOptions contains the optional parameters for the ContactsClient.BeginDelete method. +type ContactsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ContactsClientGetOptions contains the optional parameters for the ContactsClient.Get method. +type ContactsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ContactsClientListByCommunicationsGatewayOptions contains the optional parameters for the ContactsClient.NewListByCommunicationsGatewayPager +// method. +type ContactsClientListByCommunicationsGatewayOptions struct { + // placeholder for future optional parameters +} + +// ContactsClientUpdateOptions contains the optional parameters for the ContactsClient.Update method. +type ContactsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PrimaryRegionProperties - The configuration used in this region as primary, and other regions as backup. +type PrimaryRegionProperties struct { + // REQUIRED; IP address to use to contact the operator network from this region + OperatorAddresses []*string `json:"operatorAddresses,omitempty"` + + // IP address to use to contact the ESRP from this region + EsrpAddresses []*string `json:"esrpAddresses,omitempty"` +} + +// ServiceRegionProperties - The service region configuration needed for Teams Callings. +type ServiceRegionProperties struct { + // REQUIRED; The name of the region in which the resources needed for Teams Calling will be deployed. + Name *string `json:"name,omitempty"` + + // REQUIRED; The configuration used in this region as primary, and other regions as backup. + PrimaryRegionProperties *PrimaryRegionProperties `json:"primaryRegionProperties,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// TestLine - A TestLine resource +type TestLine struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // The resource-specific properties for this resource. + Properties *TestLineProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// TestLineListResult - The response of a TestLine list operation. +type TestLineListResult struct { + // REQUIRED; The TestLine items on this page + Value []*TestLine `json:"value,omitempty"` + + // The link to the next page of items + NextLink *string `json:"nextLink,omitempty"` +} + +// TestLineProperties - Details of the TestLine resource. +type TestLineProperties struct { + // REQUIRED; The phone number + PhoneNumber *string `json:"phoneNumber,omitempty"` + + // REQUIRED; Purpose of this test line, e.g. automated or manual testing + Purpose *TestLinePurpose `json:"purpose,omitempty"` + + // READ-ONLY; Resource provisioning state. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// TestLineUpdate - The type used for update operations of the TestLine. +type TestLineUpdate struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// TestLinesClientBeginCreateOrUpdateOptions contains the optional parameters for the TestLinesClient.BeginCreateOrUpdate +// method. +type TestLinesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TestLinesClientBeginDeleteOptions contains the optional parameters for the TestLinesClient.BeginDelete method. +type TestLinesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TestLinesClientGetOptions contains the optional parameters for the TestLinesClient.Get method. +type TestLinesClientGetOptions struct { + // placeholder for future optional parameters +} + +// TestLinesClientListByCommunicationsGatewayOptions contains the optional parameters for the TestLinesClient.NewListByCommunicationsGatewayPager +// method. +type TestLinesClientListByCommunicationsGatewayOptions struct { + // placeholder for future optional parameters +} + +// TestLinesClientUpdateOptions contains the optional parameters for the TestLinesClient.Update method. +type TestLinesClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/models_serde.go b/sdk/resourcemanager/voiceservices/armvoiceservices/models_serde.go new file mode 100644 index 000000000000..10a20b32b7e2 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/models_serde.go @@ -0,0 +1,719 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CommunicationsGateway. +func (c CommunicationsGateway) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationsGateway. +func (c *CommunicationsGateway) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationsGatewayListResult. +func (c CommunicationsGatewayListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationsGatewayListResult. +func (c *CommunicationsGatewayListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationsGatewayProperties. +func (c CommunicationsGatewayProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiBridge", &c.APIBridge) + populate(objectMap, "codecs", c.Codecs) + populate(objectMap, "connectivity", c.Connectivity) + populate(objectMap, "e911Type", c.E911Type) + populate(objectMap, "platforms", c.Platforms) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "serviceLocations", c.ServiceLocations) + populate(objectMap, "status", c.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationsGatewayProperties. +func (c *CommunicationsGatewayProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiBridge": + err = unpopulate(val, "APIBridge", &c.APIBridge) + delete(rawMsg, key) + case "codecs": + err = unpopulate(val, "Codecs", &c.Codecs) + delete(rawMsg, key) + case "connectivity": + err = unpopulate(val, "Connectivity", &c.Connectivity) + delete(rawMsg, key) + case "e911Type": + err = unpopulate(val, "E911Type", &c.E911Type) + delete(rawMsg, key) + case "platforms": + err = unpopulate(val, "Platforms", &c.Platforms) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "serviceLocations": + err = unpopulate(val, "ServiceLocations", &c.ServiceLocations) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunicationsGatewayUpdate. +func (c CommunicationsGatewayUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunicationsGatewayUpdate. +func (c *CommunicationsGatewayUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Contact. +func (c Contact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Contact. +func (c *Contact) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContactListResult. +func (c ContactListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactListResult. +func (c *ContactListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContactProperties. +func (c ContactProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contactName", c.ContactName) + populate(objectMap, "email", c.Email) + populate(objectMap, "phoneNumber", c.PhoneNumber) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "role", c.Role) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactProperties. +func (c *ContactProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contactName": + err = unpopulate(val, "ContactName", &c.ContactName) + delete(rawMsg, key) + case "email": + err = unpopulate(val, "Email", &c.Email) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &c.PhoneNumber) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &c.Role) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContactUpdate. +func (c ContactUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContactUpdate. +func (c *ContactUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PrimaryRegionProperties. +func (p PrimaryRegionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "esrpAddresses", p.EsrpAddresses) + populate(objectMap, "operatorAddresses", p.OperatorAddresses) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrimaryRegionProperties. +func (p *PrimaryRegionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "esrpAddresses": + err = unpopulate(val, "EsrpAddresses", &p.EsrpAddresses) + delete(rawMsg, key) + case "operatorAddresses": + err = unpopulate(val, "OperatorAddresses", &p.OperatorAddresses) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceRegionProperties. +func (s ServiceRegionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "primaryRegionProperties", s.PrimaryRegionProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceRegionProperties. +func (s *ServiceRegionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "primaryRegionProperties": + err = unpopulate(val, "PrimaryRegionProperties", &s.PrimaryRegionProperties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestLine. +func (t TestLine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestLine. +func (t *TestLine) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestLineListResult. +func (t TestLineListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestLineListResult. +func (t *TestLineListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestLineProperties. +func (t TestLineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "phoneNumber", t.PhoneNumber) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "purpose", t.Purpose) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestLineProperties. +func (t *TestLineProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &t.PhoneNumber) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) + case "purpose": + err = unpopulate(val, "Purpose", &t.Purpose) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestLineUpdate. +func (t TestLineUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestLineUpdate. +func (t *TestLineUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/operations_client.go b/sdk/resourcemanager/voiceservices/armvoiceservices/operations_client.go new file mode 100644 index 000000000000..16dd45f59077 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/operations_client.go @@ -0,0 +1,105 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2022-12-01-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.VoiceServices/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/operations_client_example_test.go b/sdk/resourcemanager/voiceservices/armvoiceservices/operations_client_example_test.go new file mode 100644 index 000000000000..8e2792493ed8 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/operations_client_example_test.go @@ -0,0 +1,55 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewOperationsClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armvoiceservices.OperationListResult{ + // Value: []*armvoiceservices.Operation{ + // { + // Name: to.Ptr("Microsoft.VoiceService/communicationsGateways/write"), + // Display: &armvoiceservices.OperationDisplay{ + // Description: to.Ptr("Write communicationsGateways resource"), + // Operation: to.Ptr("write"), + // Provider: to.Ptr("Microsoft.VoiceService"), + // Resource: to.Ptr("communicationsGateways"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/response_types.go b/sdk/resourcemanager/voiceservices/armvoiceservices/response_types.go new file mode 100644 index 000000000000..d81e547fac7c --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/response_types.go @@ -0,0 +1,95 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +// CommunicationsGatewaysClientCreateOrUpdateResponse contains the response from method CommunicationsGatewaysClient.BeginCreateOrUpdate. +type CommunicationsGatewaysClientCreateOrUpdateResponse struct { + CommunicationsGateway +} + +// CommunicationsGatewaysClientDeleteResponse contains the response from method CommunicationsGatewaysClient.BeginDelete. +type CommunicationsGatewaysClientDeleteResponse struct { + // placeholder for future response values +} + +// CommunicationsGatewaysClientGetResponse contains the response from method CommunicationsGatewaysClient.Get. +type CommunicationsGatewaysClientGetResponse struct { + CommunicationsGateway +} + +// CommunicationsGatewaysClientListByResourceGroupResponse contains the response from method CommunicationsGatewaysClient.NewListByResourceGroupPager. +type CommunicationsGatewaysClientListByResourceGroupResponse struct { + CommunicationsGatewayListResult +} + +// CommunicationsGatewaysClientListBySubscriptionResponse contains the response from method CommunicationsGatewaysClient.NewListBySubscriptionPager. +type CommunicationsGatewaysClientListBySubscriptionResponse struct { + CommunicationsGatewayListResult +} + +// CommunicationsGatewaysClientUpdateResponse contains the response from method CommunicationsGatewaysClient.Update. +type CommunicationsGatewaysClientUpdateResponse struct { + CommunicationsGateway +} + +// ContactsClientCreateOrUpdateResponse contains the response from method ContactsClient.BeginCreateOrUpdate. +type ContactsClientCreateOrUpdateResponse struct { + Contact +} + +// ContactsClientDeleteResponse contains the response from method ContactsClient.BeginDelete. +type ContactsClientDeleteResponse struct { + // placeholder for future response values +} + +// ContactsClientGetResponse contains the response from method ContactsClient.Get. +type ContactsClientGetResponse struct { + Contact +} + +// ContactsClientListByCommunicationsGatewayResponse contains the response from method ContactsClient.NewListByCommunicationsGatewayPager. +type ContactsClientListByCommunicationsGatewayResponse struct { + ContactListResult +} + +// ContactsClientUpdateResponse contains the response from method ContactsClient.Update. +type ContactsClientUpdateResponse struct { + Contact +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + OperationListResult +} + +// TestLinesClientCreateOrUpdateResponse contains the response from method TestLinesClient.BeginCreateOrUpdate. +type TestLinesClientCreateOrUpdateResponse struct { + TestLine +} + +// TestLinesClientDeleteResponse contains the response from method TestLinesClient.BeginDelete. +type TestLinesClientDeleteResponse struct { + // placeholder for future response values +} + +// TestLinesClientGetResponse contains the response from method TestLinesClient.Get. +type TestLinesClientGetResponse struct { + TestLine +} + +// TestLinesClientListByCommunicationsGatewayResponse contains the response from method TestLinesClient.NewListByCommunicationsGatewayPager. +type TestLinesClientListByCommunicationsGatewayResponse struct { + TestLineListResult +} + +// TestLinesClientUpdateResponse contains the response from method TestLinesClient.Update. +type TestLinesClientUpdateResponse struct { + TestLine +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/testlines_client.go b/sdk/resourcemanager/voiceservices/armvoiceservices/testlines_client.go new file mode 100644 index 000000000000..2691bb2104e1 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/testlines_client.go @@ -0,0 +1,395 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TestLinesClient contains the methods for the TestLines group. +// Don't use this type directly, use NewTestLinesClient() instead. +type TestLinesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewTestLinesClient creates a new instance of TestLinesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewTestLinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TestLinesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &TestLinesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a TestLine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - testLineName - Unique identifier for this test line +// - resource - Resource create parameters. +// - options - TestLinesClientBeginCreateOrUpdateOptions contains the optional parameters for the TestLinesClient.BeginCreateOrUpdate +// method. +func (client *TestLinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, resource TestLine, options *TestLinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[TestLinesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, communicationsGatewayName, testLineName, resource, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TestLinesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[TestLinesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create a TestLine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +func (client *TestLinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, resource TestLine, options *TestLinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, communicationsGatewayName, testLineName, resource, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TestLinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, resource TestLine, options *TestLinesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if testLineName == "" { + return nil, errors.New("parameter testLineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{testLineName}", url.PathEscape(testLineName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, resource) +} + +// BeginDelete - Delete a TestLine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - testLineName - Unique identifier for this test line +// - options - TestLinesClientBeginDeleteOptions contains the optional parameters for the TestLinesClient.BeginDelete method. +func (client *TestLinesClient) BeginDelete(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, options *TestLinesClientBeginDeleteOptions) (*runtime.Poller[TestLinesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communicationsGatewayName, testLineName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[TestLinesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[TestLinesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Delete a TestLine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +func (client *TestLinesClient) deleteOperation(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, options *TestLinesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, communicationsGatewayName, testLineName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TestLinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, options *TestLinesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if testLineName == "" { + return nil, errors.New("parameter testLineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{testLineName}", url.PathEscape(testLineName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a TestLine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - testLineName - Unique identifier for this test line +// - options - TestLinesClientGetOptions contains the optional parameters for the TestLinesClient.Get method. +func (client *TestLinesClient) Get(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, options *TestLinesClientGetOptions) (TestLinesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, communicationsGatewayName, testLineName, options) + if err != nil { + return TestLinesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TestLinesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TestLinesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TestLinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, options *TestLinesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if testLineName == "" { + return nil, errors.New("parameter testLineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{testLineName}", url.PathEscape(testLineName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TestLinesClient) getHandleResponse(resp *http.Response) (TestLinesClientGetResponse, error) { + result := TestLinesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TestLine); err != nil { + return TestLinesClientGetResponse{}, err + } + return result, nil +} + +// NewListByCommunicationsGatewayPager - List TestLine resources by CommunicationsGateway +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - options - TestLinesClientListByCommunicationsGatewayOptions contains the optional parameters for the TestLinesClient.NewListByCommunicationsGatewayPager +// method. +func (client *TestLinesClient) NewListByCommunicationsGatewayPager(resourceGroupName string, communicationsGatewayName string, options *TestLinesClientListByCommunicationsGatewayOptions) *runtime.Pager[TestLinesClientListByCommunicationsGatewayResponse] { + return runtime.NewPager(runtime.PagingHandler[TestLinesClientListByCommunicationsGatewayResponse]{ + More: func(page TestLinesClientListByCommunicationsGatewayResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TestLinesClientListByCommunicationsGatewayResponse) (TestLinesClientListByCommunicationsGatewayResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByCommunicationsGatewayCreateRequest(ctx, resourceGroupName, communicationsGatewayName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return TestLinesClientListByCommunicationsGatewayResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TestLinesClientListByCommunicationsGatewayResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TestLinesClientListByCommunicationsGatewayResponse{}, runtime.NewResponseError(resp) + } + return client.listByCommunicationsGatewayHandleResponse(resp) + }, + }) +} + +// listByCommunicationsGatewayCreateRequest creates the ListByCommunicationsGateway request. +func (client *TestLinesClient) listByCommunicationsGatewayCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, options *TestLinesClientListByCommunicationsGatewayOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCommunicationsGatewayHandleResponse handles the ListByCommunicationsGateway response. +func (client *TestLinesClient) listByCommunicationsGatewayHandleResponse(resp *http.Response) (TestLinesClientListByCommunicationsGatewayResponse, error) { + result := TestLinesClientListByCommunicationsGatewayResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TestLineListResult); err != nil { + return TestLinesClientListByCommunicationsGatewayResponse{}, err + } + return result, nil +} + +// Update - Update a TestLine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communicationsGatewayName - Unique identifier for this deployment +// - testLineName - Unique identifier for this test line +// - properties - The resource properties to be updated. +// - options - TestLinesClientUpdateOptions contains the optional parameters for the TestLinesClient.Update method. +func (client *TestLinesClient) Update(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, properties TestLineUpdate, options *TestLinesClientUpdateOptions) (TestLinesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, communicationsGatewayName, testLineName, properties, options) + if err != nil { + return TestLinesClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return TestLinesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return TestLinesClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *TestLinesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communicationsGatewayName string, testLineName string, properties TestLineUpdate, options *TestLinesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VoiceServices/communicationsGateways/{communicationsGatewayName}/testLines/{testLineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communicationsGatewayName == "" { + return nil, errors.New("parameter communicationsGatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communicationsGatewayName}", url.PathEscape(communicationsGatewayName)) + if testLineName == "" { + return nil, errors.New("parameter testLineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{testLineName}", url.PathEscape(testLineName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, properties) +} + +// updateHandleResponse handles the Update response. +func (client *TestLinesClient) updateHandleResponse(resp *http.Response) (TestLinesClientUpdateResponse, error) { + result := TestLinesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TestLine); err != nil { + return TestLinesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/testlines_client_example_test.go b/sdk/resourcemanager/voiceservices/armvoiceservices/testlines_client_example_test.go new file mode 100644 index 000000000000..4d9bded6f9af --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/testlines_client_example_test.go @@ -0,0 +1,178 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/voiceservices/armvoiceservices" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/TestLines_ListByCommunicationsGateway.json +func ExampleTestLinesClient_NewListByCommunicationsGatewayPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewTestLinesClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByCommunicationsGatewayPager("testrg", "myname", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.TestLineListResult = armvoiceservices.TestLineListResult{ + // Value: []*armvoiceservices.TestLine{ + // { + // Name: to.Ptr("myline"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/testLines"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/TestLines/myline"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.TestLineProperties{ + // PhoneNumber: to.Ptr("+1-555-1234"), + // Purpose: to.Ptr(armvoiceservices.TestLinePurposeAutomated), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/TestLines_Get.json +func ExampleTestLinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewTestLinesClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "testrg", "myname", "myline", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TestLine = armvoiceservices.TestLine{ + // Name: to.Ptr("myline"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/testLines"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/TestLines/myline"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.TestLineProperties{ + // PhoneNumber: to.Ptr("+1-555-1234"), + // Purpose: to.Ptr(armvoiceservices.TestLinePurposeAutomated), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/TestLines_CreateOrUpdate.json +func ExampleTestLinesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewTestLinesClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "testrg", "myname", "myline", armvoiceservices.TestLine{ + Location: to.Ptr("useast"), + Properties: &armvoiceservices.TestLineProperties{ + PhoneNumber: to.Ptr("+1-555-1234"), + Purpose: to.Ptr(armvoiceservices.TestLinePurposeAutomated), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TestLine = armvoiceservices.TestLine{ + // Name: to.Ptr("myline"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/testLines"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/TestLines/myline"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.TestLineProperties{ + // PhoneNumber: to.Ptr("+1-555-1234"), + // Purpose: to.Ptr(armvoiceservices.TestLinePurposeAutomated), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/TestLines_Delete.json +func ExampleTestLinesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewTestLinesClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginDelete(ctx, "testrg", "myname", "myline", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a7b696c2c73218fbca91c7c3bb625ee0f0bbea0/specification/voiceservices/resource-manager/Microsoft.VoiceServices/preview/2022-12-01-preview/examples/TestLines_Update.json +func ExampleTestLinesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armvoiceservices.NewTestLinesClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Update(ctx, "testrg", "myname", "myline", armvoiceservices.TestLineUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.TestLine = armvoiceservices.TestLine{ + // Name: to.Ptr("myline"), + // Type: to.Ptr("Microsoft.Voiceservice/communicationsGateways/testLines"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.VoiceService/communicationsGateway/myname/TestLines/myline"), + // Location: to.Ptr("useast"), + // Properties: &armvoiceservices.TestLineProperties{ + // PhoneNumber: to.Ptr("+1-555-1234"), + // Purpose: to.Ptr(armvoiceservices.TestLinePurposeAutomated), + // }, + // } +} diff --git a/sdk/resourcemanager/voiceservices/armvoiceservices/time_rfc3339.go b/sdk/resourcemanager/voiceservices/armvoiceservices/time_rfc3339.go new file mode 100644 index 000000000000..e30ba2185bc9 --- /dev/null +++ b/sdk/resourcemanager/voiceservices/armvoiceservices/time_rfc3339.go @@ -0,0 +1,87 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvoiceservices + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}