[Release] sdk/resourcemanager/policyinsights/armpolicyinsights/0.1.0 generation from spec commit: 16a50699c70e8e86765dd46b84a9185067debfa7 (#16838)
This commit is contained in:
Родитель
ab66a8cd6a
Коммит
b28abe3ba6
|
@ -0,0 +1,5 @@
|
|||
# Release History
|
||||
|
||||
## 0.1.0 (2022-01-14)
|
||||
|
||||
- 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 Policy Insight Module for Go
|
||||
|
||||
[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights)
|
||||
|
||||
The `armpolicyinsights` module provides operations for working with Azure Policy Insight.
|
||||
|
||||
[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/policyinsights/armpolicyinsights)
|
||||
|
||||
# Getting started
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- an [Azure subscription](https://azure.microsoft.com/free/)
|
||||
- Go 1.16 or above
|
||||
|
||||
## Install the package
|
||||
|
||||
This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management.
|
||||
|
||||
Install the Azure Policy Insight module:
|
||||
|
||||
```sh
|
||||
go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights
|
||||
```
|
||||
|
||||
## Authorization
|
||||
|
||||
When creating a client, you will need to provide a credential for authenticating with Azure Policy Insight. 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 Policy Insight 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 := armpolicyinsights.NewRemediationsClient(<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 := armpolicyinsights.NewRemediationsClient(<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 `Policy Insight` 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/16a50699c70e8e86765dd46b84a9185067debfa7/specification/policyinsights/resource-manager/readme.md
|
||||
- https://github.com/Azure/azure-rest-api-specs/blob/16a50699c70e8e86765dd46b84a9185067debfa7/specification/policyinsights/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/policyinsights/armpolicyinsights
|
||||
|
||||
package armpolicyinsights
|
|
@ -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/policyinsights/armpolicyinsights/
|
||||
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- main
|
||||
- feature/*
|
||||
- hotfix/*
|
||||
- release/*
|
||||
paths:
|
||||
include:
|
||||
- sdk/resourcemanager/policyinsights/armpolicyinsights/
|
||||
|
||||
stages:
|
||||
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
|
||||
parameters:
|
||||
ServiceDirectory: 'resourcemanager/policyinsights/armpolicyinsights'
|
|
@ -0,0 +1,9 @@
|
|||
module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go v61.1.0+incompatible
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0
|
||||
)
|
|
@ -0,0 +1,61 @@
|
|||
github.com/Azure/azure-sdk-for-go v61.1.0+incompatible h1:Qbz3jdfkXIPjZECEuk2E7i3iLhC9Ul74pG5mQRQC+z4=
|
||||
github.com/Azure/azure-sdk-for-go v61.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 h1:bLRntPH25SkY1uZ/YZW+dmxNky9r1fAHvDFrzluo+4Q=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0/go.mod h1:TmXReXZ9yPp5D5TBRMTAtyz+UyOl15Py4hL5E5p6igQ=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 h1:E+m3SkZCN0Bf5q7YdTs5lSm2CYY3CK4spn5OmUIiQtk=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c=
|
||||
github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4=
|
||||
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 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c=
|
||||
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
|
||||
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
|
||||
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI=
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/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/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/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-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
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/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
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 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
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 armpolicyinsights
|
||||
|
||||
// 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,322 @@
|
|||
//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 armpolicyinsights_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_ListSubscriptionScope.json
|
||||
func ExampleAttestationsClient_ListForSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForSubscription(&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_CreateSubscriptionScope.json
|
||||
func ExampleAttestationsClient_BeginCreateOrUpdateAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
poller, err := client.BeginCreateOrUpdateAtSubscription(ctx,
|
||||
"<attestation-name>",
|
||||
armpolicyinsights.Attestation{
|
||||
Properties: &armpolicyinsights.AttestationProperties{
|
||||
ComplianceState: armpolicyinsights.ComplianceState("Compliant").ToPtr(),
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
res, err := poller.PollUntilDone(ctx, 30*time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.AttestationsClientCreateOrUpdateAtSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_GetSubscriptionScope.json
|
||||
func ExampleAttestationsClient_GetAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtSubscription(ctx,
|
||||
"<attestation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.AttestationsClientGetAtSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_DeleteSubscriptionScope.json
|
||||
func ExampleAttestationsClient_DeleteAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.DeleteAtSubscription(ctx,
|
||||
"<attestation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_ListResourceGroupScope.json
|
||||
func ExampleAttestationsClient_ListForResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForResourceGroup("<resource-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_CreateResourceGroupScope.json
|
||||
func ExampleAttestationsClient_BeginCreateOrUpdateAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
poller, err := client.BeginCreateOrUpdateAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<attestation-name>",
|
||||
armpolicyinsights.Attestation{
|
||||
Properties: &armpolicyinsights.AttestationProperties{
|
||||
Comments: to.StringPtr("<comments>"),
|
||||
ComplianceState: armpolicyinsights.ComplianceState("Compliant").ToPtr(),
|
||||
Evidence: []*armpolicyinsights.AttestationEvidence{
|
||||
{
|
||||
Description: to.StringPtr("<description>"),
|
||||
SourceURI: to.StringPtr("<source-uri>"),
|
||||
}},
|
||||
ExpiresOn: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00Z"); return t }()),
|
||||
Owner: to.StringPtr("<owner>"),
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
PolicyDefinitionReferenceID: to.StringPtr("<policy-definition-reference-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
res, err := poller.PollUntilDone(ctx, 30*time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.AttestationsClientCreateOrUpdateAtResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_GetResourceGroupScope.json
|
||||
func ExampleAttestationsClient_GetAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<attestation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.AttestationsClientGetAtResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_DeleteResourceGroupScope.json
|
||||
func ExampleAttestationsClient_DeleteAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.DeleteAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<attestation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_ListResourceScope.json
|
||||
func ExampleAttestationsClient_ListForResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForResource("<resource-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_CreateResourceScope.json
|
||||
func ExampleAttestationsClient_BeginCreateOrUpdateAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
poller, err := client.BeginCreateOrUpdateAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<attestation-name>",
|
||||
armpolicyinsights.Attestation{
|
||||
Properties: &armpolicyinsights.AttestationProperties{
|
||||
Comments: to.StringPtr("<comments>"),
|
||||
ComplianceState: armpolicyinsights.ComplianceState("Compliant").ToPtr(),
|
||||
Evidence: []*armpolicyinsights.AttestationEvidence{
|
||||
{
|
||||
Description: to.StringPtr("<description>"),
|
||||
SourceURI: to.StringPtr("<source-uri>"),
|
||||
}},
|
||||
ExpiresOn: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-15T00:00:00Z"); return t }()),
|
||||
Owner: to.StringPtr("<owner>"),
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
PolicyDefinitionReferenceID: to.StringPtr("<policy-definition-reference-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
res, err := poller.PollUntilDone(ctx, 30*time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.AttestationsClientCreateOrUpdateAtResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_GetResourceScope.json
|
||||
func ExampleAttestationsClient_GetAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<attestation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.AttestationsClientGetAtResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-01-01/examples/Attestations_DeleteResourceScope.json
|
||||
func ExampleAttestationsClient_DeleteAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewAttestationsClient("<subscription-id>", cred, nil)
|
||||
_, err = client.DeleteAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<attestation-name>",
|
||||
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 armpolicyinsights_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_ListOperations.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 := armpolicyinsights.NewOperationsClient(cred, nil)
|
||||
res, err := client.List(ctx,
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.OperationsClientListResult)
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
//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 armpolicyinsights_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForManagementGroup(armpolicyinsights.Enum1("default"),
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndAggregateOnly.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForSubscription(armpolicyinsights.Enum1("default"),
|
||||
"<subscription-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: to.StringPtr("<filter>"),
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-02-05T18:00:00Z"); return t }()),
|
||||
To: nil,
|
||||
Apply: to.StringPtr("<apply>"),
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForResourceGroup(armpolicyinsights.Enum1("default"),
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryNestedResourceScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForResource(armpolicyinsights.Enum1("default"),
|
||||
"<resource-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForPolicySetDefinition() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForPolicySetDefinition(armpolicyinsights.Enum1("default"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-set-definition-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForPolicyDefinition() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForPolicyDefinition(armpolicyinsights.Enum1("default"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-definition-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForSubscriptionLevelPolicyAssignment() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForSubscriptionLevelPolicyAssignment(armpolicyinsights.Enum1("default"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-assignment-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScope.json
|
||||
func ExamplePolicyEventsClient_ListQueryResultsForResourceGroupLevelPolicyAssignment() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyEventsClient(cred, nil)
|
||||
pager := client.ListQueryResultsForResourceGroupLevelPolicyAssignment(armpolicyinsights.Enum1("default"),
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-assignment-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
//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 armpolicyinsights_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json
|
||||
func ExamplePolicyMetadataClient_GetResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyMetadataClient(cred, nil)
|
||||
res, err := client.GetResource(ctx,
|
||||
"<resource-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyMetadataClientGetResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json
|
||||
func ExamplePolicyMetadataClient_List() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyMetadataClient(cred, nil)
|
||||
pager := client.List(&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
//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 armpolicyinsights_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/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2020-07-01/examples/PolicyRestrictions_CheckAtSubscriptionScope.json
|
||||
func ExamplePolicyRestrictionsClient_CheckAtSubscriptionScope() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyRestrictionsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CheckAtSubscriptionScope(ctx,
|
||||
armpolicyinsights.CheckRestrictionsRequest{
|
||||
PendingFields: []*armpolicyinsights.PendingField{
|
||||
{
|
||||
Field: to.StringPtr("<field>"),
|
||||
Values: []*string{
|
||||
to.StringPtr("myVMName")},
|
||||
},
|
||||
{
|
||||
Field: to.StringPtr("<field>"),
|
||||
Values: []*string{
|
||||
to.StringPtr("eastus"),
|
||||
to.StringPtr("westus"),
|
||||
to.StringPtr("westus2"),
|
||||
to.StringPtr("westeurope")},
|
||||
},
|
||||
{
|
||||
Field: to.StringPtr("<field>"),
|
||||
}},
|
||||
ResourceDetails: &armpolicyinsights.CheckRestrictionsResourceDetails{
|
||||
APIVersion: to.StringPtr("<apiversion>"),
|
||||
ResourceContent: map[string]interface{}{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"properties": map[string]interface{}{
|
||||
"priority": "Spot",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyRestrictionsClientCheckAtSubscriptionScopeResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2020-07-01/examples/PolicyRestrictions_CheckAtResourceGroupScope.json
|
||||
func ExamplePolicyRestrictionsClient_CheckAtResourceGroupScope() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyRestrictionsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CheckAtResourceGroupScope(ctx,
|
||||
"<resource-group-name>",
|
||||
armpolicyinsights.CheckRestrictionsRequest{
|
||||
PendingFields: []*armpolicyinsights.PendingField{
|
||||
{
|
||||
Field: to.StringPtr("<field>"),
|
||||
Values: []*string{
|
||||
to.StringPtr("myVMName")},
|
||||
},
|
||||
{
|
||||
Field: to.StringPtr("<field>"),
|
||||
Values: []*string{
|
||||
to.StringPtr("eastus"),
|
||||
to.StringPtr("westus"),
|
||||
to.StringPtr("westus2"),
|
||||
to.StringPtr("westeurope")},
|
||||
},
|
||||
{
|
||||
Field: to.StringPtr("<field>"),
|
||||
}},
|
||||
ResourceDetails: &armpolicyinsights.CheckRestrictionsResourceDetails{
|
||||
APIVersion: to.StringPtr("<apiversion>"),
|
||||
ResourceContent: map[string]interface{}{
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"properties": map[string]interface{}{
|
||||
"priority": "Spot",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyRestrictionsClientCheckAtResourceGroupScopeResult)
|
||||
}
|
|
@ -0,0 +1,571 @@
|
|||
//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 armpolicyinsights_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForManagementGroup(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeManagementGroupScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForManagementGroup(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: to.Int32Ptr(0),
|
||||
Filter: to.StringPtr("<filter>"),
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00Z"); return t }()),
|
||||
To: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00Z"); return t }()),
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForManagementGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndAggregateOnly.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForSubscription(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
"<subscription-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: to.StringPtr("<filter>"),
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00Z"); return t }()),
|
||||
To: nil,
|
||||
Apply: to.StringPtr("<apply>"),
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForSubscription(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<subscription-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: to.Int32Ptr(5),
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForResourceGroup(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForResourceGroup(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryNestedResourceScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForResource(armpolicyinsights.PolicyStatesResource("default"),
|
||||
"<resource-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForResource(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<resource-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: to.Int32Ptr(2),
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerSubscriptionEvaluation.json
|
||||
func ExamplePolicyStatesClient_BeginTriggerSubscriptionEvaluation() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
poller, err := client.BeginTriggerSubscriptionEvaluation(ctx,
|
||||
"<subscription-id>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
_, err = poller.PollUntilDone(ctx, 30*time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerResourceGroupEvaluation.json
|
||||
func ExamplePolicyStatesClient_BeginTriggerResourceGroupEvaluation() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
poller, err := client.BeginTriggerResourceGroupEvaluation(ctx,
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
_, err = poller.PollUntilDone(ctx, 30*time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForPolicySetDefinition() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForPolicySetDefinition(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-set-definition-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicySetDefinitionScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForPolicySetDefinition() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForPolicySetDefinition(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-set-definition-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: to.Int32Ptr(1),
|
||||
Filter: to.StringPtr("<filter>"),
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-05T18:00:00Z"); return t }()),
|
||||
To: to.TimePtr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-06T18:00:00Z"); return t }()),
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForPolicySetDefinitionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForPolicyDefinition() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForPolicyDefinition(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-definition-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyDefinitionScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForPolicyDefinition() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForPolicyDefinition(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-definition-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForPolicyDefinitionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForSubscriptionLevelPolicyAssignment() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForSubscriptionLevelPolicyAssignment(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-assignment-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyAssignmentScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForSubscriptionLevelPolicyAssignment() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForSubscriptionLevelPolicyAssignment(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<subscription-id>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-assignment-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForSubscriptionLevelPolicyAssignmentResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json
|
||||
func ExamplePolicyStatesClient_ListQueryResultsForResourceGroupLevelPolicyAssignment() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
pager := client.ListQueryResultsForResourceGroupLevelPolicyAssignment(armpolicyinsights.PolicyStatesResource("latest"),
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-assignment-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupLevelPolicyAssignmentScope.json
|
||||
func ExamplePolicyStatesClient_SummarizeForResourceGroupLevelPolicyAssignment() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyStatesClient(cred, nil)
|
||||
res, err := client.SummarizeForResourceGroupLevelPolicyAssignment(ctx,
|
||||
armpolicyinsights.Enum6("latest"),
|
||||
"<subscription-id>",
|
||||
"<resource-group-name>",
|
||||
armpolicyinsights.Enum4("Microsoft.Authorization"),
|
||||
"<policy-assignment-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.PolicyStatesClientSummarizeForResourceGroupLevelPolicyAssignmentResult)
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
//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 armpolicyinsights_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryManagementGroupScope.json
|
||||
func ExamplePolicyTrackedResourcesClient_ListQueryResultsForManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyTrackedResourcesClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListQueryResultsForManagementGroup(armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-name>",
|
||||
armpolicyinsights.Enum1("default"),
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QuerySubscriptionScope.json
|
||||
func ExamplePolicyTrackedResourcesClient_ListQueryResultsForSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyTrackedResourcesClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListQueryResultsForSubscription(armpolicyinsights.Enum1("default"),
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceGroupScope.json
|
||||
func ExamplePolicyTrackedResourcesClient_ListQueryResultsForResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyTrackedResourcesClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListQueryResultsForResourceGroup("<resource-group-name>",
|
||||
armpolicyinsights.Enum1("default"),
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceScope.json
|
||||
func ExamplePolicyTrackedResourcesClient_ListQueryResultsForResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewPolicyTrackedResourcesClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListQueryResultsForResource("<resource-id>",
|
||||
armpolicyinsights.Enum1("default"),
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,594 @@
|
|||
//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 armpolicyinsights_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/policyinsights/armpolicyinsights"
|
||||
)
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsManagementGroupScope.json
|
||||
func ExampleRemediationsClient_ListDeploymentsAtManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListDeploymentsAtManagementGroup(armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-id>",
|
||||
"<remediation-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelManagementGroupScope.json
|
||||
func ExampleRemediationsClient_CancelAtManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CancelAtManagementGroup(ctx,
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-id>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCancelAtManagementGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListManagementGroupScope.json
|
||||
func ExampleRemediationsClient_ListForManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForManagementGroup(armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateManagementGroupScope.json
|
||||
func ExampleRemediationsClient_CreateOrUpdateAtManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdateAtManagementGroup(ctx,
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-id>",
|
||||
"<remediation-name>",
|
||||
armpolicyinsights.Remediation{
|
||||
Properties: &armpolicyinsights.RemediationProperties{
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCreateOrUpdateAtManagementGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetManagementGroupScope.json
|
||||
func ExampleRemediationsClient_GetAtManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtManagementGroup(ctx,
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-id>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientGetAtManagementGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteManagementGroupScope.json
|
||||
func ExampleRemediationsClient_DeleteAtManagementGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.DeleteAtManagementGroup(ctx,
|
||||
armpolicyinsights.Enum0("Microsoft.Management"),
|
||||
"<management-group-id>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientDeleteAtManagementGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsSubscriptionScope.json
|
||||
func ExampleRemediationsClient_ListDeploymentsAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListDeploymentsAtSubscription("<remediation-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelSubscriptionScope.json
|
||||
func ExampleRemediationsClient_CancelAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CancelAtSubscription(ctx,
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCancelAtSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json
|
||||
func ExampleRemediationsClient_ListForSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForSubscription(&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateSubscriptionScope.json
|
||||
func ExampleRemediationsClient_CreateOrUpdateAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdateAtSubscription(ctx,
|
||||
"<remediation-name>",
|
||||
armpolicyinsights.Remediation{
|
||||
Properties: &armpolicyinsights.RemediationProperties{
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCreateOrUpdateAtSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetSubscriptionScope.json
|
||||
func ExampleRemediationsClient_GetAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtSubscription(ctx,
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientGetAtSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteSubscriptionScope.json
|
||||
func ExampleRemediationsClient_DeleteAtSubscription() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.DeleteAtSubscription(ctx,
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientDeleteAtSubscriptionResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceGroupScope.json
|
||||
func ExampleRemediationsClient_ListDeploymentsAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListDeploymentsAtResourceGroup("<resource-group-name>",
|
||||
"<remediation-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceGroupScope.json
|
||||
func ExampleRemediationsClient_CancelAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CancelAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCancelAtResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceGroupScope.json
|
||||
func ExampleRemediationsClient_ListForResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForResourceGroup("<resource-group-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceGroupScope.json
|
||||
func ExampleRemediationsClient_CreateOrUpdateAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdateAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<remediation-name>",
|
||||
armpolicyinsights.Remediation{
|
||||
Properties: &armpolicyinsights.RemediationProperties{
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCreateOrUpdateAtResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceGroupScope.json
|
||||
func ExampleRemediationsClient_GetAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientGetAtResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceGroupScope.json
|
||||
func ExampleRemediationsClient_DeleteAtResourceGroup() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.DeleteAtResourceGroup(ctx,
|
||||
"<resource-group-name>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientDeleteAtResourceGroupResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceScope.json
|
||||
func ExampleRemediationsClient_ListDeploymentsAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListDeploymentsAtResource("<resource-id>",
|
||||
"<remediation-name>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceScope.json
|
||||
func ExampleRemediationsClient_CancelAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CancelAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCancelAtResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope.json
|
||||
func ExampleRemediationsClient_ListForResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
pager := client.ListForResource("<resource-id>",
|
||||
&armpolicyinsights.QueryOptions{Top: nil,
|
||||
Filter: nil,
|
||||
OrderBy: nil,
|
||||
Select: nil,
|
||||
From: nil,
|
||||
To: nil,
|
||||
Apply: nil,
|
||||
SkipToken: nil,
|
||||
Expand: nil,
|
||||
})
|
||||
for {
|
||||
nextResult := pager.NextPage(ctx)
|
||||
if err := pager.Err(); err != nil {
|
||||
log.Fatalf("failed to advance page: %v", err)
|
||||
}
|
||||
if !nextResult {
|
||||
break
|
||||
}
|
||||
for _, v := range pager.PageResponse().Value {
|
||||
log.Printf("Pager result: %#v\n", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceScope.json
|
||||
func ExampleRemediationsClient_CreateOrUpdateAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.CreateOrUpdateAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<remediation-name>",
|
||||
armpolicyinsights.Remediation{
|
||||
Properties: &armpolicyinsights.RemediationProperties{
|
||||
PolicyAssignmentID: to.StringPtr("<policy-assignment-id>"),
|
||||
},
|
||||
},
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientCreateOrUpdateAtResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json
|
||||
func ExampleRemediationsClient_GetAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.GetAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientGetAtResourceResult)
|
||||
}
|
||||
|
||||
// x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceScope.json
|
||||
func ExampleRemediationsClient_DeleteAtResource() {
|
||||
cred, err := azidentity.NewDefaultAzureCredential(nil)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to obtain a credential: %v", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
client := armpolicyinsights.NewRemediationsClient("<subscription-id>", cred, nil)
|
||||
res, err := client.DeleteAtResource(ctx,
|
||||
"<resource-id>",
|
||||
"<remediation-name>",
|
||||
nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Response result: %#v\n", res.RemediationsClientDeleteAtResourceResult)
|
||||
}
|
|
@ -0,0 +1,678 @@
|
|||
//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 armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// AttestationsClient contains the methods for the Attestations group.
|
||||
// Don't use this type directly, use NewAttestationsClient() instead.
|
||||
type AttestationsClient struct {
|
||||
host string
|
||||
subscriptionID string
|
||||
pl runtime.Pipeline
|
||||
}
|
||||
|
||||
// NewAttestationsClient creates a new instance of AttestationsClient with the specified values.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// options - pass nil to accept the default values.
|
||||
func NewAttestationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *AttestationsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Endpoint) == 0 {
|
||||
cp.Endpoint = arm.AzurePublicCloud
|
||||
}
|
||||
client := &AttestationsClient{
|
||||
subscriptionID: subscriptionID,
|
||||
host: string(cp.Endpoint),
|
||||
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// BeginCreateOrUpdateAtResource - Creates or updates an attestation at resource scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceID - Resource ID.
|
||||
// attestationName - The name of the attestation.
|
||||
// parameters - The attestation parameters.
|
||||
// options - AttestationsClientBeginCreateOrUpdateAtResourceOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtResource
|
||||
// method.
|
||||
func (client *AttestationsClient) BeginCreateOrUpdateAtResource(ctx context.Context, resourceID string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceOptions) (AttestationsClientCreateOrUpdateAtResourcePollerResponse, error) {
|
||||
resp, err := client.createOrUpdateAtResource(ctx, resourceID, attestationName, parameters, options)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtResourcePollerResponse{}, err
|
||||
}
|
||||
result := AttestationsClientCreateOrUpdateAtResourcePollerResponse{
|
||||
RawResponse: resp,
|
||||
}
|
||||
pt, err := armruntime.NewPoller("AttestationsClient.CreateOrUpdateAtResource", "", resp, client.pl)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtResourcePollerResponse{}, err
|
||||
}
|
||||
result.Poller = &AttestationsClientCreateOrUpdateAtResourcePoller{
|
||||
pt: pt,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdateAtResource - Creates or updates an attestation at resource scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
func (client *AttestationsClient) createOrUpdateAtResource(ctx context.Context, resourceID string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceOptions) (*http.Response, error) {
|
||||
req, err := client.createOrUpdateAtResourceCreateRequest(ctx, resourceID, attestationName, parameters, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) {
|
||||
return nil, runtime.NewResponseError(resp)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// createOrUpdateAtResourceCreateRequest creates the CreateOrUpdateAtResource request.
|
||||
func (client *AttestationsClient) createOrUpdateAtResourceCreateRequest(ctx context.Context, resourceID string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceOptions) (*policy.Request, error) {
|
||||
urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID)
|
||||
if attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, parameters)
|
||||
}
|
||||
|
||||
// BeginCreateOrUpdateAtResourceGroup - Creates or updates an attestation at resource group scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceGroupName - The name of the resource group. The name is case insensitive.
|
||||
// attestationName - The name of the attestation.
|
||||
// parameters - The attestation parameters.
|
||||
// options - AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtResourceGroup
|
||||
// method.
|
||||
func (client *AttestationsClient) BeginCreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions) (AttestationsClientCreateOrUpdateAtResourceGroupPollerResponse, error) {
|
||||
resp, err := client.createOrUpdateAtResourceGroup(ctx, resourceGroupName, attestationName, parameters, options)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtResourceGroupPollerResponse{}, err
|
||||
}
|
||||
result := AttestationsClientCreateOrUpdateAtResourceGroupPollerResponse{
|
||||
RawResponse: resp,
|
||||
}
|
||||
pt, err := armruntime.NewPoller("AttestationsClient.CreateOrUpdateAtResourceGroup", "", resp, client.pl)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtResourceGroupPollerResponse{}, err
|
||||
}
|
||||
result.Poller = &AttestationsClientCreateOrUpdateAtResourceGroupPoller{
|
||||
pt: pt,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdateAtResourceGroup - Creates or updates an attestation at resource group scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
func (client *AttestationsClient) createOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions) (*http.Response, error) {
|
||||
req, err := client.createOrUpdateAtResourceGroupCreateRequest(ctx, resourceGroupName, attestationName, parameters, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) {
|
||||
return nil, runtime.NewResponseError(resp)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// createOrUpdateAtResourceGroupCreateRequest creates the CreateOrUpdateAtResourceGroup request.
|
||||
func (client *AttestationsClient) createOrUpdateAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtResourceGroupOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
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 attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, parameters)
|
||||
}
|
||||
|
||||
// BeginCreateOrUpdateAtSubscription - Creates or updates an attestation at subscription scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// attestationName - The name of the attestation.
|
||||
// parameters - The attestation parameters.
|
||||
// options - AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the AttestationsClient.BeginCreateOrUpdateAtSubscription
|
||||
// method.
|
||||
func (client *AttestationsClient) BeginCreateOrUpdateAtSubscription(ctx context.Context, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions) (AttestationsClientCreateOrUpdateAtSubscriptionPollerResponse, error) {
|
||||
resp, err := client.createOrUpdateAtSubscription(ctx, attestationName, parameters, options)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtSubscriptionPollerResponse{}, err
|
||||
}
|
||||
result := AttestationsClientCreateOrUpdateAtSubscriptionPollerResponse{
|
||||
RawResponse: resp,
|
||||
}
|
||||
pt, err := armruntime.NewPoller("AttestationsClient.CreateOrUpdateAtSubscription", "", resp, client.pl)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtSubscriptionPollerResponse{}, err
|
||||
}
|
||||
result.Poller = &AttestationsClientCreateOrUpdateAtSubscriptionPoller{
|
||||
pt: pt,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateOrUpdateAtSubscription - Creates or updates an attestation at subscription scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
func (client *AttestationsClient) createOrUpdateAtSubscription(ctx context.Context, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions) (*http.Response, error) {
|
||||
req, err := client.createOrUpdateAtSubscriptionCreateRequest(ctx, attestationName, parameters, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) {
|
||||
return nil, runtime.NewResponseError(resp)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// createOrUpdateAtSubscriptionCreateRequest creates the CreateOrUpdateAtSubscription request.
|
||||
func (client *AttestationsClient) createOrUpdateAtSubscriptionCreateRequest(ctx context.Context, attestationName string, parameters Attestation, options *AttestationsClientBeginCreateOrUpdateAtSubscriptionOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
if attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, parameters)
|
||||
}
|
||||
|
||||
// DeleteAtResource - Deletes an existing attestation at individual resource scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceID - Resource ID.
|
||||
// attestationName - The name of the attestation.
|
||||
// options - AttestationsClientDeleteAtResourceOptions contains the optional parameters for the AttestationsClient.DeleteAtResource
|
||||
// method.
|
||||
func (client *AttestationsClient) DeleteAtResource(ctx context.Context, resourceID string, attestationName string, options *AttestationsClientDeleteAtResourceOptions) (AttestationsClientDeleteAtResourceResponse, error) {
|
||||
req, err := client.deleteAtResourceCreateRequest(ctx, resourceID, attestationName, options)
|
||||
if err != nil {
|
||||
return AttestationsClientDeleteAtResourceResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return AttestationsClientDeleteAtResourceResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
|
||||
return AttestationsClientDeleteAtResourceResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return AttestationsClientDeleteAtResourceResponse{RawResponse: resp}, nil
|
||||
}
|
||||
|
||||
// deleteAtResourceCreateRequest creates the DeleteAtResource request.
|
||||
func (client *AttestationsClient) deleteAtResourceCreateRequest(ctx context.Context, resourceID string, attestationName string, options *AttestationsClientDeleteAtResourceOptions) (*policy.Request, error) {
|
||||
urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID)
|
||||
if attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// DeleteAtResourceGroup - Deletes an existing attestation at resource group scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceGroupName - The name of the resource group. The name is case insensitive.
|
||||
// attestationName - The name of the attestation.
|
||||
// options - AttestationsClientDeleteAtResourceGroupOptions contains the optional parameters for the AttestationsClient.DeleteAtResourceGroup
|
||||
// method.
|
||||
func (client *AttestationsClient) DeleteAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, options *AttestationsClientDeleteAtResourceGroupOptions) (AttestationsClientDeleteAtResourceGroupResponse, error) {
|
||||
req, err := client.deleteAtResourceGroupCreateRequest(ctx, resourceGroupName, attestationName, options)
|
||||
if err != nil {
|
||||
return AttestationsClientDeleteAtResourceGroupResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return AttestationsClientDeleteAtResourceGroupResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
|
||||
return AttestationsClientDeleteAtResourceGroupResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return AttestationsClientDeleteAtResourceGroupResponse{RawResponse: resp}, nil
|
||||
}
|
||||
|
||||
// deleteAtResourceGroupCreateRequest creates the DeleteAtResourceGroup request.
|
||||
func (client *AttestationsClient) deleteAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, attestationName string, options *AttestationsClientDeleteAtResourceGroupOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
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 attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// DeleteAtSubscription - Deletes an existing attestation at subscription scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// attestationName - The name of the attestation.
|
||||
// options - AttestationsClientDeleteAtSubscriptionOptions contains the optional parameters for the AttestationsClient.DeleteAtSubscription
|
||||
// method.
|
||||
func (client *AttestationsClient) DeleteAtSubscription(ctx context.Context, attestationName string, options *AttestationsClientDeleteAtSubscriptionOptions) (AttestationsClientDeleteAtSubscriptionResponse, error) {
|
||||
req, err := client.deleteAtSubscriptionCreateRequest(ctx, attestationName, options)
|
||||
if err != nil {
|
||||
return AttestationsClientDeleteAtSubscriptionResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return AttestationsClientDeleteAtSubscriptionResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) {
|
||||
return AttestationsClientDeleteAtSubscriptionResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return AttestationsClientDeleteAtSubscriptionResponse{RawResponse: resp}, nil
|
||||
}
|
||||
|
||||
// deleteAtSubscriptionCreateRequest creates the DeleteAtSubscription request.
|
||||
func (client *AttestationsClient) deleteAtSubscriptionCreateRequest(ctx context.Context, attestationName string, options *AttestationsClientDeleteAtSubscriptionOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
if attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// GetAtResource - Gets an existing attestation at resource scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceID - Resource ID.
|
||||
// attestationName - The name of the attestation.
|
||||
// options - AttestationsClientGetAtResourceOptions contains the optional parameters for the AttestationsClient.GetAtResource
|
||||
// method.
|
||||
func (client *AttestationsClient) GetAtResource(ctx context.Context, resourceID string, attestationName string, options *AttestationsClientGetAtResourceOptions) (AttestationsClientGetAtResourceResponse, error) {
|
||||
req, err := client.getAtResourceCreateRequest(ctx, resourceID, attestationName, options)
|
||||
if err != nil {
|
||||
return AttestationsClientGetAtResourceResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return AttestationsClientGetAtResourceResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return AttestationsClientGetAtResourceResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.getAtResourceHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getAtResourceCreateRequest creates the GetAtResource request.
|
||||
func (client *AttestationsClient) getAtResourceCreateRequest(ctx context.Context, resourceID string, attestationName string, options *AttestationsClientGetAtResourceOptions) (*policy.Request, error) {
|
||||
urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID)
|
||||
if attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getAtResourceHandleResponse handles the GetAtResource response.
|
||||
func (client *AttestationsClient) getAtResourceHandleResponse(resp *http.Response) (AttestationsClientGetAtResourceResponse, error) {
|
||||
result := AttestationsClientGetAtResourceResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.Attestation); err != nil {
|
||||
return AttestationsClientGetAtResourceResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetAtResourceGroup - Gets an existing attestation at resource group scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceGroupName - The name of the resource group. The name is case insensitive.
|
||||
// attestationName - The name of the attestation.
|
||||
// options - AttestationsClientGetAtResourceGroupOptions contains the optional parameters for the AttestationsClient.GetAtResourceGroup
|
||||
// method.
|
||||
func (client *AttestationsClient) GetAtResourceGroup(ctx context.Context, resourceGroupName string, attestationName string, options *AttestationsClientGetAtResourceGroupOptions) (AttestationsClientGetAtResourceGroupResponse, error) {
|
||||
req, err := client.getAtResourceGroupCreateRequest(ctx, resourceGroupName, attestationName, options)
|
||||
if err != nil {
|
||||
return AttestationsClientGetAtResourceGroupResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return AttestationsClientGetAtResourceGroupResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return AttestationsClientGetAtResourceGroupResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.getAtResourceGroupHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getAtResourceGroupCreateRequest creates the GetAtResourceGroup request.
|
||||
func (client *AttestationsClient) getAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, attestationName string, options *AttestationsClientGetAtResourceGroupOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
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 attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getAtResourceGroupHandleResponse handles the GetAtResourceGroup response.
|
||||
func (client *AttestationsClient) getAtResourceGroupHandleResponse(resp *http.Response) (AttestationsClientGetAtResourceGroupResponse, error) {
|
||||
result := AttestationsClientGetAtResourceGroupResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.Attestation); err != nil {
|
||||
return AttestationsClientGetAtResourceGroupResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetAtSubscription - Gets an existing attestation at subscription scope.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// attestationName - The name of the attestation.
|
||||
// options - AttestationsClientGetAtSubscriptionOptions contains the optional parameters for the AttestationsClient.GetAtSubscription
|
||||
// method.
|
||||
func (client *AttestationsClient) GetAtSubscription(ctx context.Context, attestationName string, options *AttestationsClientGetAtSubscriptionOptions) (AttestationsClientGetAtSubscriptionResponse, error) {
|
||||
req, err := client.getAtSubscriptionCreateRequest(ctx, attestationName, options)
|
||||
if err != nil {
|
||||
return AttestationsClientGetAtSubscriptionResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return AttestationsClientGetAtSubscriptionResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return AttestationsClientGetAtSubscriptionResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.getAtSubscriptionHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getAtSubscriptionCreateRequest creates the GetAtSubscription request.
|
||||
func (client *AttestationsClient) getAtSubscriptionCreateRequest(ctx context.Context, attestationName string, options *AttestationsClientGetAtSubscriptionOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
if attestationName == "" {
|
||||
return nil, errors.New("parameter attestationName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{attestationName}", url.PathEscape(attestationName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getAtSubscriptionHandleResponse handles the GetAtSubscription response.
|
||||
func (client *AttestationsClient) getAtSubscriptionHandleResponse(resp *http.Response) (AttestationsClientGetAtSubscriptionResponse, error) {
|
||||
result := AttestationsClientGetAtSubscriptionResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.Attestation); err != nil {
|
||||
return AttestationsClientGetAtSubscriptionResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListForResource - Gets all attestations for a resource.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceID - Resource ID.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *AttestationsClient) ListForResource(resourceID string, options *QueryOptions) *AttestationsClientListForResourcePager {
|
||||
return &AttestationsClientListForResourcePager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listForResourceCreateRequest(ctx, resourceID, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp AttestationsClientListForResourceResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.AttestationListResult.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listForResourceCreateRequest creates the ListForResource request.
|
||||
func (client *AttestationsClient) listForResourceCreateRequest(ctx context.Context, resourceID string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/attestations"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID)
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listForResourceHandleResponse handles the ListForResource response.
|
||||
func (client *AttestationsClient) listForResourceHandleResponse(resp *http.Response) (AttestationsClientListForResourceResponse, error) {
|
||||
result := AttestationsClientListForResourceResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.AttestationListResult); err != nil {
|
||||
return AttestationsClientListForResourceResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListForResourceGroup - Gets all attestations for the resource group.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceGroupName - The name of the resource group. The name is case insensitive.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *AttestationsClient) ListForResourceGroup(resourceGroupName string, options *QueryOptions) *AttestationsClientListForResourceGroupPager {
|
||||
return &AttestationsClientListForResourceGroupPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listForResourceGroupCreateRequest(ctx, resourceGroupName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp AttestationsClientListForResourceGroupResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.AttestationListResult.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listForResourceGroupCreateRequest creates the ListForResourceGroup request.
|
||||
func (client *AttestationsClient) listForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
if resourceGroupName == "" {
|
||||
return nil, errors.New("parameter resourceGroupName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listForResourceGroupHandleResponse handles the ListForResourceGroup response.
|
||||
func (client *AttestationsClient) listForResourceGroupHandleResponse(resp *http.Response) (AttestationsClientListForResourceGroupResponse, error) {
|
||||
result := AttestationsClientListForResourceGroupResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.AttestationListResult); err != nil {
|
||||
return AttestationsClientListForResourceGroupResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListForSubscription - Gets all attestations for the subscription.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *AttestationsClient) ListForSubscription(options *QueryOptions) *AttestationsClientListForSubscriptionPager {
|
||||
return &AttestationsClientListForSubscriptionPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listForSubscriptionCreateRequest(ctx, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp AttestationsClientListForSubscriptionResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.AttestationListResult.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listForSubscriptionCreateRequest creates the ListForSubscription request.
|
||||
func (client *AttestationsClient) listForSubscriptionCreateRequest(ctx context.Context, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2021-01-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listForSubscriptionHandleResponse handles the ListForSubscription response.
|
||||
func (client *AttestationsClient) listForSubscriptionHandleResponse(resp *http.Response) (AttestationsClientListForSubscriptionResponse, error) {
|
||||
result := AttestationsClientListForSubscriptionResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.AttestationListResult); err != nil {
|
||||
return AttestationsClientListForSubscriptionResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
//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 armpolicyinsights
|
||||
|
||||
const (
|
||||
moduleName = "armpolicyinsights"
|
||||
moduleVersion = "v0.1.0"
|
||||
)
|
||||
|
||||
// ComplianceState - The compliance state that should be set on the resource.
|
||||
type ComplianceState string
|
||||
|
||||
const (
|
||||
// ComplianceStateCompliant - The resource is in compliance with the policy.
|
||||
ComplianceStateCompliant ComplianceState = "Compliant"
|
||||
// ComplianceStateNonCompliant - The resource is not in compliance with the policy.
|
||||
ComplianceStateNonCompliant ComplianceState = "NonCompliant"
|
||||
// ComplianceStateUnknown - The compliance state of the resource is not known.
|
||||
ComplianceStateUnknown ComplianceState = "Unknown"
|
||||
)
|
||||
|
||||
// PossibleComplianceStateValues returns the possible values for the ComplianceState const type.
|
||||
func PossibleComplianceStateValues() []ComplianceState {
|
||||
return []ComplianceState{
|
||||
ComplianceStateCompliant,
|
||||
ComplianceStateNonCompliant,
|
||||
ComplianceStateUnknown,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *ComplianceState pointing to the current value.
|
||||
func (c ComplianceState) ToPtr() *ComplianceState {
|
||||
return &c
|
||||
}
|
||||
|
||||
// CreatedByType - The type of identity that created the resource.
|
||||
type CreatedByType string
|
||||
|
||||
const (
|
||||
CreatedByTypeApplication CreatedByType = "Application"
|
||||
CreatedByTypeKey CreatedByType = "Key"
|
||||
CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity"
|
||||
CreatedByTypeUser CreatedByType = "User"
|
||||
)
|
||||
|
||||
// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type.
|
||||
func PossibleCreatedByTypeValues() []CreatedByType {
|
||||
return []CreatedByType{
|
||||
CreatedByTypeApplication,
|
||||
CreatedByTypeKey,
|
||||
CreatedByTypeManagedIdentity,
|
||||
CreatedByTypeUser,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *CreatedByType pointing to the current value.
|
||||
func (c CreatedByType) ToPtr() *CreatedByType {
|
||||
return &c
|
||||
}
|
||||
|
||||
type Enum0 string
|
||||
|
||||
const (
|
||||
Enum0MicrosoftManagement Enum0 = "Microsoft.Management"
|
||||
)
|
||||
|
||||
// PossibleEnum0Values returns the possible values for the Enum0 const type.
|
||||
func PossibleEnum0Values() []Enum0 {
|
||||
return []Enum0{
|
||||
Enum0MicrosoftManagement,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *Enum0 pointing to the current value.
|
||||
func (c Enum0) ToPtr() *Enum0 {
|
||||
return &c
|
||||
}
|
||||
|
||||
type Enum1 string
|
||||
|
||||
const (
|
||||
Enum1Default Enum1 = "default"
|
||||
)
|
||||
|
||||
// PossibleEnum1Values returns the possible values for the Enum1 const type.
|
||||
func PossibleEnum1Values() []Enum1 {
|
||||
return []Enum1{
|
||||
Enum1Default,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *Enum1 pointing to the current value.
|
||||
func (c Enum1) ToPtr() *Enum1 {
|
||||
return &c
|
||||
}
|
||||
|
||||
type Enum4 string
|
||||
|
||||
const (
|
||||
Enum4MicrosoftAuthorization Enum4 = "Microsoft.Authorization"
|
||||
)
|
||||
|
||||
// PossibleEnum4Values returns the possible values for the Enum4 const type.
|
||||
func PossibleEnum4Values() []Enum4 {
|
||||
return []Enum4{
|
||||
Enum4MicrosoftAuthorization,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *Enum4 pointing to the current value.
|
||||
func (c Enum4) ToPtr() *Enum4 {
|
||||
return &c
|
||||
}
|
||||
|
||||
type Enum6 string
|
||||
|
||||
const (
|
||||
Enum6Latest Enum6 = "latest"
|
||||
)
|
||||
|
||||
// PossibleEnum6Values returns the possible values for the Enum6 const type.
|
||||
func PossibleEnum6Values() []Enum6 {
|
||||
return []Enum6{
|
||||
Enum6Latest,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *Enum6 pointing to the current value.
|
||||
func (c Enum6) ToPtr() *Enum6 {
|
||||
return &c
|
||||
}
|
||||
|
||||
// FieldRestrictionResult - The type of restriction that is imposed on the field.
|
||||
type FieldRestrictionResult string
|
||||
|
||||
const (
|
||||
// FieldRestrictionResultDeny - The field and/or values will be denied by policy.
|
||||
FieldRestrictionResultDeny FieldRestrictionResult = "Deny"
|
||||
// FieldRestrictionResultRemoved - The field will be removed by policy.
|
||||
FieldRestrictionResultRemoved FieldRestrictionResult = "Removed"
|
||||
// FieldRestrictionResultRequired - The field and/or values are required by policy.
|
||||
FieldRestrictionResultRequired FieldRestrictionResult = "Required"
|
||||
)
|
||||
|
||||
// PossibleFieldRestrictionResultValues returns the possible values for the FieldRestrictionResult const type.
|
||||
func PossibleFieldRestrictionResultValues() []FieldRestrictionResult {
|
||||
return []FieldRestrictionResult{
|
||||
FieldRestrictionResultDeny,
|
||||
FieldRestrictionResultRemoved,
|
||||
FieldRestrictionResultRequired,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *FieldRestrictionResult pointing to the current value.
|
||||
func (c FieldRestrictionResult) ToPtr() *FieldRestrictionResult {
|
||||
return &c
|
||||
}
|
||||
|
||||
type PolicyStatesResource string
|
||||
|
||||
const (
|
||||
PolicyStatesResourceDefault PolicyStatesResource = "default"
|
||||
PolicyStatesResourceLatest PolicyStatesResource = "latest"
|
||||
)
|
||||
|
||||
// PossiblePolicyStatesResourceValues returns the possible values for the PolicyStatesResource const type.
|
||||
func PossiblePolicyStatesResourceValues() []PolicyStatesResource {
|
||||
return []PolicyStatesResource{
|
||||
PolicyStatesResourceDefault,
|
||||
PolicyStatesResourceLatest,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *PolicyStatesResource pointing to the current value.
|
||||
func (c PolicyStatesResource) ToPtr() *PolicyStatesResource {
|
||||
return &c
|
||||
}
|
||||
|
||||
// ResourceDiscoveryMode - The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not specified.
|
||||
type ResourceDiscoveryMode string
|
||||
|
||||
const (
|
||||
// ResourceDiscoveryModeExistingNonCompliant - Remediate resources that are already known to be non-compliant.
|
||||
ResourceDiscoveryModeExistingNonCompliant ResourceDiscoveryMode = "ExistingNonCompliant"
|
||||
// ResourceDiscoveryModeReEvaluateCompliance - Re-evaluate the compliance state of resources and then remediate the resources
|
||||
// found to be non-compliant.
|
||||
ResourceDiscoveryModeReEvaluateCompliance ResourceDiscoveryMode = "ReEvaluateCompliance"
|
||||
)
|
||||
|
||||
// PossibleResourceDiscoveryModeValues returns the possible values for the ResourceDiscoveryMode const type.
|
||||
func PossibleResourceDiscoveryModeValues() []ResourceDiscoveryMode {
|
||||
return []ResourceDiscoveryMode{
|
||||
ResourceDiscoveryModeExistingNonCompliant,
|
||||
ResourceDiscoveryModeReEvaluateCompliance,
|
||||
}
|
||||
}
|
||||
|
||||
// ToPtr returns a *ResourceDiscoveryMode pointing to the current value.
|
||||
func (c ResourceDiscoveryMode) ToPtr() *ResourceDiscoveryMode {
|
||||
return &c
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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 armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// OperationsClient contains the methods for the Operations group.
|
||||
// Don't use this type directly, use NewOperationsClient() instead.
|
||||
type OperationsClient struct {
|
||||
host string
|
||||
pl runtime.Pipeline
|
||||
}
|
||||
|
||||
// NewOperationsClient creates a new instance of OperationsClient with the specified values.
|
||||
// credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// options - pass nil to accept the default values.
|
||||
func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Endpoint) == 0 {
|
||||
cp.Endpoint = arm.AzurePublicCloud
|
||||
}
|
||||
client := &OperationsClient{
|
||||
host: string(cp.Endpoint),
|
||||
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// List - Lists available operations.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method.
|
||||
func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) {
|
||||
req, err := client.listCreateRequest(ctx, options)
|
||||
if err != nil {
|
||||
return OperationsClientListResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return OperationsClientListResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return OperationsClientListResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.listHandleResponse(resp)
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/Microsoft.PolicyInsights/operations"
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
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) (OperationsClientListResponse, error) {
|
||||
result := OperationsClientListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.OperationsListResults); err != nil {
|
||||
return OperationsClientListResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,692 @@
|
|||
//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 armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PolicyEventsClient contains the methods for the PolicyEvents group.
|
||||
// Don't use this type directly, use NewPolicyEventsClient() instead.
|
||||
type PolicyEventsClient struct {
|
||||
host string
|
||||
pl runtime.Pipeline
|
||||
}
|
||||
|
||||
// NewPolicyEventsClient creates a new instance of PolicyEventsClient with the specified values.
|
||||
// credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// options - pass nil to accept the default values.
|
||||
func NewPolicyEventsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *PolicyEventsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Endpoint) == 0 {
|
||||
cp.Endpoint = arm.AzurePublicCloud
|
||||
}
|
||||
client := &PolicyEventsClient{
|
||||
host: string(cp.Endpoint),
|
||||
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// ListQueryResultsForManagementGroup - Queries policy events for the resources under the management group.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// managementGroupsNamespace - The namespace for Microsoft Management RP; only "Microsoft.Management" is allowed.
|
||||
// managementGroupName - Management group name.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForManagementGroup(policyEventsResource Enum1, managementGroupsNamespace Enum0, managementGroupName string, options *QueryOptions) *PolicyEventsClientListQueryResultsForManagementGroupPager {
|
||||
return &PolicyEventsClientListQueryResultsForManagementGroupPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForManagementGroupCreateRequest(ctx, policyEventsResource, managementGroupsNamespace, managementGroupName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForManagementGroupResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForManagementGroupCreateRequest creates the ListQueryResultsForManagementGroup request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForManagementGroupCreateRequest(ctx context.Context, policyEventsResource Enum1, managementGroupsNamespace Enum0, managementGroupName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if managementGroupsNamespace == "" {
|
||||
return nil, errors.New("parameter managementGroupsNamespace cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{managementGroupsNamespace}", url.PathEscape(string(managementGroupsNamespace)))
|
||||
if managementGroupName == "" {
|
||||
return nil, errors.New("parameter managementGroupName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForManagementGroupHandleResponse handles the ListQueryResultsForManagementGroup response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForManagementGroupHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForManagementGroupResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForManagementGroupResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForManagementGroupResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForPolicyDefinition - Queries policy events for the subscription level policy definition.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// authorizationNamespace - The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is
|
||||
// allowed.
|
||||
// policyDefinitionName - Policy definition name.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForPolicyDefinition(policyEventsResource Enum1, subscriptionID string, authorizationNamespace Enum4, policyDefinitionName string, options *QueryOptions) *PolicyEventsClientListQueryResultsForPolicyDefinitionPager {
|
||||
return &PolicyEventsClientListQueryResultsForPolicyDefinitionPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForPolicyDefinitionCreateRequest(ctx, policyEventsResource, subscriptionID, authorizationNamespace, policyDefinitionName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForPolicyDefinitionResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForPolicyDefinitionCreateRequest creates the ListQueryResultsForPolicyDefinition request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForPolicyDefinitionCreateRequest(ctx context.Context, policyEventsResource Enum1, subscriptionID string, authorizationNamespace Enum4, policyDefinitionName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if subscriptionID == "" {
|
||||
return nil, errors.New("parameter subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID))
|
||||
if authorizationNamespace == "" {
|
||||
return nil, errors.New("parameter authorizationNamespace cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape(string(authorizationNamespace)))
|
||||
if policyDefinitionName == "" {
|
||||
return nil, errors.New("parameter policyDefinitionName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForPolicyDefinitionHandleResponse handles the ListQueryResultsForPolicyDefinition response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForPolicyDefinitionHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForPolicyDefinitionResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForPolicyDefinitionResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForPolicyDefinitionResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForPolicySetDefinition - Queries policy events for the subscription level policy set definition.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// authorizationNamespace - The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is
|
||||
// allowed.
|
||||
// policySetDefinitionName - Policy set definition name.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForPolicySetDefinition(policyEventsResource Enum1, subscriptionID string, authorizationNamespace Enum4, policySetDefinitionName string, options *QueryOptions) *PolicyEventsClientListQueryResultsForPolicySetDefinitionPager {
|
||||
return &PolicyEventsClientListQueryResultsForPolicySetDefinitionPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForPolicySetDefinitionCreateRequest(ctx, policyEventsResource, subscriptionID, authorizationNamespace, policySetDefinitionName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForPolicySetDefinitionCreateRequest creates the ListQueryResultsForPolicySetDefinition request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForPolicySetDefinitionCreateRequest(ctx context.Context, policyEventsResource Enum1, subscriptionID string, authorizationNamespace Enum4, policySetDefinitionName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if subscriptionID == "" {
|
||||
return nil, errors.New("parameter subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID))
|
||||
if authorizationNamespace == "" {
|
||||
return nil, errors.New("parameter authorizationNamespace cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape(string(authorizationNamespace)))
|
||||
if policySetDefinitionName == "" {
|
||||
return nil, errors.New("parameter policySetDefinitionName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForPolicySetDefinitionHandleResponse handles the ListQueryResultsForPolicySetDefinition response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForPolicySetDefinitionHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForPolicySetDefinitionResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForResource - Queries policy events for the resource.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// resourceID - Resource ID.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForResource(policyEventsResource Enum1, resourceID string, options *QueryOptions) *PolicyEventsClientListQueryResultsForResourcePager {
|
||||
return &PolicyEventsClientListQueryResultsForResourcePager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForResourceCreateRequest(ctx, policyEventsResource, resourceID, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForResourceResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceCreateRequest creates the ListQueryResultsForResource request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForResourceCreateRequest(ctx context.Context, policyEventsResource Enum1, resourceID string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID)
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.Expand != nil {
|
||||
reqQP.Set("$expand", *options.Expand)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceHandleResponse handles the ListQueryResultsForResource response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForResourceHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForResourceResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForResourceResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForResourceResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForResourceGroup - Queries policy events for the resources under the resource group.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// resourceGroupName - Resource group name.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForResourceGroup(policyEventsResource Enum1, subscriptionID string, resourceGroupName string, options *QueryOptions) *PolicyEventsClientListQueryResultsForResourceGroupPager {
|
||||
return &PolicyEventsClientListQueryResultsForResourceGroupPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForResourceGroupCreateRequest(ctx, policyEventsResource, subscriptionID, resourceGroupName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForResourceGroupResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceGroupCreateRequest creates the ListQueryResultsForResourceGroup request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForResourceGroupCreateRequest(ctx context.Context, policyEventsResource Enum1, subscriptionID string, resourceGroupName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if subscriptionID == "" {
|
||||
return nil, errors.New("parameter subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(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.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceGroupHandleResponse handles the ListQueryResultsForResourceGroup response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForResourceGroupHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForResourceGroupResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForResourceGroupResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForResourceGroupResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForResourceGroupLevelPolicyAssignment - Queries policy events for the resource group level policy assignment.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// resourceGroupName - Resource group name.
|
||||
// authorizationNamespace - The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is
|
||||
// allowed.
|
||||
// policyAssignmentName - Policy assignment name.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForResourceGroupLevelPolicyAssignment(policyEventsResource Enum1, subscriptionID string, resourceGroupName string, authorizationNamespace Enum4, policyAssignmentName string, options *QueryOptions) *PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentPager {
|
||||
return &PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForResourceGroupLevelPolicyAssignmentCreateRequest(ctx, policyEventsResource, subscriptionID, resourceGroupName, authorizationNamespace, policyAssignmentName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceGroupLevelPolicyAssignmentCreateRequest creates the ListQueryResultsForResourceGroupLevelPolicyAssignment request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForResourceGroupLevelPolicyAssignmentCreateRequest(ctx context.Context, policyEventsResource Enum1, subscriptionID string, resourceGroupName string, authorizationNamespace Enum4, policyAssignmentName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if subscriptionID == "" {
|
||||
return nil, errors.New("parameter subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID))
|
||||
if resourceGroupName == "" {
|
||||
return nil, errors.New("parameter resourceGroupName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
|
||||
if authorizationNamespace == "" {
|
||||
return nil, errors.New("parameter authorizationNamespace cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape(string(authorizationNamespace)))
|
||||
if policyAssignmentName == "" {
|
||||
return nil, errors.New("parameter policyAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentName}", url.PathEscape(policyAssignmentName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceGroupLevelPolicyAssignmentHandleResponse handles the ListQueryResultsForResourceGroupLevelPolicyAssignment response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForResourceGroupLevelPolicyAssignmentHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForResourceGroupLevelPolicyAssignmentResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForSubscription - Queries policy events for the resources under the subscription.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForSubscription(policyEventsResource Enum1, subscriptionID string, options *QueryOptions) *PolicyEventsClientListQueryResultsForSubscriptionPager {
|
||||
return &PolicyEventsClientListQueryResultsForSubscriptionPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForSubscriptionCreateRequest(ctx, policyEventsResource, subscriptionID, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForSubscriptionResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForSubscriptionCreateRequest creates the ListQueryResultsForSubscription request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForSubscriptionCreateRequest(ctx context.Context, policyEventsResource Enum1, subscriptionID string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if subscriptionID == "" {
|
||||
return nil, errors.New("parameter subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForSubscriptionHandleResponse handles the ListQueryResultsForSubscription response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForSubscriptionHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForSubscriptionResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForSubscriptionResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForSubscriptionResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForSubscriptionLevelPolicyAssignment - Queries policy events for the subscription level policy assignment.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyEventsResource - The name of the virtual resource under PolicyEvents resource type; only "default" is allowed.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// authorizationNamespace - The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is
|
||||
// allowed.
|
||||
// policyAssignmentName - Policy assignment name.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyEventsClient) ListQueryResultsForSubscriptionLevelPolicyAssignment(policyEventsResource Enum1, subscriptionID string, authorizationNamespace Enum4, policyAssignmentName string, options *QueryOptions) *PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentPager {
|
||||
return &PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForSubscriptionLevelPolicyAssignmentCreateRequest(ctx, policyEventsResource, subscriptionID, authorizationNamespace, policyAssignmentName, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyEventsQueryResults.ODataNextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForSubscriptionLevelPolicyAssignmentCreateRequest creates the ListQueryResultsForSubscriptionLevelPolicyAssignment request.
|
||||
func (client *PolicyEventsClient) listQueryResultsForSubscriptionLevelPolicyAssignmentCreateRequest(ctx context.Context, policyEventsResource Enum1, subscriptionID string, authorizationNamespace Enum4, policyAssignmentName string, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults"
|
||||
if policyEventsResource == "" {
|
||||
return nil, errors.New("parameter policyEventsResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyEventsResource}", url.PathEscape(string(policyEventsResource)))
|
||||
if subscriptionID == "" {
|
||||
return nil, errors.New("parameter subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID))
|
||||
if authorizationNamespace == "" {
|
||||
return nil, errors.New("parameter authorizationNamespace cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{authorizationNamespace}", url.PathEscape(string(authorizationNamespace)))
|
||||
if policyAssignmentName == "" {
|
||||
return nil, errors.New("parameter policyAssignmentName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyAssignmentName}", url.PathEscape(policyAssignmentName))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.OrderBy != nil {
|
||||
reqQP.Set("$orderby", *options.OrderBy)
|
||||
}
|
||||
if options != nil && options.Select != nil {
|
||||
reqQP.Set("$select", *options.Select)
|
||||
}
|
||||
if options != nil && options.From != nil {
|
||||
reqQP.Set("$from", options.From.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.To != nil {
|
||||
reqQP.Set("$to", options.To.Format(time.RFC3339Nano))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
if options != nil && options.Apply != nil {
|
||||
reqQP.Set("$apply", *options.Apply)
|
||||
}
|
||||
if options != nil && options.SkipToken != nil {
|
||||
reqQP.Set("$skiptoken", *options.SkipToken)
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForSubscriptionLevelPolicyAssignmentHandleResponse handles the ListQueryResultsForSubscriptionLevelPolicyAssignment response.
|
||||
func (client *PolicyEventsClient) listQueryResultsForSubscriptionLevelPolicyAssignmentHandleResponse(resp *http.Response) (PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse, error) {
|
||||
result := PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyEventsQueryResults); err != nil {
|
||||
return PolicyEventsClientListQueryResultsForSubscriptionLevelPolicyAssignmentResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
//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 armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PolicyMetadataClient contains the methods for the PolicyMetadata group.
|
||||
// Don't use this type directly, use NewPolicyMetadataClient() instead.
|
||||
type PolicyMetadataClient struct {
|
||||
host string
|
||||
pl runtime.Pipeline
|
||||
}
|
||||
|
||||
// NewPolicyMetadataClient creates a new instance of PolicyMetadataClient with the specified values.
|
||||
// credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// options - pass nil to accept the default values.
|
||||
func NewPolicyMetadataClient(credential azcore.TokenCredential, options *arm.ClientOptions) *PolicyMetadataClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Endpoint) == 0 {
|
||||
cp.Endpoint = arm.AzurePublicCloud
|
||||
}
|
||||
client := &PolicyMetadataClient{
|
||||
host: string(cp.Endpoint),
|
||||
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// GetResource - Get policy metadata resource.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceName - The name of the policy metadata resource.
|
||||
// options - PolicyMetadataClientGetResourceOptions contains the optional parameters for the PolicyMetadataClient.GetResource
|
||||
// method.
|
||||
func (client *PolicyMetadataClient) GetResource(ctx context.Context, resourceName string, options *PolicyMetadataClientGetResourceOptions) (PolicyMetadataClientGetResourceResponse, error) {
|
||||
req, err := client.getResourceCreateRequest(ctx, resourceName, options)
|
||||
if err != nil {
|
||||
return PolicyMetadataClientGetResourceResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return PolicyMetadataClientGetResourceResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return PolicyMetadataClientGetResourceResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.getResourceHandleResponse(resp)
|
||||
}
|
||||
|
||||
// getResourceCreateRequest creates the GetResource request.
|
||||
func (client *PolicyMetadataClient) getResourceCreateRequest(ctx context.Context, resourceName string, options *PolicyMetadataClientGetResourceOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/Microsoft.PolicyInsights/policyMetadata/{resourceName}"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceName}", resourceName)
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// getResourceHandleResponse handles the GetResource response.
|
||||
func (client *PolicyMetadataClient) getResourceHandleResponse(resp *http.Response) (PolicyMetadataClientGetResourceResponse, error) {
|
||||
result := PolicyMetadataClientGetResourceResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyMetadata); err != nil {
|
||||
return PolicyMetadataClientGetResourceResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// List - Get a list of the policy metadata resources.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyMetadataClient) List(options *QueryOptions) *PolicyMetadataClientListPager {
|
||||
return &PolicyMetadataClientListPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listCreateRequest(ctx, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyMetadataClientListResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyMetadataCollection.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listCreateRequest creates the List request.
|
||||
func (client *PolicyMetadataClient) listCreateRequest(ctx context.Context, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/Microsoft.PolicyInsights/policyMetadata"
|
||||
req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2019-10-01")
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listHandleResponse handles the List response.
|
||||
func (client *PolicyMetadataClient) listHandleResponse(resp *http.Response) (PolicyMetadataClientListResponse, error) {
|
||||
result := PolicyMetadataClientListResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyMetadataCollection); err != nil {
|
||||
return PolicyMetadataClientListResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
//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 armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PolicyRestrictionsClient contains the methods for the PolicyRestrictions group.
|
||||
// Don't use this type directly, use NewPolicyRestrictionsClient() instead.
|
||||
type PolicyRestrictionsClient struct {
|
||||
host string
|
||||
subscriptionID string
|
||||
pl runtime.Pipeline
|
||||
}
|
||||
|
||||
// NewPolicyRestrictionsClient creates a new instance of PolicyRestrictionsClient with the specified values.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// options - pass nil to accept the default values.
|
||||
func NewPolicyRestrictionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PolicyRestrictionsClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Endpoint) == 0 {
|
||||
cp.Endpoint = arm.AzurePublicCloud
|
||||
}
|
||||
client := &PolicyRestrictionsClient{
|
||||
subscriptionID: subscriptionID,
|
||||
host: string(cp.Endpoint),
|
||||
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// CheckAtResourceGroupScope - Checks what restrictions Azure Policy will place on a resource within a resource group. Use
|
||||
// this when the resource group the resource will be created in is already known.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceGroupName - The name of the resource group. The name is case insensitive.
|
||||
// parameters - The check policy restrictions parameters.
|
||||
// options - PolicyRestrictionsClientCheckAtResourceGroupScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtResourceGroupScope
|
||||
// method.
|
||||
func (client *PolicyRestrictionsClient) CheckAtResourceGroupScope(ctx context.Context, resourceGroupName string, parameters CheckRestrictionsRequest, options *PolicyRestrictionsClientCheckAtResourceGroupScopeOptions) (PolicyRestrictionsClientCheckAtResourceGroupScopeResponse, error) {
|
||||
req, err := client.checkAtResourceGroupScopeCreateRequest(ctx, resourceGroupName, parameters, options)
|
||||
if err != nil {
|
||||
return PolicyRestrictionsClientCheckAtResourceGroupScopeResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return PolicyRestrictionsClientCheckAtResourceGroupScopeResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return PolicyRestrictionsClientCheckAtResourceGroupScopeResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.checkAtResourceGroupScopeHandleResponse(resp)
|
||||
}
|
||||
|
||||
// checkAtResourceGroupScopeCreateRequest creates the CheckAtResourceGroupScope request.
|
||||
func (client *PolicyRestrictionsClient) checkAtResourceGroupScopeCreateRequest(ctx context.Context, resourceGroupName string, parameters CheckRestrictionsRequest, options *PolicyRestrictionsClientCheckAtResourceGroupScopeOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions"
|
||||
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.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2020-07-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, parameters)
|
||||
}
|
||||
|
||||
// checkAtResourceGroupScopeHandleResponse handles the CheckAtResourceGroupScope response.
|
||||
func (client *PolicyRestrictionsClient) checkAtResourceGroupScopeHandleResponse(resp *http.Response) (PolicyRestrictionsClientCheckAtResourceGroupScopeResponse, error) {
|
||||
result := PolicyRestrictionsClientCheckAtResourceGroupScopeResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.CheckRestrictionsResult); err != nil {
|
||||
return PolicyRestrictionsClientCheckAtResourceGroupScopeResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CheckAtSubscriptionScope - Checks what restrictions Azure Policy will place on a resource within a subscription.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// parameters - The check policy restrictions parameters.
|
||||
// options - PolicyRestrictionsClientCheckAtSubscriptionScopeOptions contains the optional parameters for the PolicyRestrictionsClient.CheckAtSubscriptionScope
|
||||
// method.
|
||||
func (client *PolicyRestrictionsClient) CheckAtSubscriptionScope(ctx context.Context, parameters CheckRestrictionsRequest, options *PolicyRestrictionsClientCheckAtSubscriptionScopeOptions) (PolicyRestrictionsClientCheckAtSubscriptionScopeResponse, error) {
|
||||
req, err := client.checkAtSubscriptionScopeCreateRequest(ctx, parameters, options)
|
||||
if err != nil {
|
||||
return PolicyRestrictionsClientCheckAtSubscriptionScopeResponse{}, err
|
||||
}
|
||||
resp, err := client.pl.Do(req)
|
||||
if err != nil {
|
||||
return PolicyRestrictionsClientCheckAtSubscriptionScopeResponse{}, err
|
||||
}
|
||||
if !runtime.HasStatusCode(resp, http.StatusOK) {
|
||||
return PolicyRestrictionsClientCheckAtSubscriptionScopeResponse{}, runtime.NewResponseError(resp)
|
||||
}
|
||||
return client.checkAtSubscriptionScopeHandleResponse(resp)
|
||||
}
|
||||
|
||||
// checkAtSubscriptionScopeCreateRequest creates the CheckAtSubscriptionScope request.
|
||||
func (client *PolicyRestrictionsClient) checkAtSubscriptionScopeCreateRequest(ctx context.Context, parameters CheckRestrictionsRequest, options *PolicyRestrictionsClientCheckAtSubscriptionScopeOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions"
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
reqQP.Set("api-version", "2020-07-01")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, runtime.MarshalAsJSON(req, parameters)
|
||||
}
|
||||
|
||||
// checkAtSubscriptionScopeHandleResponse handles the CheckAtSubscriptionScope response.
|
||||
func (client *PolicyRestrictionsClient) checkAtSubscriptionScopeHandleResponse(resp *http.Response) (PolicyRestrictionsClientCheckAtSubscriptionScopeResponse, error) {
|
||||
result := PolicyRestrictionsClientCheckAtSubscriptionScopeResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.CheckRestrictionsResult); err != nil {
|
||||
return PolicyRestrictionsClientCheckAtSubscriptionScopeResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,280 @@
|
|||
//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 armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
|
||||
armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PolicyTrackedResourcesClient contains the methods for the PolicyTrackedResources group.
|
||||
// Don't use this type directly, use NewPolicyTrackedResourcesClient() instead.
|
||||
type PolicyTrackedResourcesClient struct {
|
||||
host string
|
||||
subscriptionID string
|
||||
pl runtime.Pipeline
|
||||
}
|
||||
|
||||
// NewPolicyTrackedResourcesClient creates a new instance of PolicyTrackedResourcesClient with the specified values.
|
||||
// subscriptionID - Microsoft Azure subscription ID.
|
||||
// credential - used to authorize requests. Usually a credential from azidentity.
|
||||
// options - pass nil to accept the default values.
|
||||
func NewPolicyTrackedResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PolicyTrackedResourcesClient {
|
||||
cp := arm.ClientOptions{}
|
||||
if options != nil {
|
||||
cp = *options
|
||||
}
|
||||
if len(cp.Endpoint) == 0 {
|
||||
cp.Endpoint = arm.AzurePublicCloud
|
||||
}
|
||||
client := &PolicyTrackedResourcesClient{
|
||||
subscriptionID: subscriptionID,
|
||||
host: string(cp.Endpoint),
|
||||
pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// ListQueryResultsForManagementGroup - Queries policy tracked resources under the management group.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// managementGroupsNamespace - The namespace for Microsoft Management RP; only "Microsoft.Management" is allowed.
|
||||
// managementGroupName - Management group name.
|
||||
// policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default"
|
||||
// is allowed.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyTrackedResourcesClient) ListQueryResultsForManagementGroup(managementGroupsNamespace Enum0, managementGroupName string, policyTrackedResourcesResource Enum1, options *QueryOptions) *PolicyTrackedResourcesClientListQueryResultsForManagementGroupPager {
|
||||
return &PolicyTrackedResourcesClientListQueryResultsForManagementGroupPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForManagementGroupCreateRequest(ctx, managementGroupsNamespace, managementGroupName, policyTrackedResourcesResource, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyTrackedResourcesQueryResults.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForManagementGroupCreateRequest creates the ListQueryResultsForManagementGroup request.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForManagementGroupCreateRequest(ctx context.Context, managementGroupsNamespace Enum0, managementGroupName string, policyTrackedResourcesResource Enum1, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults"
|
||||
if managementGroupsNamespace == "" {
|
||||
return nil, errors.New("parameter managementGroupsNamespace cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{managementGroupsNamespace}", url.PathEscape(string(managementGroupsNamespace)))
|
||||
if managementGroupName == "" {
|
||||
return nil, errors.New("parameter managementGroupName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName))
|
||||
if policyTrackedResourcesResource == "" {
|
||||
return nil, errors.New("parameter policyTrackedResourcesResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyTrackedResourcesResource}", url.PathEscape(string(policyTrackedResourcesResource)))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2018-07-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForManagementGroupHandleResponse handles the ListQueryResultsForManagementGroup response.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForManagementGroupHandleResponse(resp *http.Response) (PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse, error) {
|
||||
result := PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyTrackedResourcesQueryResults); err != nil {
|
||||
return PolicyTrackedResourcesClientListQueryResultsForManagementGroupResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForResource - Queries policy tracked resources under the resource.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceID - Resource ID.
|
||||
// policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default"
|
||||
// is allowed.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyTrackedResourcesClient) ListQueryResultsForResource(resourceID string, policyTrackedResourcesResource Enum1, options *QueryOptions) *PolicyTrackedResourcesClientListQueryResultsForResourcePager {
|
||||
return &PolicyTrackedResourcesClientListQueryResultsForResourcePager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForResourceCreateRequest(ctx, resourceID, policyTrackedResourcesResource, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyTrackedResourcesClientListQueryResultsForResourceResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyTrackedResourcesQueryResults.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceCreateRequest creates the ListQueryResultsForResource request.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForResourceCreateRequest(ctx context.Context, resourceID string, policyTrackedResourcesResource Enum1, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults"
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceId}", resourceID)
|
||||
if policyTrackedResourcesResource == "" {
|
||||
return nil, errors.New("parameter policyTrackedResourcesResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyTrackedResourcesResource}", url.PathEscape(string(policyTrackedResourcesResource)))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2018-07-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceHandleResponse handles the ListQueryResultsForResource response.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForResourceHandleResponse(resp *http.Response) (PolicyTrackedResourcesClientListQueryResultsForResourceResponse, error) {
|
||||
result := PolicyTrackedResourcesClientListQueryResultsForResourceResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyTrackedResourcesQueryResults); err != nil {
|
||||
return PolicyTrackedResourcesClientListQueryResultsForResourceResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForResourceGroup - Queries policy tracked resources under the resource group.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// resourceGroupName - Resource group name.
|
||||
// policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default"
|
||||
// is allowed.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyTrackedResourcesClient) ListQueryResultsForResourceGroup(resourceGroupName string, policyTrackedResourcesResource Enum1, options *QueryOptions) *PolicyTrackedResourcesClientListQueryResultsForResourceGroupPager {
|
||||
return &PolicyTrackedResourcesClientListQueryResultsForResourceGroupPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForResourceGroupCreateRequest(ctx, resourceGroupName, policyTrackedResourcesResource, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyTrackedResourcesQueryResults.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceGroupCreateRequest creates the ListQueryResultsForResourceGroup request.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, policyTrackedResourcesResource Enum1, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults"
|
||||
if resourceGroupName == "" {
|
||||
return nil, errors.New("parameter resourceGroupName cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName))
|
||||
if policyTrackedResourcesResource == "" {
|
||||
return nil, errors.New("parameter policyTrackedResourcesResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyTrackedResourcesResource}", url.PathEscape(string(policyTrackedResourcesResource)))
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2018-07-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForResourceGroupHandleResponse handles the ListQueryResultsForResourceGroup response.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForResourceGroupHandleResponse(resp *http.Response) (PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse, error) {
|
||||
result := PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyTrackedResourcesQueryResults); err != nil {
|
||||
return PolicyTrackedResourcesClientListQueryResultsForResourceGroupResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ListQueryResultsForSubscription - Queries policy tracked resources under the subscription.
|
||||
// If the operation fails it returns an *azcore.ResponseError type.
|
||||
// policyTrackedResourcesResource - The name of the virtual resource under PolicyTrackedResources resource type; only "default"
|
||||
// is allowed.
|
||||
// options - QueryOptions contains a group of parameters for the PolicyTrackedResourcesClient.ListQueryResultsForManagementGroup
|
||||
// method.
|
||||
func (client *PolicyTrackedResourcesClient) ListQueryResultsForSubscription(policyTrackedResourcesResource Enum1, options *QueryOptions) *PolicyTrackedResourcesClientListQueryResultsForSubscriptionPager {
|
||||
return &PolicyTrackedResourcesClientListQueryResultsForSubscriptionPager{
|
||||
client: client,
|
||||
requester: func(ctx context.Context) (*policy.Request, error) {
|
||||
return client.listQueryResultsForSubscriptionCreateRequest(ctx, policyTrackedResourcesResource, options)
|
||||
},
|
||||
advancer: func(ctx context.Context, resp PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse) (*policy.Request, error) {
|
||||
return runtime.NewRequest(ctx, http.MethodGet, *resp.PolicyTrackedResourcesQueryResults.NextLink)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// listQueryResultsForSubscriptionCreateRequest creates the ListQueryResultsForSubscription request.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForSubscriptionCreateRequest(ctx context.Context, policyTrackedResourcesResource Enum1, options *QueryOptions) (*policy.Request, error) {
|
||||
urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults"
|
||||
if policyTrackedResourcesResource == "" {
|
||||
return nil, errors.New("parameter policyTrackedResourcesResource cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{policyTrackedResourcesResource}", url.PathEscape(string(policyTrackedResourcesResource)))
|
||||
if client.subscriptionID == "" {
|
||||
return nil, errors.New("parameter client.subscriptionID cannot be empty")
|
||||
}
|
||||
urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID))
|
||||
req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reqQP := req.Raw().URL.Query()
|
||||
if options != nil && options.Top != nil {
|
||||
reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10))
|
||||
}
|
||||
if options != nil && options.Filter != nil {
|
||||
reqQP.Set("$filter", *options.Filter)
|
||||
}
|
||||
reqQP.Set("api-version", "2018-07-01-preview")
|
||||
req.Raw().URL.RawQuery = reqQP.Encode()
|
||||
req.Raw().Header.Set("Accept", "application/json")
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// listQueryResultsForSubscriptionHandleResponse handles the ListQueryResultsForSubscription response.
|
||||
func (client *PolicyTrackedResourcesClient) listQueryResultsForSubscriptionHandleResponse(resp *http.Response) (PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse, error) {
|
||||
result := PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse{RawResponse: resp}
|
||||
if err := runtime.UnmarshalAsJSON(resp, &result.PolicyTrackedResourcesQueryResults); err != nil {
|
||||
return PolicyTrackedResourcesClientListQueryResultsForSubscriptionResponse{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator.
|
||||
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
|
||||
package armpolicyinsights
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AttestationsClientCreateOrUpdateAtResourceGroupPoller provides polling facilities until the operation reaches a terminal state.
|
||||
type AttestationsClientCreateOrUpdateAtResourceGroupPoller struct {
|
||||
pt *azcore.Poller
|
||||
}
|
||||
|
||||
// Done returns true if the LRO has reached a terminal state.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourceGroupPoller) Done() bool {
|
||||
return p.pt.Done()
|
||||
}
|
||||
|
||||
// Poll fetches the latest state of the LRO. It returns an HTTP response or error.
|
||||
// If the LRO has completed successfully, the poller's state is updated and the HTTP
|
||||
// response is returned.
|
||||
// If the LRO has completed with failure or was cancelled, the poller's state is
|
||||
// updated and the error is returned.
|
||||
// If the LRO has not reached a terminal state, the poller's state is updated and
|
||||
// the latest HTTP response is returned.
|
||||
// If Poll fails, the poller's state is unmodified and the error is returned.
|
||||
// Calling Poll on an LRO that has reached a terminal state will return the final
|
||||
// HTTP response or error.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourceGroupPoller) Poll(ctx context.Context) (*http.Response, error) {
|
||||
return p.pt.Poll(ctx)
|
||||
}
|
||||
|
||||
// FinalResponse performs a final GET to the service and returns the final response
|
||||
// for the polling operation. If there is an error performing the final GET then an error is returned.
|
||||
// If the final GET succeeded then the final AttestationsClientCreateOrUpdateAtResourceGroupResponse will be returned.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourceGroupPoller) FinalResponse(ctx context.Context) (AttestationsClientCreateOrUpdateAtResourceGroupResponse, error) {
|
||||
respType := AttestationsClientCreateOrUpdateAtResourceGroupResponse{}
|
||||
resp, err := p.pt.FinalResponse(ctx, &respType.Attestation)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtResourceGroupResponse{}, err
|
||||
}
|
||||
respType.RawResponse = resp
|
||||
return respType, nil
|
||||
}
|
||||
|
||||
// ResumeToken returns a value representing the poller that can be used to resume
|
||||
// the LRO at a later time. ResumeTokens are unique per service operation.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourceGroupPoller) ResumeToken() (string, error) {
|
||||
return p.pt.ResumeToken()
|
||||
}
|
||||
|
||||
// AttestationsClientCreateOrUpdateAtResourcePoller provides polling facilities until the operation reaches a terminal state.
|
||||
type AttestationsClientCreateOrUpdateAtResourcePoller struct {
|
||||
pt *azcore.Poller
|
||||
}
|
||||
|
||||
// Done returns true if the LRO has reached a terminal state.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourcePoller) Done() bool {
|
||||
return p.pt.Done()
|
||||
}
|
||||
|
||||
// Poll fetches the latest state of the LRO. It returns an HTTP response or error.
|
||||
// If the LRO has completed successfully, the poller's state is updated and the HTTP
|
||||
// response is returned.
|
||||
// If the LRO has completed with failure or was cancelled, the poller's state is
|
||||
// updated and the error is returned.
|
||||
// If the LRO has not reached a terminal state, the poller's state is updated and
|
||||
// the latest HTTP response is returned.
|
||||
// If Poll fails, the poller's state is unmodified and the error is returned.
|
||||
// Calling Poll on an LRO that has reached a terminal state will return the final
|
||||
// HTTP response or error.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourcePoller) Poll(ctx context.Context) (*http.Response, error) {
|
||||
return p.pt.Poll(ctx)
|
||||
}
|
||||
|
||||
// FinalResponse performs a final GET to the service and returns the final response
|
||||
// for the polling operation. If there is an error performing the final GET then an error is returned.
|
||||
// If the final GET succeeded then the final AttestationsClientCreateOrUpdateAtResourceResponse will be returned.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourcePoller) FinalResponse(ctx context.Context) (AttestationsClientCreateOrUpdateAtResourceResponse, error) {
|
||||
respType := AttestationsClientCreateOrUpdateAtResourceResponse{}
|
||||
resp, err := p.pt.FinalResponse(ctx, &respType.Attestation)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtResourceResponse{}, err
|
||||
}
|
||||
respType.RawResponse = resp
|
||||
return respType, nil
|
||||
}
|
||||
|
||||
// ResumeToken returns a value representing the poller that can be used to resume
|
||||
// the LRO at a later time. ResumeTokens are unique per service operation.
|
||||
func (p *AttestationsClientCreateOrUpdateAtResourcePoller) ResumeToken() (string, error) {
|
||||
return p.pt.ResumeToken()
|
||||
}
|
||||
|
||||
// AttestationsClientCreateOrUpdateAtSubscriptionPoller provides polling facilities until the operation reaches a terminal state.
|
||||
type AttestationsClientCreateOrUpdateAtSubscriptionPoller struct {
|
||||
pt *azcore.Poller
|
||||
}
|
||||
|
||||
// Done returns true if the LRO has reached a terminal state.
|
||||
func (p *AttestationsClientCreateOrUpdateAtSubscriptionPoller) Done() bool {
|
||||
return p.pt.Done()
|
||||
}
|
||||
|
||||
// Poll fetches the latest state of the LRO. It returns an HTTP response or error.
|
||||
// If the LRO has completed successfully, the poller's state is updated and the HTTP
|
||||
// response is returned.
|
||||
// If the LRO has completed with failure or was cancelled, the poller's state is
|
||||
// updated and the error is returned.
|
||||
// If the LRO has not reached a terminal state, the poller's state is updated and
|
||||
// the latest HTTP response is returned.
|
||||
// If Poll fails, the poller's state is unmodified and the error is returned.
|
||||
// Calling Poll on an LRO that has reached a terminal state will return the final
|
||||
// HTTP response or error.
|
||||
func (p *AttestationsClientCreateOrUpdateAtSubscriptionPoller) Poll(ctx context.Context) (*http.Response, error) {
|
||||
return p.pt.Poll(ctx)
|
||||
}
|
||||
|
||||
// FinalResponse performs a final GET to the service and returns the final response
|
||||
// for the polling operation. If there is an error performing the final GET then an error is returned.
|
||||
// If the final GET succeeded then the final AttestationsClientCreateOrUpdateAtSubscriptionResponse will be returned.
|
||||
func (p *AttestationsClientCreateOrUpdateAtSubscriptionPoller) FinalResponse(ctx context.Context) (AttestationsClientCreateOrUpdateAtSubscriptionResponse, error) {
|
||||
respType := AttestationsClientCreateOrUpdateAtSubscriptionResponse{}
|
||||
resp, err := p.pt.FinalResponse(ctx, &respType.Attestation)
|
||||
if err != nil {
|
||||
return AttestationsClientCreateOrUpdateAtSubscriptionResponse{}, err
|
||||
}
|
||||
respType.RawResponse = resp
|
||||
return respType, nil
|
||||
}
|
||||
|
||||
// ResumeToken returns a value representing the poller that can be used to resume
|
||||
// the LRO at a later time. ResumeTokens are unique per service operation.
|
||||
func (p *AttestationsClientCreateOrUpdateAtSubscriptionPoller) ResumeToken() (string, error) {
|
||||
return p.pt.ResumeToken()
|
||||
}
|
||||
|
||||
// PolicyStatesClientTriggerResourceGroupEvaluationPoller provides polling facilities until the operation reaches a terminal state.
|
||||
type PolicyStatesClientTriggerResourceGroupEvaluationPoller struct {
|
||||
pt *azcore.Poller
|
||||
}
|
||||
|
||||
// Done returns true if the LRO has reached a terminal state.
|
||||
func (p *PolicyStatesClientTriggerResourceGroupEvaluationPoller) Done() bool {
|
||||
return p.pt.Done()
|
||||
}
|
||||
|
||||
// Poll fetches the latest state of the LRO. It returns an HTTP response or error.
|
||||
// If the LRO has completed successfully, the poller's state is updated and the HTTP
|
||||
// response is returned.
|
||||
// If the LRO has completed with failure or was cancelled, the poller's state is
|
||||
// updated and the error is returned.
|
||||
// If the LRO has not reached a terminal state, the poller's state is updated and
|
||||
// the latest HTTP response is returned.
|
||||
// If Poll fails, the poller's state is unmodified and the error is returned.
|
||||
// Calling Poll on an LRO that has reached a terminal state will return the final
|
||||
// HTTP response or error.
|
||||
func (p *PolicyStatesClientTriggerResourceGroupEvaluationPoller) Poll(ctx context.Context) (*http.Response, error) {
|
||||
return p.pt.Poll(ctx)
|
||||
}
|
||||
|
||||
// FinalResponse performs a final GET to the service and returns the final response
|
||||
// for the polling operation. If there is an error performing the final GET then an error is returned.
|
||||
// If the final GET succeeded then the final PolicyStatesClientTriggerResourceGroupEvaluationResponse will be returned.
|
||||
func (p *PolicyStatesClientTriggerResourceGroupEvaluationPoller) FinalResponse(ctx context.Context) (PolicyStatesClientTriggerResourceGroupEvaluationResponse, error) {
|
||||
respType := PolicyStatesClientTriggerResourceGroupEvaluationResponse{}
|
||||
resp, err := p.pt.FinalResponse(ctx, nil)
|
||||
if err != nil {
|
||||
return PolicyStatesClientTriggerResourceGroupEvaluationResponse{}, err
|
||||
}
|
||||
respType.RawResponse = resp
|
||||
return respType, nil
|
||||
}
|
||||
|
||||
// ResumeToken returns a value representing the poller that can be used to resume
|
||||
// the LRO at a later time. ResumeTokens are unique per service operation.
|
||||
func (p *PolicyStatesClientTriggerResourceGroupEvaluationPoller) ResumeToken() (string, error) {
|
||||
return p.pt.ResumeToken()
|
||||
}
|
||||
|
||||
// PolicyStatesClientTriggerSubscriptionEvaluationPoller provides polling facilities until the operation reaches a terminal state.
|
||||
type PolicyStatesClientTriggerSubscriptionEvaluationPoller struct {
|
||||
pt *azcore.Poller
|
||||
}
|
||||
|
||||
// Done returns true if the LRO has reached a terminal state.
|
||||
func (p *PolicyStatesClientTriggerSubscriptionEvaluationPoller) Done() bool {
|
||||
return p.pt.Done()
|
||||
}
|
||||
|
||||
// Poll fetches the latest state of the LRO. It returns an HTTP response or error.
|
||||
// If the LRO has completed successfully, the poller's state is updated and the HTTP
|
||||
// response is returned.
|
||||
// If the LRO has completed with failure or was cancelled, the poller's state is
|
||||
// updated and the error is returned.
|
||||
// If the LRO has not reached a terminal state, the poller's state is updated and
|
||||
// the latest HTTP response is returned.
|
||||
// If Poll fails, the poller's state is unmodified and the error is returned.
|
||||
// Calling Poll on an LRO that has reached a terminal state will return the final
|
||||
// HTTP response or error.
|
||||
func (p *PolicyStatesClientTriggerSubscriptionEvaluationPoller) Poll(ctx context.Context) (*http.Response, error) {
|
||||
return p.pt.Poll(ctx)
|
||||
}
|
||||
|
||||
// FinalResponse performs a final GET to the service and returns the final response
|
||||
// for the polling operation. If there is an error performing the final GET then an error is returned.
|
||||
// If the final GET succeeded then the final PolicyStatesClientTriggerSubscriptionEvaluationResponse will be returned.
|
||||
func (p *PolicyStatesClientTriggerSubscriptionEvaluationPoller) FinalResponse(ctx context.Context) (PolicyStatesClientTriggerSubscriptionEvaluationResponse, error) {
|
||||
respType := PolicyStatesClientTriggerSubscriptionEvaluationResponse{}
|
||||
resp, err := p.pt.FinalResponse(ctx, nil)
|
||||
if err != nil {
|
||||
return PolicyStatesClientTriggerSubscriptionEvaluationResponse{}, err
|
||||
}
|
||||
respType.RawResponse = resp
|
||||
return respType, nil
|
||||
}
|
||||
|
||||
// ResumeToken returns a value representing the poller that can be used to resume
|
||||
// the LRO at a later time. ResumeTokens are unique per service operation.
|
||||
func (p *PolicyStatesClientTriggerSubscriptionEvaluationPoller) ResumeToken() (string, error) {
|
||||
return p.pt.ResumeToken()
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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 armpolicyinsights
|
||||
|
||||
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
|
||||
}
|
Загрузка…
Ссылка в новой задаче