diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/CHANGELOG.md b/sdk/resourcemanager/videoindexer/armvideoindexer/CHANGELOG.md new file mode 100644 index 000000000000..e71ad8ce18a0 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-01-06) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/LICENSE.txt b/sdk/resourcemanager/videoindexer/armvideoindexer/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/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/videoindexer/armvideoindexer/README.md b/sdk/resourcemanager/videoindexer/armvideoindexer/README.md new file mode 100644 index 000000000000..0d0e3c8644ea --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/README.md @@ -0,0 +1,75 @@ +# Azure Videoindexer Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoindexer/armvideoindexer)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoindexer/armvideoindexer) + +The `armvideoindexer` module provides operations for working with Azure Videoindexer. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/videoindexer/armvideoindexer) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.16 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Videoindexer module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoindexer/armvideoindexer +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Videoindexer. 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 Videoindexer 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 := armvideoindexer.NewGenerateClient(, 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{ + Host: arm.AzureChina, +} +client := armvideoindexer.NewGenerateClient(, 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 `Videoindexer` 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/videoindexer/armvideoindexer/autorest.md b/sdk/resourcemanager/videoindexer/armvideoindexer/autorest.md new file mode 100644 index 000000000000..faeb8668d63d --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/vi/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/vi/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/build.go b/sdk/resourcemanager/videoindexer/armvideoindexer/build.go new file mode 100644 index 000000000000..025bcb9389ae --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/videoindexer/armvideoindexer + +package armvideoindexer diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/ci.yml b/sdk/resourcemanager/videoindexer/armvideoindexer/ci.yml new file mode 100644 index 000000000000..45903561e38a --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/ci.yml @@ -0,0 +1,27 @@ +# 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/videoindexer/armvideoindexer/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/videoindexer/armvideoindexer/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/videoindexer/armvideoindexer' diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/go.mod b/sdk/resourcemanager/videoindexer/armvideoindexer/go.mod new file mode 100644 index 000000000000..6e617cc841be --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoindexer/armvideoindexer + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v61.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/go.sum b/sdk/resourcemanager/videoindexer/armvideoindexer/go.sum new file mode 100644 index 000000000000..157cc6bbf788 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v61.1.0+incompatible h1:Qbz3jdfkXIPjZECEuk2E7i3iLhC9Ul74pG5mQRQC+z4= +github.com/Azure/azure-sdk-for-go v61.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/go_mod_tidy_hack.go b/sdk/resourcemanager/videoindexer/armvideoindexer/go_mod_tidy_hack.go new file mode 100644 index 000000000000..f068af713c85 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armvideoindexer + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_accounts_client.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_accounts_client.go new file mode 100644 index 000000000000..12517dc0d528 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_accounts_client.go @@ -0,0 +1,472 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AccountsClient contains the methods for the Accounts group. +// Don't use this type directly, use NewAccountsClient() instead. +type AccountsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAccountsClient creates a new instance of AccountsClient with the specified values. +func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AccountsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks that the Video Indexer account name is valid and is not already in use. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityParameters AccountCheckNameAvailabilityParameters, options *AccountsCheckNameAvailabilityOptions) (AccountsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, checkNameAvailabilityParameters, options) + if err != nil { + return AccountsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *AccountsClient) checkNameAvailabilityCreateRequest(ctx context.Context, checkNameAvailabilityParameters AccountCheckNameAvailabilityParameters, options *AccountsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.VideoIndexer/checkNameAvailability" + 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.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, checkNameAvailabilityParameters) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *AccountsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (AccountsCheckNameAvailabilityResponse, error) { + result := AccountsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResult); err != nil { + return AccountsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *AccountsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// CreateOrUpdate - Creates or updates an Azure Video Analyzer for Media account. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse +func (client *AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, options *AccountsCreateOrUpdateOptions) (AccountsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AccountsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, *options.Parameters) + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AccountsClient) createOrUpdateHandleResponse(resp *http.Response) (AccountsCreateOrUpdateResponse, error) { + result := AccountsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Account); err != nil { + return AccountsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AccountsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete an Azure Video Analyzer for Media account. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse +func (client *AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *AccountsDeleteOptions) (AccountsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return AccountsDeleteResponse{}, client.deleteHandleError(resp) + } + return AccountsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AccountsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the properties of an Azure Video Analyzer for Media account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *AccountsGetOptions) (AccountsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsGetResponse, error) { + result := AccountsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Account); err != nil { + return AccountsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AccountsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List all Azure Video Analyzer for Media accounts available under the subscription +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) List(options *AccountsListOptions) *AccountsListPager { + return &AccountsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp AccountsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AccountList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *AccountsClient) listCreateRequest(ctx context.Context, options *AccountsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.VideoIndexer/accounts" + 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.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsListResponse, error) { + result := AccountsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountList); err != nil { + return AccountsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *AccountsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - List all Azure Video Analyzer for Media accounts available under the resource group +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccountsClient) ListByResourceGroup(resourceGroupName string, options *AccountsListByResourceGroupOptions) *AccountsListByResourceGroupPager { + return &AccountsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp AccountsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AccountList.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AccountsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts" + 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.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (AccountsListByResourceGroupResponse, error) { + result := AccountsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountList); err != nil { + return AccountsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *AccountsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Updates the properties of an existing Azure Video Analyzer for Media account. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse +func (client *AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, options *AccountsUpdateOptions) (AccountsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return AccountsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccountsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccountsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts/{accountName}" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, *options.Parameters) + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *AccountsClient) updateHandleResponse(resp *http.Response) (AccountsUpdateResponse, error) { + result := AccountsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Account); err != nil { + return AccountsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *AccountsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_classicaccounts_client.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_classicaccounts_client.go new file mode 100644 index 000000000000..6818d54a75b2 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_classicaccounts_client.go @@ -0,0 +1,104 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ClassicAccountsClient contains the methods for the ClassicAccounts group. +// Don't use this type directly, use NewClassicAccountsClient() instead. +type ClassicAccountsClient struct { + ep string + pl runtime.Pipeline +} + +// NewClassicAccountsClient creates a new instance of ClassicAccountsClient with the specified values. +func NewClassicAccountsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *ClassicAccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ClassicAccountsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// GetDetails - Gets the properties of an Azure Video Analyzer for Media Classic account. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse +func (client *ClassicAccountsClient) GetDetails(ctx context.Context, location string, accountName string, options *ClassicAccountsGetDetailsOptions) (ClassicAccountsGetDetailsResponse, error) { + req, err := client.getDetailsCreateRequest(ctx, location, accountName, options) + if err != nil { + return ClassicAccountsGetDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClassicAccountsGetDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClassicAccountsGetDetailsResponse{}, client.getDetailsHandleError(resp) + } + return client.getDetailsHandleResponse(resp) +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *ClassicAccountsClient) getDetailsCreateRequest(ctx context.Context, location string, accountName string, options *ClassicAccountsGetDetailsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.VideoIndexer/locations/{location}/classicAccounts/{accountName}" + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *ClassicAccountsClient) getDetailsHandleResponse(resp *http.Response) (ClassicAccountsGetDetailsResponse, error) { + result := ClassicAccountsGetDetailsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClassicAccount); err != nil { + return ClassicAccountsGetDetailsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getDetailsHandleError handles the GetDetails error response. +func (client *ClassicAccountsClient) getDetailsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_constants.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_constants.go new file mode 100644 index 000000000000..05b3021c1d9f --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_constants.go @@ -0,0 +1,175 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +const ( + module = "armvideoindexer" + version = "v0.1.0" +) + +// 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, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// ToPtr returns a *ManagedServiceIdentityType pointing to the current value. +func (c ManagedServiceIdentityType) ToPtr() *ManagedServiceIdentityType { + return &c +} + +// PermissionType - The requested permission +type PermissionType string + +const ( + PermissionTypeContributor PermissionType = "Contributor" + PermissionTypeReader PermissionType = "Reader" +) + +// PossiblePermissionTypeValues returns the possible values for the PermissionType const type. +func PossiblePermissionTypeValues() []PermissionType { + return []PermissionType{ + PermissionTypeContributor, + PermissionTypeReader, + } +} + +// ToPtr returns a *PermissionType pointing to the current value. +func (c PermissionType) ToPtr() *PermissionType { + return &c +} + +// ProvisioningState - Gets the status of the account at the time the operation was called. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// Reason - Gets the reason that a Video Indexer account name could not be used. The Reason element is only returned if NameAvailable is false. +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" +) + +// PossibleReasonValues returns the possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonAlreadyExists, + } +} + +// ToPtr returns a *Reason pointing to the current value. +func (c Reason) ToPtr() *Reason { + return &c +} + +// Scope - The requested media type +type Scope string + +const ( + ScopeAccount Scope = "Account" + ScopeProject Scope = "Project" + ScopeVideo Scope = "Video" +) + +// PossibleScopeValues returns the possible values for the Scope const type. +func PossibleScopeValues() []Scope { + return []Scope{ + ScopeAccount, + ScopeProject, + ScopeVideo, + } +} + +// ToPtr returns a *Scope pointing to the current value. +func (c Scope) ToPtr() *Scope { + return &c +} + +// Type - The type of resource, Microsoft.VideoIndexer/accounts +type Type string + +const ( + TypeMicrosoftVideoIndexerAccounts Type = "Microsoft.VideoIndexer/accounts" +) + +// PossibleTypeValues returns the possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ + TypeMicrosoftVideoIndexerAccounts, + } +} + +// ToPtr returns a *Type pointing to the current value. +func (c Type) ToPtr() *Type { + return &c +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_generate_client.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_generate_client.go new file mode 100644 index 000000000000..763905e0d8f9 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_generate_client.go @@ -0,0 +1,112 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GenerateClient contains the methods for the Generate group. +// Don't use this type directly, use NewGenerateClient() instead. +type GenerateClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewGenerateClient creates a new instance of GenerateClient with the specified values. +func NewGenerateClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GenerateClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GenerateClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// AccessToken - Generate an Azure Video Analyzer for Media access token. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse, *ErrorResponse +func (client *GenerateClient) AccessToken(ctx context.Context, resourceGroupName string, accountName string, options *GenerateAccessTokenOptions) (GenerateAccessTokenResponse, error) { + req, err := client.accessTokenCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return GenerateAccessTokenResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GenerateAccessTokenResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GenerateAccessTokenResponse{}, client.accessTokenHandleError(resp) + } + return client.accessTokenHandleResponse(resp) +} + +// accessTokenCreateRequest creates the AccessToken request. +func (client *GenerateClient) accessTokenCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *GenerateAccessTokenOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VideoIndexer/accounts/{accountName}/generateAccessToken" + 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 accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, *options.Parameters) + } + return req, nil +} + +// accessTokenHandleResponse handles the AccessToken response. +func (client *GenerateClient) accessTokenHandleResponse(resp *http.Response) (GenerateAccessTokenResponse, error) { + result := GenerateAccessTokenResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessToken); err != nil { + return GenerateAccessTokenResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// accessTokenHandleError handles the AccessToken error response. +func (client *GenerateClient) accessTokenHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_models.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_models.go new file mode 100644 index 000000000000..aed32027bdb6 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_models.go @@ -0,0 +1,570 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AccessToken - Azure Video Analyzer for Media access token. +type AccessToken struct { + // READ-ONLY; The access token. + AccessToken *string `json:"accessToken,omitempty" azure:"ro"` +} + +// Account - An Azure Video Analyzer for Media account. +type Account struct { + TrackedResource + // Managed service identity (system assigned and/or user assigned identities) + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // List of account properties + Properties *AccountPropertiesForPutRequest `json:"properties,omitempty"` + + // READ-ONLY; The system meta data relating to this resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + return json.Marshal(objectMap) +} + +// AccountCheckNameAvailabilityParameters - The parameters used to check the availability of the Video Indexer account name. +type AccountCheckNameAvailabilityParameters struct { + // REQUIRED; The VideoIndexer account name. + Name *string `json:"name,omitempty"` + + // REQUIRED; The type of resource, Microsoft.VideoIndexer/accounts + Type *Type `json:"type,omitempty"` +} + +// AccountList - The list operation response, that contains the data pools and their properties. +type AccountList struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; List of accounts and their properties. + Value []*Account `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccountList. +func (a AccountList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AccountPatch - Azure Video Analyzer for Media account +type AccountPatch struct { + Tags + // Managed service identity (system assigned and/or user assigned identities) + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // List of account properties + Properties *AccountPropertiesForPatchRequest `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPatch. +func (a AccountPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.Tags.marshalInternal(objectMap) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AccountPropertiesForPatchRequest - Azure Video Analyzer for Media account properties +type AccountPropertiesForPatchRequest struct { + // The media services details + MediaServices *MediaServicesForPatchRequest `json:"mediaServices,omitempty"` + + // READ-ONLY; The account's data-plane ID + AccountID *string `json:"accountId,omitempty" azure:"ro"` + + // READ-ONLY; Gets the status of the account at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The account's tenant id + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// AccountPropertiesForPutRequest - Azure Video Analyzer for Media account properties +type AccountPropertiesForPutRequest struct { + // The account's data-plane ID + AccountID *string `json:"accountId,omitempty"` + + // The media services details + MediaServices *MediaServicesForPutRequest `json:"mediaServices,omitempty"` + + // READ-ONLY; The account's name + AccountName *string `json:"accountName,omitempty" azure:"ro"` + + // READ-ONLY; Gets the status of the account at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The account's tenant id + TenantID *string `json:"tenantId,omitempty" azure:"ro"` + + // READ-ONLY; An integer representing the total seconds that have been indexed on the account + TotalSecondsIndexed *int32 `json:"totalSecondsIndexed,omitempty" azure:"ro"` +} + +// AccountsCheckNameAvailabilityOptions contains the optional parameters for the Accounts.CheckNameAvailability method. +type AccountsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// AccountsCreateOrUpdateOptions contains the optional parameters for the Accounts.CreateOrUpdate method. +type AccountsCreateOrUpdateOptions struct { + // The parameters to provide for the Azure Video Analyzer for Media account. + Parameters *Account +} + +// AccountsDeleteOptions contains the optional parameters for the Accounts.Delete method. +type AccountsDeleteOptions struct { + // placeholder for future optional parameters +} + +// AccountsGetOptions contains the optional parameters for the Accounts.Get method. +type AccountsGetOptions struct { + // placeholder for future optional parameters +} + +// AccountsListByResourceGroupOptions contains the optional parameters for the Accounts.ListByResourceGroup method. +type AccountsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AccountsListOptions contains the optional parameters for the Accounts.List method. +type AccountsListOptions struct { + // placeholder for future optional parameters +} + +// AccountsUpdateOptions contains the optional parameters for the Accounts.Update method. +type AccountsUpdateOptions struct { + // The parameters to provide for the current Azure Video Analyzer for Media account. + Parameters *AccountPatch +} + +// CheckNameAvailabilityResult - The CheckNameAvailability operation response. +type CheckNameAvailabilityResult struct { + // READ-ONLY; Gets an error message explaining the Reason value in more detail. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; Gets a boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already + // been taken. + NameAvailable *bool `json:"nameAvailable,omitempty" azure:"ro"` + + // READ-ONLY; Gets the reason that a Video Indexer account name could not be used. The Reason element is only returned if NameAvailable is false. + Reason *Reason `json:"reason,omitempty" azure:"ro"` +} + +// ClassicAccount - An Azure Video Analyzer for Media classic account. +type ClassicAccount struct { + // The account's location + Location *string `json:"location,omitempty"` + + // List of classic account properties + Properties *ClassicAccountProperties `json:"properties,omitempty"` + + // READ-ONLY; The account's name + Name *string `json:"name,omitempty" azure:"ro"` +} + +// ClassicAccountMediaServices - Azure Video Analyzer for Media classic account properties +type ClassicAccountMediaServices struct { + // The aad application id + AADApplicationID *string `json:"aadApplicationId,omitempty"` + + // The aad tenant id + AADTenantID *string `json:"aadTenantId,omitempty"` + + // Represents wether the media services is connected or not + Connected *bool `json:"connected,omitempty"` + + // Represents if the media services event grid is connected or not + EventGridProviderRegistered *bool `json:"eventGridProviderRegistered,omitempty"` + + // The media services name + Name *string `json:"name,omitempty"` + + // The resource group that the media services belong to + ResourceGroup *string `json:"resourceGroup,omitempty"` + + // Represents wether the media services streaming endpoint has started + StreamingEndpointStarted *bool `json:"streamingEndpointStarted,omitempty"` + + // The media services subscriptionId + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// ClassicAccountProperties - Azure Video Analyzer for Media classic account properties +type ClassicAccountProperties struct { + // The media services details + MediaServices *ClassicAccountMediaServices `json:"mediaServices,omitempty"` +} + +// ClassicAccountSlim - An Azure Video Analyzer for Media classic account. +type ClassicAccountSlim struct { + // READ-ONLY; The account's location + Location *string `json:"location,omitempty" azure:"ro"` + + // READ-ONLY; The account's name + Name *string `json:"name,omitempty" azure:"ro"` +} + +// ClassicAccountsGetDetailsOptions contains the optional parameters for the ClassicAccounts.GetDetails method. +type ClassicAccountsGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// ErrorDefinition - Error definition. +type ErrorDefinition struct { + // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Internal error details. + Details []*ErrorDefinition `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; Description of the error. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. +func (e ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// ErrorResponse - Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error details. + InnerError *ErrorDefinition `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// GenerateAccessTokenOptions contains the optional parameters for the Generate.AccessToken method. +type GenerateAccessTokenOptions struct { + // The parameters for generating access token + Parameters *GenerateAccessTokenParameters +} + +// GenerateAccessTokenParameters - Access token generation request's parameters +type GenerateAccessTokenParameters struct { + // REQUIRED; The requested permission + PermissionType *PermissionType `json:"permissionType,omitempty"` + + // REQUIRED; The requested media type + Scope *Scope `json:"scope,omitempty"` + + // The project ID + ProjectID *string `json:"projectId,omitempty"` + + // The video ID + VideoID *string `json:"videoId,omitempty"` +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType `json:"type,omitempty"` + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary + // values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// MediaServicesForPatchRequest - The media services details +type MediaServicesForPatchRequest struct { + // The user assigned identity to be used to grant permissions + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} + +// MediaServicesForPutRequest - The media services details +type MediaServicesForPutRequest struct { + // The media services resource id + ResourceID *string `json:"resourceId,omitempty"` + + // The user assigned identity to be used to grant permissions + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} + +// Operation detail payload +type Operation struct { + // READ-ONLY; Indicates the action type. + ActionType *string `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Display of the operation + Display *OperationDisplay `json:"display,omitempty" azure:"ro"` + + // READ-ONLY; Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; Name of the operation + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Origin of the operation + Origin *string `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Operation display payload +type OperationDisplay struct { + // READ-ONLY; Localized friendly description for the operation + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Localized friendly name for the operation + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Resource provider of the operation + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; Resource of the operation + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - Available operations of the service. +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"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // 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; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// Tags - Resource tags +type Tags struct { + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Tags. +func (t Tags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t Tags) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "tags", t.Tags) +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// UserClassicAccountList - The list of user classic accounts. +type UserClassicAccountList struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; List of classic account names and their location. + Value []*ClassicAccountSlim `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserClassicAccountList. +func (u UserClassicAccountList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UserClassicAccountsListOptions contains the optional parameters for the UserClassicAccounts.List method. +type UserClassicAccountsListOptions struct { + // placeholder for future optional parameters +} + +func populate(m map[string]interface{}, k string, v interface{}) { + 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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_operations_client.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_operations_client.go new file mode 100644 index 000000000000..7e4067b94fc3 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "context" + "fmt" + "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/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 { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available Azure Video Analyzer for Media provider operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.VideoIndexer/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_pagers.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_pagers.go new file mode 100644 index 000000000000..d37f613a4b33 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_pagers.go @@ -0,0 +1,233 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// AccountsListByResourceGroupPager provides operations for iterating over paged responses. +type AccountsListByResourceGroupPager struct { + client *AccountsClient + current AccountsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AccountsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AccountsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AccountsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AccountList.NextLink == nil || len(*p.current.AccountList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AccountsListByResourceGroupResponse page. +func (p *AccountsListByResourceGroupPager) PageResponse() AccountsListByResourceGroupResponse { + return p.current +} + +// AccountsListPager provides operations for iterating over paged responses. +type AccountsListPager struct { + client *AccountsClient + current AccountsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AccountsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AccountsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AccountsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AccountList.NextLink == nil || len(*p.current.AccountList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AccountsListResponse page. +func (p *AccountsListPager) PageResponse() AccountsListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} + +// UserClassicAccountsListPager provides operations for iterating over paged responses. +type UserClassicAccountsListPager struct { + client *UserClassicAccountsClient + current UserClassicAccountsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, UserClassicAccountsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *UserClassicAccountsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *UserClassicAccountsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.UserClassicAccountList.NextLink == nil || len(*p.current.UserClassicAccountList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current UserClassicAccountsListResponse page. +func (p *UserClassicAccountsListPager) PageResponse() UserClassicAccountsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_response_types.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_response_types.go new file mode 100644 index 000000000000..fa39f2196b90 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_response_types.go @@ -0,0 +1,137 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import "net/http" + +// AccountsCheckNameAvailabilityResponse contains the response from method Accounts.CheckNameAvailability. +type AccountsCheckNameAvailabilityResponse struct { + AccountsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsCheckNameAvailabilityResult contains the result from method Accounts.CheckNameAvailability. +type AccountsCheckNameAvailabilityResult struct { + CheckNameAvailabilityResult +} + +// AccountsCreateOrUpdateResponse contains the response from method Accounts.CreateOrUpdate. +type AccountsCreateOrUpdateResponse struct { + AccountsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsCreateOrUpdateResult contains the result from method Accounts.CreateOrUpdate. +type AccountsCreateOrUpdateResult struct { + Account +} + +// AccountsDeleteResponse contains the response from method Accounts.Delete. +type AccountsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsGetResponse contains the response from method Accounts.Get. +type AccountsGetResponse struct { + AccountsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsGetResult contains the result from method Accounts.Get. +type AccountsGetResult struct { + Account +} + +// AccountsListByResourceGroupResponse contains the response from method Accounts.ListByResourceGroup. +type AccountsListByResourceGroupResponse struct { + AccountsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsListByResourceGroupResult contains the result from method Accounts.ListByResourceGroup. +type AccountsListByResourceGroupResult struct { + AccountList +} + +// AccountsListResponse contains the response from method Accounts.List. +type AccountsListResponse struct { + AccountsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsListResult contains the result from method Accounts.List. +type AccountsListResult struct { + AccountList +} + +// AccountsUpdateResponse contains the response from method Accounts.Update. +type AccountsUpdateResponse struct { + AccountsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccountsUpdateResult contains the result from method Accounts.Update. +type AccountsUpdateResult struct { + Account +} + +// ClassicAccountsGetDetailsResponse contains the response from method ClassicAccounts.GetDetails. +type ClassicAccountsGetDetailsResponse struct { + ClassicAccountsGetDetailsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClassicAccountsGetDetailsResult contains the result from method ClassicAccounts.GetDetails. +type ClassicAccountsGetDetailsResult struct { + ClassicAccount +} + +// GenerateAccessTokenResponse contains the response from method Generate.AccessToken. +type GenerateAccessTokenResponse struct { + GenerateAccessTokenResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GenerateAccessTokenResult contains the result from method Generate.AccessToken. +type GenerateAccessTokenResult struct { + AccessToken +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// UserClassicAccountsListResponse contains the response from method UserClassicAccounts.List. +type UserClassicAccountsListResponse struct { + UserClassicAccountsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserClassicAccountsListResult contains the result from method UserClassicAccounts.List. +type UserClassicAccountsListResult struct { + UserClassicAccountList +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_time_rfc3339.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..2f719528e032 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "encoding/json" + "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]interface{}, 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, 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 err + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_userclassicaccounts_client.go b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_userclassicaccounts_client.go new file mode 100644 index 000000000000..aefa405555c1 --- /dev/null +++ b/sdk/resourcemanager/videoindexer/armvideoindexer/zz_generated_userclassicaccounts_client.go @@ -0,0 +1,97 @@ +//go:build go1.16 +// +build go1.16 + +// 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. + +package armvideoindexer + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// UserClassicAccountsClient contains the methods for the UserClassicAccounts group. +// Don't use this type directly, use NewUserClassicAccountsClient() instead. +type UserClassicAccountsClient struct { + ep string + pl runtime.Pipeline +} + +// NewUserClassicAccountsClient creates a new instance of UserClassicAccountsClient with the specified values. +func NewUserClassicAccountsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *UserClassicAccountsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &UserClassicAccountsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all Azure Video Analyzer for Media classic accounts +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse +func (client *UserClassicAccountsClient) List(location string, options *UserClassicAccountsListOptions) *UserClassicAccountsListPager { + return &UserClassicAccountsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, location, options) + }, + advancer: func(ctx context.Context, resp UserClassicAccountsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.UserClassicAccountList.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *UserClassicAccountsClient) listCreateRequest(ctx context.Context, location string, options *UserClassicAccountsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.VideoIndexer/locations/{location}/userClassicAccounts" + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-11-10-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *UserClassicAccountsClient) listHandleResponse(resp *http.Response) (UserClassicAccountsListResponse, error) { + result := UserClassicAccountsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.UserClassicAccountList); err != nil { + return UserClassicAccountsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *UserClassicAccountsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +}