[Release] sdk/resourcemanager/maintenance/armmaintenance/0.1.0 generation from spec commit: cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8 (#16440)
This commit is contained in:
Родитель
a397c681bd
Коммит
17bd7f44d1
|
@ -0,0 +1,5 @@
|
|||
# Release History
|
||||
|
||||
## 0.1.0 (2021-12-07)
|
||||
|
||||
- Init release.
|
|
@ -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.
|
|
@ -0,0 +1,75 @@
|
|||
# Azure Maintenance Module for Go
|
||||
|
||||
[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance)
|
||||
|
||||
The `armmaintenance` module provides operations for working with Azure Maintenance.
|
||||
|
||||
[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/maintenance/armmaintenance)
|
||||
|
||||
# Getting started
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- an [Azure subscription](https://azure.microsoft.com/free/)
|
||||
- Go 1.13 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 Maintenance module:
|
||||
|
||||
```sh
|
||||
go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance
|
||||
```
|
||||
|
||||
## Authorization
|
||||
|
||||
When creating a client, you will need to provide a credential for authenticating with Azure Maintenance. 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 Maintenance 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 := armmaintenance.NewApplyUpdatesClient(<subscription ID>, 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 := armmaintenance.NewApplyUpdatesClient(<subscription ID>, 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 `Maintenance` 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.
|
|
@ -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/cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8/specification/maintenance/resource-manager/readme.md
|
||||
- https://github.com/Azure/azure-rest-api-specs/blob/cf36bdc6bc70308a3f05f6399efe21a0e1e9b7d8/specification/maintenance/resource-manager/readme.go.md
|
||||
license-header: MICROSOFT_MIT_NO_VERSION
|
||||
module-version: 0.1.0
|
||||
|
||||
```
|
|
@ -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/maintenance/armmaintenance
|
||||
|
||||
package armmaintenance
|
|
@ -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/maintenance/armmaintenance/
|
||||
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
- feature/*
|
||||
- hotfix/*
|
||||
- release/*
|
||||
paths:
|
||||
include:
|
||||
- sdk/resourcemanager/maintenance/armmaintenance/
|
||||
|
||||
stages:
|
||||
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
|
||||
parameters:
|
||||
ServiceDirectory: 'resourcemanager/maintenance/armmaintenance'
|
|
@ -0,0 +1,9 @@
|
|||
module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go v60.0.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
|
||||
)
|
|
@ -0,0 +1,45 @@
|
|||
github.com/Azure/azure-sdk-for-go v60.0.0+incompatible h1:vVRJhSSTwhIHQTzTjqoZCItFJeBwfdNSqHcgGV10FHQ=
|
||||
github.com/Azure/azure-sdk-for-go v60.0.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=
|
|
@ -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 armmaintenance
|
||||
|
||||
// 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"
|
|
@ -0,0 +1,33 @@
|
|||
//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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ApplyUpdatesResourceGroup_List.json
|
||||
func ExampleApplyUpdateForResourceGroupClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewApplyUpdateForResourceGroupClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
"<resource-group-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
//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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ApplyUpdates_GetParent.json
|
||||
func ExampleApplyUpdatesClient_GetParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewApplyUpdatesClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<apply-update-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ApplyUpdate.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ApplyUpdates_Get.json
|
||||
func ExampleApplyUpdatesClient_Get() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewApplyUpdatesClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Get(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<apply-update-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ApplyUpdate.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ApplyUpdates_CreateOrUpdateParent.json
|
||||
func ExampleApplyUpdatesClient_CreateOrUpdateParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewApplyUpdatesClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdateParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ApplyUpdate.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ApplyUpdates_CreateOrUpdate.json
|
||||
func ExampleApplyUpdatesClient_CreateOrUpdate() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewApplyUpdatesClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdate(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ApplyUpdate.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ApplyUpdates_List.json
|
||||
func ExampleApplyUpdatesClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewApplyUpdatesClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
//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 armmaintenance_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/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_GetParent.json
|
||||
func ExampleConfigurationAssignmentsClient_GetParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<configuration-assignment-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ConfigurationAssignment.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_CreateOrUpdateParent.json
|
||||
func ExampleConfigurationAssignmentsClient_CreateOrUpdateParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdateParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<configuration-assignment-name>",
|
||||
armmaintenance.ConfigurationAssignment{
|
||||
Properties: &armmaintenance.ConfigurationAssignmentProperties{
|
||||
MaintenanceConfigurationID: to.StringPtr("<maintenance-configuration-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ConfigurationAssignment.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_DeleteParent.json
|
||||
func ExampleConfigurationAssignmentsClient_DeleteParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.DeleteParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<configuration-assignment-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ConfigurationAssignment.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_Get.json
|
||||
func ExampleConfigurationAssignmentsClient_Get() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Get(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<configuration-assignment-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ConfigurationAssignment.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_CreateOrUpdate.json
|
||||
func ExampleConfigurationAssignmentsClient_CreateOrUpdate() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdate(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<configuration-assignment-name>",
|
||||
armmaintenance.ConfigurationAssignment{
|
||||
Properties: &armmaintenance.ConfigurationAssignmentProperties{
|
||||
MaintenanceConfigurationID: to.StringPtr("<maintenance-configuration-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ConfigurationAssignment.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_Delete.json
|
||||
func ExampleConfigurationAssignmentsClient_Delete() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Delete(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
"<configuration-assignment-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("ConfigurationAssignment.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_ListParent.json
|
||||
func ExampleConfigurationAssignmentsClient_ListParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.ListParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignments_List.json
|
||||
func ExampleConfigurationAssignmentsClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/ConfigurationAssignmentsResultWithinSubscription_List.json
|
||||
func ExampleConfigurationAssignmentsWithinSubscriptionClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewConfigurationAssignmentsWithinSubscriptionClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
//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 armmaintenance_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/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/MaintenanceConfigurations_GetForResource.json
|
||||
func ExampleMaintenanceConfigurationsClient_Get() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Get(ctx,
|
||||
"<resource-group-name>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("MaintenanceConfiguration.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/MaintenanceConfigurations_CreateOrUpdateForResource.json
|
||||
func ExampleMaintenanceConfigurationsClient_CreateOrUpdate() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdate(ctx,
|
||||
"<resource-group-name>",
|
||||
"<resource-name>",
|
||||
armmaintenance.MaintenanceConfiguration{
|
||||
Location: to.StringPtr("<location>"),
|
||||
Properties: &armmaintenance.MaintenanceConfigurationProperties{
|
||||
MaintenanceScope: armmaintenance.MaintenanceScopeOSImage.ToPtr(),
|
||||
MaintenanceWindow: &armmaintenance.MaintenanceWindow{
|
||||
Duration: to.StringPtr("<duration>"),
|
||||
ExpirationDateTime: to.StringPtr("<expiration-date-time>"),
|
||||
RecurEvery: to.StringPtr("<recur-every>"),
|
||||
StartDateTime: to.StringPtr("<start-date-time>"),
|
||||
TimeZone: to.StringPtr("<time-zone>"),
|
||||
},
|
||||
Namespace: to.StringPtr("<namespace>"),
|
||||
Visibility: armmaintenance.VisibilityCustom.ToPtr(),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("MaintenanceConfiguration.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/MaintenanceConfigurations_DeleteForResource.json
|
||||
func ExampleMaintenanceConfigurationsClient_Delete() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Delete(ctx,
|
||||
"<resource-group-name>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("MaintenanceConfiguration.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/MaintenanceConfigurations_UpdateForResource.json
|
||||
func ExampleMaintenanceConfigurationsClient_Update() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Update(ctx,
|
||||
"<resource-group-name>",
|
||||
"<resource-name>",
|
||||
armmaintenance.MaintenanceConfiguration{
|
||||
Location: to.StringPtr("<location>"),
|
||||
Properties: &armmaintenance.MaintenanceConfigurationProperties{
|
||||
MaintenanceScope: armmaintenance.MaintenanceScopeOSImage.ToPtr(),
|
||||
MaintenanceWindow: &armmaintenance.MaintenanceWindow{
|
||||
Duration: to.StringPtr("<duration>"),
|
||||
ExpirationDateTime: to.StringPtr("<expiration-date-time>"),
|
||||
RecurEvery: to.StringPtr("<recur-every>"),
|
||||
StartDateTime: to.StringPtr("<start-date-time>"),
|
||||
TimeZone: to.StringPtr("<time-zone>"),
|
||||
},
|
||||
Namespace: to.StringPtr("<namespace>"),
|
||||
Visibility: armmaintenance.VisibilityCustom.ToPtr(),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("MaintenanceConfiguration.ID: %s\n", *res.ID)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/MaintenanceConfigurations_List.json
|
||||
func ExampleMaintenanceConfigurationsClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
//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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/MaintenanceConfigurationsResourceGroup_List.json
|
||||
func ExampleMaintenanceConfigurationsForResourceGroupClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewMaintenanceConfigurationsForResourceGroupClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
"<resource-group-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/Operations_List.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 := armmaintenance.NewOperationsClient(cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
//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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/PublicMaintenanceConfigurations_List.json
|
||||
func ExamplePublicMaintenanceConfigurationsClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewPublicMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/PublicMaintenanceConfigurations_GetForResource.json
|
||||
func ExamplePublicMaintenanceConfigurationsClient_Get() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewPublicMaintenanceConfigurationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.Get(ctx,
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("MaintenanceConfiguration.ID: %s\n", *res.ID)
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
//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 armmaintenance_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/Updates_ListParent.json
|
||||
func ExampleUpdatesClient_ListParent() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewUpdatesClient("<subscription-id>", cred, nil)
|
||||
_, err = client.ListParent(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-parent-type>",
|
||||
"<resource-parent-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2021-09-01-preview/examples/Updates_List.json
|
||||
func ExampleUpdatesClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armmaintenance.NewUpdatesClient("<subscription-id>", cred, nil)
|
||||
_, err = client.List(ctx,
|
||||
"<resource-group-name>",
|
||||
"<provider-name>",
|
||||
"<resource-type>",
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// ApplyUpdateForResourceGroupClient contains the methods for the ApplyUpdateForResourceGroup group.
|
||||
// Don't use this type directly, use NewApplyUpdateForResourceGroupClient() instead.
|
||||
type ApplyUpdateForResourceGroupClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewApplyUpdateForResourceGroupClient creates a new instance of ApplyUpdateForResourceGroupClient with the specified values.
|
||||
func NewApplyUpdateForResourceGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ApplyUpdateForResourceGroupClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &ApplyUpdateForResourceGroupClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// List - Get Configuration records within a subscription and resource group
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ApplyUpdateForResourceGroupClient) List(ctx context.Context, resourceGroupName string, options *ApplyUpdateForResourceGroupListOptions) (ApplyUpdateForResourceGroupListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, resourceGroupName, options)
|
||||
if err != nil {
|
||||
return ApplyUpdateForResourceGroupListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ApplyUpdateForResourceGroupListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ApplyUpdateForResourceGroupListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *ApplyUpdateForResourceGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *ApplyUpdateForResourceGroupListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates"
|
||||
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-09-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 *ApplyUpdateForResourceGroupClient) listHandleResponse(resp *http.Response) (ApplyUpdateForResourceGroupListResponse, error) {
|
||||
result := ApplyUpdateForResourceGroupListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListApplyUpdate); err != nil {
|
||||
return ApplyUpdateForResourceGroupListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *ApplyUpdateForResourceGroupClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,416 @@
|
|||
//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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// ApplyUpdatesClient contains the methods for the ApplyUpdates group.
|
||||
// Don't use this type directly, use NewApplyUpdatesClient() instead.
|
||||
type ApplyUpdatesClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewApplyUpdatesClient creates a new instance of ApplyUpdatesClient with the specified values.
|
||||
func NewApplyUpdatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ApplyUpdatesClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &ApplyUpdatesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate - Apply maintenance updates to resource
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ApplyUpdatesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ApplyUpdatesCreateOrUpdateOptions) (ApplyUpdatesCreateOrUpdateResponse, error) {
|
||||
req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, options)
|
||||
if err != nil {
|
||||
return ApplyUpdatesCreateOrUpdateResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ApplyUpdatesCreateOrUpdateResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ApplyUpdatesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp)
|
||||
}
|
||||
return client.createOrUpdateHandleResponse(resp)
|
||||
}
|
||||
|
||||
// createOrUpdateCreateRequest creates the CreateOrUpdate request.
|
||||
func (client *ApplyUpdatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ApplyUpdatesCreateOrUpdateOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// createOrUpdateHandleResponse handles the CreateOrUpdate response.
|
||||
func (client *ApplyUpdatesClient) createOrUpdateHandleResponse(resp *http.Response) (ApplyUpdatesCreateOrUpdateResponse, error) {
|
||||
result := ApplyUpdatesCreateOrUpdateResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {
|
||||
return ApplyUpdatesCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createOrUpdateHandleError handles the CreateOrUpdate error response.
|
||||
func (client *ApplyUpdatesClient) createOrUpdateHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// CreateOrUpdateParent - Apply maintenance updates to resource with parent
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ApplyUpdatesClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ApplyUpdatesCreateOrUpdateParentOptions) (ApplyUpdatesCreateOrUpdateParentResponse, error) {
|
||||
req, err := client.createOrUpdateParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options)
|
||||
if err != nil {
|
||||
return ApplyUpdatesCreateOrUpdateParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ApplyUpdatesCreateOrUpdateParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ApplyUpdatesCreateOrUpdateParentResponse{}, client.createOrUpdateParentHandleError(resp)
|
||||
}
|
||||
return client.createOrUpdateParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// createOrUpdateParentCreateRequest creates the CreateOrUpdateParent request.
|
||||
func (client *ApplyUpdatesClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ApplyUpdatesCreateOrUpdateParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// createOrUpdateParentHandleResponse handles the CreateOrUpdateParent response.
|
||||
func (client *ApplyUpdatesClient) createOrUpdateParentHandleResponse(resp *http.Response) (ApplyUpdatesCreateOrUpdateParentResponse, error) {
|
||||
result := ApplyUpdatesCreateOrUpdateParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {
|
||||
return ApplyUpdatesCreateOrUpdateParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createOrUpdateParentHandleError handles the CreateOrUpdateParent error response.
|
||||
func (client *ApplyUpdatesClient) createOrUpdateParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 - Track maintenance updates to resource
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ApplyUpdatesClient) Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesGetOptions) (ApplyUpdatesGetResponse, error) {
|
||||
req, err := client.getCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, applyUpdateName, options)
|
||||
if err != nil {
|
||||
return ApplyUpdatesGetResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ApplyUpdatesGetResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ApplyUpdatesGetResponse{}, client.getHandleError(resp)
|
||||
}
|
||||
return client.getHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getCreateRequest creates the Get request.
|
||||
func (client *ApplyUpdatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesGetOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if applyUpdateName == "" {
|
||||
return nil, errors.New("parameter applyUpdateName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{applyUpdateName}", url.PathEscape(applyUpdateName))
|
||||
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-09-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 *ApplyUpdatesClient) getHandleResponse(resp *http.Response) (ApplyUpdatesGetResponse, error) {
|
||||
result := ApplyUpdatesGetResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {
|
||||
return ApplyUpdatesGetResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getHandleError handles the Get error response.
|
||||
func (client *ApplyUpdatesClient) getHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// GetParent - Track maintenance updates to resource with parent
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ApplyUpdatesClient) GetParent(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesGetParentOptions) (ApplyUpdatesGetParentResponse, error) {
|
||||
req, err := client.getParentCreateRequest(ctx, resourceGroupName, resourceParentType, resourceParentName, providerName, resourceType, resourceName, applyUpdateName, options)
|
||||
if err != nil {
|
||||
return ApplyUpdatesGetParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ApplyUpdatesGetParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ApplyUpdatesGetParentResponse{}, client.getParentHandleError(resp)
|
||||
}
|
||||
return client.getParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getParentCreateRequest creates the GetParent request.
|
||||
func (client *ApplyUpdatesClient) getParentCreateRequest(ctx context.Context, resourceGroupName string, resourceParentType string, resourceParentName string, providerName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesGetParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"
|
||||
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 resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if applyUpdateName == "" {
|
||||
return nil, errors.New("parameter applyUpdateName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{applyUpdateName}", url.PathEscape(applyUpdateName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getParentHandleResponse handles the GetParent response.
|
||||
func (client *ApplyUpdatesClient) getParentHandleResponse(resp *http.Response) (ApplyUpdatesGetParentResponse, error) {
|
||||
result := ApplyUpdatesGetParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {
|
||||
return ApplyUpdatesGetParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getParentHandleError handles the GetParent error response.
|
||||
func (client *ApplyUpdatesClient) getParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 Configuration records within a subscription
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ApplyUpdatesClient) List(ctx context.Context, options *ApplyUpdatesListOptions) (ApplyUpdatesListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, options)
|
||||
if err != nil {
|
||||
return ApplyUpdatesListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ApplyUpdatesListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ApplyUpdatesListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *ApplyUpdatesClient) listCreateRequest(ctx context.Context, options *ApplyUpdatesListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"
|
||||
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-09-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 *ApplyUpdatesClient) listHandleResponse(resp *http.Response) (ApplyUpdatesListResponse, error) {
|
||||
result := ApplyUpdatesListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListApplyUpdate); err != nil {
|
||||
return ApplyUpdatesListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *ApplyUpdatesClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,683 @@
|
|||
//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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// ConfigurationAssignmentsClient contains the methods for the ConfigurationAssignments group.
|
||||
// Don't use this type directly, use NewConfigurationAssignmentsClient() instead.
|
||||
type ConfigurationAssignmentsClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewConfigurationAssignmentsClient creates a new instance of ConfigurationAssignmentsClient with the specified values.
|
||||
func NewConfigurationAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ConfigurationAssignmentsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &ConfigurationAssignmentsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate - Register configuration for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsCreateOrUpdateOptions) (ConfigurationAssignmentsCreateOrUpdateResponse, error) {
|
||||
req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, configurationAssignment, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsCreateOrUpdateResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsCreateOrUpdateResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp)
|
||||
}
|
||||
return client.createOrUpdateHandleResponse(resp)
|
||||
}
|
||||
|
||||
// createOrUpdateCreateRequest creates the CreateOrUpdate request.
|
||||
func (client *ConfigurationAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsCreateOrUpdateOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if configurationAssignmentName == "" {
|
||||
return nil, errors.New("parameter configurationAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{configurationAssignmentName}", url.PathEscape(configurationAssignmentName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, configurationAssignment)
|
||||
}
|
||||
|
||||
// createOrUpdateHandleResponse handles the CreateOrUpdate response.
|
||||
func (client *ConfigurationAssignmentsClient) createOrUpdateHandleResponse(resp *http.Response) (ConfigurationAssignmentsCreateOrUpdateResponse, error) {
|
||||
result := ConfigurationAssignmentsCreateOrUpdateResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationAssignment); err != nil {
|
||||
return ConfigurationAssignmentsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createOrUpdateHandleError handles the CreateOrUpdate error response.
|
||||
func (client *ConfigurationAssignmentsClient) createOrUpdateHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// CreateOrUpdateParent - Register configuration for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsCreateOrUpdateParentOptions) (ConfigurationAssignmentsCreateOrUpdateParentResponse, error) {
|
||||
req, err := client.createOrUpdateParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, configurationAssignment, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsCreateOrUpdateParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsCreateOrUpdateParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsCreateOrUpdateParentResponse{}, client.createOrUpdateParentHandleError(resp)
|
||||
}
|
||||
return client.createOrUpdateParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// createOrUpdateParentCreateRequest creates the CreateOrUpdateParent request.
|
||||
func (client *ConfigurationAssignmentsClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsCreateOrUpdateParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if configurationAssignmentName == "" {
|
||||
return nil, errors.New("parameter configurationAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{configurationAssignmentName}", url.PathEscape(configurationAssignmentName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, configurationAssignment)
|
||||
}
|
||||
|
||||
// createOrUpdateParentHandleResponse handles the CreateOrUpdateParent response.
|
||||
func (client *ConfigurationAssignmentsClient) createOrUpdateParentHandleResponse(resp *http.Response) (ConfigurationAssignmentsCreateOrUpdateParentResponse, error) {
|
||||
result := ConfigurationAssignmentsCreateOrUpdateParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationAssignment); err != nil {
|
||||
return ConfigurationAssignmentsCreateOrUpdateParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createOrUpdateParentHandleError handles the CreateOrUpdateParent error response.
|
||||
func (client *ConfigurationAssignmentsClient) createOrUpdateParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 - Unregister configuration for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsDeleteOptions) (ConfigurationAssignmentsDeleteResponse, error) {
|
||||
req, err := client.deleteCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsDeleteResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsDeleteResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
|
||||
return ConfigurationAssignmentsDeleteResponse{}, client.deleteHandleError(resp)
|
||||
}
|
||||
return client.deleteHandleResponse(resp)
|
||||
}
|
||||
|
||||
// deleteCreateRequest creates the Delete request.
|
||||
func (client *ConfigurationAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsDeleteOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if configurationAssignmentName == "" {
|
||||
return nil, errors.New("parameter configurationAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{configurationAssignmentName}", url.PathEscape(configurationAssignmentName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// deleteHandleResponse handles the Delete response.
|
||||
func (client *ConfigurationAssignmentsClient) deleteHandleResponse(resp *http.Response) (ConfigurationAssignmentsDeleteResponse, error) {
|
||||
result := ConfigurationAssignmentsDeleteResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationAssignment); err != nil {
|
||||
return ConfigurationAssignmentsDeleteResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// deleteHandleError handles the Delete error response.
|
||||
func (client *ConfigurationAssignmentsClient) deleteHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// DeleteParent - Unregister configuration for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) DeleteParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsDeleteParentOptions) (ConfigurationAssignmentsDeleteParentResponse, error) {
|
||||
req, err := client.deleteParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsDeleteParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsDeleteParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
|
||||
return ConfigurationAssignmentsDeleteParentResponse{}, client.deleteParentHandleError(resp)
|
||||
}
|
||||
return client.deleteParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// deleteParentCreateRequest creates the DeleteParent request.
|
||||
func (client *ConfigurationAssignmentsClient) deleteParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsDeleteParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if configurationAssignmentName == "" {
|
||||
return nil, errors.New("parameter configurationAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{configurationAssignmentName}", url.PathEscape(configurationAssignmentName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// deleteParentHandleResponse handles the DeleteParent response.
|
||||
func (client *ConfigurationAssignmentsClient) deleteParentHandleResponse(resp *http.Response) (ConfigurationAssignmentsDeleteParentResponse, error) {
|
||||
result := ConfigurationAssignmentsDeleteParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationAssignment); err != nil {
|
||||
return ConfigurationAssignmentsDeleteParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// deleteParentHandleError handles the DeleteParent error response.
|
||||
func (client *ConfigurationAssignmentsClient) deleteParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 configuration for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsGetOptions) (ConfigurationAssignmentsGetResponse, error) {
|
||||
req, err := client.getCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsGetResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsGetResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsGetResponse{}, client.getHandleError(resp)
|
||||
}
|
||||
return client.getHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getCreateRequest creates the Get request.
|
||||
func (client *ConfigurationAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsGetOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if configurationAssignmentName == "" {
|
||||
return nil, errors.New("parameter configurationAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{configurationAssignmentName}", url.PathEscape(configurationAssignmentName))
|
||||
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-09-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 *ConfigurationAssignmentsClient) getHandleResponse(resp *http.Response) (ConfigurationAssignmentsGetResponse, error) {
|
||||
result := ConfigurationAssignmentsGetResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationAssignment); err != nil {
|
||||
return ConfigurationAssignmentsGetResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getHandleError handles the Get error response.
|
||||
func (client *ConfigurationAssignmentsClient) getHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// GetParent - Get configuration for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) GetParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsGetParentOptions) (ConfigurationAssignmentsGetParentResponse, error) {
|
||||
req, err := client.getParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsGetParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsGetParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsGetParentResponse{}, client.getParentHandleError(resp)
|
||||
}
|
||||
return client.getParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getParentCreateRequest creates the GetParent request.
|
||||
func (client *ConfigurationAssignmentsClient) getParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsGetParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
if configurationAssignmentName == "" {
|
||||
return nil, errors.New("parameter configurationAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{configurationAssignmentName}", url.PathEscape(configurationAssignmentName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getParentHandleResponse handles the GetParent response.
|
||||
func (client *ConfigurationAssignmentsClient) getParentHandleResponse(resp *http.Response) (ConfigurationAssignmentsGetParentResponse, error) {
|
||||
result := ConfigurationAssignmentsGetParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationAssignment); err != nil {
|
||||
return ConfigurationAssignmentsGetParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getParentHandleError handles the GetParent error response.
|
||||
func (client *ConfigurationAssignmentsClient) getParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 configurationAssignments for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ConfigurationAssignmentsListOptions) (ConfigurationAssignmentsListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *ConfigurationAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ConfigurationAssignmentsListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-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 *ConfigurationAssignmentsClient) listHandleResponse(resp *http.Response) (ConfigurationAssignmentsListResponse, error) {
|
||||
result := ConfigurationAssignmentsListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListConfigurationAssignmentsResult); err != nil {
|
||||
return ConfigurationAssignmentsListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *ConfigurationAssignmentsClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// ListParent - List configurationAssignments for resource.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ConfigurationAssignmentsListParentOptions) (ConfigurationAssignmentsListParentResponse, error) {
|
||||
req, err := client.listParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsListParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsListParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsListParentResponse{}, client.listParentHandleError(resp)
|
||||
}
|
||||
return client.listParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listParentCreateRequest creates the ListParent request.
|
||||
func (client *ConfigurationAssignmentsClient) listParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ConfigurationAssignmentsListParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listParentHandleResponse handles the ListParent response.
|
||||
func (client *ConfigurationAssignmentsClient) listParentHandleResponse(resp *http.Response) (ConfigurationAssignmentsListParentResponse, error) {
|
||||
result := ConfigurationAssignmentsListParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListConfigurationAssignmentsResult); err != nil {
|
||||
return ConfigurationAssignmentsListParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listParentHandleError handles the ListParent error response.
|
||||
func (client *ConfigurationAssignmentsClient) listParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
//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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// ConfigurationAssignmentsWithinSubscriptionClient contains the methods for the ConfigurationAssignmentsWithinSubscription group.
|
||||
// Don't use this type directly, use NewConfigurationAssignmentsWithinSubscriptionClient() instead.
|
||||
type ConfigurationAssignmentsWithinSubscriptionClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewConfigurationAssignmentsWithinSubscriptionClient creates a new instance of ConfigurationAssignmentsWithinSubscriptionClient with the specified values.
|
||||
func NewConfigurationAssignmentsWithinSubscriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ConfigurationAssignmentsWithinSubscriptionClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &ConfigurationAssignmentsWithinSubscriptionClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// List - Get configuration assignment within a subscription
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *ConfigurationAssignmentsWithinSubscriptionClient) List(ctx context.Context, options *ConfigurationAssignmentsWithinSubscriptionListOptions) (ConfigurationAssignmentsWithinSubscriptionListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, options)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsWithinSubscriptionListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return ConfigurationAssignmentsWithinSubscriptionListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return ConfigurationAssignmentsWithinSubscriptionListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *ConfigurationAssignmentsWithinSubscriptionClient) listCreateRequest(ctx context.Context, options *ConfigurationAssignmentsWithinSubscriptionListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"
|
||||
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-09-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 *ConfigurationAssignmentsWithinSubscriptionClient) listHandleResponse(resp *http.Response) (ConfigurationAssignmentsWithinSubscriptionListResponse, error) {
|
||||
result := ConfigurationAssignmentsWithinSubscriptionListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListConfigurationAssignmentsResult); err != nil {
|
||||
return ConfigurationAssignmentsWithinSubscriptionListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *ConfigurationAssignmentsWithinSubscriptionClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
//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 armmaintenance
|
||||
|
||||
const (
|
||||
module = "armmaintenance"
|
||||
version = "v0.1.0"
|
||||
)
|
||||
|
||||
// CreatedByType - The type of identity that created the resource.
|
||||
type CreatedByType string
|
||||
|
||||
const (
|
||||
CreatedByTypeApplication CreatedByType = "Application"
|
||||
CreatedByTypeKey CreatedByType = "Key"
|
||||
CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity"
|
||||
CreatedByTypeUser CreatedByType = "User"
|
||||
)
|
||||
|
||||
// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type.
|
||||
func PossibleCreatedByTypeValues() []CreatedByType {
|
||||
return []CreatedByType{
|
||||
CreatedByTypeApplication,
|
||||
CreatedByTypeKey,
|
||||
CreatedByTypeManagedIdentity,
|
||||
CreatedByTypeUser,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *CreatedByType pointing to the current value.
|
||||
func (c CreatedByType) ToPtr() *CreatedByType {
|
||||
return &c
|
||||
}
|
||||
|
||||
// ImpactType - The impact type
|
||||
type ImpactType string
|
||||
|
||||
const (
|
||||
// ImpactTypeFreeze - Pending updates can freeze network or disk io operation on resource.
|
||||
ImpactTypeFreeze ImpactType = "Freeze"
|
||||
// ImpactTypeNone - Pending updates has no impact on resource.
|
||||
ImpactTypeNone ImpactType = "None"
|
||||
// ImpactTypeRedeploy - Pending updates can redeploy resource.
|
||||
ImpactTypeRedeploy ImpactType = "Redeploy"
|
||||
// ImpactTypeRestart - Pending updates can cause resource to restart.
|
||||
ImpactTypeRestart ImpactType = "Restart"
|
||||
)
|
||||
|
||||
// PossibleImpactTypeValues returns the possible values for the ImpactType const type.
|
||||
func PossibleImpactTypeValues() []ImpactType {
|
||||
return []ImpactType{
|
||||
ImpactTypeFreeze,
|
||||
ImpactTypeNone,
|
||||
ImpactTypeRedeploy,
|
||||
ImpactTypeRestart,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *ImpactType pointing to the current value.
|
||||
func (c ImpactType) ToPtr() *ImpactType {
|
||||
return &c
|
||||
}
|
||||
|
||||
// MaintenanceScope - Gets or sets maintenanceScope of the configuration
|
||||
type MaintenanceScope string
|
||||
|
||||
const (
|
||||
// MaintenanceScopeExtension - This maintenance scope controls extension installation on VM/VMSS
|
||||
MaintenanceScopeExtension MaintenanceScope = "Extension"
|
||||
// MaintenanceScopeHost - This maintenance scope controls installation of azure platform updates i.e. services on physical nodes hosting customer VMs.
|
||||
MaintenanceScopeHost MaintenanceScope = "Host"
|
||||
// MaintenanceScopeInGuestPatch - This maintenance scope controls installation of windows and linux packages on VM/VMSS
|
||||
MaintenanceScopeInGuestPatch MaintenanceScope = "InGuestPatch"
|
||||
// MaintenanceScopeOSImage - This maintenance scope controls os image installation on VM/VMSS
|
||||
MaintenanceScopeOSImage MaintenanceScope = "OSImage"
|
||||
// MaintenanceScopeSQLDB - This maintenance scope controls installation of SQL server platform updates.
|
||||
MaintenanceScopeSQLDB MaintenanceScope = "SQLDB"
|
||||
// MaintenanceScopeSQLManagedInstance - This maintenance scope controls installation of SQL managed instance platform update.
|
||||
MaintenanceScopeSQLManagedInstance MaintenanceScope = "SQLManagedInstance"
|
||||
)
|
||||
|
||||
// PossibleMaintenanceScopeValues returns the possible values for the MaintenanceScope const type.
|
||||
func PossibleMaintenanceScopeValues() []MaintenanceScope {
|
||||
return []MaintenanceScope{
|
||||
MaintenanceScopeExtension,
|
||||
MaintenanceScopeHost,
|
||||
MaintenanceScopeInGuestPatch,
|
||||
MaintenanceScopeOSImage,
|
||||
MaintenanceScopeSQLDB,
|
||||
MaintenanceScopeSQLManagedInstance,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *MaintenanceScope pointing to the current value.
|
||||
func (c MaintenanceScope) ToPtr() *MaintenanceScope {
|
||||
return &c
|
||||
}
|
||||
|
||||
// RebootOptions - Possible reboot preference as defined by the user based on which it would be decided to reboot the machine or not after the patch operation
|
||||
// is completed.
|
||||
type RebootOptions string
|
||||
|
||||
const (
|
||||
RebootOptionsAlways RebootOptions = "Always"
|
||||
RebootOptionsIfRequired RebootOptions = "IfRequired"
|
||||
RebootOptionsNever RebootOptions = "Never"
|
||||
)
|
||||
|
||||
// PossibleRebootOptionsValues returns the possible values for the RebootOptions const type.
|
||||
func PossibleRebootOptionsValues() []RebootOptions {
|
||||
return []RebootOptions{
|
||||
RebootOptionsAlways,
|
||||
RebootOptionsIfRequired,
|
||||
RebootOptionsNever,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *RebootOptions pointing to the current value.
|
||||
func (c RebootOptions) ToPtr() *RebootOptions {
|
||||
return &c
|
||||
}
|
||||
|
||||
// TaskScope - Global Task execute once when schedule trigger. Resource task execute for each VM.
|
||||
type TaskScope string
|
||||
|
||||
const (
|
||||
TaskScopeGlobal TaskScope = "Global"
|
||||
TaskScopeResource TaskScope = "Resource"
|
||||
)
|
||||
|
||||
// PossibleTaskScopeValues returns the possible values for the TaskScope const type.
|
||||
func PossibleTaskScopeValues() []TaskScope {
|
||||
return []TaskScope{
|
||||
TaskScopeGlobal,
|
||||
TaskScopeResource,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *TaskScope pointing to the current value.
|
||||
func (c TaskScope) ToPtr() *TaskScope {
|
||||
return &c
|
||||
}
|
||||
|
||||
// UpdateStatus - The status
|
||||
type UpdateStatus string
|
||||
|
||||
const (
|
||||
// UpdateStatusCompleted - All updates are successfully applied.
|
||||
UpdateStatusCompleted UpdateStatus = "Completed"
|
||||
// UpdateStatusInProgress - Updates installation are in progress.
|
||||
UpdateStatusInProgress UpdateStatus = "InProgress"
|
||||
// UpdateStatusPending - There are pending updates to be installed.
|
||||
UpdateStatusPending UpdateStatus = "Pending"
|
||||
// UpdateStatusRetryLater - Updates installation failed and should be retried later.
|
||||
UpdateStatusRetryLater UpdateStatus = "RetryLater"
|
||||
// UpdateStatusRetryNow - Updates installation failed but are ready to retry again.
|
||||
UpdateStatusRetryNow UpdateStatus = "RetryNow"
|
||||
)
|
||||
|
||||
// PossibleUpdateStatusValues returns the possible values for the UpdateStatus const type.
|
||||
func PossibleUpdateStatusValues() []UpdateStatus {
|
||||
return []UpdateStatus{
|
||||
UpdateStatusCompleted,
|
||||
UpdateStatusInProgress,
|
||||
UpdateStatusPending,
|
||||
UpdateStatusRetryLater,
|
||||
UpdateStatusRetryNow,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *UpdateStatus pointing to the current value.
|
||||
func (c UpdateStatus) ToPtr() *UpdateStatus {
|
||||
return &c
|
||||
}
|
||||
|
||||
// Visibility - Gets or sets the visibility of the configuration. The default value is 'Custom'
|
||||
type Visibility string
|
||||
|
||||
const (
|
||||
// VisibilityCustom - Only visible to users with permissions.
|
||||
VisibilityCustom Visibility = "Custom"
|
||||
// VisibilityPublic - Visible to all users.
|
||||
VisibilityPublic Visibility = "Public"
|
||||
)
|
||||
|
||||
// PossibleVisibilityValues returns the possible values for the Visibility const type.
|
||||
func PossibleVisibilityValues() []Visibility {
|
||||
return []Visibility{
|
||||
VisibilityCustom,
|
||||
VisibilityPublic,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *Visibility pointing to the current value.
|
||||
func (c Visibility) ToPtr() *Visibility {
|
||||
return &c
|
||||
}
|
|
@ -0,0 +1,360 @@
|
|||
//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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// MaintenanceConfigurationsClient contains the methods for the MaintenanceConfigurations group.
|
||||
// Don't use this type directly, use NewMaintenanceConfigurationsClient() instead.
|
||||
type MaintenanceConfigurationsClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewMaintenanceConfigurationsClient creates a new instance of MaintenanceConfigurationsClient with the specified values.
|
||||
func NewMaintenanceConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *MaintenanceConfigurationsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &MaintenanceConfigurationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate - Create or Update configuration record
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *MaintenanceConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, configuration MaintenanceConfiguration, options *MaintenanceConfigurationsCreateOrUpdateOptions) (MaintenanceConfigurationsCreateOrUpdateResponse, error) {
|
||||
req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, configuration, options)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsCreateOrUpdateResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsCreateOrUpdateResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return MaintenanceConfigurationsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp)
|
||||
}
|
||||
return client.createOrUpdateHandleResponse(resp)
|
||||
}
|
||||
|
||||
// createOrUpdateCreateRequest creates the CreateOrUpdate request.
|
||||
func (client *MaintenanceConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, configuration MaintenanceConfiguration, options *MaintenanceConfigurationsCreateOrUpdateOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"
|
||||
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 resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, configuration)
|
||||
}
|
||||
|
||||
// createOrUpdateHandleResponse handles the CreateOrUpdate response.
|
||||
func (client *MaintenanceConfigurationsClient) createOrUpdateHandleResponse(resp *http.Response) (MaintenanceConfigurationsCreateOrUpdateResponse, error) {
|
||||
result := MaintenanceConfigurationsCreateOrUpdateResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.MaintenanceConfiguration); err != nil {
|
||||
return MaintenanceConfigurationsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createOrUpdateHandleError handles the CreateOrUpdate error response.
|
||||
func (client *MaintenanceConfigurationsClient) createOrUpdateHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 Configuration record
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *MaintenanceConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, options *MaintenanceConfigurationsDeleteOptions) (MaintenanceConfigurationsDeleteResponse, error) {
|
||||
req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsDeleteResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsDeleteResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
|
||||
return MaintenanceConfigurationsDeleteResponse{}, client.deleteHandleError(resp)
|
||||
}
|
||||
return client.deleteHandleResponse(resp)
|
||||
}
|
||||
|
||||
// deleteCreateRequest creates the Delete request.
|
||||
func (client *MaintenanceConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *MaintenanceConfigurationsDeleteOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"
|
||||
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 resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// deleteHandleResponse handles the Delete response.
|
||||
func (client *MaintenanceConfigurationsClient) deleteHandleResponse(resp *http.Response) (MaintenanceConfigurationsDeleteResponse, error) {
|
||||
result := MaintenanceConfigurationsDeleteResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.MaintenanceConfiguration); err != nil {
|
||||
return MaintenanceConfigurationsDeleteResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// deleteHandleError handles the Delete error response.
|
||||
func (client *MaintenanceConfigurationsClient) deleteHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 Configuration record
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *MaintenanceConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *MaintenanceConfigurationsGetOptions) (MaintenanceConfigurationsGetResponse, error) {
|
||||
req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsGetResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsGetResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return MaintenanceConfigurationsGetResponse{}, client.getHandleError(resp)
|
||||
}
|
||||
return client.getHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getCreateRequest creates the Get request.
|
||||
func (client *MaintenanceConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *MaintenanceConfigurationsGetOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"
|
||||
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 resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-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 *MaintenanceConfigurationsClient) getHandleResponse(resp *http.Response) (MaintenanceConfigurationsGetResponse, error) {
|
||||
result := MaintenanceConfigurationsGetResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.MaintenanceConfiguration); err != nil {
|
||||
return MaintenanceConfigurationsGetResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getHandleError handles the Get error response.
|
||||
func (client *MaintenanceConfigurationsClient) getHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 Configuration records within a subscription
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *MaintenanceConfigurationsClient) List(ctx context.Context, options *MaintenanceConfigurationsListOptions) (MaintenanceConfigurationsListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, options)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return MaintenanceConfigurationsListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *MaintenanceConfigurationsClient) listCreateRequest(ctx context.Context, options *MaintenanceConfigurationsListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"
|
||||
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-09-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 *MaintenanceConfigurationsClient) listHandleResponse(resp *http.Response) (MaintenanceConfigurationsListResponse, error) {
|
||||
result := MaintenanceConfigurationsListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListMaintenanceConfigurationsResult); err != nil {
|
||||
return MaintenanceConfigurationsListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *MaintenanceConfigurationsClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 - Patch configuration record
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *MaintenanceConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, configuration MaintenanceConfiguration, options *MaintenanceConfigurationsUpdateOptions) (MaintenanceConfigurationsUpdateResponse, error) {
|
||||
req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, configuration, options)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsUpdateResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsUpdateResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return MaintenanceConfigurationsUpdateResponse{}, client.updateHandleError(resp)
|
||||
}
|
||||
return client.updateHandleResponse(resp)
|
||||
}
|
||||
|
||||
// updateCreateRequest creates the Update request.
|
||||
func (client *MaintenanceConfigurationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, configuration MaintenanceConfiguration, options *MaintenanceConfigurationsUpdateOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"
|
||||
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 resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, configuration)
|
||||
}
|
||||
|
||||
// updateHandleResponse handles the Update response.
|
||||
func (client *MaintenanceConfigurationsClient) updateHandleResponse(resp *http.Response) (MaintenanceConfigurationsUpdateResponse, error) {
|
||||
result := MaintenanceConfigurationsUpdateResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.MaintenanceConfiguration); err != nil {
|
||||
return MaintenanceConfigurationsUpdateResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// updateHandleError handles the Update error response.
|
||||
func (client *MaintenanceConfigurationsClient) updateHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// MaintenanceConfigurationsForResourceGroupClient contains the methods for the MaintenanceConfigurationsForResourceGroup group.
|
||||
// Don't use this type directly, use NewMaintenanceConfigurationsForResourceGroupClient() instead.
|
||||
type MaintenanceConfigurationsForResourceGroupClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewMaintenanceConfigurationsForResourceGroupClient creates a new instance of MaintenanceConfigurationsForResourceGroupClient with the specified values.
|
||||
func NewMaintenanceConfigurationsForResourceGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *MaintenanceConfigurationsForResourceGroupClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &MaintenanceConfigurationsForResourceGroupClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// List - Get Configuration records within a subscription and resource group
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *MaintenanceConfigurationsForResourceGroupClient) List(ctx context.Context, resourceGroupName string, options *MaintenanceConfigurationsForResourceGroupListOptions) (MaintenanceConfigurationsForResourceGroupListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, resourceGroupName, options)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsForResourceGroupListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return MaintenanceConfigurationsForResourceGroupListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return MaintenanceConfigurationsForResourceGroupListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *MaintenanceConfigurationsForResourceGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *MaintenanceConfigurationsForResourceGroupListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations"
|
||||
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-09-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 *MaintenanceConfigurationsForResourceGroupClient) listHandleResponse(resp *http.Response) (MaintenanceConfigurationsForResourceGroupListResponse, error) {
|
||||
result := MaintenanceConfigurationsForResourceGroupListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListMaintenanceConfigurationsResult); err != nil {
|
||||
return MaintenanceConfigurationsForResourceGroupListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *MaintenanceConfigurationsForResourceGroupClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,734 @@
|
|||
//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 armmaintenance
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ApplyUpdate - Apply Update request
|
||||
type ApplyUpdate struct {
|
||||
Resource
|
||||
// Properties of the apply update
|
||||
Properties *ApplyUpdateProperties `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ApplyUpdate.
|
||||
func (a ApplyUpdate) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
a.Resource.marshalInternal(objectMap)
|
||||
populate(objectMap, "properties", a.Properties)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// ApplyUpdateForResourceGroupListOptions contains the optional parameters for the ApplyUpdateForResourceGroup.List method.
|
||||
type ApplyUpdateForResourceGroupListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ApplyUpdateProperties - Properties for apply update
|
||||
type ApplyUpdateProperties struct {
|
||||
// Last Update time
|
||||
LastUpdateTime *time.Time `json:"lastUpdateTime,omitempty"`
|
||||
|
||||
// The resourceId
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
|
||||
// The status
|
||||
Status *UpdateStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ApplyUpdateProperties.
|
||||
func (a ApplyUpdateProperties) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populateTimeRFC3339(objectMap, "lastUpdateTime", a.LastUpdateTime)
|
||||
populate(objectMap, "resourceId", a.ResourceID)
|
||||
populate(objectMap, "status", a.Status)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type ApplyUpdateProperties.
|
||||
func (a *ApplyUpdateProperties) 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 "lastUpdateTime":
|
||||
err = unpopulateTimeRFC3339(val, &a.LastUpdateTime)
|
||||
delete(rawMsg, key)
|
||||
case "resourceId":
|
||||
err = unpopulate(val, &a.ResourceID)
|
||||
delete(rawMsg, key)
|
||||
case "status":
|
||||
err = unpopulate(val, &a.Status)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ApplyUpdatesCreateOrUpdateOptions contains the optional parameters for the ApplyUpdates.CreateOrUpdate method.
|
||||
type ApplyUpdatesCreateOrUpdateOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ApplyUpdatesCreateOrUpdateParentOptions contains the optional parameters for the ApplyUpdates.CreateOrUpdateParent method.
|
||||
type ApplyUpdatesCreateOrUpdateParentOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ApplyUpdatesGetOptions contains the optional parameters for the ApplyUpdates.Get method.
|
||||
type ApplyUpdatesGetOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ApplyUpdatesGetParentOptions contains the optional parameters for the ApplyUpdates.GetParent method.
|
||||
type ApplyUpdatesGetParentOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ApplyUpdatesListOptions contains the optional parameters for the ApplyUpdates.List method.
|
||||
type ApplyUpdatesListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignment - Configuration Assignment
|
||||
type ConfigurationAssignment struct {
|
||||
Resource
|
||||
// Location of the resource
|
||||
Location *string `json:"location,omitempty"`
|
||||
|
||||
// Properties of the configuration assignment
|
||||
Properties *ConfigurationAssignmentProperties `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ConfigurationAssignment.
|
||||
func (c ConfigurationAssignment) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
c.Resource.marshalInternal(objectMap)
|
||||
populate(objectMap, "location", c.Location)
|
||||
populate(objectMap, "properties", c.Properties)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentProperties - Properties for configuration assignment
|
||||
type ConfigurationAssignmentProperties struct {
|
||||
// The maintenance configuration Id
|
||||
MaintenanceConfigurationID *string `json:"maintenanceConfigurationId,omitempty"`
|
||||
|
||||
// The unique resourceId
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsCreateOrUpdateOptions contains the optional parameters for the ConfigurationAssignments.CreateOrUpdate method.
|
||||
type ConfigurationAssignmentsCreateOrUpdateOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsCreateOrUpdateParentOptions contains the optional parameters for the ConfigurationAssignments.CreateOrUpdateParent method.
|
||||
type ConfigurationAssignmentsCreateOrUpdateParentOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsDeleteOptions contains the optional parameters for the ConfigurationAssignments.Delete method.
|
||||
type ConfigurationAssignmentsDeleteOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsDeleteParentOptions contains the optional parameters for the ConfigurationAssignments.DeleteParent method.
|
||||
type ConfigurationAssignmentsDeleteParentOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsGetOptions contains the optional parameters for the ConfigurationAssignments.Get method.
|
||||
type ConfigurationAssignmentsGetOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsGetParentOptions contains the optional parameters for the ConfigurationAssignments.GetParent method.
|
||||
type ConfigurationAssignmentsGetParentOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsListOptions contains the optional parameters for the ConfigurationAssignments.List method.
|
||||
type ConfigurationAssignmentsListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsListParentOptions contains the optional parameters for the ConfigurationAssignments.ListParent method.
|
||||
type ConfigurationAssignmentsListParentOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsWithinSubscriptionListOptions contains the optional parameters for the ConfigurationAssignmentsWithinSubscription.List method.
|
||||
type ConfigurationAssignmentsWithinSubscriptionListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// ErrorDetails - An error response details received from the Azure Maintenance service.
|
||||
type ErrorDetails struct {
|
||||
// Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response.
|
||||
Code *string `json:"code,omitempty"`
|
||||
|
||||
// Human-readable representation of the error.
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// InputLinuxParameters - Input properties for patching a Linux machine.
|
||||
type InputLinuxParameters struct {
|
||||
// Classification category of patches to be patched
|
||||
ClassificationsToInclude []*string `json:"classificationsToInclude,omitempty"`
|
||||
|
||||
// Package names to be excluded for patching.
|
||||
PackageNameMasksToExclude []*string `json:"packageNameMasksToExclude,omitempty"`
|
||||
|
||||
// Package names to be included for patching.
|
||||
PackageNameMasksToInclude []*string `json:"packageNameMasksToInclude,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type InputLinuxParameters.
|
||||
func (i InputLinuxParameters) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "classificationsToInclude", i.ClassificationsToInclude)
|
||||
populate(objectMap, "packageNameMasksToExclude", i.PackageNameMasksToExclude)
|
||||
populate(objectMap, "packageNameMasksToInclude", i.PackageNameMasksToInclude)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// InputPatchConfiguration - Input configuration for a patch run
|
||||
type InputPatchConfiguration struct {
|
||||
// Input parameters specific to patching Linux machine. For Windows machines, do not pass this property.
|
||||
LinuxParameters *InputLinuxParameters `json:"linuxParameters,omitempty"`
|
||||
|
||||
// Possible reboot preference as defined by the user based on which it would be decided to reboot the machine or not after the patch operation is completed.
|
||||
RebootSetting *RebootOptions `json:"rebootSetting,omitempty"`
|
||||
|
||||
// Tasks information for the Software update configuration.
|
||||
Tasks *SoftwareUpdateConfigurationTasks `json:"tasks,omitempty"`
|
||||
|
||||
// Input parameters specific to patching a Windows machine. For Linux machines, do not pass this property.
|
||||
WindowsParameters *InputWindowsParameters `json:"windowsParameters,omitempty"`
|
||||
}
|
||||
|
||||
// InputWindowsParameters - Input properties for patching a Windows machine.
|
||||
type InputWindowsParameters struct {
|
||||
// Classification category of patches to be patched
|
||||
ClassificationsToInclude []*string `json:"classificationsToInclude,omitempty"`
|
||||
|
||||
// Exclude patches which need reboot
|
||||
ExcludeKbsRequiringReboot *bool `json:"excludeKbsRequiringReboot,omitempty"`
|
||||
|
||||
// Windows KBID to be excluded for patching.
|
||||
KbNumbersToExclude []*string `json:"kbNumbersToExclude,omitempty"`
|
||||
|
||||
// Windows KBID to be included for patching.
|
||||
KbNumbersToInclude []*string `json:"kbNumbersToInclude,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type InputWindowsParameters.
|
||||
func (i InputWindowsParameters) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "classificationsToInclude", i.ClassificationsToInclude)
|
||||
populate(objectMap, "excludeKbsRequiringReboot", i.ExcludeKbsRequiringReboot)
|
||||
populate(objectMap, "kbNumbersToExclude", i.KbNumbersToExclude)
|
||||
populate(objectMap, "kbNumbersToInclude", i.KbNumbersToInclude)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// ListApplyUpdate - Response for ApplyUpdate list
|
||||
type ListApplyUpdate struct {
|
||||
// The list of apply updates
|
||||
Value []*ApplyUpdate `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ListApplyUpdate.
|
||||
func (l ListApplyUpdate) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "value", l.Value)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// ListConfigurationAssignmentsResult - Response for ConfigurationAssignments list
|
||||
type ListConfigurationAssignmentsResult struct {
|
||||
// The list of configuration Assignments
|
||||
Value []*ConfigurationAssignment `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ListConfigurationAssignmentsResult.
|
||||
func (l ListConfigurationAssignmentsResult) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "value", l.Value)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// ListMaintenanceConfigurationsResult - Response for MaintenanceConfigurations list
|
||||
type ListMaintenanceConfigurationsResult struct {
|
||||
// The list of maintenance Configurations
|
||||
Value []*MaintenanceConfiguration `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ListMaintenanceConfigurationsResult.
|
||||
func (l ListMaintenanceConfigurationsResult) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "value", l.Value)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// ListUpdatesResult - Response for Updates list
|
||||
type ListUpdatesResult struct {
|
||||
// The pending updates
|
||||
Value []*Update `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type ListUpdatesResult.
|
||||
func (l ListUpdatesResult) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "value", l.Value)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// MaintenanceConfiguration - Maintenance configuration record type
|
||||
type MaintenanceConfiguration struct {
|
||||
Resource
|
||||
// Gets or sets location of the resource
|
||||
Location *string `json:"location,omitempty"`
|
||||
|
||||
// Gets or sets properties of the resource
|
||||
Properties *MaintenanceConfigurationProperties `json:"properties,omitempty"`
|
||||
|
||||
// Gets or sets tags of the resource
|
||||
Tags map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type MaintenanceConfiguration.
|
||||
func (m MaintenanceConfiguration) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
m.Resource.marshalInternal(objectMap)
|
||||
populate(objectMap, "location", m.Location)
|
||||
populate(objectMap, "properties", m.Properties)
|
||||
populate(objectMap, "tags", m.Tags)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationProperties - Properties for maintenance configuration
|
||||
type MaintenanceConfigurationProperties struct {
|
||||
// Gets or sets extensionProperties of the maintenanceConfiguration
|
||||
ExtensionProperties map[string]*string `json:"extensionProperties,omitempty"`
|
||||
|
||||
// The input parameters to be passed to the patch run operation.
|
||||
InstallPatches *InputPatchConfiguration `json:"installPatches,omitempty"`
|
||||
|
||||
// Gets or sets maintenanceScope of the configuration
|
||||
MaintenanceScope *MaintenanceScope `json:"maintenanceScope,omitempty"`
|
||||
|
||||
// Definition of a MaintenanceWindow
|
||||
MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"`
|
||||
|
||||
// Gets or sets namespace of the resource
|
||||
Namespace *string `json:"namespace,omitempty"`
|
||||
|
||||
// Gets or sets the visibility of the configuration. The default value is 'Custom'
|
||||
Visibility *Visibility `json:"visibility,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type MaintenanceConfigurationProperties.
|
||||
func (m MaintenanceConfigurationProperties) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "extensionProperties", m.ExtensionProperties)
|
||||
populate(objectMap, "installPatches", m.InstallPatches)
|
||||
populate(objectMap, "maintenanceScope", m.MaintenanceScope)
|
||||
populate(objectMap, "maintenanceWindow", m.MaintenanceWindow)
|
||||
populate(objectMap, "namespace", m.Namespace)
|
||||
populate(objectMap, "visibility", m.Visibility)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsCreateOrUpdateOptions contains the optional parameters for the MaintenanceConfigurations.CreateOrUpdate method.
|
||||
type MaintenanceConfigurationsCreateOrUpdateOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsDeleteOptions contains the optional parameters for the MaintenanceConfigurations.Delete method.
|
||||
type MaintenanceConfigurationsDeleteOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsForResourceGroupListOptions contains the optional parameters for the MaintenanceConfigurationsForResourceGroup.List method.
|
||||
type MaintenanceConfigurationsForResourceGroupListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsGetOptions contains the optional parameters for the MaintenanceConfigurations.Get method.
|
||||
type MaintenanceConfigurationsGetOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsListOptions contains the optional parameters for the MaintenanceConfigurations.List method.
|
||||
type MaintenanceConfigurationsListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsUpdateOptions contains the optional parameters for the MaintenanceConfigurations.Update method.
|
||||
type MaintenanceConfigurationsUpdateOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// MaintenanceError - An error response received from the Azure Maintenance service.
|
||||
// Implements the error and azcore.HTTPResponse interfaces.
|
||||
type MaintenanceError struct {
|
||||
raw string
|
||||
// Details of the error
|
||||
InnerError *ErrorDetails `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Error implements the error interface for type MaintenanceError.
|
||||
// The contents of the error text are not contractual and subject to change.
|
||||
func (e MaintenanceError) Error() string {
|
||||
return e.raw
|
||||
}
|
||||
|
||||
// MaintenanceWindow - Definition of a MaintenanceWindow
|
||||
type MaintenanceWindow struct {
|
||||
// Duration of the maintenance window in HH:mm format. If not provided, default value will be used based on maintenance scope provided. Example: 05:00.
|
||||
Duration *string `json:"duration,omitempty"`
|
||||
|
||||
// Effective expiration date of the maintenance window in YYYY-MM-DD hh:mm format. The window will be created in the time zone provided and adjusted to
|
||||
// daylight savings according to that time zone.
|
||||
// Expiration date must be set to a future date. If not provided, it will be set to the maximum datetime 9999-12-31 23:59:59.
|
||||
ExpirationDateTime *string `json:"expirationDateTime,omitempty"`
|
||||
|
||||
// Rate at which a Maintenance window is expected to recur. The rate can be expressed as daily, weekly, or monthly schedules. Daily schedule are formatted
|
||||
// as recurEvery: [Frequency as integer]['Day(s)'].
|
||||
// If no frequency is provided, the default frequency is 1. Daily schedule examples are recurEvery: Day, recurEvery: 3Days. Weekly schedule are formatted
|
||||
// as recurEvery: [Frequency as integer]['Week(s)']
|
||||
// [Optional comma separated list of weekdays Monday-Sunday]. Weekly schedule examples are recurEvery: 3Weeks, recurEvery: Week Saturday,Sunday. Monthly
|
||||
// schedules are formatted as [Frequency as
|
||||
// integer]['Month(s)'] [Comma separated list of month days] or [Frequency as integer]['Month(s)'] [Week of Month (First, Second, Third, Fourth, Last)]
|
||||
// [Weekday Monday-Sunday] [Optional Offset(No. of
|
||||
// days)]. Offset value must be between -6 to 6 inclusive. Monthly schedule examples are recurEvery: Month, recurEvery: 2Months, recurEvery: Month day23,day24,
|
||||
// recurEvery: Month Last Sunday, recurEvery:
|
||||
// Month Fourth Monday, recurEvery: Month Last Sunday Offset-3, recurEvery: Month Third Sunday Offset6.
|
||||
RecurEvery *string `json:"recurEvery,omitempty"`
|
||||
|
||||
// Effective start date of the maintenance window in YYYY-MM-DD hh:mm format. The start date can be set to either the current date or future date. The window
|
||||
// will be created in the time zone provided and
|
||||
// adjusted to daylight savings according to that time zone.
|
||||
StartDateTime *string `json:"startDateTime,omitempty"`
|
||||
|
||||
// Name of the timezone. List of timezones can be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. Example: Pacific Standard
|
||||
// Time, UTC, W. Europe Standard Time, Korea
|
||||
// Standard Time, Cen. Australia Standard Time.
|
||||
TimeZone *string `json:"timeZone,omitempty"`
|
||||
}
|
||||
|
||||
// Operation - Represents an operation returned by the GetOperations request
|
||||
type Operation struct {
|
||||
// Display name of the operation
|
||||
Display *OperationInfo `json:"display,omitempty"`
|
||||
|
||||
// Indicates whether the operation is a data action
|
||||
IsDataAction *bool `json:"isDataAction,omitempty"`
|
||||
|
||||
// Name of the operation
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
||||
// Origin of the operation
|
||||
Origin *string `json:"origin,omitempty"`
|
||||
|
||||
// Properties of the operation
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// OperationInfo - Information about an operation
|
||||
type OperationInfo struct {
|
||||
// Description of the operation
|
||||
Description *string `json:"description,omitempty"`
|
||||
|
||||
// Name of the operation
|
||||
Operation *string `json:"operation,omitempty"`
|
||||
|
||||
// Name of the provider
|
||||
Provider *string `json:"provider,omitempty"`
|
||||
|
||||
// Name of the resource type
|
||||
Resource *string `json:"resource,omitempty"`
|
||||
}
|
||||
|
||||
// OperationsListOptions contains the optional parameters for the Operations.List method.
|
||||
type OperationsListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// OperationsListResult - Result of the List Operations operation
|
||||
type OperationsListResult struct {
|
||||
// A collection of operations
|
||||
Value []*Operation `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type OperationsListResult.
|
||||
func (o OperationsListResult) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "value", o.Value)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// PublicMaintenanceConfigurationsGetOptions contains the optional parameters for the PublicMaintenanceConfigurations.Get method.
|
||||
type PublicMaintenanceConfigurationsGetOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// PublicMaintenanceConfigurationsListOptions contains the optional parameters for the PublicMaintenanceConfigurations.List method.
|
||||
type PublicMaintenanceConfigurationsListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// Resource - Definition of a Resource
|
||||
type Resource struct {
|
||||
// READ-ONLY; Fully qualified identifier of the resource
|
||||
ID *string `json:"id,omitempty" azure:"ro"`
|
||||
|
||||
// READ-ONLY; 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; Type of the resource
|
||||
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)
|
||||
}
|
||||
|
||||
// SoftwareUpdateConfigurationTasks - Task properties of the software update configuration.
|
||||
type SoftwareUpdateConfigurationTasks struct {
|
||||
// List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', 'parameters': { 'arg1': 'value1'}}]
|
||||
PostTasks []*TaskProperties `json:"postTasks,omitempty"`
|
||||
|
||||
// List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', 'parameters': { 'arg1': 'value1'}}]
|
||||
PreTasks []*TaskProperties `json:"preTasks,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type SoftwareUpdateConfigurationTasks.
|
||||
func (s SoftwareUpdateConfigurationTasks) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "postTasks", s.PostTasks)
|
||||
populate(objectMap, "preTasks", s.PreTasks)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// TaskProperties - Task properties of the software update configuration.
|
||||
type TaskProperties struct {
|
||||
// Gets or sets the parameters of the task.
|
||||
Parameters map[string]*string `json:"parameters,omitempty"`
|
||||
|
||||
// Gets or sets the name of the runbook.
|
||||
Source *string `json:"source,omitempty"`
|
||||
|
||||
// Global Task execute once when schedule trigger. Resource task execute for each VM.
|
||||
TaskScope *TaskScope `json:"taskScope,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type TaskProperties.
|
||||
func (t TaskProperties) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "parameters", t.Parameters)
|
||||
populate(objectMap, "source", t.Source)
|
||||
populate(objectMap, "taskScope", t.TaskScope)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// Update - Maintenance update on a resource
|
||||
type Update struct {
|
||||
// Duration of impact in seconds
|
||||
ImpactDurationInSec *int32 `json:"impactDurationInSec,omitempty"`
|
||||
|
||||
// The impact type
|
||||
ImpactType *ImpactType `json:"impactType,omitempty"`
|
||||
|
||||
// The impact area
|
||||
MaintenanceScope *MaintenanceScope `json:"maintenanceScope,omitempty"`
|
||||
|
||||
// Time when Azure will start force updates if not self-updated by customer before this time
|
||||
NotBefore *time.Time `json:"notBefore,omitempty"`
|
||||
|
||||
// Properties of the apply update
|
||||
Properties *UpdateProperties `json:"properties,omitempty"`
|
||||
|
||||
// The status
|
||||
Status *UpdateStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaller interface for type Update.
|
||||
func (u Update) MarshalJSON() ([]byte, error) {
|
||||
objectMap := make(map[string]interface{})
|
||||
populate(objectMap, "impactDurationInSec", u.ImpactDurationInSec)
|
||||
populate(objectMap, "impactType", u.ImpactType)
|
||||
populate(objectMap, "maintenanceScope", u.MaintenanceScope)
|
||||
populateTimeRFC3339(objectMap, "notBefore", u.NotBefore)
|
||||
populate(objectMap, "properties", u.Properties)
|
||||
populate(objectMap, "status", u.Status)
|
||||
return json.Marshal(objectMap)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface for type Update.
|
||||
func (u *Update) 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 "impactDurationInSec":
|
||||
err = unpopulate(val, &u.ImpactDurationInSec)
|
||||
delete(rawMsg, key)
|
||||
case "impactType":
|
||||
err = unpopulate(val, &u.ImpactType)
|
||||
delete(rawMsg, key)
|
||||
case "maintenanceScope":
|
||||
err = unpopulate(val, &u.MaintenanceScope)
|
||||
delete(rawMsg, key)
|
||||
case "notBefore":
|
||||
err = unpopulateTimeRFC3339(val, &u.NotBefore)
|
||||
delete(rawMsg, key)
|
||||
case "properties":
|
||||
err = unpopulate(val, &u.Properties)
|
||||
delete(rawMsg, key)
|
||||
case "status":
|
||||
err = unpopulate(val, &u.Status)
|
||||
delete(rawMsg, key)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateProperties - Properties for update
|
||||
type UpdateProperties struct {
|
||||
// The resourceId
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
}
|
||||
|
||||
// UpdatesListOptions contains the optional parameters for the Updates.List method.
|
||||
type UpdatesListOptions struct {
|
||||
// placeholder for future optional parameters
|
||||
}
|
||||
|
||||
// UpdatesListParentOptions contains the optional parameters for the Updates.ListParent method.
|
||||
type UpdatesListParentOptions 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)
|
||||
}
|
|
@ -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 armmaintenance
|
||||
|
||||
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 - List the available operations supported by the Microsoft.Maintenance resource provider
|
||||
// If the operation fails it returns the *MaintenanceError 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.Maintenance/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-09-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.OperationsListResult); 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 := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
//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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// PublicMaintenanceConfigurationsClient contains the methods for the PublicMaintenanceConfigurations group.
|
||||
// Don't use this type directly, use NewPublicMaintenanceConfigurationsClient() instead.
|
||||
type PublicMaintenanceConfigurationsClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewPublicMaintenanceConfigurationsClient creates a new instance of PublicMaintenanceConfigurationsClient with the specified values.
|
||||
func NewPublicMaintenanceConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PublicMaintenanceConfigurationsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &PublicMaintenanceConfigurationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// Get - Get Public Maintenance Configuration record
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *PublicMaintenanceConfigurationsClient) Get(ctx context.Context, resourceName string, options *PublicMaintenanceConfigurationsGetOptions) (PublicMaintenanceConfigurationsGetResponse, error) {
|
||||
req, err := client.getCreateRequest(ctx, resourceName, options)
|
||||
if err != nil {
|
||||
return PublicMaintenanceConfigurationsGetResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return PublicMaintenanceConfigurationsGetResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return PublicMaintenanceConfigurationsGetResponse{}, client.getHandleError(resp)
|
||||
}
|
||||
return client.getHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getCreateRequest creates the Get request.
|
||||
func (client *PublicMaintenanceConfigurationsClient) getCreateRequest(ctx context.Context, resourceName string, options *PublicMaintenanceConfigurationsGetOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-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 *PublicMaintenanceConfigurationsClient) getHandleResponse(resp *http.Response) (PublicMaintenanceConfigurationsGetResponse, error) {
|
||||
result := PublicMaintenanceConfigurationsGetResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.MaintenanceConfiguration); err != nil {
|
||||
return PublicMaintenanceConfigurationsGetResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// getHandleError handles the Get error response.
|
||||
func (client *PublicMaintenanceConfigurationsClient) getHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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 Public Maintenance Configuration records
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *PublicMaintenanceConfigurationsClient) List(ctx context.Context, options *PublicMaintenanceConfigurationsListOptions) (PublicMaintenanceConfigurationsListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, options)
|
||||
if err != nil {
|
||||
return PublicMaintenanceConfigurationsListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return PublicMaintenanceConfigurationsListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return PublicMaintenanceConfigurationsListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *PublicMaintenanceConfigurationsClient) listCreateRequest(ctx context.Context, options *PublicMaintenanceConfigurationsListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations"
|
||||
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-09-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 *PublicMaintenanceConfigurationsClient) listHandleResponse(resp *http.Response) (PublicMaintenanceConfigurationsListResponse, error) {
|
||||
result := PublicMaintenanceConfigurationsListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListMaintenanceConfigurationsResult); err != nil {
|
||||
return PublicMaintenanceConfigurationsListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *PublicMaintenanceConfigurationsClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
//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 armmaintenance
|
||||
|
||||
import "net/http"
|
||||
|
||||
// ApplyUpdateForResourceGroupListResponse contains the response from method ApplyUpdateForResourceGroup.List.
|
||||
type ApplyUpdateForResourceGroupListResponse struct {
|
||||
ApplyUpdateForResourceGroupListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ApplyUpdateForResourceGroupListResult contains the result from method ApplyUpdateForResourceGroup.List.
|
||||
type ApplyUpdateForResourceGroupListResult struct {
|
||||
ListApplyUpdate
|
||||
}
|
||||
|
||||
// ApplyUpdatesCreateOrUpdateParentResponse contains the response from method ApplyUpdates.CreateOrUpdateParent.
|
||||
type ApplyUpdatesCreateOrUpdateParentResponse struct {
|
||||
ApplyUpdatesCreateOrUpdateParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ApplyUpdatesCreateOrUpdateParentResult contains the result from method ApplyUpdates.CreateOrUpdateParent.
|
||||
type ApplyUpdatesCreateOrUpdateParentResult struct {
|
||||
ApplyUpdate
|
||||
}
|
||||
|
||||
// ApplyUpdatesCreateOrUpdateResponse contains the response from method ApplyUpdates.CreateOrUpdate.
|
||||
type ApplyUpdatesCreateOrUpdateResponse struct {
|
||||
ApplyUpdatesCreateOrUpdateResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ApplyUpdatesCreateOrUpdateResult contains the result from method ApplyUpdates.CreateOrUpdate.
|
||||
type ApplyUpdatesCreateOrUpdateResult struct {
|
||||
ApplyUpdate
|
||||
}
|
||||
|
||||
// ApplyUpdatesGetParentResponse contains the response from method ApplyUpdates.GetParent.
|
||||
type ApplyUpdatesGetParentResponse struct {
|
||||
ApplyUpdatesGetParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ApplyUpdatesGetParentResult contains the result from method ApplyUpdates.GetParent.
|
||||
type ApplyUpdatesGetParentResult struct {
|
||||
ApplyUpdate
|
||||
}
|
||||
|
||||
// ApplyUpdatesGetResponse contains the response from method ApplyUpdates.Get.
|
||||
type ApplyUpdatesGetResponse struct {
|
||||
ApplyUpdatesGetResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ApplyUpdatesGetResult contains the result from method ApplyUpdates.Get.
|
||||
type ApplyUpdatesGetResult struct {
|
||||
ApplyUpdate
|
||||
}
|
||||
|
||||
// ApplyUpdatesListResponse contains the response from method ApplyUpdates.List.
|
||||
type ApplyUpdatesListResponse struct {
|
||||
ApplyUpdatesListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ApplyUpdatesListResult contains the result from method ApplyUpdates.List.
|
||||
type ApplyUpdatesListResult struct {
|
||||
ListApplyUpdate
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsCreateOrUpdateParentResponse contains the response from method ConfigurationAssignments.CreateOrUpdateParent.
|
||||
type ConfigurationAssignmentsCreateOrUpdateParentResponse struct {
|
||||
ConfigurationAssignmentsCreateOrUpdateParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsCreateOrUpdateParentResult contains the result from method ConfigurationAssignments.CreateOrUpdateParent.
|
||||
type ConfigurationAssignmentsCreateOrUpdateParentResult struct {
|
||||
ConfigurationAssignment
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsCreateOrUpdateResponse contains the response from method ConfigurationAssignments.CreateOrUpdate.
|
||||
type ConfigurationAssignmentsCreateOrUpdateResponse struct {
|
||||
ConfigurationAssignmentsCreateOrUpdateResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsCreateOrUpdateResult contains the result from method ConfigurationAssignments.CreateOrUpdate.
|
||||
type ConfigurationAssignmentsCreateOrUpdateResult struct {
|
||||
ConfigurationAssignment
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsDeleteParentResponse contains the response from method ConfigurationAssignments.DeleteParent.
|
||||
type ConfigurationAssignmentsDeleteParentResponse struct {
|
||||
ConfigurationAssignmentsDeleteParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsDeleteParentResult contains the result from method ConfigurationAssignments.DeleteParent.
|
||||
type ConfigurationAssignmentsDeleteParentResult struct {
|
||||
ConfigurationAssignment
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsDeleteResponse contains the response from method ConfigurationAssignments.Delete.
|
||||
type ConfigurationAssignmentsDeleteResponse struct {
|
||||
ConfigurationAssignmentsDeleteResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsDeleteResult contains the result from method ConfigurationAssignments.Delete.
|
||||
type ConfigurationAssignmentsDeleteResult struct {
|
||||
ConfigurationAssignment
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsGetParentResponse contains the response from method ConfigurationAssignments.GetParent.
|
||||
type ConfigurationAssignmentsGetParentResponse struct {
|
||||
ConfigurationAssignmentsGetParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsGetParentResult contains the result from method ConfigurationAssignments.GetParent.
|
||||
type ConfigurationAssignmentsGetParentResult struct {
|
||||
ConfigurationAssignment
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsGetResponse contains the response from method ConfigurationAssignments.Get.
|
||||
type ConfigurationAssignmentsGetResponse struct {
|
||||
ConfigurationAssignmentsGetResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsGetResult contains the result from method ConfigurationAssignments.Get.
|
||||
type ConfigurationAssignmentsGetResult struct {
|
||||
ConfigurationAssignment
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsListParentResponse contains the response from method ConfigurationAssignments.ListParent.
|
||||
type ConfigurationAssignmentsListParentResponse struct {
|
||||
ConfigurationAssignmentsListParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsListParentResult contains the result from method ConfigurationAssignments.ListParent.
|
||||
type ConfigurationAssignmentsListParentResult struct {
|
||||
ListConfigurationAssignmentsResult
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsListResponse contains the response from method ConfigurationAssignments.List.
|
||||
type ConfigurationAssignmentsListResponse struct {
|
||||
ConfigurationAssignmentsListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsListResult contains the result from method ConfigurationAssignments.List.
|
||||
type ConfigurationAssignmentsListResult struct {
|
||||
ListConfigurationAssignmentsResult
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsWithinSubscriptionListResponse contains the response from method ConfigurationAssignmentsWithinSubscription.List.
|
||||
type ConfigurationAssignmentsWithinSubscriptionListResponse struct {
|
||||
ConfigurationAssignmentsWithinSubscriptionListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// ConfigurationAssignmentsWithinSubscriptionListResult contains the result from method ConfigurationAssignmentsWithinSubscription.List.
|
||||
type ConfigurationAssignmentsWithinSubscriptionListResult struct {
|
||||
ListConfigurationAssignmentsResult
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsCreateOrUpdateResponse contains the response from method MaintenanceConfigurations.CreateOrUpdate.
|
||||
type MaintenanceConfigurationsCreateOrUpdateResponse struct {
|
||||
MaintenanceConfigurationsCreateOrUpdateResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsCreateOrUpdateResult contains the result from method MaintenanceConfigurations.CreateOrUpdate.
|
||||
type MaintenanceConfigurationsCreateOrUpdateResult struct {
|
||||
MaintenanceConfiguration
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsDeleteResponse contains the response from method MaintenanceConfigurations.Delete.
|
||||
type MaintenanceConfigurationsDeleteResponse struct {
|
||||
MaintenanceConfigurationsDeleteResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsDeleteResult contains the result from method MaintenanceConfigurations.Delete.
|
||||
type MaintenanceConfigurationsDeleteResult struct {
|
||||
MaintenanceConfiguration
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsForResourceGroupListResponse contains the response from method MaintenanceConfigurationsForResourceGroup.List.
|
||||
type MaintenanceConfigurationsForResourceGroupListResponse struct {
|
||||
MaintenanceConfigurationsForResourceGroupListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsForResourceGroupListResult contains the result from method MaintenanceConfigurationsForResourceGroup.List.
|
||||
type MaintenanceConfigurationsForResourceGroupListResult struct {
|
||||
ListMaintenanceConfigurationsResult
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsGetResponse contains the response from method MaintenanceConfigurations.Get.
|
||||
type MaintenanceConfigurationsGetResponse struct {
|
||||
MaintenanceConfigurationsGetResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsGetResult contains the result from method MaintenanceConfigurations.Get.
|
||||
type MaintenanceConfigurationsGetResult struct {
|
||||
MaintenanceConfiguration
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsListResponse contains the response from method MaintenanceConfigurations.List.
|
||||
type MaintenanceConfigurationsListResponse struct {
|
||||
MaintenanceConfigurationsListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsListResult contains the result from method MaintenanceConfigurations.List.
|
||||
type MaintenanceConfigurationsListResult struct {
|
||||
ListMaintenanceConfigurationsResult
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsUpdateResponse contains the response from method MaintenanceConfigurations.Update.
|
||||
type MaintenanceConfigurationsUpdateResponse struct {
|
||||
MaintenanceConfigurationsUpdateResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// MaintenanceConfigurationsUpdateResult contains the result from method MaintenanceConfigurations.Update.
|
||||
type MaintenanceConfigurationsUpdateResult struct {
|
||||
MaintenanceConfiguration
|
||||
}
|
||||
|
||||
// OperationsListResponse contains the response from method Operations.List.
|
||||
type OperationsListResponse struct {
|
||||
OperationsListResultEnvelope
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// OperationsListResultEnvelope contains the result from method Operations.List.
|
||||
type OperationsListResultEnvelope struct {
|
||||
OperationsListResult
|
||||
}
|
||||
|
||||
// PublicMaintenanceConfigurationsGetResponse contains the response from method PublicMaintenanceConfigurations.Get.
|
||||
type PublicMaintenanceConfigurationsGetResponse struct {
|
||||
PublicMaintenanceConfigurationsGetResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// PublicMaintenanceConfigurationsGetResult contains the result from method PublicMaintenanceConfigurations.Get.
|
||||
type PublicMaintenanceConfigurationsGetResult struct {
|
||||
MaintenanceConfiguration
|
||||
}
|
||||
|
||||
// PublicMaintenanceConfigurationsListResponse contains the response from method PublicMaintenanceConfigurations.List.
|
||||
type PublicMaintenanceConfigurationsListResponse struct {
|
||||
PublicMaintenanceConfigurationsListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// PublicMaintenanceConfigurationsListResult contains the result from method PublicMaintenanceConfigurations.List.
|
||||
type PublicMaintenanceConfigurationsListResult struct {
|
||||
ListMaintenanceConfigurationsResult
|
||||
}
|
||||
|
||||
// UpdatesListParentResponse contains the response from method Updates.ListParent.
|
||||
type UpdatesListParentResponse struct {
|
||||
UpdatesListParentResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// UpdatesListParentResult contains the result from method Updates.ListParent.
|
||||
type UpdatesListParentResult struct {
|
||||
ListUpdatesResult
|
||||
}
|
||||
|
||||
// UpdatesListResponse contains the response from method Updates.List.
|
||||
type UpdatesListResponse struct {
|
||||
UpdatesListResult
|
||||
// RawResponse contains the underlying HTTP response.
|
||||
RawResponse *http.Response
|
||||
}
|
||||
|
||||
// UpdatesListResult contains the result from method Updates.List.
|
||||
type UpdatesListResult struct {
|
||||
ListUpdatesResult
|
||||
}
|
|
@ -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 armmaintenance
|
||||
|
||||
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
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
//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 armmaintenance
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// UpdatesClient contains the methods for the Updates group.
|
||||
// Don't use this type directly, use NewUpdatesClient() instead.
|
||||
type UpdatesClient struct {
|
||||
ep string
|
||||
pl runtime.Pipeline
|
||||
subscriptionID string
|
||||
}
|
||||
|
||||
// NewUpdatesClient creates a new instance of UpdatesClient with the specified values.
|
||||
func NewUpdatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *UpdatesClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Host) == 0 {
|
||||
cp.Host = arm.AzurePublicCloud
|
||||
}
|
||||
return &UpdatesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}
|
||||
}
|
||||
|
||||
// List - Get updates to resources.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *UpdatesClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *UpdatesListOptions) (UpdatesListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, options)
|
||||
if err != nil {
|
||||
return UpdatesListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return UpdatesListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return UpdatesListResponse{}, client.listHandleError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *UpdatesClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *UpdatesListOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-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 *UpdatesClient) listHandleResponse(resp *http.Response) (UpdatesListResponse, error) {
|
||||
result := UpdatesListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListUpdatesResult); err != nil {
|
||||
return UpdatesListResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listHandleError handles the List error response.
|
||||
func (client *UpdatesClient) listHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
||||
|
||||
// ListParent - Get updates to resources.
|
||||
// If the operation fails it returns the *MaintenanceError error type.
|
||||
func (client *UpdatesClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *UpdatesListParentOptions) (UpdatesListParentResponse, error) {
|
||||
req, err := client.listParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options)
|
||||
if err != nil {
|
||||
return UpdatesListParentResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return UpdatesListParentResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return UpdatesListParentResponse{}, client.listParentHandleError(resp)
|
||||
}
|
||||
return client.listParentHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listParentCreateRequest creates the ListParent request.
|
||||
func (client *UpdatesClient) listParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *UpdatesListParentOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"
|
||||
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 providerName == "" {
|
||||
return nil, errors.New("parameter providerName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName))
|
||||
if resourceParentType == "" {
|
||||
return nil, errors.New("parameter resourceParentType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentType}", url.PathEscape(resourceParentType))
|
||||
if resourceParentName == "" {
|
||||
return nil, errors.New("parameter resourceParentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceParentName}", url.PathEscape(resourceParentName))
|
||||
if resourceType == "" {
|
||||
return nil, errors.New("parameter resourceType cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType))
|
||||
if resourceName == "" {
|
||||
return nil, errors.New("parameter resourceName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName))
|
||||
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-09-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listParentHandleResponse handles the ListParent response.
|
||||
func (client *UpdatesClient) listParentHandleResponse(resp *http.Response) (UpdatesListParentResponse, error) {
|
||||
result := UpdatesListParentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.ListUpdatesResult); err != nil {
|
||||
return UpdatesListParentResponse{}, runtime.NewResponseError(err, resp)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// listParentHandleError handles the ListParent error response.
|
||||
func (client *UpdatesClient) listParentHandleError(resp *http.Response) error {
|
||||
body, err := runtime.Payload(resp)
|
||||
if err != nil {
|
||||
return runtime.NewResponseError(err, resp)
|
||||
}
|
||||
errType := MaintenanceError{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)
|
||||
}
|
Загрузка…
Ссылка в новой задаче