diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/CHANGELOG.md b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/CHANGELOG.md new file mode 100644 index 000000000000..1dea10904247 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-23) + +- Init release. diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/LICENSE.txt b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/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/videoanalyzer/armvideoanalyzer/README.md b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/README.md new file mode 100644 index 000000000000..e3242e1afd8b --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/README.md @@ -0,0 +1,75 @@ +# Azure Video Analyzer Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer) + +The `armvideoanalyzer` module provides operations for working with Azure Video Analyzer. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/videoanalyzer/armvideoanalyzer) + +# 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 Video Analyzer module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Video Analyzer. 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 Video Analyzer 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 := armvideoanalyzer.NewVideoAnalyzersClient(, 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 := armvideoanalyzer.NewVideoAnalyzersClient(, 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 `Video Analyzer` 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/videoanalyzer/armvideoanalyzer/autorest.md b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/autorest.md new file mode 100644 index 000000000000..a94ef7500190 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/c09b26d4aaa40fb37380aae01b7019b75cff3e34/specification/videoanalyzer/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/c09b26d4aaa40fb37380aae01b7019b75cff3e34/specification/videoanalyzer/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/videoanalyzer/armvideoanalyzer/build.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/build.go new file mode 100644 index 000000000000..1de6433bfe7f --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/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/videoanalyzer/armvideoanalyzer + +package armvideoanalyzer diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ci.yml b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ci.yml new file mode 100644 index 000000000000..a1a7b824e33f --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/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/videoanalyzer/armvideoanalyzer/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/videoanalyzer/armvideoanalyzer' diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go.mod b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go.mod new file mode 100644 index 000000000000..6534a8e0aa58 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v60.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 +) diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go.sum b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go.sum new file mode 100644 index 000000000000..35739a609db5 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go.sum @@ -0,0 +1,45 @@ +github.com/Azure/azure-sdk-for-go v60.1.0+incompatible h1:j6y8ddurcaiyLfwBwPmJFaunp6BDzyQTuAgMrm1r++o= +github.com/Azure/azure-sdk-for-go v60.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/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS9cgjHVYSH6DDa0XJMyrblsI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0/go.mod h1:GJzjM4SR9T0KyX5gKCVyz1ytD8FeWeUPCwtFCt1AyfE= +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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/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/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +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/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go_mod_tidy_hack.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/go_mod_tidy_hack.go new file mode 100644 index 000000000000..650553d3d529 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/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 armvideoanalyzer + +// 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/videoanalyzer/armvideoanalyzer/ze_generated_example_accesspolicies_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_accesspolicies_client_test.go new file mode 100644 index 000000000000..fe14978a26bc --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_accesspolicies_client_test.go @@ -0,0 +1,198 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/access-policy-list.json +func ExampleAccessPoliciesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewAccessPoliciesClient("", cred, nil) + pager := client.List("", + "", + &armvideoanalyzer.AccessPoliciesListOptions{Top: to.Int32Ptr(2)}) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("AccessPolicyEntity.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/access-policy-get.json +func ExampleAccessPoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewAccessPoliciesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("AccessPolicyEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/access-policy-create.json +func ExampleAccessPoliciesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewAccessPoliciesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armvideoanalyzer.AccessPolicyEntity{ + Properties: &armvideoanalyzer.AccessPolicyProperties{ + Authentication: &armvideoanalyzer.JwtAuthentication{ + AuthenticationBase: armvideoanalyzer.AuthenticationBase{ + Type: to.StringPtr(""), + }, + Audiences: []*string{ + to.StringPtr("audience1")}, + Claims: []*armvideoanalyzer.TokenClaim{ + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }, + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }}, + Issuers: []*string{ + to.StringPtr("issuer1"), + to.StringPtr("issuer2")}, + Keys: []armvideoanalyzer.TokenKeyClassification{ + &armvideoanalyzer.RsaTokenKey{ + TokenKey: armvideoanalyzer.TokenKey{ + Type: to.StringPtr(""), + Kid: to.StringPtr(""), + }, + Alg: armvideoanalyzer.AccessPolicyRsaAlgoRS256.ToPtr(), + E: to.StringPtr(""), + N: to.StringPtr(""), + }, + &armvideoanalyzer.EccTokenKey{ + TokenKey: armvideoanalyzer.TokenKey{ + Type: to.StringPtr(""), + Kid: to.StringPtr(""), + }, + Alg: armvideoanalyzer.AccessPolicyEccAlgoES256.ToPtr(), + X: to.StringPtr(""), + Y: to.StringPtr(""), + }}, + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("AccessPolicyEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/access-policy-delete.json +func ExampleAccessPoliciesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewAccessPoliciesClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/access-policy-patch.json +func ExampleAccessPoliciesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewAccessPoliciesClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + "", + armvideoanalyzer.AccessPolicyEntity{ + Properties: &armvideoanalyzer.AccessPolicyProperties{ + Authentication: &armvideoanalyzer.JwtAuthentication{ + AuthenticationBase: armvideoanalyzer.AuthenticationBase{ + Type: to.StringPtr(""), + }, + Audiences: []*string{ + to.StringPtr("audience1")}, + Claims: []*armvideoanalyzer.TokenClaim{ + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }, + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }}, + Issuers: []*string{ + to.StringPtr("issuer1"), + to.StringPtr("issuer2")}, + Keys: []armvideoanalyzer.TokenKeyClassification{ + &armvideoanalyzer.RsaTokenKey{ + TokenKey: armvideoanalyzer.TokenKey{ + Type: to.StringPtr(""), + Kid: to.StringPtr(""), + }, + Alg: armvideoanalyzer.AccessPolicyRsaAlgoRS256.ToPtr(), + E: to.StringPtr(""), + N: to.StringPtr(""), + }, + &armvideoanalyzer.EccTokenKey{ + TokenKey: armvideoanalyzer.TokenKey{ + Type: to.StringPtr(""), + Kid: to.StringPtr(""), + }, + Alg: armvideoanalyzer.AccessPolicyEccAlgoES256.ToPtr(), + X: to.StringPtr(""), + Y: to.StringPtr(""), + }}, + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("AccessPolicyEntity.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_edgemodules_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_edgemodules_client_test.go new file mode 100644 index 000000000000..9a995bbca95f --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_edgemodules_client_test.go @@ -0,0 +1,119 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/edge-modules-list.json +func ExampleEdgeModulesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewEdgeModulesClient("", cred, nil) + pager := client.List("", + "", + &armvideoanalyzer.EdgeModulesListOptions{Top: nil}) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("EdgeModuleEntity.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/edge-modules-get.json +func ExampleEdgeModulesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewEdgeModulesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("EdgeModuleEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/edge-modules-create.json +func ExampleEdgeModulesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewEdgeModulesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armvideoanalyzer.EdgeModuleEntity{}, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("EdgeModuleEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/edge-modules-delete.json +func ExampleEdgeModulesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewEdgeModulesClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/edge-modules-listProvisioningToken.json +func ExampleEdgeModulesClient_ListProvisioningToken() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewEdgeModulesClient("", cred, nil) + _, err = client.ListProvisioningToken(ctx, + "", + "", + "", + armvideoanalyzer.ListProvisioningTokenInput{ + ExpirationDate: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-01-23T11:04:49.0526841-08:00"); return t }()), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_livepipelineoperationstatuses_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_livepipelineoperationstatuses_client_test.go new file mode 100644 index 000000000000..eda100a7fa3b --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_livepipelineoperationstatuses_client_test.go @@ -0,0 +1,36 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-operation-status-get.json +func ExampleLivePipelineOperationStatusesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelineOperationStatusesClient("", cred, nil) + _, err = client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_livepipelines_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_livepipelines_client_test.go new file mode 100644 index 000000000000..62ba6e796557 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_livepipelines_client_test.go @@ -0,0 +1,179 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-list.json +func ExampleLivePipelinesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + pager := client.List("", + "", + &armvideoanalyzer.LivePipelinesListOptions{Filter: nil, + Top: to.Int32Ptr(2), + }) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("LivePipeline.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-get-by-name.json +func ExampleLivePipelinesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("LivePipeline.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-create.json +func ExampleLivePipelinesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armvideoanalyzer.LivePipeline{ + Properties: &armvideoanalyzer.LivePipelineProperties{ + Description: to.StringPtr(""), + BitrateKbps: to.Int32Ptr(500), + Parameters: []*armvideoanalyzer.ParameterDefinition{ + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }}, + TopologyName: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("LivePipeline.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-delete.json +func ExampleLivePipelinesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-patch.json +func ExampleLivePipelinesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + "", + armvideoanalyzer.LivePipelineUpdate{ + Properties: &armvideoanalyzer.LivePipelinePropertiesUpdate{ + Description: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("LivePipeline.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-activate.json +func ExampleLivePipelinesClient_BeginActivate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + poller, err := client.BeginActivate(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/live-pipeline-deactivate.json +func ExampleLivePipelinesClient_BeginDeactivate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLivePipelinesClient("", cred, nil) + poller, err := client.BeginDeactivate(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_locations_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_locations_client_test.go new file mode 100644 index 000000000000..42399c9bc49e --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_locations_client_test.go @@ -0,0 +1,38 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/accounts-check-name-availability.json +func ExampleLocationsClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewLocationsClient("", cred, nil) + _, err = client.CheckNameAvailability(ctx, + "", + armvideoanalyzer.CheckNameAvailabilityRequest{ + Name: to.StringPtr(""), + Type: to.StringPtr(""), + }, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operationresults_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operationresults_client_test.go new file mode 100644 index 000000000000..0395cf58f15c --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operationresults_client_test.go @@ -0,0 +1,37 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-endpoint-connection-operation-result-by-id.json +func ExampleOperationResultsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewOperationResultsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateEndpointConnection.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operations_client_test.go new file mode 100644 index 000000000000..fec65c2af5d6 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operations_client_test.go @@ -0,0 +1,32 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/operations-list-all.json +func ExampleOperationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewOperationsClient(cred, nil) + _, err = client.List(ctx, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operationstatuses_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operationstatuses_client_test.go new file mode 100644 index 000000000000..be4744e7f67f --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_operationstatuses_client_test.go @@ -0,0 +1,37 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-endpoint-connection-operation-status-by-id-terminal-state.json +func ExampleOperationStatusesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewOperationStatusesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoAnalyzerPrivateEndpointConnectionOperationStatus.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinejoboperationstatuses_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinejoboperationstatuses_client_test.go new file mode 100644 index 000000000000..38d6375f8a18 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinejoboperationstatuses_client_test.go @@ -0,0 +1,36 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-operation-status-get.json +func ExamplePipelineJobOperationStatusesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobOperationStatusesClient("", cred, nil) + _, err = client.Get(ctx, + "", + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinejobs_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinejobs_client_test.go new file mode 100644 index 000000000000..6b903b79f26f --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinejobs_client_test.go @@ -0,0 +1,160 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-list.json +func ExamplePipelineJobsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobsClient("", cred, nil) + pager := client.List("", + "", + &armvideoanalyzer.PipelineJobsListOptions{Filter: nil, + Top: to.Int32Ptr(2), + }) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("PipelineJob.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-get-by-name.json +func ExamplePipelineJobsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobsClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PipelineJob.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-create.json +func ExamplePipelineJobsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobsClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armvideoanalyzer.PipelineJob{ + Properties: &armvideoanalyzer.PipelineJobProperties{ + Description: to.StringPtr(""), + Parameters: []*armvideoanalyzer.ParameterDefinition{ + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }, + { + Name: to.StringPtr(""), + Value: to.StringPtr(""), + }}, + TopologyName: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PipelineJob.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-delete.json +func ExamplePipelineJobsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobsClient("", cred, nil) + _, err = client.Delete(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-patch.json +func ExamplePipelineJobsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobsClient("", cred, nil) + res, err := client.Update(ctx, + "", + "", + "", + armvideoanalyzer.PipelineJobUpdate{ + Properties: &armvideoanalyzer.PipelineJobPropertiesUpdate{ + Description: to.StringPtr(""), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PipelineJob.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-job-cancel.json +func ExamplePipelineJobsClient_BeginCancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineJobsClient("", cred, nil) + poller, err := client.BeginCancel(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + _, err = poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinetopologies_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinetopologies_client_test.go new file mode 100644 index 000000000000..53ba3e2340d2 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_pipelinetopologies_client_test.go @@ -0,0 +1,189 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-topology-list.json +func ExamplePipelineTopologiesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineTopologiesClient("", cred, nil) + pager := client.List("", + "", + &armvideoanalyzer.PipelineTopologiesListOptions{Filter: nil, + Top: to.Int32Ptr(2), + }) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("PipelineTopology.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-topology-get-by-name.json +func ExamplePipelineTopologiesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineTopologiesClient("", cred, nil) + res, err := client.Get(ctx, + "", + "", + "", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PipelineTopology.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-topology-create.json +func ExamplePipelineTopologiesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineTopologiesClient("", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "", + "", + "", + armvideoanalyzer.PipelineTopology{ + Kind: armvideoanalyzer.KindLive.ToPtr(), + Properties: &armvideoanalyzer.PipelineTopologyProperties{ + Description: to.StringPtr(""), + Parameters: []*armvideoanalyzer.ParameterDeclaration{ + { + Name: to.StringPtr(""), + Type: armvideoanalyzer.ParameterTypeString.ToPtr(), + Description: to.StringPtr(""), + Default: to.StringPtr(""), + }, + { + Name: to.StringPtr(""), + Type: armvideoanalyzer.ParameterTypeSecretString.ToPtr(), + Description: to.StringPtr(""), + Default: to.StringPtr(""), + }}, + Sinks: []armvideoanalyzer.SinkNodeBaseClassification{ + &armvideoanalyzer.VideoSink{ + SinkNodeBase: armvideoanalyzer.SinkNodeBase{ + NodeBase: armvideoanalyzer.NodeBase{ + Name: to.StringPtr(""), + Type: to.StringPtr(""), + }, + Inputs: []*armvideoanalyzer.NodeInput{ + { + NodeName: to.StringPtr(""), + }}, + }, + VideoCreationProperties: &armvideoanalyzer.VideoCreationProperties{ + Description: to.StringPtr(""), + SegmentLength: to.StringPtr(""), + Title: to.StringPtr(""), + }, + VideoName: to.StringPtr("<video-name>"), + VideoPublishingOptions: &armvideoanalyzer.VideoPublishingOptions{ + DisableArchive: to.StringPtr("<disable-archive>"), + DisableRtspPublishing: to.StringPtr("<disable-rtsp-publishing>"), + }, + }}, + Sources: []armvideoanalyzer.SourceNodeBaseClassification{ + &armvideoanalyzer.RtspSource{ + SourceNodeBase: armvideoanalyzer.SourceNodeBase{ + NodeBase: armvideoanalyzer.NodeBase{ + Name: to.StringPtr("<name>"), + Type: to.StringPtr("<type>"), + }, + }, + Endpoint: &armvideoanalyzer.UnsecuredEndpoint{ + EndpointBase: armvideoanalyzer.EndpointBase{ + Type: to.StringPtr("<type>"), + Credentials: &armvideoanalyzer.UsernamePasswordCredentials{ + CredentialsBase: armvideoanalyzer.CredentialsBase{ + Type: to.StringPtr("<type>"), + }, + Password: to.StringPtr("<password>"), + Username: to.StringPtr("<username>"), + }, + URL: to.StringPtr("<url>"), + }, + }, + Transport: armvideoanalyzer.RtspTransportHTTP.ToPtr(), + }}, + }, + SKU: &armvideoanalyzer.SKU{ + Name: armvideoanalyzer.SKUNameLiveS1.ToPtr(), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PipelineTopology.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-topology-delete.json +func ExamplePipelineTopologiesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineTopologiesClient("<subscription-id>", cred, nil) + _, err = client.Delete(ctx, + "<resource-group-name>", + "<account-name>", + "<pipeline-topology-name>", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/pipeline-topology-patch.json +func ExamplePipelineTopologiesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPipelineTopologiesClient("<subscription-id>", cred, nil) + res, err := client.Update(ctx, + "<resource-group-name>", + "<account-name>", + "<pipeline-topology-name>", + armvideoanalyzer.PipelineTopologyUpdate{ + Properties: &armvideoanalyzer.PipelineTopologyPropertiesUpdate{ + Description: to.StringPtr("<description>"), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PipelineTopology.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_privateendpointconnections_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_privateendpointconnections_client_test.go new file mode 100644 index 000000000000..e897e2950ebf --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_privateendpointconnections_client_test.go @@ -0,0 +1,99 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-endpoint-connection-list.json +func ExamplePrivateEndpointConnectionsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPrivateEndpointConnectionsClient("<subscription-id>", cred, nil) + _, err = client.List(ctx, + "<resource-group-name>", + "<account-name>", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-endpoint-connection-get-by-name.json +func ExamplePrivateEndpointConnectionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPrivateEndpointConnectionsClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<account-name>", + "<name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateEndpointConnection.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-endpoint-connection-put.json +func ExamplePrivateEndpointConnectionsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPrivateEndpointConnectionsClient("<subscription-id>", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "<resource-group-name>", + "<account-name>", + "<name>", + armvideoanalyzer.PrivateEndpointConnection{ + Properties: &armvideoanalyzer.PrivateEndpointConnectionProperties{ + PrivateLinkServiceConnectionState: &armvideoanalyzer.PrivateLinkServiceConnectionState{ + Description: to.StringPtr("<description>"), + Status: armvideoanalyzer.PrivateEndpointServiceConnectionStatusApproved.ToPtr(), + }, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateEndpointConnection.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-endpoint-connection-delete.json +func ExamplePrivateEndpointConnectionsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPrivateEndpointConnectionsClient("<subscription-id>", cred, nil) + _, err = client.Delete(ctx, + "<resource-group-name>", + "<account-name>", + "<name>", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_privatelinkresources_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_privatelinkresources_client_test.go new file mode 100644 index 000000000000..131d446664bb --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_privatelinkresources_client_test.go @@ -0,0 +1,53 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-link-resources-list.json +func ExamplePrivateLinkResourcesClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPrivateLinkResourcesClient("<subscription-id>", cred, nil) + _, err = client.List(ctx, + "<resource-group-name>", + "<account-name>", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-private-link-resources-get-by-name.json +func ExamplePrivateLinkResourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewPrivateLinkResourcesClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<account-name>", + "<name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("PrivateLinkResource.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzeroperationresults_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzeroperationresults_client_test.go new file mode 100644 index 000000000000..ef8d361415bf --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzeroperationresults_client_test.go @@ -0,0 +1,35 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-operation-result-by-id.json +func ExampleVideoAnalyzerOperationResultsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzerOperationResultsClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<location-name>", + "<operation-id>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoAnalyzer.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzeroperationstatuses_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzeroperationstatuses_client_test.go new file mode 100644 index 000000000000..23253a14ac82 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzeroperationstatuses_client_test.go @@ -0,0 +1,35 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-operation-status-by-id-non-terminal-state-failed.json +func ExampleVideoAnalyzerOperationStatusesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzerOperationStatusesClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<location-name>", + "<operation-id>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoAnalyzerOperationStatus.ID: %s\n", *res.ID) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzers_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzers_client_test.go new file mode 100644 index 000000000000..b4dfabd8a1a4 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videoanalyzers_client_test.go @@ -0,0 +1,177 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-accounts-list-all-accounts.json +func ExampleVideoAnalyzersClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzersClient("<subscription-id>", cred, nil) + _, err = client.List(ctx, + "<resource-group-name>", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-accounts-get-by-name.json +func ExampleVideoAnalyzersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzersClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<account-name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoAnalyzer.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-accounts-create-or-update.json +func ExampleVideoAnalyzersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzersClient("<subscription-id>", cred, nil) + poller, err := client.BeginCreateOrUpdate(ctx, + "<resource-group-name>", + "<account-name>", + armvideoanalyzer.VideoAnalyzer{ + TrackedResource: armvideoanalyzer.TrackedResource{ + Location: to.StringPtr("<location>"), + Tags: map[string]*string{ + "tag1": to.StringPtr("value1"), + "tag2": to.StringPtr("value2"), + }, + }, + Identity: &armvideoanalyzer.VideoAnalyzerIdentity{ + Type: to.StringPtr("<type>"), + UserAssignedIdentities: map[string]*armvideoanalyzer.UserAssignedManagedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": {}, + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id3": {}, + }, + }, + Properties: &armvideoanalyzer.VideoAnalyzerProperties{ + Encryption: &armvideoanalyzer.AccountEncryption{ + Type: armvideoanalyzer.AccountEncryptionKeyTypeSystemKey.ToPtr(), + }, + IotHubs: []*armvideoanalyzer.IotHub{ + { + ID: to.StringPtr("<id>"), + Identity: &armvideoanalyzer.ResourceIdentity{ + UserAssignedIdentity: to.StringPtr("<user-assigned-identity>"), + }, + }, + { + ID: to.StringPtr("<id>"), + Identity: &armvideoanalyzer.ResourceIdentity{ + UserAssignedIdentity: to.StringPtr("<user-assigned-identity>"), + }, + }}, + StorageAccounts: []*armvideoanalyzer.StorageAccount{ + { + ID: to.StringPtr("<id>"), + Identity: &armvideoanalyzer.ResourceIdentity{ + UserAssignedIdentity: to.StringPtr("<user-assigned-identity>"), + }, + }}, + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoAnalyzer.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-accounts-delete.json +func ExampleVideoAnalyzersClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzersClient("<subscription-id>", cred, nil) + _, err = client.Delete(ctx, + "<resource-group-name>", + "<account-name>", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-accounts-update.json +func ExampleVideoAnalyzersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzersClient("<subscription-id>", cred, nil) + poller, err := client.BeginUpdate(ctx, + "<resource-group-name>", + "<account-name>", + armvideoanalyzer.VideoAnalyzerUpdate{ + Tags: map[string]*string{ + "key1": to.StringPtr("value3"), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + res, err := poller.PollUntilDone(ctx, 30*time.Second) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoAnalyzer.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-analyzer-accounts-subscription-list-all-accounts.json +func ExampleVideoAnalyzersClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideoAnalyzersClient("<subscription-id>", cred, nil) + _, err = client.ListBySubscription(ctx, + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videos_client_test.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videos_client_test.go new file mode 100644 index 000000000000..6bd2de7ff65b --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/ze_generated_example_videos_client_test.go @@ -0,0 +1,143 @@ +//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 armvideoanalyzer_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/videoanalyzer/armvideoanalyzer" +) + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-list.json +func ExampleVideosClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideosClient("<subscription-id>", cred, nil) + pager := client.List("<resource-group-name>", + "<account-name>", + &armvideoanalyzer.VideosListOptions{Top: to.Int32Ptr(2)}) + for pager.NextPage(ctx) { + if err := pager.Err(); err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range pager.PageResponse().Value { + log.Printf("VideoEntity.ID: %s\n", *v.ID) + } + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-get.json +func ExampleVideosClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideosClient("<subscription-id>", cred, nil) + res, err := client.Get(ctx, + "<resource-group-name>", + "<account-name>", + "<video-name>", + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-create.json +func ExampleVideosClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideosClient("<subscription-id>", cred, nil) + res, err := client.CreateOrUpdate(ctx, + "<resource-group-name>", + "<account-name>", + "<video-name>", + armvideoanalyzer.VideoEntity{ + Properties: &armvideoanalyzer.VideoProperties{ + Description: to.StringPtr("<description>"), + Title: to.StringPtr("<title>"), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-delete.json +func ExampleVideosClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideosClient("<subscription-id>", cred, nil) + _, err = client.Delete(ctx, + "<resource-group-name>", + "<account-name>", + "<video-name>", + nil) + if err != nil { + log.Fatal(err) + } +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-patch.json +func ExampleVideosClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideosClient("<subscription-id>", cred, nil) + res, err := client.Update(ctx, + "<resource-group-name>", + "<account-name>", + "<video-name>", + armvideoanalyzer.VideoEntity{ + Properties: &armvideoanalyzer.VideoProperties{ + Description: to.StringPtr("<description>"), + }, + }, + nil) + if err != nil { + log.Fatal(err) + } + log.Printf("VideoEntity.ID: %s\n", *res.ID) +} + +// x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/video-listContentToken.json +func ExampleVideosClient_ListContentToken() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client := armvideoanalyzer.NewVideosClient("<subscription-id>", cred, nil) + _, err = client.ListContentToken(ctx, + "<resource-group-name>", + "<account-name>", + "<video-name>", + nil) + if err != nil { + log.Fatal(err) + } +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_accesspolicies_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_accesspolicies_client.go new file mode 100644 index 000000000000..2d4612fcb69b --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_accesspolicies_client.go @@ -0,0 +1,376 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// AccessPoliciesClient contains the methods for the AccessPolicies group. +// Don't use this type directly, use NewAccessPoliciesClient() instead. +type AccessPoliciesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAccessPoliciesClient creates a new instance of AccessPoliciesClient with the specified values. +func NewAccessPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AccessPoliciesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &AccessPoliciesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new access policy resource or updates an existing one with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccessPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, parameters AccessPolicyEntity, options *AccessPoliciesCreateOrUpdateOptions) (AccessPoliciesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, accessPolicyName, parameters, options) + if err != nil { + return AccessPoliciesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccessPoliciesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return AccessPoliciesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AccessPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, parameters AccessPolicyEntity, options *AccessPoliciesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/accessPolicies/{accessPolicyName}" + 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)) + if accessPolicyName == "" { + return nil, errors.New("parameter accessPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AccessPoliciesClient) createOrUpdateHandleResponse(resp *http.Response) (AccessPoliciesCreateOrUpdateResponse, error) { + result := AccessPoliciesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessPolicyEntity); err != nil { + return AccessPoliciesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AccessPoliciesClient) 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 - Deletes an existing access policy resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccessPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, options *AccessPoliciesDeleteOptions) (AccessPoliciesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, accessPolicyName, options) + if err != nil { + return AccessPoliciesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccessPoliciesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return AccessPoliciesDeleteResponse{}, client.deleteHandleError(resp) + } + return AccessPoliciesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AccessPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, options *AccessPoliciesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/accessPolicies/{accessPolicyName}" + 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)) + if accessPolicyName == "" { + return nil, errors.New("parameter accessPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) + 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-01-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 *AccessPoliciesClient) 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 - Retrieves an existing access policy resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccessPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, options *AccessPoliciesGetOptions) (AccessPoliciesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, accessPolicyName, options) + if err != nil { + return AccessPoliciesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccessPoliciesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccessPoliciesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AccessPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, options *AccessPoliciesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/accessPolicies/{accessPolicyName}" + 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)) + if accessPolicyName == "" { + return nil, errors.New("parameter accessPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AccessPoliciesClient) getHandleResponse(resp *http.Response) (AccessPoliciesGetResponse, error) { + result := AccessPoliciesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessPolicyEntity); err != nil { + return AccessPoliciesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AccessPoliciesClient) 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 - Retrieves all existing access policy resources, along with their JSON representations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccessPoliciesClient) List(resourceGroupName string, accountName string, options *AccessPoliciesListOptions) *AccessPoliciesListPager { + return &AccessPoliciesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp AccessPoliciesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AccessPolicyEntityCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *AccessPoliciesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccessPoliciesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/accessPolicies" + 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-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AccessPoliciesClient) listHandleResponse(resp *http.Response) (AccessPoliciesListResponse, error) { + result := AccessPoliciesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessPolicyEntityCollection); err != nil { + return AccessPoliciesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *AccessPoliciesClient) 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) +} + +// Update - Updates individual properties of an existing access policy resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AccessPoliciesClient) Update(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, parameters AccessPolicyEntity, options *AccessPoliciesUpdateOptions) (AccessPoliciesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, accessPolicyName, parameters, options) + if err != nil { + return AccessPoliciesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AccessPoliciesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AccessPoliciesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AccessPoliciesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, accessPolicyName string, parameters AccessPolicyEntity, options *AccessPoliciesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/accessPolicies/{accessPolicyName}" + 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)) + if accessPolicyName == "" { + return nil, errors.New("parameter accessPolicyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *AccessPoliciesClient) updateHandleResponse(resp *http.Response) (AccessPoliciesUpdateResponse, error) { + result := AccessPoliciesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AccessPolicyEntity); err != nil { + return AccessPoliciesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *AccessPoliciesClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_constants.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_constants.go new file mode 100644 index 000000000000..bbe51560c76a --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_constants.go @@ -0,0 +1,624 @@ +//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 armvideoanalyzer + +const ( + module = "armvideoanalyzer" + version = "v0.1.0" +) + +// AccessPolicyEccAlgo - Elliptical curve algorithm to be used: ES256, ES384 or ES512. +type AccessPolicyEccAlgo string + +const ( + // AccessPolicyEccAlgoES256 - ES265 + AccessPolicyEccAlgoES256 AccessPolicyEccAlgo = "ES256" + // AccessPolicyEccAlgoES384 - ES384 + AccessPolicyEccAlgoES384 AccessPolicyEccAlgo = "ES384" + // AccessPolicyEccAlgoES512 - ES512 + AccessPolicyEccAlgoES512 AccessPolicyEccAlgo = "ES512" +) + +// PossibleAccessPolicyEccAlgoValues returns the possible values for the AccessPolicyEccAlgo const type. +func PossibleAccessPolicyEccAlgoValues() []AccessPolicyEccAlgo { + return []AccessPolicyEccAlgo{ + AccessPolicyEccAlgoES256, + AccessPolicyEccAlgoES384, + AccessPolicyEccAlgoES512, + } +} + +// ToPtr returns a *AccessPolicyEccAlgo pointing to the current value. +func (c AccessPolicyEccAlgo) ToPtr() *AccessPolicyEccAlgo { + return &c +} + +// AccessPolicyRole - Defines the access level granted by this policy. +type AccessPolicyRole string + +const ( + // AccessPolicyRoleReader - Reader role allows for read-only operations to be performed through the client APIs. + AccessPolicyRoleReader AccessPolicyRole = "Reader" +) + +// PossibleAccessPolicyRoleValues returns the possible values for the AccessPolicyRole const type. +func PossibleAccessPolicyRoleValues() []AccessPolicyRole { + return []AccessPolicyRole{ + AccessPolicyRoleReader, + } +} + +// ToPtr returns a *AccessPolicyRole pointing to the current value. +func (c AccessPolicyRole) ToPtr() *AccessPolicyRole { + return &c +} + +// AccessPolicyRsaAlgo - RSA algorithm to be used: RS256, RS384 or RS512. +type AccessPolicyRsaAlgo string + +const ( + // AccessPolicyRsaAlgoRS256 - RS256 + AccessPolicyRsaAlgoRS256 AccessPolicyRsaAlgo = "RS256" + // AccessPolicyRsaAlgoRS384 - RS384 + AccessPolicyRsaAlgoRS384 AccessPolicyRsaAlgo = "RS384" + // AccessPolicyRsaAlgoRS512 - RS512 + AccessPolicyRsaAlgoRS512 AccessPolicyRsaAlgo = "RS512" +) + +// PossibleAccessPolicyRsaAlgoValues returns the possible values for the AccessPolicyRsaAlgo const type. +func PossibleAccessPolicyRsaAlgoValues() []AccessPolicyRsaAlgo { + return []AccessPolicyRsaAlgo{ + AccessPolicyRsaAlgoRS256, + AccessPolicyRsaAlgoRS384, + AccessPolicyRsaAlgoRS512, + } +} + +// ToPtr returns a *AccessPolicyRsaAlgo pointing to the current value. +func (c AccessPolicyRsaAlgo) ToPtr() *AccessPolicyRsaAlgo { + return &c +} + +// AccountEncryptionKeyType - The type of key used to encrypt the Account Key. +type AccountEncryptionKeyType string + +const ( + // AccountEncryptionKeyTypeCustomerKey - The Account Key is encrypted with a Customer Key. + AccountEncryptionKeyTypeCustomerKey AccountEncryptionKeyType = "CustomerKey" + // AccountEncryptionKeyTypeSystemKey - The Account Key is encrypted with a System Key. + AccountEncryptionKeyTypeSystemKey AccountEncryptionKeyType = "SystemKey" +) + +// PossibleAccountEncryptionKeyTypeValues returns the possible values for the AccountEncryptionKeyType const type. +func PossibleAccountEncryptionKeyTypeValues() []AccountEncryptionKeyType { + return []AccountEncryptionKeyType{ + AccountEncryptionKeyTypeCustomerKey, + AccountEncryptionKeyTypeSystemKey, + } +} + +// ToPtr returns a *AccountEncryptionKeyType pointing to the current value. +func (c AccountEncryptionKeyType) ToPtr() *AccountEncryptionKeyType { + return &c +} + +// ActionType - Indicates the action type. +type ActionType string + +const ( + // ActionTypeInternal - An internal action. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ToPtr returns a *ActionType pointing to the current value. +func (c ActionType) ToPtr() *ActionType { + return &c +} + +// CheckNameAvailabilityReason - The reason why the given name is not available. +type CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns the possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{ + CheckNameAvailabilityReasonAlreadyExists, + CheckNameAvailabilityReasonInvalid, + } +} + +// ToPtr returns a *CheckNameAvailabilityReason pointing to the current value. +func (c CheckNameAvailabilityReason) ToPtr() *CheckNameAvailabilityReason { + return &c +} + +// 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 +} + +// EncoderSystemPresetType - Name of the built-in encoding preset. +type EncoderSystemPresetType string + +const ( + // EncoderSystemPresetTypeSingleLayer1080PH264AAC - Produces an MP4 file where the video is encoded with H.264 codec at a picture height of 1080 pixels, + // and at a maximum bitrate of 6000 Kbps. Encoded video has the same average frame rate as the input. The aspect ratio of the input is preserved. If the + // input content has audio, then it is encoded with AAC-LC codec at 128 Kbps + EncoderSystemPresetTypeSingleLayer1080PH264AAC EncoderSystemPresetType = "SingleLayer_1080p_H264_AAC" + // EncoderSystemPresetTypeSingleLayer2160PH264AAC - Produces an MP4 file where the video is encoded with H.264 codec at a picture height of 2160 pixels, + // and at a maximum bitrate of 16000 Kbps. Encoded video has the same average frame rate as the input. The aspect ratio of the input is preserved. If the + // input content has audio, then it is encoded with AAC-LC codec at 128 Kbps + EncoderSystemPresetTypeSingleLayer2160PH264AAC EncoderSystemPresetType = "SingleLayer_2160p_H264_AAC" + // EncoderSystemPresetTypeSingleLayer540PH264AAC - Produces an MP4 file where the video is encoded with H.264 codec at a picture height of 540 pixels, and + // at a maximum bitrate of 2000 Kbps. Encoded video has the same average frame rate as the input. The aspect ratio of the input is preserved. If the input + // content has audio, then it is encoded with AAC-LC codec at 96 Kbps + EncoderSystemPresetTypeSingleLayer540PH264AAC EncoderSystemPresetType = "SingleLayer_540p_H264_AAC" + // EncoderSystemPresetTypeSingleLayer720PH264AAC - Produces an MP4 file where the video is encoded with H.264 codec at a picture height of 720 pixels, and + // at a maximum bitrate of 3500 Kbps. Encoded video has the same average frame rate as the input. The aspect ratio of the input is preserved. If the input + // content has audio, then it is encoded with AAC-LC codec at 96 Kbps + EncoderSystemPresetTypeSingleLayer720PH264AAC EncoderSystemPresetType = "SingleLayer_720p_H264_AAC" +) + +// PossibleEncoderSystemPresetTypeValues returns the possible values for the EncoderSystemPresetType const type. +func PossibleEncoderSystemPresetTypeValues() []EncoderSystemPresetType { + return []EncoderSystemPresetType{ + EncoderSystemPresetTypeSingleLayer1080PH264AAC, + EncoderSystemPresetTypeSingleLayer2160PH264AAC, + EncoderSystemPresetTypeSingleLayer540PH264AAC, + EncoderSystemPresetTypeSingleLayer720PH264AAC, + } +} + +// ToPtr returns a *EncoderSystemPresetType pointing to the current value. +func (c EncoderSystemPresetType) ToPtr() *EncoderSystemPresetType { + return &c +} + +// Kind - Topology kind. +type Kind string + +const ( + // KindBatch - Batch pipeline topology resource. + KindBatch Kind = "Batch" + // KindLive - Live pipeline topology resource. + KindLive Kind = "Live" +) + +// PossibleKindValues returns the possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{ + KindBatch, + KindLive, + } +} + +// ToPtr returns a *Kind pointing to the current value. +func (c Kind) ToPtr() *Kind { + return &c +} + +// LivePipelineState - Current state of the pipeline (read-only). +type LivePipelineState string + +const ( + // LivePipelineStateActivating - The live pipeline is transitioning into the active state. + LivePipelineStateActivating LivePipelineState = "Activating" + // LivePipelineStateActive - The live pipeline is active and able to process media. If your data source is not available, for instance, if your RTSP camera + // is powered off or unreachable, the pipeline will still be active and periodically retrying the connection. Your Azure subscription will be billed for + // the duration in which the live pipeline is in the active state. + LivePipelineStateActive LivePipelineState = "Active" + // LivePipelineStateDeactivating - The live pipeline is transitioning into the inactive state. + LivePipelineStateDeactivating LivePipelineState = "Deactivating" + // LivePipelineStateInactive - The live pipeline is idle and not processing media. + LivePipelineStateInactive LivePipelineState = "Inactive" +) + +// PossibleLivePipelineStateValues returns the possible values for the LivePipelineState const type. +func PossibleLivePipelineStateValues() []LivePipelineState { + return []LivePipelineState{ + LivePipelineStateActivating, + LivePipelineStateActive, + LivePipelineStateDeactivating, + LivePipelineStateInactive, + } +} + +// ToPtr returns a *LivePipelineState pointing to the current value. +func (c LivePipelineState) ToPtr() *LivePipelineState { + return &c +} + +// MetricAggregationType - The metric aggregation type +type MetricAggregationType string + +const ( + // MetricAggregationTypeAverage - The average. + MetricAggregationTypeAverage MetricAggregationType = "Average" + // MetricAggregationTypeCount - The count of a number of items, usually requests. + MetricAggregationTypeCount MetricAggregationType = "Count" + // MetricAggregationTypeTotal - The sum. + MetricAggregationTypeTotal MetricAggregationType = "Total" +) + +// PossibleMetricAggregationTypeValues returns the possible values for the MetricAggregationType const type. +func PossibleMetricAggregationTypeValues() []MetricAggregationType { + return []MetricAggregationType{ + MetricAggregationTypeAverage, + MetricAggregationTypeCount, + MetricAggregationTypeTotal, + } +} + +// ToPtr returns a *MetricAggregationType pointing to the current value. +func (c MetricAggregationType) ToPtr() *MetricAggregationType { + return &c +} + +// MetricUnit - The metric unit +type MetricUnit string + +const ( + // MetricUnitBytes - The number of bytes. + MetricUnitBytes MetricUnit = "Bytes" + // MetricUnitCount - The count. + MetricUnitCount MetricUnit = "Count" + // MetricUnitMilliseconds - The number of milliseconds. + MetricUnitMilliseconds MetricUnit = "Milliseconds" +) + +// PossibleMetricUnitValues returns the possible values for the MetricUnit const type. +func PossibleMetricUnitValues() []MetricUnit { + return []MetricUnit{ + MetricUnitBytes, + MetricUnitCount, + MetricUnitMilliseconds, + } +} + +// ToPtr returns a *MetricUnit pointing to the current value. +func (c MetricUnit) ToPtr() *MetricUnit { + return &c +} + +// ParameterType - Type of the parameter. +type ParameterType string + +const ( + // ParameterTypeBool - The parameter's value is a boolean value that is either true or false. + ParameterTypeBool ParameterType = "Bool" + // ParameterTypeDouble - The parameter's value is a 64-bit double-precision floating point. + ParameterTypeDouble ParameterType = "Double" + // ParameterTypeInt - The parameter's value is a 32-bit signed integer. + ParameterTypeInt ParameterType = "Int" + // ParameterTypeSecretString - The parameter's value is a string that holds sensitive information. + ParameterTypeSecretString ParameterType = "SecretString" + // ParameterTypeString - The parameter's value is a string. + ParameterTypeString ParameterType = "String" +) + +// PossibleParameterTypeValues returns the possible values for the ParameterType const type. +func PossibleParameterTypeValues() []ParameterType { + return []ParameterType{ + ParameterTypeBool, + ParameterTypeDouble, + ParameterTypeInt, + ParameterTypeSecretString, + ParameterTypeString, + } +} + +// ToPtr returns a *ParameterType pointing to the current value. +func (c ParameterType) ToPtr() *ParameterType { + return &c +} + +// PipelineJobState - Current state of the pipeline (read-only). +type PipelineJobState string + +const ( + // PipelineJobStateCanceled - Pipeline job is canceled. + PipelineJobStateCanceled PipelineJobState = "Canceled" + // PipelineJobStateCompleted - Pipeline job completed. + PipelineJobStateCompleted PipelineJobState = "Completed" + // PipelineJobStateFailed - Pipeline job failed. + PipelineJobStateFailed PipelineJobState = "Failed" + // PipelineJobStateProcessing - Pipeline job is processing. + PipelineJobStateProcessing PipelineJobState = "Processing" +) + +// PossiblePipelineJobStateValues returns the possible values for the PipelineJobState const type. +func PossiblePipelineJobStateValues() []PipelineJobState { + return []PipelineJobState{ + PipelineJobStateCanceled, + PipelineJobStateCompleted, + PipelineJobStateFailed, + PipelineJobStateProcessing, + } +} + +// ToPtr returns a *PipelineJobState pointing to the current value. +func (c PipelineJobState) ToPtr() *PipelineJobState { + return &c +} + +// PrivateEndpointConnectionProvisioningState - The current provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns the possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{ + PrivateEndpointConnectionProvisioningStateCreating, + PrivateEndpointConnectionProvisioningStateDeleting, + PrivateEndpointConnectionProvisioningStateFailed, + PrivateEndpointConnectionProvisioningStateSucceeded, + } +} + +// ToPtr returns a *PrivateEndpointConnectionProvisioningState pointing to the current value. +func (c PrivateEndpointConnectionProvisioningState) ToPtr() *PrivateEndpointConnectionProvisioningState { + return &c +} + +// PrivateEndpointServiceConnectionStatus - The private endpoint connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns the possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{ + PrivateEndpointServiceConnectionStatusApproved, + PrivateEndpointServiceConnectionStatusPending, + PrivateEndpointServiceConnectionStatusRejected, + } +} + +// ToPtr returns a *PrivateEndpointServiceConnectionStatus pointing to the current value. +func (c PrivateEndpointServiceConnectionStatus) ToPtr() *PrivateEndpointServiceConnectionStatus { + return &c +} + +// ProvisioningState - Provisioning state of the Video Analyzer account. +type ProvisioningState string + +const ( + // ProvisioningStateFailed - Provisioning state failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateInProgress - Provisioning state in progress. + ProvisioningStateInProgress ProvisioningState = "InProgress" + // ProvisioningStateSucceeded - Provisioning state succeeded. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateFailed, + ProvisioningStateInProgress, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// PublicNetworkAccess - Whether or not public network access is allowed for resources under the Video Analyzer account. +type PublicNetworkAccess string + +const ( + // PublicNetworkAccessDisabled - Public network access is disabled. + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + // PublicNetworkAccessEnabled - Public network access is enabled. + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + } +} + +// ToPtr returns a *PublicNetworkAccess pointing to the current value. +func (c PublicNetworkAccess) ToPtr() *PublicNetworkAccess { + return &c +} + +// RtspTransport - Network transport utilized by the RTSP and RTP exchange: TCP or HTTP. When using TCP, the RTP packets are interleaved on the TCP RTSP +// connection. When using HTTP, the RTSP messages are exchanged +// through long lived HTTP connections, and the RTP packages are interleaved in the HTTP connections alongside the RTSP messages. +type RtspTransport string + +const ( + // RtspTransportHTTP - HTTP transport. RTSP messages are exchanged over long running HTTP requests and RTP packets are interleaved within the HTTP channel. + RtspTransportHTTP RtspTransport = "Http" + // RtspTransportTCP - TCP transport. RTSP is used directly over TCP and RTP packets are interleaved within the TCP channel. + RtspTransportTCP RtspTransport = "Tcp" +) + +// PossibleRtspTransportValues returns the possible values for the RtspTransport const type. +func PossibleRtspTransportValues() []RtspTransport { + return []RtspTransport{ + RtspTransportHTTP, + RtspTransportTCP, + } +} + +// ToPtr returns a *RtspTransport pointing to the current value. +func (c RtspTransport) ToPtr() *RtspTransport { + return &c +} + +// SKUName - The SKU name. +type SKUName string + +const ( + // SKUNameBatchS1 - Represents the Batch S1 SKU name. Using this SKU you can create pipeline jobs to process recorded content. + SKUNameBatchS1 SKUName = "Batch_S1" + // SKUNameLiveS1 - Represents the Live S1 SKU name. Using this SKU you can create live pipelines to capture, record, and stream live video from RTSP-capable + // cameras at bitrate settings from 0.5 Kbps to 3000 Kbps. + SKUNameLiveS1 SKUName = "Live_S1" +) + +// PossibleSKUNameValues returns the possible values for the SKUName const type. +func PossibleSKUNameValues() []SKUName { + return []SKUName{ + SKUNameBatchS1, + SKUNameLiveS1, + } +} + +// ToPtr returns a *SKUName pointing to the current value. +func (c SKUName) ToPtr() *SKUName { + return &c +} + +// SKUTier - The SKU tier. +type SKUTier string + +const ( + // SKUTierStandard - Standard tier. + SKUTierStandard SKUTier = "Standard" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierStandard, + } +} + +// ToPtr returns a *SKUTier pointing to the current value. +func (c SKUTier) ToPtr() *SKUTier { + return &c +} + +// VideoAnalyzerEndpointType - The type of the endpoint. +type VideoAnalyzerEndpointType string + +const ( + // VideoAnalyzerEndpointTypeClientAPI - The client API endpoint. + VideoAnalyzerEndpointTypeClientAPI VideoAnalyzerEndpointType = "ClientApi" +) + +// PossibleVideoAnalyzerEndpointTypeValues returns the possible values for the VideoAnalyzerEndpointType const type. +func PossibleVideoAnalyzerEndpointTypeValues() []VideoAnalyzerEndpointType { + return []VideoAnalyzerEndpointType{ + VideoAnalyzerEndpointTypeClientAPI, + } +} + +// ToPtr returns a *VideoAnalyzerEndpointType pointing to the current value. +func (c VideoAnalyzerEndpointType) ToPtr() *VideoAnalyzerEndpointType { + return &c +} + +// VideoScaleMode - Describes the video scaling mode to be applied. Default mode is 'Pad'. If the mode is 'Pad' or 'Stretch' then both width and height +// must be specified. Else if the mode is 'PreserveAspectRatio' then +// only one of width or height need be provided. +type VideoScaleMode string + +const ( + // VideoScaleModePad - Pads the video with black horizontal stripes (letterbox) or black vertical stripes (pillar-box) so the video is resized to the specified + // dimensions while not altering the content aspect ratio. + VideoScaleModePad VideoScaleMode = "Pad" + // VideoScaleModePreserveAspectRatio - Preserves the same aspect ratio as the input video. If only one video dimension is provided, the second dimension + // is calculated based on the input video aspect ratio. When 2 dimensions are provided, the video is resized to fit the most constraining dimension, considering + // the input video size and aspect ratio. + VideoScaleModePreserveAspectRatio VideoScaleMode = "PreserveAspectRatio" + // VideoScaleModeStretch - Stretches the original video so it resized to the specified dimensions. + VideoScaleModeStretch VideoScaleMode = "Stretch" +) + +// PossibleVideoScaleModeValues returns the possible values for the VideoScaleMode const type. +func PossibleVideoScaleModeValues() []VideoScaleMode { + return []VideoScaleMode{ + VideoScaleModePad, + VideoScaleModePreserveAspectRatio, + VideoScaleModeStretch, + } +} + +// ToPtr returns a *VideoScaleMode pointing to the current value. +func (c VideoScaleMode) ToPtr() *VideoScaleMode { + return &c +} + +// VideoType - Video content type. Different content types are suitable for different applications and scenarios. +type VideoType string + +const ( + // VideoTypeArchive - Archive is flexible format that represents a video stream associated with wall-clock time. The video archive can either be continuous + // or discontinuous. An archive is discontinuous when there are gaps in the recording due to various reasons, such as the live pipeline being stopped, camera + // being disconnected or due to the use of event based recordings through the use of a signal gate. There is no limit to the archive duration and new video + // data can be appended to the existing archive at any time, as long as the same video codec and codec parameters are being used. Videos of this type are + // suitable for appending and long term archival. + VideoTypeArchive VideoType = "Archive" + // VideoTypeFile - File represents a video which is stored as a single media file, such as MP4. Videos of this type are suitable to be downloaded for external + // consumption. + VideoTypeFile VideoType = "File" +) + +// PossibleVideoTypeValues returns the possible values for the VideoType const type. +func PossibleVideoTypeValues() []VideoType { + return []VideoType{ + VideoTypeArchive, + VideoTypeFile, + } +} + +// ToPtr returns a *VideoType pointing to the current value. +func (c VideoType) ToPtr() *VideoType { + return &c +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_edgemodules_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_edgemodules_client.go new file mode 100644 index 000000000000..a7162e6668b3 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_edgemodules_client.go @@ -0,0 +1,389 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// EdgeModulesClient contains the methods for the EdgeModules group. +// Don't use this type directly, use NewEdgeModulesClient() instead. +type EdgeModulesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewEdgeModulesClient creates a new instance of EdgeModulesClient with the specified values. +func NewEdgeModulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *EdgeModulesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &EdgeModulesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new edge module or updates an existing one. An edge module resource enables a single instance of an Azure Video Analyzer IoT +// edge module to interact with the Video Analyzer Account. This is +// used for authorization and also to make sure that the particular edge module instance only has access to the data it requires from the Azure Video Analyzer +// service. A new edge module resource should +// be created for every new instance of an Azure Video Analyzer edge module deployed to you Azure IoT edge environment. Edge module resources can be deleted +// if the specific module is not in use anymore. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EdgeModulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, parameters EdgeModuleEntity, options *EdgeModulesCreateOrUpdateOptions) (EdgeModulesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, edgeModuleName, parameters, options) + if err != nil { + return EdgeModulesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EdgeModulesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return EdgeModulesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EdgeModulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, parameters EdgeModuleEntity, options *EdgeModulesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/edgeModules/{edgeModuleName}" + 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)) + if edgeModuleName == "" { + return nil, errors.New("parameter edgeModuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeModuleName}", url.PathEscape(edgeModuleName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EdgeModulesClient) createOrUpdateHandleResponse(resp *http.Response) (EdgeModulesCreateOrUpdateResponse, error) { + result := EdgeModulesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeModuleEntity); err != nil { + return EdgeModulesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *EdgeModulesClient) 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 - Deletes an existing edge module resource. Deleting the edge module resource will prevent an Azure Video Analyzer IoT edge module which was previously +// initiated with the module provisioning token from +// communicating with the cloud. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EdgeModulesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, options *EdgeModulesDeleteOptions) (EdgeModulesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, edgeModuleName, options) + if err != nil { + return EdgeModulesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EdgeModulesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return EdgeModulesDeleteResponse{}, client.deleteHandleError(resp) + } + return EdgeModulesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EdgeModulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, options *EdgeModulesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/edgeModules/{edgeModuleName}" + 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)) + if edgeModuleName == "" { + return nil, errors.New("parameter edgeModuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeModuleName}", url.PathEscape(edgeModuleName)) + 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-01-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 *EdgeModulesClient) 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 - Retrieves an existing edge module resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EdgeModulesClient) Get(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, options *EdgeModulesGetOptions) (EdgeModulesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, edgeModuleName, options) + if err != nil { + return EdgeModulesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EdgeModulesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EdgeModulesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *EdgeModulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, options *EdgeModulesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/edgeModules/{edgeModuleName}" + 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)) + if edgeModuleName == "" { + return nil, errors.New("parameter edgeModuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeModuleName}", url.PathEscape(edgeModuleName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EdgeModulesClient) getHandleResponse(resp *http.Response) (EdgeModulesGetResponse, error) { + result := EdgeModulesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeModuleEntity); err != nil { + return EdgeModulesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *EdgeModulesClient) 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 existing edge module resources, along with their JSON representations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EdgeModulesClient) List(resourceGroupName string, accountName string, options *EdgeModulesListOptions) *EdgeModulesListPager { + return &EdgeModulesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp EdgeModulesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.EdgeModuleEntityCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *EdgeModulesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *EdgeModulesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/edgeModules" + 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-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EdgeModulesClient) listHandleResponse(resp *http.Response) (EdgeModulesListResponse, error) { + result := EdgeModulesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeModuleEntityCollection); err != nil { + return EdgeModulesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *EdgeModulesClient) 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) +} + +// ListProvisioningToken - Creates a new provisioning token. A provisioning token allows for a single instance of Azure Video analyzer IoT edge module to +// be initialized and authorized to the cloud account. The provisioning +// token itself is short lived and it is only used for the initial handshake between IoT edge module and the cloud. After the initial handshake, the IoT +// edge module will agree on a set of authentication +// keys which will be auto-rotated as long as the module is able to periodically connect to the cloud. A new provisioning token can be generated for the +// same IoT edge module in case the module state lost +// or reset. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EdgeModulesClient) ListProvisioningToken(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, parameters ListProvisioningTokenInput, options *EdgeModulesListProvisioningTokenOptions) (EdgeModulesListProvisioningTokenResponse, error) { + req, err := client.listProvisioningTokenCreateRequest(ctx, resourceGroupName, accountName, edgeModuleName, parameters, options) + if err != nil { + return EdgeModulesListProvisioningTokenResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EdgeModulesListProvisioningTokenResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EdgeModulesListProvisioningTokenResponse{}, client.listProvisioningTokenHandleError(resp) + } + return client.listProvisioningTokenHandleResponse(resp) +} + +// listProvisioningTokenCreateRequest creates the ListProvisioningToken request. +func (client *EdgeModulesClient) listProvisioningTokenCreateRequest(ctx context.Context, resourceGroupName string, accountName string, edgeModuleName string, parameters ListProvisioningTokenInput, options *EdgeModulesListProvisioningTokenOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/edgeModules/{edgeModuleName}/listProvisioningToken" + 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)) + if edgeModuleName == "" { + return nil, errors.New("parameter edgeModuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeModuleName}", url.PathEscape(edgeModuleName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// listProvisioningTokenHandleResponse handles the ListProvisioningToken response. +func (client *EdgeModulesClient) listProvisioningTokenHandleResponse(resp *http.Response) (EdgeModulesListProvisioningTokenResponse, error) { + result := EdgeModulesListProvisioningTokenResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeModuleProvisioningToken); err != nil { + return EdgeModulesListProvisioningTokenResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listProvisioningTokenHandleError handles the ListProvisioningToken error response. +func (client *EdgeModulesClient) listProvisioningTokenHandleError(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/videoanalyzer/armvideoanalyzer/zz_generated_livepipelineoperationstatuses_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_livepipelineoperationstatuses_client.go new file mode 100644 index 000000000000..f8e890b25468 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_livepipelineoperationstatuses_client.go @@ -0,0 +1,116 @@ +//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 armvideoanalyzer + +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" +) + +// LivePipelineOperationStatusesClient contains the methods for the LivePipelineOperationStatuses group. +// Don't use this type directly, use NewLivePipelineOperationStatusesClient() instead. +type LivePipelineOperationStatusesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLivePipelineOperationStatusesClient creates a new instance of LivePipelineOperationStatusesClient with the specified values. +func NewLivePipelineOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LivePipelineOperationStatusesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LivePipelineOperationStatusesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get the operation status of a live pipeline. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelineOperationStatusesClient) Get(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, operationID string, options *LivePipelineOperationStatusesGetOptions) (LivePipelineOperationStatusesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, operationID, options) + if err != nil { + return LivePipelineOperationStatusesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LivePipelineOperationStatusesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LivePipelineOperationStatusesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LivePipelineOperationStatusesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, operationID string, options *LivePipelineOperationStatusesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}/operationStatuses/{operationId}" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LivePipelineOperationStatusesClient) getHandleResponse(resp *http.Response) (LivePipelineOperationStatusesGetResponse, error) { + result := LivePipelineOperationStatusesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LivePipelineOperationStatus); err != nil { + return LivePipelineOperationStatusesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LivePipelineOperationStatusesClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_livepipelines_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_livepipelines_client.go new file mode 100644 index 000000000000..45e254fed3b9 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_livepipelines_client.go @@ -0,0 +1,542 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// LivePipelinesClient contains the methods for the LivePipelines group. +// Don't use this type directly, use NewLivePipelinesClient() instead. +type LivePipelinesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLivePipelinesClient creates a new instance of LivePipelinesClient with the specified values. +func NewLivePipelinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LivePipelinesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LivePipelinesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginActivate - Activates a live pipeline with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) BeginActivate(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesBeginActivateOptions) (LivePipelinesActivatePollerResponse, error) { + resp, err := client.activate(ctx, resourceGroupName, accountName, livePipelineName, options) + if err != nil { + return LivePipelinesActivatePollerResponse{}, err + } + result := LivePipelinesActivatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LivePipelinesClient.Activate", "", resp, client.pl, client.activateHandleError) + if err != nil { + return LivePipelinesActivatePollerResponse{}, err + } + result.Poller = &LivePipelinesActivatePoller{ + pt: pt, + } + return result, nil +} + +// Activate - Activates a live pipeline with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) activate(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesBeginActivateOptions) (*http.Response, error) { + req, err := client.activateCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.activateHandleError(resp) + } + return resp, nil +} + +// activateCreateRequest creates the Activate request. +func (client *LivePipelinesClient) activateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesBeginActivateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}/activate" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// activateHandleError handles the Activate error response. +func (client *LivePipelinesClient) activateHandleError(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 a new live pipeline or updates an existing one, with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, parameters LivePipeline, options *LivePipelinesCreateOrUpdateOptions) (LivePipelinesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, parameters, options) + if err != nil { + return LivePipelinesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LivePipelinesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return LivePipelinesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LivePipelinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, parameters LivePipeline, options *LivePipelinesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *LivePipelinesClient) createOrUpdateHandleResponse(resp *http.Response) (LivePipelinesCreateOrUpdateResponse, error) { + result := LivePipelinesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LivePipeline); err != nil { + return LivePipelinesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LivePipelinesClient) 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) +} + +// BeginDeactivate - Deactivates a live pipeline with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) BeginDeactivate(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesBeginDeactivateOptions) (LivePipelinesDeactivatePollerResponse, error) { + resp, err := client.deactivate(ctx, resourceGroupName, accountName, livePipelineName, options) + if err != nil { + return LivePipelinesDeactivatePollerResponse{}, err + } + result := LivePipelinesDeactivatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("LivePipelinesClient.Deactivate", "", resp, client.pl, client.deactivateHandleError) + if err != nil { + return LivePipelinesDeactivatePollerResponse{}, err + } + result.Poller = &LivePipelinesDeactivatePoller{ + pt: pt, + } + return result, nil +} + +// Deactivate - Deactivates a live pipeline with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) deactivate(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesBeginDeactivateOptions) (*http.Response, error) { + req, err := client.deactivateCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.deactivateHandleError(resp) + } + return resp, nil +} + +// deactivateCreateRequest creates the Deactivate request. +func (client *LivePipelinesClient) deactivateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesBeginDeactivateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}/deactivate" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deactivateHandleError handles the Deactivate error response. +func (client *LivePipelinesClient) deactivateHandleError(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 - Deletes a live pipeline with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesDeleteOptions) (LivePipelinesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, options) + if err != nil { + return LivePipelinesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LivePipelinesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return LivePipelinesDeleteResponse{}, client.deleteHandleError(resp) + } + return LivePipelinesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LivePipelinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + 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-01-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 *LivePipelinesClient) 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 - Retrieves a specific live pipeline by name. If a live pipeline with that name has been previously created, the call will return the JSON representation +// of that instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) Get(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesGetOptions) (LivePipelinesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, options) + if err != nil { + return LivePipelinesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LivePipelinesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LivePipelinesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LivePipelinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, options *LivePipelinesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LivePipelinesClient) getHandleResponse(resp *http.Response) (LivePipelinesGetResponse, error) { + result := LivePipelinesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LivePipeline); err != nil { + return LivePipelinesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LivePipelinesClient) 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 - Retrieves a list of live pipelines that have been created, along with their JSON representations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) List(resourceGroupName string, accountName string, options *LivePipelinesListOptions) *LivePipelinesListPager { + return &LivePipelinesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp LivePipelinesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.LivePipelineCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *LivePipelinesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *LivePipelinesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines" + 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-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *LivePipelinesClient) listHandleResponse(resp *http.Response) (LivePipelinesListResponse, error) { + result := LivePipelinesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LivePipelineCollection); err != nil { + return LivePipelinesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *LivePipelinesClient) 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) +} + +// Update - Updates an existing live pipeline with the given name. Properties that can be updated include: description, bitrateKbps, and parameter definitions. +// Only the description can be updated while the live +// pipeline is active. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LivePipelinesClient) Update(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, parameters LivePipelineUpdate, options *LivePipelinesUpdateOptions) (LivePipelinesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, livePipelineName, parameters, options) + if err != nil { + return LivePipelinesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LivePipelinesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LivePipelinesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *LivePipelinesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, livePipelineName string, parameters LivePipelineUpdate, options *LivePipelinesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/livePipelines/{livePipelineName}" + 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)) + if livePipelineName == "" { + return nil, errors.New("parameter livePipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{livePipelineName}", url.PathEscape(livePipelineName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *LivePipelinesClient) updateHandleResponse(resp *http.Response) (LivePipelinesUpdateResponse, error) { + result := LivePipelinesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.LivePipeline); err != nil { + return LivePipelinesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *LivePipelinesClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_locations_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_locations_client.go new file mode 100644 index 000000000000..f9e02f0c40ef --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_locations_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 armvideoanalyzer + +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" +) + +// LocationsClient contains the methods for the Locations group. +// Don't use this type directly, use NewLocationsClient() instead. +type LocationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLocationsClient creates a new instance of LocationsClient with the specified values. +func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LocationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LocationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Checks whether the Video Analyzer resource name is available. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LocationsClient) CheckNameAvailability(ctx context.Context, locationName string, parameters CheckNameAvailabilityRequest, options *LocationsCheckNameAvailabilityOptions) (LocationsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, locationName, parameters, options) + if err != nil { + return LocationsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LocationsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LocationsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *LocationsClient) checkNameAvailabilityCreateRequest(ctx context.Context, locationName string, parameters CheckNameAvailabilityRequest, options *LocationsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *LocationsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (LocationsCheckNameAvailabilityResponse, error) { + result := LocationsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return LocationsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *LocationsClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_models.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_models.go new file mode 100644 index 000000000000..25f82b2900dd --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_models.go @@ -0,0 +1,3529 @@ +//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 armvideoanalyzer + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AccessPoliciesCreateOrUpdateOptions contains the optional parameters for the AccessPolicies.CreateOrUpdate method. +type AccessPoliciesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AccessPoliciesDeleteOptions contains the optional parameters for the AccessPolicies.Delete method. +type AccessPoliciesDeleteOptions struct { + // placeholder for future optional parameters +} + +// AccessPoliciesGetOptions contains the optional parameters for the AccessPolicies.Get method. +type AccessPoliciesGetOptions struct { + // placeholder for future optional parameters +} + +// AccessPoliciesListOptions contains the optional parameters for the AccessPolicies.List method. +type AccessPoliciesListOptions struct { + // Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to + // but not greater than the specified value n. + Top *int32 +} + +// AccessPoliciesUpdateOptions contains the optional parameters for the AccessPolicies.Update method. +type AccessPoliciesUpdateOptions struct { + // placeholder for future optional parameters +} + +// AccessPolicyEntity - Access policies help define the authentication rules, and control access to specific video resources. +type AccessPolicyEntity struct { + ProxyResource + // The resource properties. + Properties *AccessPolicyProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyEntity. +func (a AccessPolicyEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AccessPolicyEntityCollection - A collection of AccessPolicyEntity items. +type AccessPolicyEntityCollection struct { + // A link to the next page of the collection (when the collection contains too many results to return in one response). + NextLink *string `json:"@nextLink,omitempty"` + + // A collection of AccessPolicyEntity items. + Value []*AccessPolicyEntity `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyEntityCollection. +func (a AccessPolicyEntityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AccessPolicyProperties - Application level properties for the access policy resource. +type AccessPolicyProperties struct { + // Authentication method to be used when validating client API access. + Authentication AuthenticationBaseClassification `json:"authentication,omitempty"` + + // Defines the access level granted by this policy. + Role *AccessPolicyRole `json:"role,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyProperties. +func (a AccessPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authentication", a.Authentication) + populate(objectMap, "role", a.Role) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyProperties. +func (a *AccessPolicyProperties) 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 "authentication": + a.Authentication, err = unmarshalAuthenticationBaseClassification(val) + delete(rawMsg, key) + case "role": + err = unpopulate(val, &a.Role) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AccountEncryption - Defines how the Video Analyzer account is (optionally) encrypted. +type AccountEncryption struct { + // REQUIRED; The type of key used to encrypt the Account Key. + Type *AccountEncryptionKeyType `json:"type,omitempty"` + + // The Key Vault identity. + Identity *ResourceIdentity `json:"identity,omitempty"` + + // The properties of the key used to encrypt the account. + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + + // READ-ONLY; The current status of the Key Vault mapping. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// AudioEncoderAac - A custom preset for encoding audio with the AAC codec. +type AudioEncoderAac struct { + AudioEncoderBase +} + +// MarshalJSON implements the json.Marshaller interface for type AudioEncoderAac. +func (a AudioEncoderAac) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.AudioEncoderBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.AudioEncoderAac") + return json.Marshal(objectMap) +} + +// AudioEncoderBaseClassification provides polymorphic access to related types. +// Call the interface's GetAudioEncoderBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AudioEncoderAac, *AudioEncoderBase +type AudioEncoderBaseClassification interface { + // GetAudioEncoderBase returns the AudioEncoderBase content of the underlying type. + GetAudioEncoderBase() *AudioEncoderBase +} + +// AudioEncoderBase - Base type for all audio encoder presets, which define the recipe or instructions on how audio should be processed. +type AudioEncoderBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` + + // Bitrate, in kilobits per second or Kbps, at which audio should be encoded (2-channel stereo audio at a sampling rate of 48 kHz). Allowed values are 96, + // 112, 128, 160, 192, 224, and 256. If omitted, + // the bitrate of the input audio is used. + BitrateKbps *string `json:"bitrateKbps,omitempty"` +} + +// GetAudioEncoderBase implements the AudioEncoderBaseClassification interface for type AudioEncoderBase. +func (a *AudioEncoderBase) GetAudioEncoderBase() *AudioEncoderBase { return a } + +// UnmarshalJSON implements the json.Unmarshaller interface for type AudioEncoderBase. +func (a *AudioEncoderBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return a.unmarshalInternal(rawMsg) +} + +func (a AudioEncoderBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + populate(objectMap, "bitrateKbps", a.BitrateKbps) + a.Type = &discValue + objectMap["@type"] = a.Type +} + +func (a *AudioEncoderBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "bitrateKbps": + err = unpopulate(val, &a.BitrateKbps) + delete(rawMsg, key) + case "@type": + err = unpopulate(val, &a.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AuthenticationBaseClassification provides polymorphic access to related types. +// Call the interface's GetAuthenticationBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AuthenticationBase, *JwtAuthentication +type AuthenticationBaseClassification interface { + // GetAuthenticationBase returns the AuthenticationBase content of the underlying type. + GetAuthenticationBase() *AuthenticationBase +} + +// AuthenticationBase - Base class for access policies authentication methods. +type AuthenticationBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetAuthenticationBase implements the AuthenticationBaseClassification interface for type AuthenticationBase. +func (a *AuthenticationBase) GetAuthenticationBase() *AuthenticationBase { return a } + +// UnmarshalJSON implements the json.Unmarshaller interface for type AuthenticationBase. +func (a *AuthenticationBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return a.unmarshalInternal(rawMsg) +} + +func (a AuthenticationBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + a.Type = &discValue + objectMap["@type"] = a.Type +} + +func (a *AuthenticationBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "@type": + err = unpopulate(val, &a.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CertificateSourceClassification provides polymorphic access to related types. +// Call the interface's GetCertificateSource() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *CertificateSource, *PemCertificateList +type CertificateSourceClassification interface { + // GetCertificateSource returns the CertificateSource content of the underlying type. + GetCertificateSource() *CertificateSource +} + +// CertificateSource - Base class for certificate sources. +type CertificateSource struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetCertificateSource implements the CertificateSourceClassification interface for type CertificateSource. +func (c *CertificateSource) GetCertificateSource() *CertificateSource { return c } + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateSource. +func (c *CertificateSource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return c.unmarshalInternal(rawMsg) +} + +func (c CertificateSource) marshalInternal(objectMap map[string]interface{}, discValue string) { + c.Type = &discValue + objectMap["@type"] = c.Type +} + +func (c *CertificateSource) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "@type": + err = unpopulate(val, &c.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CheckNameAvailabilityRequest - The check availability request body. +type CheckNameAvailabilityRequest struct { + // The name of the resource for which availability needs to be checked. + Name *string `json:"name,omitempty"` + + // The resource type. + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityResponse - The check availability result. +type CheckNameAvailabilityResponse struct { + // Detailed reason why the given name is available. + Message *string `json:"message,omitempty"` + + // Indicates if the resource name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // The reason why the given name is not available. + Reason *CheckNameAvailabilityReason `json:"reason,omitempty"` +} + +// CredentialsBaseClassification provides polymorphic access to related types. +// Call the interface's GetCredentialsBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *CredentialsBase, *UsernamePasswordCredentials +type CredentialsBaseClassification interface { + // GetCredentialsBase returns the CredentialsBase content of the underlying type. + GetCredentialsBase() *CredentialsBase +} + +// CredentialsBase - Base class for credential objects. +type CredentialsBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetCredentialsBase implements the CredentialsBaseClassification interface for type CredentialsBase. +func (c *CredentialsBase) GetCredentialsBase() *CredentialsBase { return c } + +// UnmarshalJSON implements the json.Unmarshaller interface for type CredentialsBase. +func (c *CredentialsBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return c.unmarshalInternal(rawMsg) +} + +func (c CredentialsBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + c.Type = &discValue + objectMap["@type"] = c.Type +} + +func (c *CredentialsBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "@type": + err = unpopulate(val, &c.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EccTokenKey - Required validation properties for tokens generated with Elliptical Curve algorithm. +type EccTokenKey struct { + TokenKey + // REQUIRED; Elliptical curve algorithm to be used: ES256, ES384 or ES512. + Alg *AccessPolicyEccAlgo `json:"alg,omitempty"` + + // REQUIRED; X coordinate. + X *string `json:"x,omitempty"` + + // REQUIRED; Y coordinate. + Y *string `json:"y,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EccTokenKey. +func (e EccTokenKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.TokenKey.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.EccTokenKey") + populate(objectMap, "alg", e.Alg) + populate(objectMap, "x", e.X) + populate(objectMap, "y", e.Y) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EccTokenKey. +func (e *EccTokenKey) 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 "alg": + err = unpopulate(val, &e.Alg) + delete(rawMsg, key) + case "x": + err = unpopulate(val, &e.X) + delete(rawMsg, key) + case "y": + err = unpopulate(val, &e.Y) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.TokenKey.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// EdgeModuleEntity - The representation of an edge module. +type EdgeModuleEntity struct { + ProxyResource + // The resource properties. + Properties *EdgeModuleProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EdgeModuleEntity. +func (e EdgeModuleEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// EdgeModuleEntityCollection - A collection of EdgeModuleEntity items. +type EdgeModuleEntityCollection struct { + // A link to the next page of the collection (when the collection contains too many results to return in one response). + NextLink *string `json:"@nextLink,omitempty"` + + // A collection of EdgeModuleEntity items. + Value []*EdgeModuleEntity `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EdgeModuleEntityCollection. +func (e EdgeModuleEntityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// EdgeModuleProperties - Application level properties for the edge module resource. +type EdgeModuleProperties struct { + // READ-ONLY; Internal ID generated for the instance of the Video Analyzer edge module. + EdgeModuleID *string `json:"edgeModuleId,omitempty" azure:"ro"` +} + +// EdgeModuleProvisioningToken - Provisioning token properties. A provisioning token allows for a single instance of Azure Video analyzer IoT edge module +// to be initialized and authorized to the cloud account. The provisioning token +// itself is short lived and it is only used for the initial handshake between IoT edge module and the cloud. After the initial handshake, the IoT edge +// module will agree on a set of authentication keys +// which will be auto-rotated as long as the module is able to periodically connect to the cloud. A new provisioning token can be generated for the same +// IoT edge module in case the module state lost or +// reset. +type EdgeModuleProvisioningToken struct { + // READ-ONLY; The expiration date of the registration token. The Azure Video Analyzer IoT edge module must be initialized and connected to the Internet + // prior to the token expiration date. + ExpirationDate *time.Time `json:"expirationDate,omitempty" azure:"ro"` + + // READ-ONLY; The token blob to be provided to the Azure Video Analyzer IoT edge module through the Azure IoT Edge module twin properties. + Token *string `json:"token,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EdgeModuleProvisioningToken. +func (e EdgeModuleProvisioningToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "expirationDate", e.ExpirationDate) + populate(objectMap, "token", e.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeModuleProvisioningToken. +func (e *EdgeModuleProvisioningToken) 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 "expirationDate": + err = unpopulateTimeRFC3339(val, &e.ExpirationDate) + delete(rawMsg, key) + case "token": + err = unpopulate(val, &e.Token) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EdgeModulesCreateOrUpdateOptions contains the optional parameters for the EdgeModules.CreateOrUpdate method. +type EdgeModulesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// EdgeModulesDeleteOptions contains the optional parameters for the EdgeModules.Delete method. +type EdgeModulesDeleteOptions struct { + // placeholder for future optional parameters +} + +// EdgeModulesGetOptions contains the optional parameters for the EdgeModules.Get method. +type EdgeModulesGetOptions struct { + // placeholder for future optional parameters +} + +// EdgeModulesListOptions contains the optional parameters for the EdgeModules.List method. +type EdgeModulesListOptions struct { + // Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to + // but not greater than the specified value n. + Top *int32 +} + +// EdgeModulesListProvisioningTokenOptions contains the optional parameters for the EdgeModules.ListProvisioningToken method. +type EdgeModulesListProvisioningTokenOptions struct { + // placeholder for future optional parameters +} + +// EncoderCustomPreset - Describes a custom preset for encoding the input content using the encoder processor. +type EncoderCustomPreset struct { + EncoderPresetBase + // Describes a custom preset for encoding audio. + AudioEncoder AudioEncoderBaseClassification `json:"audioEncoder,omitempty"` + + // Describes a custom preset for encoding video. + VideoEncoder VideoEncoderBaseClassification `json:"videoEncoder,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EncoderCustomPreset. +func (e EncoderCustomPreset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.EncoderPresetBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.EncoderCustomPreset") + populate(objectMap, "audioEncoder", e.AudioEncoder) + populate(objectMap, "videoEncoder", e.VideoEncoder) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncoderCustomPreset. +func (e *EncoderCustomPreset) 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 "audioEncoder": + e.AudioEncoder, err = unmarshalAudioEncoderBaseClassification(val) + delete(rawMsg, key) + case "videoEncoder": + e.VideoEncoder, err = unmarshalVideoEncoderBaseClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.EncoderPresetBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// EncoderPresetBaseClassification provides polymorphic access to related types. +// Call the interface's GetEncoderPresetBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EncoderCustomPreset, *EncoderPresetBase, *EncoderSystemPreset +type EncoderPresetBaseClassification interface { + // GetEncoderPresetBase returns the EncoderPresetBase content of the underlying type. + GetEncoderPresetBase() *EncoderPresetBase +} + +// EncoderPresetBase - Base type for all encoder presets, which define the recipe or instructions on how the input content should be processed. +type EncoderPresetBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetEncoderPresetBase implements the EncoderPresetBaseClassification interface for type EncoderPresetBase. +func (e *EncoderPresetBase) GetEncoderPresetBase() *EncoderPresetBase { return e } + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncoderPresetBase. +func (e *EncoderPresetBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return e.unmarshalInternal(rawMsg) +} + +func (e EncoderPresetBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + e.Type = &discValue + objectMap["@type"] = e.Type +} + +func (e *EncoderPresetBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "@type": + err = unpopulate(val, &e.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EncoderProcessor - Encoder processor allows for encoding of the input content. For example, it can used to change the resolution from 4K to 1280x720. +type EncoderProcessor struct { + ProcessorNodeBase + // REQUIRED; The encoder preset, which defines the recipe or instructions on how the input content should be processed. + Preset EncoderPresetBaseClassification `json:"preset,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EncoderProcessor. +func (e EncoderProcessor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.ProcessorNodeBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.EncoderProcessor") + populate(objectMap, "preset", e.Preset) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncoderProcessor. +func (e *EncoderProcessor) 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 "preset": + e.Preset, err = unmarshalEncoderPresetBaseClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.ProcessorNodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// EncoderSystemPreset - Describes a built-in preset for encoding the input content using the encoder processor. +type EncoderSystemPreset struct { + EncoderPresetBase + // REQUIRED; Name of the built-in encoding preset. + Name *EncoderSystemPresetType `json:"name,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EncoderSystemPreset. +func (e EncoderSystemPreset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.EncoderPresetBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.EncoderSystemPreset") + populate(objectMap, "name", e.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncoderSystemPreset. +func (e *EncoderSystemPreset) 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 "name": + err = unpopulate(val, &e.Name) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.EncoderPresetBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// Endpoint - The endpoint details. +type Endpoint struct { + // REQUIRED; The type of the endpoint. + Type *VideoAnalyzerEndpointType `json:"type,omitempty"` + + // The URL of the endpoint. + EndpointURL *string `json:"endpointUrl,omitempty"` +} + +// EndpointBaseClassification provides polymorphic access to related types. +// Call the interface's GetEndpointBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EndpointBase, *TlsEndpoint, *UnsecuredEndpoint +type EndpointBaseClassification interface { + // GetEndpointBase returns the EndpointBase content of the underlying type. + GetEndpointBase() *EndpointBase +} + +// EndpointBase - Base class for endpoints. +type EndpointBase struct { + // REQUIRED; Credentials to be presented to the endpoint. + Credentials CredentialsBaseClassification `json:"credentials,omitempty"` + + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` + + // REQUIRED; The endpoint URL for Video Analyzer to connect to. + URL *string `json:"url,omitempty"` + + // Describes the tunnel through which Video Analyzer can connect to the endpoint URL. This is an optional property, typically used when the endpoint is + // behind a firewall. + Tunnel TunnelBaseClassification `json:"tunnel,omitempty"` +} + +// GetEndpointBase implements the EndpointBaseClassification interface for type EndpointBase. +func (e *EndpointBase) GetEndpointBase() *EndpointBase { return e } + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointBase. +func (e *EndpointBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return e.unmarshalInternal(rawMsg) +} + +func (e EndpointBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + populate(objectMap, "credentials", e.Credentials) + populate(objectMap, "tunnel", e.Tunnel) + e.Type = &discValue + objectMap["@type"] = e.Type + populate(objectMap, "url", e.URL) +} + +func (e *EndpointBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "credentials": + e.Credentials, err = unmarshalCredentialsBaseClassification(val) + delete(rawMsg, key) + case "tunnel": + e.Tunnel, err = unmarshalTunnelBaseClassification(val) + delete(rawMsg, key) + case "@type": + err = unpopulate(val, &e.Type) + delete(rawMsg, key) + case "url": + err = unpopulate(val, &e.URL) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error object. + InnerError *ErrorDetail `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 +} + +// GroupLevelAccessControl - Group level network access control. +type GroupLevelAccessControl struct { + // Whether or not public network access is allowed for specified resources under the Video Analyzer account. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// IotHub - The IoT Hub details. +type IotHub struct { + // REQUIRED; The IoT Hub resource identifier. + ID *string `json:"id,omitempty"` + + // REQUIRED; The IoT Hub identity. + Identity *ResourceIdentity `json:"identity,omitempty"` + + // READ-ONLY; The current status of the Iot Hub mapping. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// JwtAuthentication - Properties for access validation based on JSON Web Tokens (JWT). +type JwtAuthentication struct { + AuthenticationBase + // List of expected token audiences. Token audience is valid if it matches at least one of the given values. + Audiences []*string `json:"audiences,omitempty"` + + // List of additional token claims to be validated. Token must contains all claims and respective values for it to be valid. + Claims []*TokenClaim `json:"claims,omitempty"` + + // List of expected token issuers. Token issuer is valid if it matches at least one of the given values. + Issuers []*string `json:"issuers,omitempty"` + + // List of keys which can be used to validate access tokens. Having multiple keys allow for seamless key rotation of the token signing key. Token signature + // must match exactly one key. + Keys []TokenKeyClassification `json:"keys,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type JwtAuthentication. +func (j JwtAuthentication) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + j.AuthenticationBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.JwtAuthentication") + populate(objectMap, "audiences", j.Audiences) + populate(objectMap, "claims", j.Claims) + populate(objectMap, "issuers", j.Issuers) + populate(objectMap, "keys", j.Keys) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JwtAuthentication. +func (j *JwtAuthentication) 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 "audiences": + err = unpopulate(val, &j.Audiences) + delete(rawMsg, key) + case "claims": + err = unpopulate(val, &j.Claims) + delete(rawMsg, key) + case "issuers": + err = unpopulate(val, &j.Issuers) + delete(rawMsg, key) + case "keys": + j.Keys, err = unmarshalTokenKeyClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := j.AuthenticationBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// KeyVaultProperties - The details for accessing the encryption keys in Key Vault. +type KeyVaultProperties struct { + // REQUIRED; The URL of the Key Vault key used to encrypt the account. The key may either be versioned (for example https://vault/keys/mykey/version1) or + // reference a key without a version (for example + // https://vault/keys/mykey). + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + + // READ-ONLY; The current key used to encrypt Video Analyzer account, including the key version. + CurrentKeyIdentifier *string `json:"currentKeyIdentifier,omitempty" azure:"ro"` +} + +// ListProvisioningTokenInput - The input parameters to generate registration token for the Azure Video Analyzer IoT edge module. +type ListProvisioningTokenInput struct { + // REQUIRED; The desired expiration date of the registration token. The Azure Video Analyzer IoT edge module must be initialized and connected to the Internet + // prior to the token expiration date. + ExpirationDate *time.Time `json:"expirationDate,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ListProvisioningTokenInput. +func (l ListProvisioningTokenInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListProvisioningTokenInput. +func (l *ListProvisioningTokenInput) 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 "expirationDate": + err = unpopulateTimeRFC3339(val, &l.ExpirationDate) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// LivePipeline - Live pipeline represents a unique instance of a live topology, used for real-time ingestion, archiving and publishing of content for a +// unique RTSP camera. +type LivePipeline struct { + ProxyResource + // The resource properties. + Properties *LivePipelineProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LivePipeline. +func (l LivePipeline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LivePipelineCollection - A collection of LivePipeline items. +type LivePipelineCollection struct { + // A link to the next page of the collection (when the collection contains too many results to return in one response). + NextLink *string `json:"@nextLink,omitempty"` + + // A collection of LivePipeline items. + Value []*LivePipeline `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LivePipelineCollection. +func (l LivePipelineCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LivePipelineOperationStatus - Used for tracking the status of an operation on the live pipeline. +type LivePipelineOperationStatus struct { + // READ-ONLY; The error details for the live pipeline operation. + Error *ErrorDetail `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; The name of the live pipeline operation. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status of the live pipeline operation. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// LivePipelineOperationStatusesGetOptions contains the optional parameters for the LivePipelineOperationStatuses.Get method. +type LivePipelineOperationStatusesGetOptions struct { + // placeholder for future optional parameters +} + +// LivePipelineProperties - Live pipeline properties. +type LivePipelineProperties struct { + // REQUIRED; Maximum bitrate capacity in Kbps reserved for the live pipeline. The allowed range is from 500 to 3000 Kbps in increments of 100 Kbps. If the + // RTSP camera exceeds this capacity, then the service will + // disconnect temporarily from the camera. It will retry to re-establish connection (with exponential backoff), checking to see if the camera bitrate is + // now below the reserved capacity. Doing so will + // ensure that one 'noisy neighbor' does not affect other live pipelines in your account. + BitrateKbps *int32 `json:"bitrateKbps,omitempty"` + + // REQUIRED; The reference to an existing pipeline topology defined for real-time content processing. When activated, this live pipeline will process content + // according to the pipeline topology definition. + TopologyName *string `json:"topologyName,omitempty"` + + // An optional description for the pipeline. + Description *string `json:"description,omitempty"` + + // List of the instance level parameter values for the user-defined topology parameters. A pipeline can only define or override parameters values for parameters + // which have been declared in the referenced + // topology. Topology parameters without a default value must be defined. Topology parameters with a default value can be optionally be overridden. + Parameters []*ParameterDefinition `json:"parameters,omitempty"` + + // READ-ONLY; Current state of the pipeline (read-only). + State *LivePipelineState `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LivePipelineProperties. +func (l LivePipelineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "bitrateKbps", l.BitrateKbps) + populate(objectMap, "description", l.Description) + populate(objectMap, "parameters", l.Parameters) + populate(objectMap, "state", l.State) + populate(objectMap, "topologyName", l.TopologyName) + return json.Marshal(objectMap) +} + +// LivePipelinePropertiesUpdate - Live pipeline properties. +type LivePipelinePropertiesUpdate struct { + // Maximum bitrate capacity in Kbps reserved for the live pipeline. The allowed range is from 500 to 3000 Kbps in increments of 100 Kbps. If the RTSP camera + // exceeds this capacity, then the service will + // disconnect temporarily from the camera. It will retry to re-establish connection (with exponential backoff), checking to see if the camera bitrate is + // now below the reserved capacity. Doing so will + // ensure that one 'noisy neighbor' does not affect other live pipelines in your account. + BitrateKbps *int32 `json:"bitrateKbps,omitempty"` + + // An optional description for the pipeline. + Description *string `json:"description,omitempty"` + + // List of the instance level parameter values for the user-defined topology parameters. A pipeline can only define or override parameters values for parameters + // which have been declared in the referenced + // topology. Topology parameters without a default value must be defined. Topology parameters with a default value can be optionally be overridden. + Parameters []*ParameterDefinition `json:"parameters,omitempty"` + + // The reference to an existing pipeline topology defined for real-time content processing. When activated, this live pipeline will process content according + // to the pipeline topology definition. + TopologyName *string `json:"topologyName,omitempty"` + + // READ-ONLY; Current state of the pipeline (read-only). + State *LivePipelineState `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type LivePipelinePropertiesUpdate. +func (l LivePipelinePropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "bitrateKbps", l.BitrateKbps) + populate(objectMap, "description", l.Description) + populate(objectMap, "parameters", l.Parameters) + populate(objectMap, "state", l.State) + populate(objectMap, "topologyName", l.TopologyName) + return json.Marshal(objectMap) +} + +// LivePipelineUpdate - Live pipeline represents a unique instance of a live topology, used for real-time ingestion, archiving and publishing of content +// for a unique RTSP camera. +type LivePipelineUpdate struct { + ProxyResource + // The resource properties. + Properties *LivePipelinePropertiesUpdate `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LivePipelineUpdate. +func (l LivePipelineUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + l.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LivePipelinesBeginActivateOptions contains the optional parameters for the LivePipelines.BeginActivate method. +type LivePipelinesBeginActivateOptions struct { + // placeholder for future optional parameters +} + +// LivePipelinesBeginDeactivateOptions contains the optional parameters for the LivePipelines.BeginDeactivate method. +type LivePipelinesBeginDeactivateOptions struct { + // placeholder for future optional parameters +} + +// LivePipelinesCreateOrUpdateOptions contains the optional parameters for the LivePipelines.CreateOrUpdate method. +type LivePipelinesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// LivePipelinesDeleteOptions contains the optional parameters for the LivePipelines.Delete method. +type LivePipelinesDeleteOptions struct { + // placeholder for future optional parameters +} + +// LivePipelinesGetOptions contains the optional parameters for the LivePipelines.Get method. +type LivePipelinesGetOptions struct { + // placeholder for future optional parameters +} + +// LivePipelinesListOptions contains the optional parameters for the LivePipelines.List method. +type LivePipelinesListOptions struct { + // Restricts the set of items returned. + Filter *string + // Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to + // but not greater than the specified value n. + Top *int32 +} + +// LivePipelinesUpdateOptions contains the optional parameters for the LivePipelines.Update method. +type LivePipelinesUpdateOptions struct { + // placeholder for future optional parameters +} + +// LocationsCheckNameAvailabilityOptions contains the optional parameters for the Locations.CheckNameAvailability method. +type LocationsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// LogSpecification - A diagnostic log emitted by service. +type LogSpecification struct { + // READ-ONLY; The time range for requests in each blob. + BlobDuration *string `json:"blobDuration,omitempty" azure:"ro"` + + // READ-ONLY; The diagnostic log category display name. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; The diagnostic log category name. + Name *string `json:"name,omitempty" azure:"ro"` +} + +// MetricDimension - A metric dimension. +type MetricDimension struct { + // READ-ONLY; The display name for the dimension. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; The metric dimension name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Whether to export metric to shoebox. + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty" azure:"ro"` +} + +// MetricSpecification - A metric emitted by service. +type MetricSpecification struct { + // Supported aggregation types. + SupportedAggregationTypes []*string `json:"supportedAggregationTypes,omitempty"` + + // READ-ONLY; The metric aggregation type + AggregationType *MetricAggregationType `json:"aggregationType,omitempty" azure:"ro"` + + // READ-ONLY; The metric dimensions. + Dimensions []*MetricDimension `json:"dimensions,omitempty" azure:"ro"` + + // READ-ONLY; The metric display description. + DisplayDescription *string `json:"displayDescription,omitempty" azure:"ro"` + + // READ-ONLY; The metric display name. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; Indicates whether regional MDM account is enabled. + EnableRegionalMdmAccount *bool `json:"enableRegionalMdmAccount,omitempty" azure:"ro"` + + // READ-ONLY; The metric lock aggregation type + LockAggregationType *MetricAggregationType `json:"lockAggregationType,omitempty" azure:"ro"` + + // READ-ONLY; The metric name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The source MDM account. + SourceMdmAccount *string `json:"sourceMdmAccount,omitempty" azure:"ro"` + + // READ-ONLY; The source MDM namespace. + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty" azure:"ro"` + + // READ-ONLY; The supported time grain types. + SupportedTimeGrainTypes []*string `json:"supportedTimeGrainTypes,omitempty" azure:"ro"` + + // READ-ONLY; The metric unit + Unit *MetricUnit `json:"unit,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "enableRegionalMdmAccount", m.EnableRegionalMdmAccount) + populate(objectMap, "lockAggregationType", m.LockAggregationType) + populate(objectMap, "name", m.Name) + populate(objectMap, "sourceMdmAccount", m.SourceMdmAccount) + populate(objectMap, "sourceMdmNamespace", m.SourceMdmNamespace) + populate(objectMap, "supportedAggregationTypes", m.SupportedAggregationTypes) + populate(objectMap, "supportedTimeGrainTypes", m.SupportedTimeGrainTypes) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// NetworkAccessControl - Network access control for video analyzer account. +type NetworkAccessControl struct { + // Public network access for consumption group. + Consumption *GroupLevelAccessControl `json:"consumption,omitempty"` + + // Public network access for ingestion group. + Ingestion *GroupLevelAccessControl `json:"ingestion,omitempty"` + + // Public network access for integration group. + Integration *GroupLevelAccessControl `json:"integration,omitempty"` +} + +// NodeBaseClassification provides polymorphic access to related types. +// Call the interface's GetNodeBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EncoderProcessor, *NodeBase, *ProcessorNodeBase, *RtspSource, *SinkNodeBase, *SourceNodeBase, *VideoSink, *VideoSource +type NodeBaseClassification interface { + // GetNodeBase returns the NodeBase content of the underlying type. + GetNodeBase() *NodeBase +} + +// NodeBase - Base class for nodes. +type NodeBase struct { + // REQUIRED; Node name. Must be unique within the topology. + Name *string `json:"name,omitempty"` + + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetNodeBase implements the NodeBaseClassification interface for type NodeBase. +func (n *NodeBase) GetNodeBase() *NodeBase { return n } + +// UnmarshalJSON implements the json.Unmarshaller interface for type NodeBase. +func (n *NodeBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return n.unmarshalInternal(rawMsg) +} + +func (n NodeBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + populate(objectMap, "name", n.Name) + n.Type = &discValue + objectMap["@type"] = n.Type +} + +func (n *NodeBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, &n.Name) + delete(rawMsg, key) + case "@type": + err = unpopulate(val, &n.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// NodeInput - Describes an input signal to be used on a pipeline node. +type NodeInput struct { + // REQUIRED; The name of the upstream node in the pipeline which output is used as input of the current node. + NodeName *string `json:"nodeName,omitempty"` +} + +// Operation - An operation. +type Operation struct { + // REQUIRED; The operation name. + Name *string `json:"name,omitempty"` + + // Indicates the action type. + ActionType *ActionType `json:"actionType,omitempty"` + + // The operation display name. + Display *OperationDisplay `json:"display,omitempty"` + + // Whether the operation applies to data-plane. + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Origin of the operation. + Origin *string `json:"origin,omitempty"` + + // Operation properties format. + Properties *Properties `json:"properties,omitempty"` +} + +// OperationCollection - A collection of Operation items. +type OperationCollection struct { + // A collection of Operation items. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationCollection. +func (o OperationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationDisplay - Operation details. +type OperationDisplay struct { + // The operation description. + Description *string `json:"description,omitempty"` + + // The operation type. + Operation *string `json:"operation,omitempty"` + + // The service provider. + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationResultsGetOptions contains the optional parameters for the OperationResults.Get method. +type OperationResultsGetOptions struct { + // placeholder for future optional parameters +} + +// OperationStatusesGetOptions contains the optional parameters for the OperationStatuses.Get method. +type OperationStatusesGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ParameterDeclaration - Single topology parameter declaration. Declared parameters can and must be referenced throughout the topology and can optionally +// have default values to be used when they are not defined in the +// pipelines. +type ParameterDeclaration struct { + // REQUIRED; Name of the parameter. + Name *string `json:"name,omitempty"` + + // REQUIRED; Type of the parameter. + Type *ParameterType `json:"type,omitempty"` + + // The default value for the parameter to be used if the pipeline does not specify a value. + Default *string `json:"default,omitempty"` + + // Description of the parameter. + Description *string `json:"description,omitempty"` +} + +// ParameterDefinition - Defines the parameter value of an specific pipeline topology parameter. See pipeline topology parameters for more information. +type ParameterDefinition struct { + // REQUIRED; Name of the parameter declared in the pipeline topology. + Name *string `json:"name,omitempty"` + + // Parameter value to be applied on this specific pipeline. + Value *string `json:"value,omitempty"` +} + +// PemCertificateList - A list of PEM formatted certificates. +type PemCertificateList struct { + CertificateSource + // REQUIRED; PEM formatted public certificates. One certificate per entry. + Certificates []*string `json:"certificates,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PemCertificateList. +func (p PemCertificateList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.CertificateSource.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.PemCertificateList") + populate(objectMap, "certificates", p.Certificates) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PemCertificateList. +func (p *PemCertificateList) 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 "certificates": + err = unpopulate(val, &p.Certificates) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.CertificateSource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// PipelineJob - Pipeline job represents a unique instance of a batch topology, used for offline processing of selected portions of archived content. +type PipelineJob struct { + ProxyResource + // The resource properties. + Properties *PipelineJobProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineJob. +func (p PipelineJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PipelineJobCollection - A collection of PipelineJob items. +type PipelineJobCollection struct { + // A link to the next page of the collection (when the collection contains too many results to return in one response). + NextLink *string `json:"@nextLink,omitempty"` + + // A collection of PipelineJob items. + Value []*PipelineJob `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineJobCollection. +func (p PipelineJobCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PipelineJobError - Details about the error for a failed pipeline job. +type PipelineJobError struct { + // The error code. + Code *string `json:"code,omitempty"` + + // The error message. + Message *string `json:"message,omitempty"` +} + +// PipelineJobOperationStatus - Used for tracking the status of an operation on the pipeline job. +type PipelineJobOperationStatus struct { + // READ-ONLY; The error details for the pipeline job operation. + Error *ErrorDetail `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; The name of the pipeline job operation. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The status of the pipeline job operation. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// PipelineJobOperationStatusesGetOptions contains the optional parameters for the PipelineJobOperationStatuses.Get method. +type PipelineJobOperationStatusesGetOptions struct { + // placeholder for future optional parameters +} + +// PipelineJobProperties - Pipeline job properties. +type PipelineJobProperties struct { + // REQUIRED; Reference to an existing pipeline topology. When activated, this pipeline job will process content according to the pipeline topology definition. + TopologyName *string `json:"topologyName,omitempty"` + + // An optional description for the pipeline. + Description *string `json:"description,omitempty"` + + // List of the instance level parameter values for the user-defined topology parameters. A pipeline can only define or override parameters values for parameters + // which have been declared in the referenced + // topology. Topology parameters without a default value must be defined. Topology parameters with a default value can be optionally be overridden. + Parameters []*ParameterDefinition `json:"parameters,omitempty"` + + // READ-ONLY; Details about the error, in case the pipeline job fails. + Error *PipelineJobError `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; The date-time by when this pipeline job will be automatically deleted from your account. + Expiration *time.Time `json:"expiration,omitempty" azure:"ro"` + + // READ-ONLY; Current state of the pipeline (read-only). + State *PipelineJobState `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineJobProperties. +func (p PipelineJobProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "error", p.Error) + populateTimeRFC3339(objectMap, "expiration", p.Expiration) + populate(objectMap, "parameters", p.Parameters) + populate(objectMap, "state", p.State) + populate(objectMap, "topologyName", p.TopologyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineJobProperties. +func (p *PipelineJobProperties) 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 "description": + err = unpopulate(val, &p.Description) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &p.Error) + delete(rawMsg, key) + case "expiration": + err = unpopulateTimeRFC3339(val, &p.Expiration) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, &p.Parameters) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &p.State) + delete(rawMsg, key) + case "topologyName": + err = unpopulate(val, &p.TopologyName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// PipelineJobPropertiesUpdate - Pipeline job properties. +type PipelineJobPropertiesUpdate struct { + // An optional description for the pipeline. + Description *string `json:"description,omitempty"` + + // List of the instance level parameter values for the user-defined topology parameters. A pipeline can only define or override parameters values for parameters + // which have been declared in the referenced + // topology. Topology parameters without a default value must be defined. Topology parameters with a default value can be optionally be overridden. + Parameters []*ParameterDefinition `json:"parameters,omitempty"` + + // Reference to an existing pipeline topology. When activated, this pipeline job will process content according to the pipeline topology definition. + TopologyName *string `json:"topologyName,omitempty"` + + // READ-ONLY; Details about the error, in case the pipeline job fails. + Error *PipelineJobError `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; The date-time by when this pipeline job will be automatically deleted from your account. + Expiration *time.Time `json:"expiration,omitempty" azure:"ro"` + + // READ-ONLY; Current state of the pipeline (read-only). + State *PipelineJobState `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineJobPropertiesUpdate. +func (p PipelineJobPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "error", p.Error) + populateTimeRFC3339(objectMap, "expiration", p.Expiration) + populate(objectMap, "parameters", p.Parameters) + populate(objectMap, "state", p.State) + populate(objectMap, "topologyName", p.TopologyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineJobPropertiesUpdate. +func (p *PipelineJobPropertiesUpdate) 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 "description": + err = unpopulate(val, &p.Description) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &p.Error) + delete(rawMsg, key) + case "expiration": + err = unpopulateTimeRFC3339(val, &p.Expiration) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, &p.Parameters) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &p.State) + delete(rawMsg, key) + case "topologyName": + err = unpopulate(val, &p.TopologyName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// PipelineJobUpdate - Pipeline job represents a unique instance of a batch topology, used for offline processing of selected portions of archived content. +type PipelineJobUpdate struct { + ProxyResource + // The resource properties. + Properties *PipelineJobPropertiesUpdate `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineJobUpdate. +func (p PipelineJobUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PipelineJobsBeginCancelOptions contains the optional parameters for the PipelineJobs.BeginCancel method. +type PipelineJobsBeginCancelOptions struct { + // placeholder for future optional parameters +} + +// PipelineJobsCreateOrUpdateOptions contains the optional parameters for the PipelineJobs.CreateOrUpdate method. +type PipelineJobsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PipelineJobsDeleteOptions contains the optional parameters for the PipelineJobs.Delete method. +type PipelineJobsDeleteOptions struct { + // placeholder for future optional parameters +} + +// PipelineJobsGetOptions contains the optional parameters for the PipelineJobs.Get method. +type PipelineJobsGetOptions struct { + // placeholder for future optional parameters +} + +// PipelineJobsListOptions contains the optional parameters for the PipelineJobs.List method. +type PipelineJobsListOptions struct { + // Restricts the set of items returned. + Filter *string + // Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to + // but not greater than the specified value n. + Top *int32 +} + +// PipelineJobsUpdateOptions contains the optional parameters for the PipelineJobs.Update method. +type PipelineJobsUpdateOptions struct { + // placeholder for future optional parameters +} + +// PipelineTopologiesCreateOrUpdateOptions contains the optional parameters for the PipelineTopologies.CreateOrUpdate method. +type PipelineTopologiesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PipelineTopologiesDeleteOptions contains the optional parameters for the PipelineTopologies.Delete method. +type PipelineTopologiesDeleteOptions struct { + // placeholder for future optional parameters +} + +// PipelineTopologiesGetOptions contains the optional parameters for the PipelineTopologies.Get method. +type PipelineTopologiesGetOptions struct { + // placeholder for future optional parameters +} + +// PipelineTopologiesListOptions contains the optional parameters for the PipelineTopologies.List method. +type PipelineTopologiesListOptions struct { + // Restricts the set of items returned. + Filter *string + // Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to + // but not greater than the specified value n. + Top *int32 +} + +// PipelineTopologiesUpdateOptions contains the optional parameters for the PipelineTopologies.Update method. +type PipelineTopologiesUpdateOptions struct { + // placeholder for future optional parameters +} + +// PipelineTopology - Pipeline topology describes the processing steps to be applied when processing content for a particular outcome. The topology should +// be defined according to the scenario to be achieved and can be +// reused across many pipeline instances which share the same processing characteristics. For instance, a pipeline topology which captures content from +// a RTSP camera and archives the content can be +// reused across many different cameras, as long as the same processing is to be applied across all the cameras. Individual instance properties can be defined +// through the use of user-defined parameters, +// which allow for a topology to be parameterized. This allows individual pipelines refer to different values, such as individual cameras' RTSP endpoints +// and credentials. Overall a topology is composed +// of the following: +// * Parameters: list of user defined parameters that can be references across the topology nodes. +// * Sources: list of one or more data sources nodes such as an RTSP source which allows for content to be ingested from cameras. +// * Processors: list of nodes which perform data analysis or transformations. +// * Sinks: list of one or more data sinks which allow for data to be stored or exported to other destinations. +type PipelineTopology struct { + ProxyResource + // REQUIRED; Topology kind. + Kind *Kind `json:"kind,omitempty"` + + // REQUIRED; Describes the properties of a SKU. + SKU *SKU `json:"sku,omitempty"` + + // The resource properties. + Properties *PipelineTopologyProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineTopology. +func (p PipelineTopology) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "kind", p.Kind) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + return json.Marshal(objectMap) +} + +// PipelineTopologyCollection - A collection of PipelineTopology items. +type PipelineTopologyCollection struct { + // A link to the next page of the collection (when the collection contains too many results to return in one response). + NextLink *string `json:"@nextLink,omitempty"` + + // A collection of PipelineTopology items. + Value []*PipelineTopology `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineTopologyCollection. +func (p PipelineTopologyCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PipelineTopologyProperties - Describes the properties of a pipeline topology. +type PipelineTopologyProperties struct { + // REQUIRED; List of the topology sink nodes. Sink nodes allow pipeline data to be stored or exported. + Sinks []SinkNodeBaseClassification `json:"sinks,omitempty"` + + // REQUIRED; List of the topology source nodes. Source nodes enable external data to be ingested by the pipeline. + Sources []SourceNodeBaseClassification `json:"sources,omitempty"` + + // An optional description of the pipeline topology. It is recommended that the expected use of the topology to be described here. + Description *string `json:"description,omitempty"` + + // List of the topology parameter declarations. Parameters declared here can be referenced throughout the topology nodes through the use of "${PARAMETER_NAME}" + // string pattern. Parameters can have + // optional default values and can later be defined in individual instances of the pipeline. + Parameters []*ParameterDeclaration `json:"parameters,omitempty"` + + // List of the topology processor nodes. Processor nodes enable pipeline data to be analyzed, processed or transformed. + Processors []ProcessorNodeBaseClassification `json:"processors,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineTopologyProperties. +func (p PipelineTopologyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "parameters", p.Parameters) + populate(objectMap, "processors", p.Processors) + populate(objectMap, "sinks", p.Sinks) + populate(objectMap, "sources", p.Sources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineTopologyProperties. +func (p *PipelineTopologyProperties) 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 "description": + err = unpopulate(val, &p.Description) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, &p.Parameters) + delete(rawMsg, key) + case "processors": + p.Processors, err = unmarshalProcessorNodeBaseClassificationArray(val) + delete(rawMsg, key) + case "sinks": + p.Sinks, err = unmarshalSinkNodeBaseClassificationArray(val) + delete(rawMsg, key) + case "sources": + p.Sources, err = unmarshalSourceNodeBaseClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// PipelineTopologyPropertiesUpdate - Describes the properties of a pipeline topology. +type PipelineTopologyPropertiesUpdate struct { + // An optional description of the pipeline topology. It is recommended that the expected use of the topology to be described here. + Description *string `json:"description,omitempty"` + + // List of the topology parameter declarations. Parameters declared here can be referenced throughout the topology nodes through the use of "${PARAMETER_NAME}" + // string pattern. Parameters can have + // optional default values and can later be defined in individual instances of the pipeline. + Parameters []*ParameterDeclaration `json:"parameters,omitempty"` + + // List of the topology processor nodes. Processor nodes enable pipeline data to be analyzed, processed or transformed. + Processors []ProcessorNodeBaseClassification `json:"processors,omitempty"` + + // List of the topology sink nodes. Sink nodes allow pipeline data to be stored or exported. + Sinks []SinkNodeBaseClassification `json:"sinks,omitempty"` + + // List of the topology source nodes. Source nodes enable external data to be ingested by the pipeline. + Sources []SourceNodeBaseClassification `json:"sources,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineTopologyPropertiesUpdate. +func (p PipelineTopologyPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "parameters", p.Parameters) + populate(objectMap, "processors", p.Processors) + populate(objectMap, "sinks", p.Sinks) + populate(objectMap, "sources", p.Sources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineTopologyPropertiesUpdate. +func (p *PipelineTopologyPropertiesUpdate) 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 "description": + err = unpopulate(val, &p.Description) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, &p.Parameters) + delete(rawMsg, key) + case "processors": + p.Processors, err = unmarshalProcessorNodeBaseClassificationArray(val) + delete(rawMsg, key) + case "sinks": + p.Sinks, err = unmarshalSinkNodeBaseClassificationArray(val) + delete(rawMsg, key) + case "sources": + p.Sources, err = unmarshalSourceNodeBaseClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// PipelineTopologyUpdate - Pipeline topology describes the processing steps to be applied when processing content for a particular outcome. The topology +// should be defined according to the scenario to be achieved and can be +// reused across many pipeline instances which share the same processing characteristics. For instance, a pipeline topology which captures content from +// a RTSP camera and archives the content can be +// reused across many different cameras, as long as the same processing is to be applied across all the cameras. Individual instance properties can be defined +// through the use of user-defined parameters, +// which allow for a topology to be parameterized. This allows individual pipelines refer to different values, such as individual cameras' RTSP endpoints +// and credentials. Overall a topology is composed +// of the following: +// * Parameters: list of user defined parameters that can be references across the topology nodes. +// * Sources: list of one or more data sources nodes such as an RTSP source which allows for content to be ingested from cameras. +// * Processors: list of nodes which perform data analysis or transformations. +// * Sinks: list of one or more data sinks which allow for data to be stored or exported to other destinations. +type PipelineTopologyUpdate struct { + ProxyResource + // Topology kind. + Kind *Kind `json:"kind,omitempty"` + + // The resource properties. + Properties *PipelineTopologyPropertiesUpdate `json:"properties,omitempty"` + + // Describes the properties of a SKU. + SKU *SKU `json:"sku,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineTopologyUpdate. +func (p PipelineTopologyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "kind", p.Kind) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "sku", p.SKU) + return json.Marshal(objectMap) +} + +// PrivateEndpoint - The Private Endpoint resource. +type PrivateEndpoint struct { + // READ-ONLY; The ARM identifier for Private Endpoint + ID *string `json:"id,omitempty" azure:"ro"` +} + +// PrivateEndpointConnection - The Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + Resource + // Resource properties. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account +type PrivateEndpointConnectionListResult struct { + // Array of private endpoint connections + Value []*PrivateEndpointConnection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. +type PrivateEndpointConnectionProperties struct { + // REQUIRED; A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + + // The resource of private end point. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + + // READ-ONLY; The provisioning state of the private endpoint connection resource. + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionsCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnections.CreateOrUpdate method. +type PrivateEndpointConnectionsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsDeleteOptions contains the optional parameters for the PrivateEndpointConnections.Delete method. +type PrivateEndpointConnectionsDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. +type PrivateEndpointConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. +type PrivateEndpointConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResource - A private link resource +type PrivateLinkResource struct { + Resource + // Resource properties. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceListResult - A list of private link resources +type PrivateLinkResourceListResult struct { + // Array of private link resources + Value []*PrivateLinkResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceProperties - Properties of a private link resource. +type PrivateLinkResourceProperties struct { + // The private link resource Private link DNS zone name. + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` + + // READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty" azure:"ro"` + + // READ-ONLY; The private link resource required member names. + RequiredMembers []*string `json:"requiredMembers,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// PrivateLinkResourcesGetOptions contains the optional parameters for the PrivateLinkResources.Get method. +type PrivateLinkResourcesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesListOptions contains the optional parameters for the PrivateLinkResources.List method. +type PrivateLinkResourcesListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer and provider. +type PrivateLinkServiceConnectionState struct { + // A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` + + // The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + + // Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} + +// ProcessorNodeBaseClassification provides polymorphic access to related types. +// Call the interface's GetProcessorNodeBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EncoderProcessor, *ProcessorNodeBase +type ProcessorNodeBaseClassification interface { + NodeBaseClassification + // GetProcessorNodeBase returns the ProcessorNodeBase content of the underlying type. + GetProcessorNodeBase() *ProcessorNodeBase +} + +// ProcessorNodeBase - Base class for topology processor nodes. +type ProcessorNodeBase struct { + NodeBase + // REQUIRED; An array of upstream node references within the topology to be used as inputs for this node. + Inputs []*NodeInput `json:"inputs,omitempty"` +} + +// GetProcessorNodeBase implements the ProcessorNodeBaseClassification interface for type ProcessorNodeBase. +func (p *ProcessorNodeBase) GetProcessorNodeBase() *ProcessorNodeBase { return p } + +// MarshalJSON implements the json.Marshaller interface for type ProcessorNodeBase. +func (p ProcessorNodeBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.ProcessorNodeBase") + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProcessorNodeBase. +func (p *ProcessorNodeBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return p.unmarshalInternal(rawMsg) +} + +func (p ProcessorNodeBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + p.NodeBase.marshalInternal(objectMap, discValue) + populate(objectMap, "inputs", p.Inputs) +} + +func (p *ProcessorNodeBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "inputs": + err = unpopulate(val, &p.Inputs) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := p.NodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// Properties - Metric properties. +type Properties struct { + // READ-ONLY; The service specifications. + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty" azure:"ro"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal(objectMap map[string]interface{}) { + p.Resource.marshalInternal(objectMap) +} + +// 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// 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, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) +} + +// ResourceIdentity - The user assigned managed identity to use when accessing a resource. +type ResourceIdentity struct { + // REQUIRED; The user assigned managed identity's resource identifier to use when accessing a resource. + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} + +// RsaTokenKey - Required validation properties for tokens generated with RSA algorithm. +type RsaTokenKey struct { + TokenKey + // REQUIRED; RSA algorithm to be used: RS256, RS384 or RS512. + Alg *AccessPolicyRsaAlgo `json:"alg,omitempty"` + + // REQUIRED; RSA public key exponent. + E *string `json:"e,omitempty"` + + // REQUIRED; RSA public key modulus. + N *string `json:"n,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RsaTokenKey. +func (r RsaTokenKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.TokenKey.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.RsaTokenKey") + populate(objectMap, "alg", r.Alg) + populate(objectMap, "e", r.E) + populate(objectMap, "n", r.N) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RsaTokenKey. +func (r *RsaTokenKey) 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 "alg": + err = unpopulate(val, &r.Alg) + delete(rawMsg, key) + case "e": + err = unpopulate(val, &r.E) + delete(rawMsg, key) + case "n": + err = unpopulate(val, &r.N) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := r.TokenKey.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// RtspSource - RTSP source allows for media from an RTSP camera or generic RTSP server to be ingested into a pipeline. +type RtspSource struct { + SourceNodeBase + // REQUIRED; RTSP endpoint information for Video Analyzer to connect to. This contains the required information for Video Analyzer to connect to RTSP cameras + // and/or generic RTSP servers. + Endpoint EndpointBaseClassification `json:"endpoint,omitempty"` + + // Network transport utilized by the RTSP and RTP exchange: TCP or HTTP. When using TCP, the RTP packets are interleaved on the TCP RTSP connection. When + // using HTTP, the RTSP messages are exchanged + // through long lived HTTP connections, and the RTP packages are interleaved in the HTTP connections alongside the RTSP messages. + Transport *RtspTransport `json:"transport,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RtspSource. +func (r RtspSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.SourceNodeBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.RtspSource") + populate(objectMap, "endpoint", r.Endpoint) + populate(objectMap, "transport", r.Transport) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RtspSource. +func (r *RtspSource) 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 "endpoint": + r.Endpoint, err = unmarshalEndpointBaseClassification(val) + delete(rawMsg, key) + case "transport": + err = unpopulate(val, &r.Transport) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := r.SourceNodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// SKU - The SKU details. +type SKU struct { + // REQUIRED; The SKU name. + Name *SKUName `json:"name,omitempty"` + + // READ-ONLY; The SKU tier. + Tier *SKUTier `json:"tier,omitempty" azure:"ro"` +} + +// SecureIotDeviceRemoteTunnel - A remote tunnel securely established using IoT Hub device information. +type SecureIotDeviceRemoteTunnel struct { + TunnelBase + // REQUIRED; The IoT device id to use when establishing the remote tunnel. This string is case-sensitive. + DeviceID *string `json:"deviceId,omitempty"` + + // REQUIRED; Name of the IoT Hub. + IotHubName *string `json:"iotHubName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SecureIotDeviceRemoteTunnel. +func (s SecureIotDeviceRemoteTunnel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.TunnelBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.SecureIotDeviceRemoteTunnel") + populate(objectMap, "deviceId", s.DeviceID) + populate(objectMap, "iotHubName", s.IotHubName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecureIotDeviceRemoteTunnel. +func (s *SecureIotDeviceRemoteTunnel) 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 "deviceId": + err = unpopulate(val, &s.DeviceID) + delete(rawMsg, key) + case "iotHubName": + err = unpopulate(val, &s.IotHubName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.TunnelBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ServiceSpecification - The service metric specifications. +type ServiceSpecification struct { + // READ-ONLY; List of log specifications. + LogSpecifications []*LogSpecification `json:"logSpecifications,omitempty" azure:"ro"` + + // READ-ONLY; List of metric specifications. + MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "logSpecifications", s.LogSpecifications) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +// SinkNodeBaseClassification provides polymorphic access to related types. +// Call the interface's GetSinkNodeBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *SinkNodeBase, *VideoSink +type SinkNodeBaseClassification interface { + NodeBaseClassification + // GetSinkNodeBase returns the SinkNodeBase content of the underlying type. + GetSinkNodeBase() *SinkNodeBase +} + +// SinkNodeBase - Base class for topology sink nodes. +type SinkNodeBase struct { + NodeBase + // REQUIRED; An array of upstream node references within the topology to be used as inputs for this node. + Inputs []*NodeInput `json:"inputs,omitempty"` +} + +// GetSinkNodeBase implements the SinkNodeBaseClassification interface for type SinkNodeBase. +func (s *SinkNodeBase) GetSinkNodeBase() *SinkNodeBase { return s } + +// MarshalJSON implements the json.Marshaller interface for type SinkNodeBase. +func (s SinkNodeBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.SinkNodeBase") + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SinkNodeBase. +func (s *SinkNodeBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return s.unmarshalInternal(rawMsg) +} + +func (s SinkNodeBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + s.NodeBase.marshalInternal(objectMap, discValue) + populate(objectMap, "inputs", s.Inputs) +} + +func (s *SinkNodeBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "inputs": + err = unpopulate(val, &s.Inputs) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.NodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// SourceNodeBaseClassification provides polymorphic access to related types. +// Call the interface's GetSourceNodeBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *RtspSource, *SourceNodeBase, *VideoSource +type SourceNodeBaseClassification interface { + NodeBaseClassification + // GetSourceNodeBase returns the SourceNodeBase content of the underlying type. + GetSourceNodeBase() *SourceNodeBase +} + +// SourceNodeBase - Base class for topology source nodes. +type SourceNodeBase struct { + NodeBase +} + +// GetSourceNodeBase implements the SourceNodeBaseClassification interface for type SourceNodeBase. +func (s *SourceNodeBase) GetSourceNodeBase() *SourceNodeBase { return s } + +// MarshalJSON implements the json.Marshaller interface for type SourceNodeBase. +func (s SourceNodeBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.SourceNodeBase") + return json.Marshal(objectMap) +} + +func (s SourceNodeBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + s.NodeBase.marshalInternal(objectMap, discValue) +} + +func (s *SourceNodeBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + if err := s.NodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// StorageAccount - The details about the associated storage account. +type StorageAccount struct { + // REQUIRED; The ID of the storage account resource. Video Analyzer relies on tables, queues, and blobs. The primary storage account must be a Standard + // Storage account (either Microsoft.ClassicStorage or + // Microsoft.Storage). + ID *string `json:"id,omitempty"` + + // A managed identity that Video Analyzer will use to access the storage account. + Identity *ResourceIdentity `json:"identity,omitempty"` + + // READ-ONLY; The current status of the storage account mapping. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// 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 +} + +// TLSEndpoint - TLS endpoint describes an endpoint that the pipeline can connect to over TLS transport (data is encrypted in transit). +type TLSEndpoint struct { + EndpointBase + // List of trusted certificate authorities when authenticating a TLS connection. A null list designates that Azure Video Analyzer's list of trusted authorities + // should be used. + TrustedCertificates CertificateSourceClassification `json:"trustedCertificates,omitempty"` + + // Validation options to use when authenticating a TLS connection. By default, strict validation is used. + ValidationOptions *TLSValidationOptions `json:"validationOptions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TLSEndpoint. +func (t TLSEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.EndpointBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.TlsEndpoint") + populate(objectMap, "trustedCertificates", t.TrustedCertificates) + populate(objectMap, "validationOptions", t.ValidationOptions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TLSEndpoint. +func (t *TLSEndpoint) 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 "trustedCertificates": + t.TrustedCertificates, err = unmarshalCertificateSourceClassification(val) + delete(rawMsg, key) + case "validationOptions": + err = unpopulate(val, &t.ValidationOptions) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := t.EndpointBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// TLSValidationOptions - Options for controlling the validation of TLS endpoints. +type TLSValidationOptions struct { + // When set to 'true' causes the certificate subject name validation to be skipped. Default is 'false'. + IgnoreHostname *string `json:"ignoreHostname,omitempty"` + + // When set to 'true' causes the certificate chain trust validation to be skipped. Default is 'false'. + IgnoreSignature *string `json:"ignoreSignature,omitempty"` +} + +// TimeSequenceBaseClassification provides polymorphic access to related types. +// Call the interface's GetTimeSequenceBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *TimeSequenceBase, *VideoSequenceAbsoluteTimeMarkers +type TimeSequenceBaseClassification interface { + // GetTimeSequenceBase returns the TimeSequenceBase content of the underlying type. + GetTimeSequenceBase() *TimeSequenceBase +} + +// TimeSequenceBase - A sequence of datetime ranges as a string. +type TimeSequenceBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetTimeSequenceBase implements the TimeSequenceBaseClassification interface for type TimeSequenceBase. +func (t *TimeSequenceBase) GetTimeSequenceBase() *TimeSequenceBase { return t } + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimeSequenceBase. +func (t *TimeSequenceBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return t.unmarshalInternal(rawMsg) +} + +func (t TimeSequenceBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + t.Type = &discValue + objectMap["@type"] = t.Type +} + +func (t *TimeSequenceBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "@type": + err = unpopulate(val, &t.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TokenClaim - Properties for expected token claims. +type TokenClaim struct { + // REQUIRED; Name of the claim which must be present on the token. + Name *string `json:"name,omitempty"` + + // REQUIRED; Expected value of the claim to be present on the token. + Value *string `json:"value,omitempty"` +} + +// TokenKeyClassification provides polymorphic access to related types. +// Call the interface's GetTokenKey() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EccTokenKey, *RsaTokenKey, *TokenKey +type TokenKeyClassification interface { + // GetTokenKey returns the TokenKey content of the underlying type. + GetTokenKey() *TokenKey +} + +// TokenKey - Key properties for JWT token validation. +type TokenKey struct { + // REQUIRED; JWT token key id. Validation keys are looked up based on the key id present on the JWT token header. + Kid *string `json:"kid,omitempty"` + + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetTokenKey implements the TokenKeyClassification interface for type TokenKey. +func (t *TokenKey) GetTokenKey() *TokenKey { return t } + +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenKey. +func (t *TokenKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return t.unmarshalInternal(rawMsg) +} + +func (t TokenKey) marshalInternal(objectMap map[string]interface{}, discValue string) { + populate(objectMap, "kid", t.Kid) + t.Type = &discValue + objectMap["@type"] = t.Type +} + +func (t *TokenKey) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "kid": + err = unpopulate(val, &t.Kid) + delete(rawMsg, key) + case "@type": + err = unpopulate(val, &t.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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) +} + +// TunnelBaseClassification provides polymorphic access to related types. +// Call the interface's GetTunnelBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *SecureIotDeviceRemoteTunnel, *TunnelBase +type TunnelBaseClassification interface { + // GetTunnelBase returns the TunnelBase content of the underlying type. + GetTunnelBase() *TunnelBase +} + +// TunnelBase - Base class for tunnel objects. +type TunnelBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` +} + +// GetTunnelBase implements the TunnelBaseClassification interface for type TunnelBase. +func (t *TunnelBase) GetTunnelBase() *TunnelBase { return t } + +// UnmarshalJSON implements the json.Unmarshaller interface for type TunnelBase. +func (t *TunnelBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return t.unmarshalInternal(rawMsg) +} + +func (t TunnelBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + t.Type = &discValue + objectMap["@type"] = t.Type +} + +func (t *TunnelBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "@type": + err = unpopulate(val, &t.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// UnsecuredEndpoint - Unsecured endpoint describes an endpoint that the pipeline can connect to over clear transport (no encryption in transit). +type UnsecuredEndpoint struct { + EndpointBase +} + +// MarshalJSON implements the json.Marshaller interface for type UnsecuredEndpoint. +func (u UnsecuredEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.EndpointBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.UnsecuredEndpoint") + return json.Marshal(objectMap) +} + +// UserAssignedManagedIdentity - The details of the user assigned managed identity used by the Video Analyzer resource. +type UserAssignedManagedIdentity struct { + // READ-ONLY; The client ID. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal ID. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// UsernamePasswordCredentials - Username and password credentials. +type UsernamePasswordCredentials struct { + CredentialsBase + // REQUIRED; Password to be presented as part of the credentials. It is recommended that this value is parameterized as a secret string in order to prevent + // this value to be returned as part of the resource on API + // requests. + Password *string `json:"password,omitempty"` + + // REQUIRED; Username to be presented as part of the credentials. + Username *string `json:"username,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UsernamePasswordCredentials. +func (u UsernamePasswordCredentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + u.CredentialsBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.UsernamePasswordCredentials") + populate(objectMap, "password", u.Password) + populate(objectMap, "username", u.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsernamePasswordCredentials. +func (u *UsernamePasswordCredentials) 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 "password": + err = unpopulate(val, &u.Password) + delete(rawMsg, key) + case "username": + err = unpopulate(val, &u.Username) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := u.CredentialsBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VideoAnalyzer - The Video Analyzer account. +type VideoAnalyzer struct { + TrackedResource + // The identities associated to the Video Analyzer resource. + Identity *VideoAnalyzerIdentity `json:"identity,omitempty"` + + // The resource properties. + Properties *VideoAnalyzerProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoAnalyzer. +func (v VideoAnalyzer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", v.Identity) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// VideoAnalyzerCollection - A collection of VideoAnalyzer items. +type VideoAnalyzerCollection struct { + // A collection of VideoAnalyzer items. + Value []*VideoAnalyzer `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoAnalyzerCollection. +func (v VideoAnalyzerCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// VideoAnalyzerIdentity - The managed identity for the Video Analyzer resource. +type VideoAnalyzerIdentity struct { + // REQUIRED; The identity type. + Type *string `json:"type,omitempty"` + + // The User Assigned Managed Identities. + UserAssignedIdentities map[string]*UserAssignedManagedIdentity `json:"userAssignedIdentities,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoAnalyzerIdentity. +func (v VideoAnalyzerIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "type", v.Type) + populate(objectMap, "userAssignedIdentities", v.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// VideoAnalyzerOperationResultsGetOptions contains the optional parameters for the VideoAnalyzerOperationResults.Get method. +type VideoAnalyzerOperationResultsGetOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzerOperationStatus - Status of video analyzer operation. +type VideoAnalyzerOperationStatus struct { + // REQUIRED; Operation identifier. + Name *string `json:"name,omitempty"` + + // Operation end time. + EndTime *string `json:"endTime,omitempty"` + + // The error detail. + Error *ErrorDetail `json:"error,omitempty"` + + // Operation resource ID. + ID *string `json:"id,omitempty"` + + // Operation start time. + StartTime *string `json:"startTime,omitempty"` + + // Operation status. + Status *string `json:"status,omitempty"` +} + +// VideoAnalyzerOperationStatusesGetOptions contains the optional parameters for the VideoAnalyzerOperationStatuses.Get method. +type VideoAnalyzerOperationStatusesGetOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzerPrivateEndpointConnectionOperationStatus - Status of private endpoint connection operation. +type VideoAnalyzerPrivateEndpointConnectionOperationStatus struct { + // REQUIRED; Operation identifier. + Name *string `json:"name,omitempty"` + + // Operation end time. + EndTime *string `json:"endTime,omitempty"` + + // The error detail. + Error *ErrorDetail `json:"error,omitempty"` + + // Operation resource ID. + ID *string `json:"id,omitempty"` + + // Operation start time. + StartTime *string `json:"startTime,omitempty"` + + // Operation status. + Status *string `json:"status,omitempty"` +} + +// VideoAnalyzerProperties - The properties of the Video Analyzer account. +type VideoAnalyzerProperties struct { + // REQUIRED; The storage accounts for this resource. + StorageAccounts []*StorageAccount `json:"storageAccounts,omitempty"` + + // The account encryption properties. + Encryption *AccountEncryption `json:"encryption,omitempty"` + + // The IoT Hubs for this resource. + IotHubs []*IotHub `json:"iotHubs,omitempty"` + + // Network access control for Video Analyzer. + NetworkAccessControl *NetworkAccessControl `json:"networkAccessControl,omitempty"` + + // Whether or not public network access is allowed for resources under the Video Analyzer account. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // READ-ONLY; The endpoints associated with this resource. + Endpoints []*Endpoint `json:"endpoints,omitempty" azure:"ro"` + + // READ-ONLY; Private Endpoint Connections created under Video Analyzer account. + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the Video Analyzer account. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoAnalyzerProperties. +func (v VideoAnalyzerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "encryption", v.Encryption) + populate(objectMap, "endpoints", v.Endpoints) + populate(objectMap, "iotHubs", v.IotHubs) + populate(objectMap, "networkAccessControl", v.NetworkAccessControl) + populate(objectMap, "privateEndpointConnections", v.PrivateEndpointConnections) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "publicNetworkAccess", v.PublicNetworkAccess) + populate(objectMap, "storageAccounts", v.StorageAccounts) + return json.Marshal(objectMap) +} + +// VideoAnalyzerPropertiesUpdate - The properties of the Video Analyzer account. +type VideoAnalyzerPropertiesUpdate struct { + // The account encryption properties. + Encryption *AccountEncryption `json:"encryption,omitempty"` + + // The IoT Hubs for this resource. + IotHubs []*IotHub `json:"iotHubs,omitempty"` + + // Network access control for Video Analyzer. + NetworkAccessControl *NetworkAccessControl `json:"networkAccessControl,omitempty"` + + // Whether or not public network access is allowed for resources under the Video Analyzer account. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // The storage accounts for this resource. + StorageAccounts []*StorageAccount `json:"storageAccounts,omitempty"` + + // READ-ONLY; The endpoints associated with this resource. + Endpoints []*Endpoint `json:"endpoints,omitempty" azure:"ro"` + + // READ-ONLY; Private Endpoint Connections created under Video Analyzer account. + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the Video Analyzer account. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoAnalyzerPropertiesUpdate. +func (v VideoAnalyzerPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "encryption", v.Encryption) + populate(objectMap, "endpoints", v.Endpoints) + populate(objectMap, "iotHubs", v.IotHubs) + populate(objectMap, "networkAccessControl", v.NetworkAccessControl) + populate(objectMap, "privateEndpointConnections", v.PrivateEndpointConnections) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "publicNetworkAccess", v.PublicNetworkAccess) + populate(objectMap, "storageAccounts", v.StorageAccounts) + return json.Marshal(objectMap) +} + +// VideoAnalyzerUpdate - The update operation for a Video Analyzer account. +type VideoAnalyzerUpdate struct { + // The identities associated to the Video Analyzer resource. + Identity *VideoAnalyzerIdentity `json:"identity,omitempty"` + + // The resource properties. + Properties *VideoAnalyzerPropertiesUpdate `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoAnalyzerUpdate. +func (v VideoAnalyzerUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", v.Identity) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// VideoAnalyzersBeginCreateOrUpdateOptions contains the optional parameters for the VideoAnalyzers.BeginCreateOrUpdate method. +type VideoAnalyzersBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzersBeginUpdateOptions contains the optional parameters for the VideoAnalyzers.BeginUpdate method. +type VideoAnalyzersBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzersDeleteOptions contains the optional parameters for the VideoAnalyzers.Delete method. +type VideoAnalyzersDeleteOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzersGetOptions contains the optional parameters for the VideoAnalyzers.Get method. +type VideoAnalyzersGetOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzersListBySubscriptionOptions contains the optional parameters for the VideoAnalyzers.ListBySubscription method. +type VideoAnalyzersListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VideoAnalyzersListOptions contains the optional parameters for the VideoAnalyzers.List method. +type VideoAnalyzersListOptions struct { + // placeholder for future optional parameters +} + +// VideoArchival - Video archival properties. +type VideoArchival struct { + // Video retention period indicates the maximum age of the video archive segments which are intended to be kept in storage. It must be provided in the ISO8601 + // duration format in the granularity of days, + // up to a maximum of 10 years. For example, if this is set to P30D (30 days), content older than 30 days will be periodically deleted. This value can be + // updated at any time and the new desired retention + // period will be effective within 24 hours. + RetentionPeriod *string `json:"retentionPeriod,omitempty"` +} + +// VideoContentToken - "Video content token grants access to the video content URLs." +type VideoContentToken struct { + // READ-ONLY; The content token expiration date in ISO8601 format (eg. 2021-01-01T00:00:00Z). + ExpirationDate *time.Time `json:"expirationDate,omitempty" azure:"ro"` + + // READ-ONLY; The content token value to be added to the video content URL as the value for the "token" query string parameter. The token is specific to + // a single video. + Token *string `json:"token,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoContentToken. +func (v VideoContentToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "expirationDate", v.ExpirationDate) + populate(objectMap, "token", v.Token) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VideoContentToken. +func (v *VideoContentToken) 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 "expirationDate": + err = unpopulateTimeRFC3339(val, &v.ExpirationDate) + delete(rawMsg, key) + case "token": + err = unpopulate(val, &v.Token) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// VideoContentUrls - Set of URLs to the video content. +type VideoContentUrls struct { + // Video archive streaming base URL. The archived content can be automatically played by the Azure Video Analyzer player widget. Alternatively, this URL + // can be used in conjunction with the video content + // authorization token on any compatible DASH or HLS players by appending the following to the base URL: + // - HLSv4: /manifest(format=m3u8-aapl).m3u8 + // - HLS CMAF: /manifest(format=m3u8-cmaf) + // - DASH CMAF: /manifest(format=mpd-time-cmaf) + // Moreover, an ongoing video recording can be played in "live mode" with latencies which are approximately double of the chosen video segment length. It + // is available when the video type is 'archive' and video archiving is enabled. + ArchiveBaseURL *string `json:"archiveBaseUrl,omitempty"` + + // Video file download URL. This URL can be used in conjunction with the video content authorization token to download the video MP4 file. The resulting + // MP4 file can be played on any standard media + // player. It is available when the video type is 'file' and video file is available for consumption. + DownloadURL *string `json:"downloadUrl,omitempty"` + + // Video preview image URLs. These URLs can be used in conjunction with the video content authorization token to download the most recent still image from + // the video archive in different resolutions. They + // are available when the video type is 'archive' and preview images are enabled. + PreviewImageUrls *VideoPreviewImageUrls `json:"previewImageUrls,omitempty"` + + // Video low-latency streaming URL. The live content can be automatically played by the Azure Video Analyzer player widget. Alternatively, this URL can + // be used in conjunction with the video content + // authorization token to expose a WebSocket tunneled RTSP stream. It is available when the video type is 'archive' and a live, low-latency feed is available + // from the source. + RtspTunnelURL *string `json:"rtspTunnelUrl,omitempty"` +} + +// VideoCreationProperties - Optional properties to be used in case a new video resource needs to be created on the service. These will not take effect +// if the video already exists. +type VideoCreationProperties struct { + // Optional description provided by the user. Value can be up to 2048 characters long. + Description *string `json:"description,omitempty"` + + // Video retention period indicates how long the video is kept in storage. Value must be specified in ISO8601 duration format (i.e. "P1D" equals 1 day) + // and can vary between 1 day to 10 years, in 1 day + // increments. When absent (null), all video content is retained indefinitely. This property is only allowed for topologies where "kind" is set to "live". + RetentionPeriod *string `json:"retentionPeriod,omitempty"` + + // Segment length indicates the length of individual content files (segments) which are persisted to storage. Smaller segments provide lower archive playback + // latency but generate larger volume of storage + // transactions. Larger segments reduce the amount of storage transactions while increasing the archive playback latency. Value must be specified in ISO8601 + // duration format (i.e. "PT30S" equals 30 + // seconds) and can vary between 30 seconds to 5 minutes, in 30 seconds increments. Changing this value after the initial call to create the video resource + // can lead to errors when uploading content to + // the archive. Default value is 30 seconds. This property is only allowed for topologies where "kind" is set to "live". + SegmentLength *string `json:"segmentLength,omitempty"` + + // Optional title provided by the user. Value can be up to 256 characters long. + Title *string `json:"title,omitempty"` +} + +// VideoEncoderBaseClassification provides polymorphic access to related types. +// Call the interface's GetVideoEncoderBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *VideoEncoderBase, *VideoEncoderH264 +type VideoEncoderBaseClassification interface { + // GetVideoEncoderBase returns the VideoEncoderBase content of the underlying type. + GetVideoEncoderBase() *VideoEncoderBase +} + +// VideoEncoderBase - Base type for all video encoding presets, which define the recipe or instructions on how the input video should be processed. +type VideoEncoderBase struct { + // REQUIRED; The discriminator for derived types. + Type *string `json:"@type,omitempty"` + + // The maximum bitrate, in kilobits per second or Kbps, at which video should be encoded. If omitted, encoder sets it automatically to try and match the + // quality of the input video. + BitrateKbps *string `json:"bitrateKbps,omitempty"` + + // The frame rate (in frames per second) of the encoded video. The value must be greater than zero, and less than or equal to 300. If omitted, the encoder + // uses the average frame rate of the input video. + FrameRate *string `json:"frameRate,omitempty"` + + // Describes the resolution of the encoded video. If omitted, the encoder uses the resolution of the input video. + Scale *VideoScale `json:"scale,omitempty"` +} + +// GetVideoEncoderBase implements the VideoEncoderBaseClassification interface for type VideoEncoderBase. +func (v *VideoEncoderBase) GetVideoEncoderBase() *VideoEncoderBase { return v } + +// UnmarshalJSON implements the json.Unmarshaller interface for type VideoEncoderBase. +func (v *VideoEncoderBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return v.unmarshalInternal(rawMsg) +} + +func (v VideoEncoderBase) marshalInternal(objectMap map[string]interface{}, discValue string) { + populate(objectMap, "bitrateKbps", v.BitrateKbps) + populate(objectMap, "frameRate", v.FrameRate) + populate(objectMap, "scale", v.Scale) + v.Type = &discValue + objectMap["@type"] = v.Type +} + +func (v *VideoEncoderBase) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "bitrateKbps": + err = unpopulate(val, &v.BitrateKbps) + delete(rawMsg, key) + case "frameRate": + err = unpopulate(val, &v.FrameRate) + delete(rawMsg, key) + case "scale": + err = unpopulate(val, &v.Scale) + delete(rawMsg, key) + case "@type": + err = unpopulate(val, &v.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// VideoEncoderH264 - A custom preset for encoding video with the H.264 (AVC) codec. +type VideoEncoderH264 struct { + VideoEncoderBase +} + +// MarshalJSON implements the json.Marshaller interface for type VideoEncoderH264. +func (v VideoEncoderH264) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.VideoEncoderBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.VideoEncoderH264") + return json.Marshal(objectMap) +} + +// VideoEntity - Represents a video resource within Azure Video Analyzer. Videos can be ingested from RTSP cameras through live pipelines or can be created +// by exporting sequences from existing captured video through a +// pipeline job. Videos ingested through live pipelines can be streamed through Azure Video Analyzer Player Widget or compatible players. Exported videos +// can be downloaded as MP4 files. +type VideoEntity struct { + ProxyResource + // The resource properties. + Properties *VideoProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoEntity. +func (v VideoEntity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// VideoEntityCollection - A collection of VideoEntity items. +type VideoEntityCollection struct { + // A link to the next page of the collection (when the collection contains too many results to return in one response). + NextLink *string `json:"@nextLink,omitempty"` + + // A collection of VideoEntity items. + Value []*VideoEntity `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoEntityCollection. +func (v VideoEntityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "@nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// VideoFlags - Video flags contain information about the available video actions and its dynamic properties based on the current video state. +type VideoFlags struct { + // REQUIRED; Value indicating whether or not the video can be streamed. Only "archive" type videos can be streamed. + CanStream *bool `json:"canStream,omitempty"` + + // REQUIRED; Value indicating whether or not there has ever been data recorded or uploaded into the video. Newly created videos have this value set to false. + HasData *bool `json:"hasData,omitempty"` + + // REQUIRED; Value indicating whether or not the video is currently being referenced be an active pipeline. The fact that is being referenced, doesn't necessarily + // indicate that data is being received. For example, + // video recording may be gated on events or camera may not be accessible at the time. + IsInUse *bool `json:"isInUse,omitempty"` +} + +// VideoMediaInfo - Contains information about the video and audio content. +type VideoMediaInfo struct { + // Video segment length indicates the length of individual video files (segments) which are persisted to storage. Smaller segments provide lower archive + // playback latency but generate larger volume of + // storage transactions. Larger segments reduce the amount of storage transactions while increasing the archive playback latency. Value must be specified + // in ISO8601 duration format (i.e. "PT30S" equals + // 30 seconds) and can vary between 30 seconds to 5 minutes, in 30 seconds increments. + SegmentLength *string `json:"segmentLength,omitempty"` +} + +// VideoPreviewImageUrls - Video preview image URLs. These URLs can be used in conjunction with the video content authorization token to download the most +// recent still image from the video archive in different resolutions. They +// are available when the video type is 'archive' and preview images are enabled. +type VideoPreviewImageUrls struct { + // High resolution preview image URL. + Large *string `json:"large,omitempty"` + + // Medium resolution preview image URL. + Medium *string `json:"medium,omitempty"` + + // Low resolution preview image URL. + Small *string `json:"small,omitempty"` +} + +// VideoProperties - Application level properties for the video resource. +type VideoProperties struct { + // Video archival properties. + Archival *VideoArchival `json:"archival,omitempty"` + + // Optional video description provided by the user. Value can be up to 2048 characters long. + Description *string `json:"description,omitempty"` + + // Contains information about the video and audio content. + MediaInfo *VideoMediaInfo `json:"mediaInfo,omitempty"` + + // Optional video title provided by the user. Value can be up to 256 characters long. + Title *string `json:"title,omitempty"` + + // READ-ONLY; Set of URLs to the video content. + ContentUrls *VideoContentUrls `json:"contentUrls,omitempty" azure:"ro"` + + // READ-ONLY; Video flags contain information about the available video actions and its dynamic properties based on the current video state. + Flags *VideoFlags `json:"flags,omitempty" azure:"ro"` + + // READ-ONLY; Video content type. Different content types are suitable for different applications and scenarios. + Type *VideoType `json:"type,omitempty" azure:"ro"` +} + +// VideoPublishingOptions - Optional flags used to change how video is published. These are only allowed for topologies where "kind" is set to "live". +type VideoPublishingOptions struct { + // When set to 'true' content will not be archived or recorded. This is used, for example, when the topology is used only for low latency video streaming. + // Default is 'false'. If set to 'true', then + // "disableRtspPublishing" must be set to 'false'. + DisableArchive *string `json:"disableArchive,omitempty"` + + // When set to 'true' the RTSP playback URL will not be published, disabling low latency streaming. This is used, for example, when the topology is used + // only for archiving content. Default is 'false'. If + // set to 'true', then "disableArchive" must be set to 'false'. + DisableRtspPublishing *string `json:"disableRtspPublishing,omitempty"` +} + +// VideoScale - The video scaling information. +type VideoScale struct { + // The desired output video height. + Height *string `json:"height,omitempty"` + + // Describes the video scaling mode to be applied. Default mode is 'Pad'. If the mode is 'Pad' or 'Stretch' then both width and height must be specified. + // Else if the mode is 'PreserveAspectRatio' then + // only one of width or height need be provided. + Mode *VideoScaleMode `json:"mode,omitempty"` + + // The desired output video width. + Width *string `json:"width,omitempty"` +} + +// VideoSequenceAbsoluteTimeMarkers - A sequence of absolute datetime ranges as a string. The datetime values should follow IS08601, and the sum of the +// ranges should add up to 24 hours or less. Currently, there can be only one range +// specified in the sequence. +type VideoSequenceAbsoluteTimeMarkers struct { + TimeSequenceBase + // REQUIRED; The sequence of datetime ranges. Example: '[["2021-10-05T03:30:00Z", "2021-10-05T03:40:00Z"]]'. + Ranges *string `json:"ranges,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoSequenceAbsoluteTimeMarkers. +func (v VideoSequenceAbsoluteTimeMarkers) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.TimeSequenceBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.VideoSequenceAbsoluteTimeMarkers") + populate(objectMap, "ranges", v.Ranges) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VideoSequenceAbsoluteTimeMarkers. +func (v *VideoSequenceAbsoluteTimeMarkers) 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 "ranges": + err = unpopulate(val, &v.Ranges) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := v.TimeSequenceBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VideoSink - Video sink in a live topology allows for video and audio to be captured, optionally archived, and published via a video resource. If archiving +// is enabled, this results in a video of type 'archive'. If +// used in a batch topology, this allows for video and audio to be stored as a file, and published via a video resource of type 'file' +type VideoSink struct { + SinkNodeBase + // REQUIRED; Name of a new or existing video resource used to capture and publish content. Note: if downstream of RTSP source, and if disableArchive is + // set to true, then no content is archived. + VideoName *string `json:"videoName,omitempty"` + + // Optional video properties to be used in case a new video resource needs to be created on the service. + VideoCreationProperties *VideoCreationProperties `json:"videoCreationProperties,omitempty"` + + // Options to change how the video sink publishes content via the video resource. This property is only allowed for topologies where "kind" is set to "live". + VideoPublishingOptions *VideoPublishingOptions `json:"videoPublishingOptions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoSink. +func (v VideoSink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.SinkNodeBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.VideoSink") + populate(objectMap, "videoCreationProperties", v.VideoCreationProperties) + populate(objectMap, "videoName", v.VideoName) + populate(objectMap, "videoPublishingOptions", v.VideoPublishingOptions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VideoSink. +func (v *VideoSink) 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 "videoCreationProperties": + err = unpopulate(val, &v.VideoCreationProperties) + delete(rawMsg, key) + case "videoName": + err = unpopulate(val, &v.VideoName) + delete(rawMsg, key) + case "videoPublishingOptions": + err = unpopulate(val, &v.VideoPublishingOptions) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := v.SinkNodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VideoSource - Video source allows for content from a Video Analyzer video resource to be ingested into a pipeline. Currently supported only with batch +// pipelines. +type VideoSource struct { + SourceNodeBase + // REQUIRED; Describes a sequence of datetime ranges. The video source only picks up recorded media within these ranges. + TimeSequences TimeSequenceBaseClassification `json:"timeSequences,omitempty"` + + // REQUIRED; Name of the Video Analyzer video resource to be used as the source. + VideoName *string `json:"videoName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type VideoSource. +func (v VideoSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + v.SourceNodeBase.marshalInternal(objectMap, "#Microsoft.VideoAnalyzer.VideoSource") + populate(objectMap, "timeSequences", v.TimeSequences) + populate(objectMap, "videoName", v.VideoName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VideoSource. +func (v *VideoSource) 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 "timeSequences": + v.TimeSequences, err = unmarshalTimeSequenceBaseClassification(val) + delete(rawMsg, key) + case "videoName": + err = unpopulate(val, &v.VideoName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := v.SourceNodeBase.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// VideosCreateOrUpdateOptions contains the optional parameters for the Videos.CreateOrUpdate method. +type VideosCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// VideosDeleteOptions contains the optional parameters for the Videos.Delete method. +type VideosDeleteOptions struct { + // placeholder for future optional parameters +} + +// VideosGetOptions contains the optional parameters for the Videos.Get method. +type VideosGetOptions struct { + // placeholder for future optional parameters +} + +// VideosListContentTokenOptions contains the optional parameters for the Videos.ListContentToken method. +type VideosListContentTokenOptions struct { + // placeholder for future optional parameters +} + +// VideosListOptions contains the optional parameters for the Videos.List method. +type VideosListOptions struct { + // Specifies a non-negative integer n that limits the number of items returned from a collection. The service returns the number of available items up to + // but not greater than the specified value n. + Top *int32 +} + +// VideosUpdateOptions contains the optional parameters for the Videos.Update method. +type VideosUpdateOptions 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/videoanalyzer/armvideoanalyzer/zz_generated_operationresults_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operationresults_client.go new file mode 100644 index 000000000000..b4c992f920f0 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operationresults_client.go @@ -0,0 +1,116 @@ +//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 armvideoanalyzer + +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" +) + +// OperationResultsClient contains the methods for the OperationResults group. +// Don't use this type directly, use NewOperationResultsClient() instead. +type OperationResultsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewOperationResultsClient creates a new instance of OperationResultsClient with the specified values. +func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *OperationResultsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationResultsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get private endpoint connection operation result. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationResultsClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string, operationID string, options *OperationResultsGetOptions) (OperationResultsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, name, operationID, options) + if err != nil { + return OperationResultsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationResultsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return OperationResultsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OperationResultsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, name string, operationID string, options *OperationResultsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateEndpointConnections/{name}/operationResults/{operationId}" + 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)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationResultsClient) getHandleResponse(resp *http.Response) (OperationResultsGetResponse, error) { + result := OperationResultsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil { + return OperationResultsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OperationResultsClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operations_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operations_client.go new file mode 100644 index 000000000000..eee1e34ded93 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operations_client.go @@ -0,0 +1,92 @@ +//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 armvideoanalyzer + +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 the Media operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Media/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-01-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.OperationCollection); 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/videoanalyzer/armvideoanalyzer/zz_generated_operationstatuses_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operationstatuses_client.go new file mode 100644 index 000000000000..d99159955ac4 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_operationstatuses_client.go @@ -0,0 +1,116 @@ +//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 armvideoanalyzer + +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" +) + +// OperationStatusesClient contains the methods for the OperationStatuses group. +// Don't use this type directly, use NewOperationStatusesClient() instead. +type OperationStatusesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewOperationStatusesClient creates a new instance of OperationStatusesClient with the specified values. +func NewOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *OperationStatusesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationStatusesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get private endpoint connection operation status. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationStatusesClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string, operationID string, options *OperationStatusesGetOptions) (OperationStatusesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, name, operationID, options) + if err != nil { + return OperationStatusesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationStatusesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationStatusesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OperationStatusesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, name string, operationID string, options *OperationStatusesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateEndpointConnections/{name}/operationStatuses/{operationId}" + 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)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationStatusesClient) getHandleResponse(resp *http.Response) (OperationStatusesGetResponse, error) { + result := OperationStatusesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoAnalyzerPrivateEndpointConnectionOperationStatus); err != nil { + return OperationStatusesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OperationStatusesClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pagers.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pagers.go new file mode 100644 index 000000000000..bc842b09f552 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pagers.go @@ -0,0 +1,341 @@ +//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 armvideoanalyzer + +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" +) + +// AccessPoliciesListPager provides operations for iterating over paged responses. +type AccessPoliciesListPager struct { + client *AccessPoliciesClient + current AccessPoliciesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AccessPoliciesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AccessPoliciesListPager) 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 *AccessPoliciesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AccessPolicyEntityCollection.NextLink == nil || len(*p.current.AccessPolicyEntityCollection.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 AccessPoliciesListResponse page. +func (p *AccessPoliciesListPager) PageResponse() AccessPoliciesListResponse { + return p.current +} + +// EdgeModulesListPager provides operations for iterating over paged responses. +type EdgeModulesListPager struct { + client *EdgeModulesClient + current EdgeModulesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, EdgeModulesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *EdgeModulesListPager) 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 *EdgeModulesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EdgeModuleEntityCollection.NextLink == nil || len(*p.current.EdgeModuleEntityCollection.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 EdgeModulesListResponse page. +func (p *EdgeModulesListPager) PageResponse() EdgeModulesListResponse { + return p.current +} + +// LivePipelinesListPager provides operations for iterating over paged responses. +type LivePipelinesListPager struct { + client *LivePipelinesClient + current LivePipelinesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LivePipelinesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LivePipelinesListPager) 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 *LivePipelinesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.LivePipelineCollection.NextLink == nil || len(*p.current.LivePipelineCollection.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 LivePipelinesListResponse page. +func (p *LivePipelinesListPager) PageResponse() LivePipelinesListResponse { + return p.current +} + +// PipelineJobsListPager provides operations for iterating over paged responses. +type PipelineJobsListPager struct { + client *PipelineJobsClient + current PipelineJobsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PipelineJobsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PipelineJobsListPager) 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 *PipelineJobsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PipelineJobCollection.NextLink == nil || len(*p.current.PipelineJobCollection.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 PipelineJobsListResponse page. +func (p *PipelineJobsListPager) PageResponse() PipelineJobsListResponse { + return p.current +} + +// PipelineTopologiesListPager provides operations for iterating over paged responses. +type PipelineTopologiesListPager struct { + client *PipelineTopologiesClient + current PipelineTopologiesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, PipelineTopologiesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *PipelineTopologiesListPager) 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 *PipelineTopologiesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PipelineTopologyCollection.NextLink == nil || len(*p.current.PipelineTopologyCollection.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 PipelineTopologiesListResponse page. +func (p *PipelineTopologiesListPager) PageResponse() PipelineTopologiesListResponse { + return p.current +} + +// VideosListPager provides operations for iterating over paged responses. +type VideosListPager struct { + client *VideosClient + current VideosListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, VideosListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *VideosListPager) 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 *VideosListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.VideoEntityCollection.NextLink == nil || len(*p.current.VideoEntityCollection.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 VideosListResponse page. +func (p *VideosListPager) PageResponse() VideosListResponse { + return p.current +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinejoboperationstatuses_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinejoboperationstatuses_client.go new file mode 100644 index 000000000000..6e13120168cf --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinejoboperationstatuses_client.go @@ -0,0 +1,116 @@ +//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 armvideoanalyzer + +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" +) + +// PipelineJobOperationStatusesClient contains the methods for the PipelineJobOperationStatuses group. +// Don't use this type directly, use NewPipelineJobOperationStatusesClient() instead. +type PipelineJobOperationStatusesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPipelineJobOperationStatusesClient creates a new instance of PipelineJobOperationStatusesClient with the specified values. +func NewPipelineJobOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PipelineJobOperationStatusesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PipelineJobOperationStatusesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get the operation status of a pipeline job with the given operationId. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobOperationStatusesClient) Get(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, operationID string, options *PipelineJobOperationStatusesGetOptions) (PipelineJobOperationStatusesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, pipelineJobName, operationID, options) + if err != nil { + return PipelineJobOperationStatusesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineJobOperationStatusesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelineJobOperationStatusesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PipelineJobOperationStatusesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, operationID string, options *PipelineJobOperationStatusesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs/{pipelineJobName}/operationStatuses/{operationId}" + 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)) + if pipelineJobName == "" { + return nil, errors.New("parameter pipelineJobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineJobName}", url.PathEscape(pipelineJobName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PipelineJobOperationStatusesClient) getHandleResponse(resp *http.Response) (PipelineJobOperationStatusesGetResponse, error) { + result := PipelineJobOperationStatusesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineJobOperationStatus); err != nil { + return PipelineJobOperationStatusesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PipelineJobOperationStatusesClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinejobs_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinejobs_client.go new file mode 100644 index 000000000000..78dc923a5281 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinejobs_client.go @@ -0,0 +1,460 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// PipelineJobsClient contains the methods for the PipelineJobs group. +// Don't use this type directly, use NewPipelineJobsClient() instead. +type PipelineJobsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPipelineJobsClient creates a new instance of PipelineJobsClient with the specified values. +func NewPipelineJobsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PipelineJobsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PipelineJobsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCancel - Cancels a pipeline job with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) BeginCancel(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsBeginCancelOptions) (PipelineJobsCancelPollerResponse, error) { + resp, err := client.cancel(ctx, resourceGroupName, accountName, pipelineJobName, options) + if err != nil { + return PipelineJobsCancelPollerResponse{}, err + } + result := PipelineJobsCancelPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PipelineJobsClient.Cancel", "", resp, client.pl, client.cancelHandleError) + if err != nil { + return PipelineJobsCancelPollerResponse{}, err + } + result.Poller = &PipelineJobsCancelPoller{ + pt: pt, + } + return result, nil +} + +// Cancel - Cancels a pipeline job with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) cancel(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsBeginCancelOptions) (*http.Response, error) { + req, err := client.cancelCreateRequest(ctx, resourceGroupName, accountName, pipelineJobName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.cancelHandleError(resp) + } + return resp, nil +} + +// cancelCreateRequest creates the Cancel request. +func (client *PipelineJobsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsBeginCancelOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs/{pipelineJobName}/cancel" + 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)) + if pipelineJobName == "" { + return nil, errors.New("parameter pipelineJobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineJobName}", url.PathEscape(pipelineJobName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// cancelHandleError handles the Cancel error response. +func (client *PipelineJobsClient) cancelHandleError(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 a new pipeline job or updates an existing one, with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, parameters PipelineJob, options *PipelineJobsCreateOrUpdateOptions) (PipelineJobsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, pipelineJobName, parameters, options) + if err != nil { + return PipelineJobsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineJobsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PipelineJobsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PipelineJobsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, parameters PipelineJob, options *PipelineJobsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs/{pipelineJobName}" + 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)) + if pipelineJobName == "" { + return nil, errors.New("parameter pipelineJobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineJobName}", url.PathEscape(pipelineJobName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PipelineJobsClient) createOrUpdateHandleResponse(resp *http.Response) (PipelineJobsCreateOrUpdateResponse, error) { + result := PipelineJobsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineJob); err != nil { + return PipelineJobsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PipelineJobsClient) 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 - Deletes a pipeline job with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsDeleteOptions) (PipelineJobsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, pipelineJobName, options) + if err != nil { + return PipelineJobsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineJobsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PipelineJobsDeleteResponse{}, client.deleteHandleError(resp) + } + return PipelineJobsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PipelineJobsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs/{pipelineJobName}" + 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)) + if pipelineJobName == "" { + return nil, errors.New("parameter pipelineJobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineJobName}", url.PathEscape(pipelineJobName)) + 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-01-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 *PipelineJobsClient) 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 - Retrieves a specific pipeline job by name. If a pipeline job with that name has been previously created, the call will return the JSON representation +// of that instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) Get(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsGetOptions) (PipelineJobsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, pipelineJobName, options) + if err != nil { + return PipelineJobsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineJobsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelineJobsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PipelineJobsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, options *PipelineJobsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs/{pipelineJobName}" + 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)) + if pipelineJobName == "" { + return nil, errors.New("parameter pipelineJobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineJobName}", url.PathEscape(pipelineJobName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PipelineJobsClient) getHandleResponse(resp *http.Response) (PipelineJobsGetResponse, error) { + result := PipelineJobsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineJob); err != nil { + return PipelineJobsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PipelineJobsClient) 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 - Retrieves a list of all live pipelines that have been created, along with their JSON representations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) List(resourceGroupName string, accountName string, options *PipelineJobsListOptions) *PipelineJobsListPager { + return &PipelineJobsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp PipelineJobsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PipelineJobCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PipelineJobsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *PipelineJobsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs" + 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-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PipelineJobsClient) listHandleResponse(resp *http.Response) (PipelineJobsListResponse, error) { + result := PipelineJobsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineJobCollection); err != nil { + return PipelineJobsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PipelineJobsClient) 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) +} + +// Update - Updates an existing pipeline job with the given name. Properties that can be updated include: description. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineJobsClient) Update(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, parameters PipelineJobUpdate, options *PipelineJobsUpdateOptions) (PipelineJobsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, pipelineJobName, parameters, options) + if err != nil { + return PipelineJobsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineJobsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelineJobsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *PipelineJobsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineJobName string, parameters PipelineJobUpdate, options *PipelineJobsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineJobs/{pipelineJobName}" + 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)) + if pipelineJobName == "" { + return nil, errors.New("parameter pipelineJobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineJobName}", url.PathEscape(pipelineJobName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *PipelineJobsClient) updateHandleResponse(resp *http.Response) (PipelineJobsUpdateResponse, error) { + result := PipelineJobsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineJob); err != nil { + return PipelineJobsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *PipelineJobsClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_pipelinetopologies_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinetopologies_client.go new file mode 100644 index 000000000000..3b778417d68f --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pipelinetopologies_client.go @@ -0,0 +1,385 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// PipelineTopologiesClient contains the methods for the PipelineTopologies group. +// Don't use this type directly, use NewPipelineTopologiesClient() instead. +type PipelineTopologiesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPipelineTopologiesClient creates a new instance of PipelineTopologiesClient with the specified values. +func NewPipelineTopologiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PipelineTopologiesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PipelineTopologiesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new pipeline topology or updates an existing one, with the given name. A pipeline topology describes the processing steps +// to be applied when processing content for a particular outcome. The +// topology should be defined according to the scenario to be achieved and can be reused across many pipeline instances which share the same processing +// characteristics. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineTopologiesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, parameters PipelineTopology, options *PipelineTopologiesCreateOrUpdateOptions) (PipelineTopologiesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, pipelineTopologyName, parameters, options) + if err != nil { + return PipelineTopologiesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineTopologiesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return PipelineTopologiesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PipelineTopologiesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, parameters PipelineTopology, options *PipelineTopologiesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineTopologies/{pipelineTopologyName}" + 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)) + if pipelineTopologyName == "" { + return nil, errors.New("parameter pipelineTopologyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineTopologyName}", url.PathEscape(pipelineTopologyName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PipelineTopologiesClient) createOrUpdateHandleResponse(resp *http.Response) (PipelineTopologiesCreateOrUpdateResponse, error) { + result := PipelineTopologiesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineTopology); err != nil { + return PipelineTopologiesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PipelineTopologiesClient) 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 - Deletes a pipeline topology with the given name. This method should be called after all instances of the topology have been stopped and deleted. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineTopologiesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, options *PipelineTopologiesDeleteOptions) (PipelineTopologiesDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, pipelineTopologyName, options) + if err != nil { + return PipelineTopologiesDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineTopologiesDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PipelineTopologiesDeleteResponse{}, client.deleteHandleError(resp) + } + return PipelineTopologiesDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PipelineTopologiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, options *PipelineTopologiesDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineTopologies/{pipelineTopologyName}" + 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)) + if pipelineTopologyName == "" { + return nil, errors.New("parameter pipelineTopologyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineTopologyName}", url.PathEscape(pipelineTopologyName)) + 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-01-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 *PipelineTopologiesClient) 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 - Retrieves a specific pipeline topology by name. If a topology with that name has been previously created, the call will return the JSON representation +// of that topology. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineTopologiesClient) Get(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, options *PipelineTopologiesGetOptions) (PipelineTopologiesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, pipelineTopologyName, options) + if err != nil { + return PipelineTopologiesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineTopologiesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelineTopologiesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PipelineTopologiesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, options *PipelineTopologiesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineTopologies/{pipelineTopologyName}" + 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)) + if pipelineTopologyName == "" { + return nil, errors.New("parameter pipelineTopologyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineTopologyName}", url.PathEscape(pipelineTopologyName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PipelineTopologiesClient) getHandleResponse(resp *http.Response) (PipelineTopologiesGetResponse, error) { + result := PipelineTopologiesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineTopology); err != nil { + return PipelineTopologiesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PipelineTopologiesClient) 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 - Retrieves a list of pipeline topologies that have been added to the account, if any, along with their JSON representation. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineTopologiesClient) List(resourceGroupName string, accountName string, options *PipelineTopologiesListOptions) *PipelineTopologiesListPager { + return &PipelineTopologiesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp PipelineTopologiesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.PipelineTopologyCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *PipelineTopologiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *PipelineTopologiesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineTopologies" + 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-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PipelineTopologiesClient) listHandleResponse(resp *http.Response) (PipelineTopologiesListResponse, error) { + result := PipelineTopologiesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineTopologyCollection); err != nil { + return PipelineTopologiesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PipelineTopologiesClient) 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) +} + +// Update - Updates an existing pipeline topology with the given name. If the associated live pipelines or pipeline jobs are in active or processing state, +// respectively, then only the description can be updated. +// Else, the properties that can be updated include: description, parameter declarations, sources, processors, and sinks. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PipelineTopologiesClient) Update(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, parameters PipelineTopologyUpdate, options *PipelineTopologiesUpdateOptions) (PipelineTopologiesUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, pipelineTopologyName, parameters, options) + if err != nil { + return PipelineTopologiesUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PipelineTopologiesUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelineTopologiesUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *PipelineTopologiesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, pipelineTopologyName string, parameters PipelineTopologyUpdate, options *PipelineTopologiesUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/pipelineTopologies/{pipelineTopologyName}" + 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)) + if pipelineTopologyName == "" { + return nil, errors.New("parameter pipelineTopologyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineTopologyName}", url.PathEscape(pipelineTopologyName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *PipelineTopologiesClient) updateHandleResponse(resp *http.Response) (PipelineTopologiesUpdateResponse, error) { + result := PipelineTopologiesUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelineTopology); err != nil { + return PipelineTopologiesUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *PipelineTopologiesClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_pollers.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pollers.go new file mode 100644 index 000000000000..07adb8df4849 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_pollers.go @@ -0,0 +1,230 @@ +//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 armvideoanalyzer + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// LivePipelinesActivatePoller provides polling facilities until the operation reaches a terminal state. +type LivePipelinesActivatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LivePipelinesActivatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *LivePipelinesActivatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final LivePipelinesActivateResponse will be returned. +func (p *LivePipelinesActivatePoller) FinalResponse(ctx context.Context) (LivePipelinesActivateResponse, error) { + respType := LivePipelinesActivateResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LivePipelinesActivateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *LivePipelinesActivatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// LivePipelinesDeactivatePoller provides polling facilities until the operation reaches a terminal state. +type LivePipelinesDeactivatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *LivePipelinesDeactivatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *LivePipelinesDeactivatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final LivePipelinesDeactivateResponse will be returned. +func (p *LivePipelinesDeactivatePoller) FinalResponse(ctx context.Context) (LivePipelinesDeactivateResponse, error) { + respType := LivePipelinesDeactivateResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return LivePipelinesDeactivateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *LivePipelinesDeactivatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PipelineJobsCancelPoller provides polling facilities until the operation reaches a terminal state. +type PipelineJobsCancelPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PipelineJobsCancelPoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *PipelineJobsCancelPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final PipelineJobsCancelResponse will be returned. +func (p *PipelineJobsCancelPoller) FinalResponse(ctx context.Context) (PipelineJobsCancelResponse, error) { + respType := PipelineJobsCancelResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PipelineJobsCancelResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *PipelineJobsCancelPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VideoAnalyzersCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type VideoAnalyzersCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VideoAnalyzersCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *VideoAnalyzersCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final VideoAnalyzersCreateOrUpdateResponse will be returned. +func (p *VideoAnalyzersCreateOrUpdatePoller) FinalResponse(ctx context.Context) (VideoAnalyzersCreateOrUpdateResponse, error) { + respType := VideoAnalyzersCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.VideoAnalyzer) + if err != nil { + return VideoAnalyzersCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *VideoAnalyzersCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// VideoAnalyzersUpdatePoller provides polling facilities until the operation reaches a terminal state. +type VideoAnalyzersUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *VideoAnalyzersUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *VideoAnalyzersUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final VideoAnalyzersUpdateResponse will be returned. +func (p *VideoAnalyzersUpdatePoller) FinalResponse(ctx context.Context) (VideoAnalyzersUpdateResponse, error) { + respType := VideoAnalyzersUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.VideoAnalyzer) + if err != nil { + return VideoAnalyzersUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *VideoAnalyzersUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..7a7e8885a88c --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_polymorphic_helpers.go @@ -0,0 +1,815 @@ +//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 armvideoanalyzer + +import "encoding/json" + +func unmarshalAudioEncoderBaseClassification(rawMsg json.RawMessage) (AudioEncoderBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b AudioEncoderBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.AudioEncoderAac": + b = &AudioEncoderAac{} + default: + b = &AudioEncoderBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalAudioEncoderBaseClassificationArray(rawMsg json.RawMessage) ([]AudioEncoderBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]AudioEncoderBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalAudioEncoderBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalAudioEncoderBaseClassificationMap(rawMsg json.RawMessage) (map[string]AudioEncoderBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]AudioEncoderBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalAudioEncoderBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalAuthenticationBaseClassification(rawMsg json.RawMessage) (AuthenticationBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b AuthenticationBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.JwtAuthentication": + b = &JwtAuthentication{} + default: + b = &AuthenticationBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalAuthenticationBaseClassificationArray(rawMsg json.RawMessage) ([]AuthenticationBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]AuthenticationBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalAuthenticationBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalAuthenticationBaseClassificationMap(rawMsg json.RawMessage) (map[string]AuthenticationBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]AuthenticationBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalAuthenticationBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalCertificateSourceClassification(rawMsg json.RawMessage) (CertificateSourceClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b CertificateSourceClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.PemCertificateList": + b = &PemCertificateList{} + default: + b = &CertificateSource{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalCertificateSourceClassificationArray(rawMsg json.RawMessage) ([]CertificateSourceClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]CertificateSourceClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalCertificateSourceClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalCertificateSourceClassificationMap(rawMsg json.RawMessage) (map[string]CertificateSourceClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]CertificateSourceClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalCertificateSourceClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalCredentialsBaseClassification(rawMsg json.RawMessage) (CredentialsBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b CredentialsBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.UsernamePasswordCredentials": + b = &UsernamePasswordCredentials{} + default: + b = &CredentialsBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalCredentialsBaseClassificationArray(rawMsg json.RawMessage) ([]CredentialsBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]CredentialsBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalCredentialsBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalCredentialsBaseClassificationMap(rawMsg json.RawMessage) (map[string]CredentialsBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]CredentialsBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalCredentialsBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalEncoderPresetBaseClassification(rawMsg json.RawMessage) (EncoderPresetBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EncoderPresetBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.EncoderCustomPreset": + b = &EncoderCustomPreset{} + case "#Microsoft.VideoAnalyzer.EncoderSystemPreset": + b = &EncoderSystemPreset{} + default: + b = &EncoderPresetBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalEncoderPresetBaseClassificationArray(rawMsg json.RawMessage) ([]EncoderPresetBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]EncoderPresetBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalEncoderPresetBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalEncoderPresetBaseClassificationMap(rawMsg json.RawMessage) (map[string]EncoderPresetBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]EncoderPresetBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalEncoderPresetBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalEndpointBaseClassification(rawMsg json.RawMessage) (EndpointBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EndpointBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.TlsEndpoint": + b = &TLSEndpoint{} + case "#Microsoft.VideoAnalyzer.UnsecuredEndpoint": + b = &UnsecuredEndpoint{} + default: + b = &EndpointBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalEndpointBaseClassificationArray(rawMsg json.RawMessage) ([]EndpointBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]EndpointBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalEndpointBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalEndpointBaseClassificationMap(rawMsg json.RawMessage) (map[string]EndpointBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]EndpointBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalEndpointBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalNodeBaseClassification(rawMsg json.RawMessage) (NodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b NodeBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.EncoderProcessor": + b = &EncoderProcessor{} + case "#Microsoft.VideoAnalyzer.ProcessorNodeBase": + b = &ProcessorNodeBase{} + case "#Microsoft.VideoAnalyzer.RtspSource": + b = &RtspSource{} + case "#Microsoft.VideoAnalyzer.SinkNodeBase": + b = &SinkNodeBase{} + case "#Microsoft.VideoAnalyzer.SourceNodeBase": + b = &SourceNodeBase{} + case "#Microsoft.VideoAnalyzer.VideoSink": + b = &VideoSink{} + case "#Microsoft.VideoAnalyzer.VideoSource": + b = &VideoSource{} + default: + b = &NodeBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalNodeBaseClassificationArray(rawMsg json.RawMessage) ([]NodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]NodeBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalNodeBaseClassificationMap(rawMsg json.RawMessage) (map[string]NodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]NodeBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalProcessorNodeBaseClassification(rawMsg json.RawMessage) (ProcessorNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b ProcessorNodeBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.EncoderProcessor": + b = &EncoderProcessor{} + default: + b = &ProcessorNodeBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalProcessorNodeBaseClassificationArray(rawMsg json.RawMessage) ([]ProcessorNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]ProcessorNodeBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalProcessorNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalProcessorNodeBaseClassificationMap(rawMsg json.RawMessage) (map[string]ProcessorNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]ProcessorNodeBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalProcessorNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalSinkNodeBaseClassification(rawMsg json.RawMessage) (SinkNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b SinkNodeBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.VideoSink": + b = &VideoSink{} + default: + b = &SinkNodeBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalSinkNodeBaseClassificationArray(rawMsg json.RawMessage) ([]SinkNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]SinkNodeBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalSinkNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalSinkNodeBaseClassificationMap(rawMsg json.RawMessage) (map[string]SinkNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]SinkNodeBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalSinkNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalSourceNodeBaseClassification(rawMsg json.RawMessage) (SourceNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b SourceNodeBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.RtspSource": + b = &RtspSource{} + case "#Microsoft.VideoAnalyzer.VideoSource": + b = &VideoSource{} + default: + b = &SourceNodeBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalSourceNodeBaseClassificationArray(rawMsg json.RawMessage) ([]SourceNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]SourceNodeBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalSourceNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalSourceNodeBaseClassificationMap(rawMsg json.RawMessage) (map[string]SourceNodeBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]SourceNodeBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalSourceNodeBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalTimeSequenceBaseClassification(rawMsg json.RawMessage) (TimeSequenceBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TimeSequenceBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.VideoSequenceAbsoluteTimeMarkers": + b = &VideoSequenceAbsoluteTimeMarkers{} + default: + b = &TimeSequenceBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalTimeSequenceBaseClassificationArray(rawMsg json.RawMessage) ([]TimeSequenceBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]TimeSequenceBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalTimeSequenceBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalTimeSequenceBaseClassificationMap(rawMsg json.RawMessage) (map[string]TimeSequenceBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]TimeSequenceBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalTimeSequenceBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalTokenKeyClassification(rawMsg json.RawMessage) (TokenKeyClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TokenKeyClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.EccTokenKey": + b = &EccTokenKey{} + case "#Microsoft.VideoAnalyzer.RsaTokenKey": + b = &RsaTokenKey{} + default: + b = &TokenKey{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalTokenKeyClassificationArray(rawMsg json.RawMessage) ([]TokenKeyClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]TokenKeyClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalTokenKeyClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalTokenKeyClassificationMap(rawMsg json.RawMessage) (map[string]TokenKeyClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]TokenKeyClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalTokenKeyClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalTunnelBaseClassification(rawMsg json.RawMessage) (TunnelBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TunnelBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.SecureIotDeviceRemoteTunnel": + b = &SecureIotDeviceRemoteTunnel{} + default: + b = &TunnelBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalTunnelBaseClassificationArray(rawMsg json.RawMessage) ([]TunnelBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]TunnelBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalTunnelBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalTunnelBaseClassificationMap(rawMsg json.RawMessage) (map[string]TunnelBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]TunnelBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalTunnelBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} + +func unmarshalVideoEncoderBaseClassification(rawMsg json.RawMessage) (VideoEncoderBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b VideoEncoderBaseClassification + switch m["@type"] { + case "#Microsoft.VideoAnalyzer.VideoEncoderH264": + b = &VideoEncoderH264{} + default: + b = &VideoEncoderBase{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalVideoEncoderBaseClassificationArray(rawMsg json.RawMessage) ([]VideoEncoderBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]VideoEncoderBaseClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalVideoEncoderBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalVideoEncoderBaseClassificationMap(rawMsg json.RawMessage) (map[string]VideoEncoderBaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]VideoEncoderBaseClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalVideoEncoderBaseClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_privateendpointconnections_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..8bc277cca72c --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,321 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateEndpointConnectionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateEndpointConnectionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Update private endpoint connection state under video analyzer account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, name string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsCreateOrUpdateOptions) (PrivateEndpointConnectionsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, name, parameters, options) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, name string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateEndpointConnections/{name}" + 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)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PrivateEndpointConnectionsClient) createOrUpdateHandleResponse(resp *http.Response) (PrivateEndpointConnectionsCreateOrUpdateResponse, error) { + result := PrivateEndpointConnectionsCreateOrUpdateResponse{RawResponse: resp} + if val := resp.Header.Get("Retry-After"); val != "" { + retryAfter32, err := strconv.ParseInt(val, 10, 32) + retryAfter := int32(retryAfter32) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, err + } + result.RetryAfter = &retryAfter + } + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val + } + if val := resp.Header.Get("Azure-AsyncOperation"); val != "" { + result.AzureAsyncOperation = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateEndpointConnectionsClient) 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 private endpoint connection under video analyzer account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateEndpointConnectionsDeleteOptions) (PrivateEndpointConnectionsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, name, options) + if err != nil { + return PrivateEndpointConnectionsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return PrivateEndpointConnectionsDeleteResponse{}, client.deleteHandleError(resp) + } + return PrivateEndpointConnectionsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateEndpointConnectionsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateEndpointConnections/{name}" + 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)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + 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-01-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 *PrivateEndpointConnectionsClient) 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 - Get private endpoint connection under video analyzer account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, name, options) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateEndpointConnectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateEndpointConnectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateEndpointConnections/{name}" + 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)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Response) (PrivateEndpointConnectionsGetResponse, error) { + result := PrivateEndpointConnectionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil { + return PrivateEndpointConnectionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateEndpointConnectionsClient) 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 - Get all private endpoint connections under video analyzer account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, accountName string, options *PrivateEndpointConnectionsListOptions) (PrivateEndpointConnectionsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateEndpointConnectionsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *PrivateEndpointConnectionsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateEndpointConnections" + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *http.Response) (PrivateEndpointConnectionsListResponse, error) { + result := PrivateEndpointConnectionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnectionListResult); err != nil { + return PrivateEndpointConnectionsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateEndpointConnectionsClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_privatelinkresources_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_privatelinkresources_client.go new file mode 100644 index 000000000000..103da6fecb75 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_privatelinkresources_client.go @@ -0,0 +1,177 @@ +//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 armvideoanalyzer + +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" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateLinkResourcesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateLinkResourcesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get group ID for video analyzer account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateLinkResourcesGetOptions) (PrivateLinkResourcesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, name, options) + if err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateLinkResourcesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, name string, options *PrivateLinkResourcesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateLinkResources/{name}" + 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)) + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) (PrivateLinkResourcesGetResponse, error) { + result := PrivateLinkResourcesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResource); err != nil { + return PrivateLinkResourcesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkResourcesClient) 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 - Get list of group IDs for video analyzer account. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesListOptions) (PrivateLinkResourcesListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return PrivateLinkResourcesListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateLinkResourcesListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateLinkResourcesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/privateLinkResources" + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateLinkResourcesClient) listHandleResponse(resp *http.Response) (PrivateLinkResourcesListResponse, error) { + result := PrivateLinkResourcesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateLinkResourceListResult); err != nil { + return PrivateLinkResourcesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateLinkResourcesClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_response_types.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_response_types.go new file mode 100644 index 000000000000..5f475e20a3bd --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_response_types.go @@ -0,0 +1,806 @@ +//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 armvideoanalyzer + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// AccessPoliciesCreateOrUpdateResponse contains the response from method AccessPolicies.CreateOrUpdate. +type AccessPoliciesCreateOrUpdateResponse struct { + AccessPoliciesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccessPoliciesCreateOrUpdateResult contains the result from method AccessPolicies.CreateOrUpdate. +type AccessPoliciesCreateOrUpdateResult struct { + AccessPolicyEntity +} + +// AccessPoliciesDeleteResponse contains the response from method AccessPolicies.Delete. +type AccessPoliciesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccessPoliciesGetResponse contains the response from method AccessPolicies.Get. +type AccessPoliciesGetResponse struct { + AccessPoliciesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccessPoliciesGetResult contains the result from method AccessPolicies.Get. +type AccessPoliciesGetResult struct { + AccessPolicyEntity +} + +// AccessPoliciesListResponse contains the response from method AccessPolicies.List. +type AccessPoliciesListResponse struct { + AccessPoliciesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccessPoliciesListResult contains the result from method AccessPolicies.List. +type AccessPoliciesListResult struct { + AccessPolicyEntityCollection +} + +// AccessPoliciesUpdateResponse contains the response from method AccessPolicies.Update. +type AccessPoliciesUpdateResponse struct { + AccessPoliciesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AccessPoliciesUpdateResult contains the result from method AccessPolicies.Update. +type AccessPoliciesUpdateResult struct { + AccessPolicyEntity +} + +// EdgeModulesCreateOrUpdateResponse contains the response from method EdgeModules.CreateOrUpdate. +type EdgeModulesCreateOrUpdateResponse struct { + EdgeModulesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EdgeModulesCreateOrUpdateResult contains the result from method EdgeModules.CreateOrUpdate. +type EdgeModulesCreateOrUpdateResult struct { + EdgeModuleEntity +} + +// EdgeModulesDeleteResponse contains the response from method EdgeModules.Delete. +type EdgeModulesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EdgeModulesGetResponse contains the response from method EdgeModules.Get. +type EdgeModulesGetResponse struct { + EdgeModulesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EdgeModulesGetResult contains the result from method EdgeModules.Get. +type EdgeModulesGetResult struct { + EdgeModuleEntity +} + +// EdgeModulesListProvisioningTokenResponse contains the response from method EdgeModules.ListProvisioningToken. +type EdgeModulesListProvisioningTokenResponse struct { + EdgeModulesListProvisioningTokenResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EdgeModulesListProvisioningTokenResult contains the result from method EdgeModules.ListProvisioningToken. +type EdgeModulesListProvisioningTokenResult struct { + EdgeModuleProvisioningToken +} + +// EdgeModulesListResponse contains the response from method EdgeModules.List. +type EdgeModulesListResponse struct { + EdgeModulesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EdgeModulesListResult contains the result from method EdgeModules.List. +type EdgeModulesListResult struct { + EdgeModuleEntityCollection +} + +// LivePipelineOperationStatusesGetResponse contains the response from method LivePipelineOperationStatuses.Get. +type LivePipelineOperationStatusesGetResponse struct { + LivePipelineOperationStatusesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelineOperationStatusesGetResult contains the result from method LivePipelineOperationStatuses.Get. +type LivePipelineOperationStatusesGetResult struct { + LivePipelineOperationStatus +} + +// LivePipelinesActivatePollerResponse contains the response from method LivePipelines.Activate. +type LivePipelinesActivatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LivePipelinesActivatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l LivePipelinesActivatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LivePipelinesActivateResponse, error) { + respType := LivePipelinesActivateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LivePipelinesActivatePollerResponse from the provided client and resume token. +func (l *LivePipelinesActivatePollerResponse) Resume(ctx context.Context, client *LivePipelinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LivePipelinesClient.Activate", token, client.pl, client.activateHandleError) + if err != nil { + return err + } + poller := &LivePipelinesActivatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LivePipelinesActivateResponse contains the response from method LivePipelines.Activate. +type LivePipelinesActivateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesCreateOrUpdateResponse contains the response from method LivePipelines.CreateOrUpdate. +type LivePipelinesCreateOrUpdateResponse struct { + LivePipelinesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesCreateOrUpdateResult contains the result from method LivePipelines.CreateOrUpdate. +type LivePipelinesCreateOrUpdateResult struct { + LivePipeline +} + +// LivePipelinesDeactivatePollerResponse contains the response from method LivePipelines.Deactivate. +type LivePipelinesDeactivatePollerResponse struct { + // Poller contains an initialized poller. + Poller *LivePipelinesDeactivatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l LivePipelinesDeactivatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LivePipelinesDeactivateResponse, error) { + respType := LivePipelinesDeactivateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a LivePipelinesDeactivatePollerResponse from the provided client and resume token. +func (l *LivePipelinesDeactivatePollerResponse) Resume(ctx context.Context, client *LivePipelinesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("LivePipelinesClient.Deactivate", token, client.pl, client.deactivateHandleError) + if err != nil { + return err + } + poller := &LivePipelinesDeactivatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// LivePipelinesDeactivateResponse contains the response from method LivePipelines.Deactivate. +type LivePipelinesDeactivateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesDeleteResponse contains the response from method LivePipelines.Delete. +type LivePipelinesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesGetResponse contains the response from method LivePipelines.Get. +type LivePipelinesGetResponse struct { + LivePipelinesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesGetResult contains the result from method LivePipelines.Get. +type LivePipelinesGetResult struct { + LivePipeline +} + +// LivePipelinesListResponse contains the response from method LivePipelines.List. +type LivePipelinesListResponse struct { + LivePipelinesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesListResult contains the result from method LivePipelines.List. +type LivePipelinesListResult struct { + LivePipelineCollection +} + +// LivePipelinesUpdateResponse contains the response from method LivePipelines.Update. +type LivePipelinesUpdateResponse struct { + LivePipelinesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LivePipelinesUpdateResult contains the result from method LivePipelines.Update. +type LivePipelinesUpdateResult struct { + LivePipeline +} + +// LocationsCheckNameAvailabilityResponse contains the response from method Locations.CheckNameAvailability. +type LocationsCheckNameAvailabilityResponse struct { + LocationsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationsCheckNameAvailabilityResult contains the result from method Locations.CheckNameAvailability. +type LocationsCheckNameAvailabilityResult struct { + CheckNameAvailabilityResponse +} + +// OperationResultsGetResponse contains the response from method OperationResults.Get. +type OperationResultsGetResponse struct { + OperationResultsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationResultsGetResult contains the result from method OperationResults.Get. +type OperationResultsGetResult struct { + PrivateEndpointConnection +} + +// OperationStatusesGetResponse contains the response from method OperationStatuses.Get. +type OperationStatusesGetResponse struct { + OperationStatusesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationStatusesGetResult contains the result from method OperationStatuses.Get. +type OperationStatusesGetResult struct { + VideoAnalyzerPrivateEndpointConnectionOperationStatus +} + +// 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 { + OperationCollection +} + +// PipelineJobOperationStatusesGetResponse contains the response from method PipelineJobOperationStatuses.Get. +type PipelineJobOperationStatusesGetResponse struct { + PipelineJobOperationStatusesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobOperationStatusesGetResult contains the result from method PipelineJobOperationStatuses.Get. +type PipelineJobOperationStatusesGetResult struct { + PipelineJobOperationStatus +} + +// PipelineJobsCancelPollerResponse contains the response from method PipelineJobs.Cancel. +type PipelineJobsCancelPollerResponse struct { + // Poller contains an initialized poller. + Poller *PipelineJobsCancelPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l PipelineJobsCancelPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PipelineJobsCancelResponse, error) { + respType := PipelineJobsCancelResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PipelineJobsCancelPollerResponse from the provided client and resume token. +func (l *PipelineJobsCancelPollerResponse) Resume(ctx context.Context, client *PipelineJobsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PipelineJobsClient.Cancel", token, client.pl, client.cancelHandleError) + if err != nil { + return err + } + poller := &PipelineJobsCancelPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PipelineJobsCancelResponse contains the response from method PipelineJobs.Cancel. +type PipelineJobsCancelResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobsCreateOrUpdateResponse contains the response from method PipelineJobs.CreateOrUpdate. +type PipelineJobsCreateOrUpdateResponse struct { + PipelineJobsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobsCreateOrUpdateResult contains the result from method PipelineJobs.CreateOrUpdate. +type PipelineJobsCreateOrUpdateResult struct { + PipelineJob +} + +// PipelineJobsDeleteResponse contains the response from method PipelineJobs.Delete. +type PipelineJobsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobsGetResponse contains the response from method PipelineJobs.Get. +type PipelineJobsGetResponse struct { + PipelineJobsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobsGetResult contains the result from method PipelineJobs.Get. +type PipelineJobsGetResult struct { + PipelineJob +} + +// PipelineJobsListResponse contains the response from method PipelineJobs.List. +type PipelineJobsListResponse struct { + PipelineJobsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobsListResult contains the result from method PipelineJobs.List. +type PipelineJobsListResult struct { + PipelineJobCollection +} + +// PipelineJobsUpdateResponse contains the response from method PipelineJobs.Update. +type PipelineJobsUpdateResponse struct { + PipelineJobsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineJobsUpdateResult contains the result from method PipelineJobs.Update. +type PipelineJobsUpdateResult struct { + PipelineJob +} + +// PipelineTopologiesCreateOrUpdateResponse contains the response from method PipelineTopologies.CreateOrUpdate. +type PipelineTopologiesCreateOrUpdateResponse struct { + PipelineTopologiesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineTopologiesCreateOrUpdateResult contains the result from method PipelineTopologies.CreateOrUpdate. +type PipelineTopologiesCreateOrUpdateResult struct { + PipelineTopology +} + +// PipelineTopologiesDeleteResponse contains the response from method PipelineTopologies.Delete. +type PipelineTopologiesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineTopologiesGetResponse contains the response from method PipelineTopologies.Get. +type PipelineTopologiesGetResponse struct { + PipelineTopologiesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineTopologiesGetResult contains the result from method PipelineTopologies.Get. +type PipelineTopologiesGetResult struct { + PipelineTopology +} + +// PipelineTopologiesListResponse contains the response from method PipelineTopologies.List. +type PipelineTopologiesListResponse struct { + PipelineTopologiesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineTopologiesListResult contains the result from method PipelineTopologies.List. +type PipelineTopologiesListResult struct { + PipelineTopologyCollection +} + +// PipelineTopologiesUpdateResponse contains the response from method PipelineTopologies.Update. +type PipelineTopologiesUpdateResponse struct { + PipelineTopologiesUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineTopologiesUpdateResult contains the result from method PipelineTopologies.Update. +type PipelineTopologiesUpdateResult struct { + PipelineTopology +} + +// PrivateEndpointConnectionsCreateOrUpdateResponse contains the response from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdateResponse struct { + PrivateEndpointConnectionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsCreateOrUpdateResult contains the result from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdateResult struct { + PrivateEndpointConnection + // AzureAsyncOperation contains the information returned from the Azure-AsyncOperation header response. + AzureAsyncOperation *string + + // Location contains the information returned from the Location header response. + Location *string + + // RetryAfter contains the information returned from the Retry-After header response. + RetryAfter *int32 +} + +// PrivateEndpointConnectionsDeleteResponse contains the response from method PrivateEndpointConnections.Delete. +type PrivateEndpointConnectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResponse contains the response from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResponse struct { + PrivateEndpointConnectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResult contains the result from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResult struct { + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsListResponse contains the response from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResponse struct { + PrivateEndpointConnectionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsListResult contains the result from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResult struct { + PrivateEndpointConnectionListResult +} + +// PrivateLinkResourcesGetResponse contains the response from method PrivateLinkResources.Get. +type PrivateLinkResourcesGetResponse struct { + PrivateLinkResourcesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesGetResult contains the result from method PrivateLinkResources.Get. +type PrivateLinkResourcesGetResult struct { + PrivateLinkResource +} + +// PrivateLinkResourcesListResponse contains the response from method PrivateLinkResources.List. +type PrivateLinkResourcesListResponse struct { + PrivateLinkResourcesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesListResult contains the result from method PrivateLinkResources.List. +type PrivateLinkResourcesListResult struct { + PrivateLinkResourceListResult +} + +// VideoAnalyzerOperationResultsGetResponse contains the response from method VideoAnalyzerOperationResults.Get. +type VideoAnalyzerOperationResultsGetResponse struct { + VideoAnalyzerOperationResultsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzerOperationResultsGetResult contains the result from method VideoAnalyzerOperationResults.Get. +type VideoAnalyzerOperationResultsGetResult struct { + VideoAnalyzer +} + +// VideoAnalyzerOperationStatusesGetResponse contains the response from method VideoAnalyzerOperationStatuses.Get. +type VideoAnalyzerOperationStatusesGetResponse struct { + VideoAnalyzerOperationStatusesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzerOperationStatusesGetResult contains the result from method VideoAnalyzerOperationStatuses.Get. +type VideoAnalyzerOperationStatusesGetResult struct { + VideoAnalyzerOperationStatus +} + +// VideoAnalyzersCreateOrUpdatePollerResponse contains the response from method VideoAnalyzers.CreateOrUpdate. +type VideoAnalyzersCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *VideoAnalyzersCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l VideoAnalyzersCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VideoAnalyzersCreateOrUpdateResponse, error) { + respType := VideoAnalyzersCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.VideoAnalyzer) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VideoAnalyzersCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *VideoAnalyzersCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *VideoAnalyzersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VideoAnalyzersClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &VideoAnalyzersCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VideoAnalyzersCreateOrUpdateResponse contains the response from method VideoAnalyzers.CreateOrUpdate. +type VideoAnalyzersCreateOrUpdateResponse struct { + VideoAnalyzersCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzersCreateOrUpdateResult contains the result from method VideoAnalyzers.CreateOrUpdate. +type VideoAnalyzersCreateOrUpdateResult struct { + VideoAnalyzer +} + +// VideoAnalyzersDeleteResponse contains the response from method VideoAnalyzers.Delete. +type VideoAnalyzersDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzersGetResponse contains the response from method VideoAnalyzers.Get. +type VideoAnalyzersGetResponse struct { + VideoAnalyzersGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzersGetResult contains the result from method VideoAnalyzers.Get. +type VideoAnalyzersGetResult struct { + VideoAnalyzer +} + +// VideoAnalyzersListBySubscriptionResponse contains the response from method VideoAnalyzers.ListBySubscription. +type VideoAnalyzersListBySubscriptionResponse struct { + VideoAnalyzersListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzersListBySubscriptionResult contains the result from method VideoAnalyzers.ListBySubscription. +type VideoAnalyzersListBySubscriptionResult struct { + VideoAnalyzerCollection +} + +// VideoAnalyzersListResponse contains the response from method VideoAnalyzers.List. +type VideoAnalyzersListResponse struct { + VideoAnalyzersListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzersListResult contains the result from method VideoAnalyzers.List. +type VideoAnalyzersListResult struct { + VideoAnalyzerCollection +} + +// VideoAnalyzersUpdatePollerResponse contains the response from method VideoAnalyzers.Update. +type VideoAnalyzersUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *VideoAnalyzersUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l VideoAnalyzersUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (VideoAnalyzersUpdateResponse, error) { + respType := VideoAnalyzersUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.VideoAnalyzer) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a VideoAnalyzersUpdatePollerResponse from the provided client and resume token. +func (l *VideoAnalyzersUpdatePollerResponse) Resume(ctx context.Context, client *VideoAnalyzersClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("VideoAnalyzersClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &VideoAnalyzersUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// VideoAnalyzersUpdateResponse contains the response from method VideoAnalyzers.Update. +type VideoAnalyzersUpdateResponse struct { + VideoAnalyzersUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideoAnalyzersUpdateResult contains the result from method VideoAnalyzers.Update. +type VideoAnalyzersUpdateResult struct { + VideoAnalyzer +} + +// VideosCreateOrUpdateResponse contains the response from method Videos.CreateOrUpdate. +type VideosCreateOrUpdateResponse struct { + VideosCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideosCreateOrUpdateResult contains the result from method Videos.CreateOrUpdate. +type VideosCreateOrUpdateResult struct { + VideoEntity +} + +// VideosDeleteResponse contains the response from method Videos.Delete. +type VideosDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideosGetResponse contains the response from method Videos.Get. +type VideosGetResponse struct { + VideosGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideosGetResult contains the result from method Videos.Get. +type VideosGetResult struct { + VideoEntity +} + +// VideosListContentTokenResponse contains the response from method Videos.ListContentToken. +type VideosListContentTokenResponse struct { + VideosListContentTokenResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideosListContentTokenResult contains the result from method Videos.ListContentToken. +type VideosListContentTokenResult struct { + VideoContentToken +} + +// VideosListResponse contains the response from method Videos.List. +type VideosListResponse struct { + VideosListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideosListResult contains the result from method Videos.List. +type VideosListResult struct { + VideoEntityCollection +} + +// VideosUpdateResponse contains the response from method Videos.Update. +type VideosUpdateResponse struct { + VideosUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// VideosUpdateResult contains the result from method Videos.Update. +type VideosUpdateResult struct { + VideoEntity +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_time_rfc3339.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..1fe85a6a0111 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/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 armvideoanalyzer + +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/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzeroperationresults_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzeroperationresults_client.go new file mode 100644 index 000000000000..07dde075f09e --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzeroperationresults_client.go @@ -0,0 +1,108 @@ +//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 armvideoanalyzer + +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" +) + +// VideoAnalyzerOperationResultsClient contains the methods for the VideoAnalyzerOperationResults group. +// Don't use this type directly, use NewVideoAnalyzerOperationResultsClient() instead. +type VideoAnalyzerOperationResultsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVideoAnalyzerOperationResultsClient creates a new instance of VideoAnalyzerOperationResultsClient with the specified values. +func NewVideoAnalyzerOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VideoAnalyzerOperationResultsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VideoAnalyzerOperationResultsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get video analyzer operation result. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzerOperationResultsClient) Get(ctx context.Context, locationName string, operationID string, options *VideoAnalyzerOperationResultsGetOptions) (VideoAnalyzerOperationResultsGetResponse, error) { + req, err := client.getCreateRequest(ctx, locationName, operationID, options) + if err != nil { + return VideoAnalyzerOperationResultsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideoAnalyzerOperationResultsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return VideoAnalyzerOperationResultsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VideoAnalyzerOperationResultsClient) getCreateRequest(ctx context.Context, locationName string, operationID string, options *VideoAnalyzerOperationResultsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/videoAnalyzerOperationResults/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VideoAnalyzerOperationResultsClient) getHandleResponse(resp *http.Response) (VideoAnalyzerOperationResultsGetResponse, error) { + result := VideoAnalyzerOperationResultsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoAnalyzer); err != nil { + return VideoAnalyzerOperationResultsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *VideoAnalyzerOperationResultsClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzeroperationstatuses_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzeroperationstatuses_client.go new file mode 100644 index 000000000000..46254ffdf47a --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzeroperationstatuses_client.go @@ -0,0 +1,108 @@ +//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 armvideoanalyzer + +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" +) + +// VideoAnalyzerOperationStatusesClient contains the methods for the VideoAnalyzerOperationStatuses group. +// Don't use this type directly, use NewVideoAnalyzerOperationStatusesClient() instead. +type VideoAnalyzerOperationStatusesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVideoAnalyzerOperationStatusesClient creates a new instance of VideoAnalyzerOperationStatusesClient with the specified values. +func NewVideoAnalyzerOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VideoAnalyzerOperationStatusesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VideoAnalyzerOperationStatusesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get video analyzer operation status. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzerOperationStatusesClient) Get(ctx context.Context, locationName string, operationID string, options *VideoAnalyzerOperationStatusesGetOptions) (VideoAnalyzerOperationStatusesGetResponse, error) { + req, err := client.getCreateRequest(ctx, locationName, operationID, options) + if err != nil { + return VideoAnalyzerOperationStatusesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideoAnalyzerOperationStatusesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideoAnalyzerOperationStatusesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VideoAnalyzerOperationStatusesClient) getCreateRequest(ctx context.Context, locationName string, operationID string, options *VideoAnalyzerOperationStatusesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Media/locations/{locationName}/videoAnalyzerOperationStatuses/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VideoAnalyzerOperationStatusesClient) getHandleResponse(resp *http.Response) (VideoAnalyzerOperationStatusesGetResponse, error) { + result := VideoAnalyzerOperationStatusesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoAnalyzerOperationStatus); err != nil { + return VideoAnalyzerOperationStatusesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *VideoAnalyzerOperationStatusesClient) 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) +} diff --git a/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzers_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzers_client.go new file mode 100644 index 000000000000..be608d4366df --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videoanalyzers_client.go @@ -0,0 +1,434 @@ +//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 armvideoanalyzer + +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" +) + +// VideoAnalyzersClient contains the methods for the VideoAnalyzers group. +// Don't use this type directly, use NewVideoAnalyzersClient() instead. +type VideoAnalyzersClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVideoAnalyzersClient creates a new instance of VideoAnalyzersClient with the specified values. +func NewVideoAnalyzersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VideoAnalyzersClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VideoAnalyzersClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update an instance of a Video Analyzer account +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters VideoAnalyzer, options *VideoAnalyzersBeginCreateOrUpdateOptions) (VideoAnalyzersCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, accountName, parameters, options) + if err != nil { + return VideoAnalyzersCreateOrUpdatePollerResponse{}, err + } + result := VideoAnalyzersCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VideoAnalyzersClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return VideoAnalyzersCreateOrUpdatePollerResponse{}, err + } + result.Poller = &VideoAnalyzersCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update an instance of a Video Analyzer account +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) createOrUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters VideoAnalyzer, options *VideoAnalyzersBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VideoAnalyzersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters VideoAnalyzer, options *VideoAnalyzersBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *VideoAnalyzersClient) 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 the specified Video Analyzer account +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *VideoAnalyzersDeleteOptions) (VideoAnalyzersDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return VideoAnalyzersDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideoAnalyzersDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VideoAnalyzersDeleteResponse{}, client.deleteHandleError(resp) + } + return VideoAnalyzersDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VideoAnalyzersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *VideoAnalyzersDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{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-01-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 *VideoAnalyzersClient) 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 - Get the details of the specified Video Analyzer account +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *VideoAnalyzersGetOptions) (VideoAnalyzersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) + if err != nil { + return VideoAnalyzersGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideoAnalyzersGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideoAnalyzersGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VideoAnalyzersClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *VideoAnalyzersGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VideoAnalyzersClient) getHandleResponse(resp *http.Response) (VideoAnalyzersGetResponse, error) { + result := VideoAnalyzersGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoAnalyzer); err != nil { + return VideoAnalyzersGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *VideoAnalyzersClient) 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 - Lists the Video Analyzer accounts in the specified resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) List(ctx context.Context, resourceGroupName string, options *VideoAnalyzersListOptions) (VideoAnalyzersListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return VideoAnalyzersListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideoAnalyzersListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideoAnalyzersListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *VideoAnalyzersClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *VideoAnalyzersListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers" + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VideoAnalyzersClient) listHandleResponse(resp *http.Response) (VideoAnalyzersListResponse, error) { + result := VideoAnalyzersListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoAnalyzerCollection); err != nil { + return VideoAnalyzersListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *VideoAnalyzersClient) 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) +} + +// ListBySubscription - List all Video Analyzer accounts in the specified subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) ListBySubscription(ctx context.Context, options *VideoAnalyzersListBySubscriptionOptions) (VideoAnalyzersListBySubscriptionResponse, error) { + req, err := client.listBySubscriptionCreateRequest(ctx, options) + if err != nil { + return VideoAnalyzersListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideoAnalyzersListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideoAnalyzersListBySubscriptionResponse{}, client.listBySubscriptionHandleError(resp) + } + return client.listBySubscriptionHandleResponse(resp) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VideoAnalyzersClient) listBySubscriptionCreateRequest(ctx context.Context, options *VideoAnalyzersListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Media/videoAnalyzers" + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VideoAnalyzersClient) listBySubscriptionHandleResponse(resp *http.Response) (VideoAnalyzersListBySubscriptionResponse, error) { + result := VideoAnalyzersListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoAnalyzerCollection); err != nil { + return VideoAnalyzersListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *VideoAnalyzersClient) listBySubscriptionHandleError(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) +} + +// BeginUpdate - Updates an existing instance of Video Analyzer account +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) BeginUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters VideoAnalyzerUpdate, options *VideoAnalyzersBeginUpdateOptions) (VideoAnalyzersUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, accountName, parameters, options) + if err != nil { + return VideoAnalyzersUpdatePollerResponse{}, err + } + result := VideoAnalyzersUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("VideoAnalyzersClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return VideoAnalyzersUpdatePollerResponse{}, err + } + result.Poller = &VideoAnalyzersUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Updates an existing instance of Video Analyzer account +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideoAnalyzersClient) update(ctx context.Context, resourceGroupName string, accountName string, parameters VideoAnalyzerUpdate, options *VideoAnalyzersBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VideoAnalyzersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters VideoAnalyzerUpdate, options *VideoAnalyzersBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleError handles the Update error response. +func (client *VideoAnalyzersClient) 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/videoanalyzer/armvideoanalyzer/zz_generated_videos_client.go b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videos_client.go new file mode 100644 index 000000000000..c1fc12d7f3f8 --- /dev/null +++ b/sdk/resourcemanager/videoanalyzer/armvideoanalyzer/zz_generated_videos_client.go @@ -0,0 +1,445 @@ +//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 armvideoanalyzer + +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" + "strconv" + "strings" +) + +// VideosClient contains the methods for the Videos group. +// Don't use this type directly, use NewVideosClient() instead. +type VideosClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewVideosClient creates a new instance of VideosClient with the specified values. +func NewVideosClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *VideosClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &VideosClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates a new video resource or updates an existing video resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideosClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity, options *VideosCreateOrUpdateOptions) (VideosCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, videoName, parameters, options) + if err != nil { + return VideosCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideosCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return VideosCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VideosClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity, options *VideosCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}" + 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)) + if videoName == "" { + return nil, errors.New("parameter videoName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{videoName}", url.PathEscape(videoName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *VideosClient) createOrUpdateHandleResponse(resp *http.Response) (VideosCreateOrUpdateResponse, error) { + result := VideosCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoEntity); err != nil { + return VideosCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *VideosClient) 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 - Deletes an existing video resource and its underlying data. This operation is irreversible. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideosClient) Delete(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosDeleteOptions) (VideosDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, videoName, options) + if err != nil { + return VideosDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideosDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VideosDeleteResponse{}, client.deleteHandleError(resp) + } + return VideosDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VideosClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}" + 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)) + if videoName == "" { + return nil, errors.New("parameter videoName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{videoName}", url.PathEscape(videoName)) + 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-01-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 *VideosClient) 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 - Retrieves an existing video resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideosClient) Get(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosGetOptions) (VideosGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, videoName, options) + if err != nil { + return VideosGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideosGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideosGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *VideosClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}" + 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)) + if videoName == "" { + return nil, errors.New("parameter videoName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{videoName}", url.PathEscape(videoName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VideosClient) getHandleResponse(resp *http.Response) (VideosGetResponse, error) { + result := VideosGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoEntity); err != nil { + return VideosGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *VideosClient) 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 - Retrieves a list of video resources that have been created, along with their JSON representations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideosClient) List(resourceGroupName string, accountName string, options *VideosListOptions) *VideosListPager { + return &VideosListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, accountName, options) + }, + advancer: func(ctx context.Context, resp VideosListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.VideoEntityCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *VideosClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *VideosListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos" + 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-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VideosClient) listHandleResponse(resp *http.Response) (VideosListResponse, error) { + result := VideosListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoEntityCollection); err != nil { + return VideosListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *VideosClient) 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) +} + +// ListContentToken - Generates a streaming token which can be used for accessing content from video content URLs, for a video resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideosClient) ListContentToken(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosListContentTokenOptions) (VideosListContentTokenResponse, error) { + req, err := client.listContentTokenCreateRequest(ctx, resourceGroupName, accountName, videoName, options) + if err != nil { + return VideosListContentTokenResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideosListContentTokenResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideosListContentTokenResponse{}, client.listContentTokenHandleError(resp) + } + return client.listContentTokenHandleResponse(resp) +} + +// listContentTokenCreateRequest creates the ListContentToken request. +func (client *VideosClient) listContentTokenCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosListContentTokenOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}/listContentToken" + 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)) + if videoName == "" { + return nil, errors.New("parameter videoName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{videoName}", url.PathEscape(videoName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listContentTokenHandleResponse handles the ListContentToken response. +func (client *VideosClient) listContentTokenHandleResponse(resp *http.Response) (VideosListContentTokenResponse, error) { + result := VideosListContentTokenResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoContentToken); err != nil { + return VideosListContentTokenResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listContentTokenHandleError handles the ListContentToken error response. +func (client *VideosClient) listContentTokenHandleError(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 individual properties of an existing video resource with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *VideosClient) Update(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity, options *VideosUpdateOptions) (VideosUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, videoName, parameters, options) + if err != nil { + return VideosUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VideosUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VideosUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *VideosClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity, options *VideosUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}" + 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)) + if videoName == "" { + return nil, errors.New("parameter videoName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{videoName}", url.PathEscape(videoName)) + 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-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *VideosClient) updateHandleResponse(resp *http.Response) (VideosUpdateResponse, error) { + result := VideosUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.VideoEntity); err != nil { + return VideosUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *VideosClient) 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) +}