diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md new file mode 100644 index 000000000000..8b8db847a1a2 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-30) diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/LICENSE.txt b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md new file mode 100644 index 000000000000..a6978e31731b --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md @@ -0,0 +1,75 @@ +# Azure Guestconfiguration Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration) + +The `armguestconfiguration` module provides operations for working with Azure Guestconfiguration. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/guestconfiguration/armguestconfiguration) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Guestconfiguration module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Guestconfiguration. 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 Guestconfiguration 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 := armguestconfiguration.NewGuestConfigurationHCRPAssignmentReportsClient(, 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 := armguestconfiguration.NewGuestConfigurationHCRPAssignmentReportsClient(, 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 `Guestconfiguration` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md new file mode 100644 index 000000000000..160871eb71a8 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/guestconfiguration/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/guestconfiguration/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/build.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/build.go new file mode 100644 index 000000000000..43286d04ae4c --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/guestconfiguration/armguestconfiguration + +package armguestconfiguration diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ci.yml b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ci.yml new file mode 100644 index 000000000000..8573e9263de5 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/guestconfiguration/armguestconfiguration/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/guestconfiguration/armguestconfiguration/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/guestconfiguration/armguestconfiguration' diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod new file mode 100644 index 000000000000..f3d9d66734d4 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.4.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum new file mode 100644 index 000000000000..aa6cc05eede2 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go_mod_tidy_hack.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go_mod_tidy_hack.go new file mode 100644 index 000000000000..d4b214f9d9b7 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armguestconfiguration + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_constants.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_constants.go new file mode 100644 index 000000000000..1baff7150725 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_constants.go @@ -0,0 +1,174 @@ +//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 armguestconfiguration + +const ( + module = "armguestconfiguration" + version = "v0.1.0" +) + +// ActionAfterReboot - Specifies what happens after a reboot during the application of a configuration. The possible values are ContinueConfiguration and +// StopConfiguration +type ActionAfterReboot string + +const ( + ActionAfterRebootContinueConfiguration ActionAfterReboot = "ContinueConfiguration" + ActionAfterRebootStopConfiguration ActionAfterReboot = "StopConfiguration" +) + +// PossibleActionAfterRebootValues returns the possible values for the ActionAfterReboot const type. +func PossibleActionAfterRebootValues() []ActionAfterReboot { + return []ActionAfterReboot{ + ActionAfterRebootContinueConfiguration, + ActionAfterRebootStopConfiguration, + } +} + +// ToPtr returns a *ActionAfterReboot pointing to the current value. +func (c ActionAfterReboot) ToPtr() *ActionAfterReboot { + return &c +} + +// AssignmentType - Specifies the assignment type and execution of the configuration. Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect +// and ApplyAndMonitor. +type AssignmentType string + +const ( + AssignmentTypeApplyAndAutoCorrect AssignmentType = "ApplyAndAutoCorrect" + AssignmentTypeApplyAndMonitor AssignmentType = "ApplyAndMonitor" + AssignmentTypeAudit AssignmentType = "Audit" + AssignmentTypeDeployAndAutoCorrect AssignmentType = "DeployAndAutoCorrect" +) + +// PossibleAssignmentTypeValues returns the possible values for the AssignmentType const type. +func PossibleAssignmentTypeValues() []AssignmentType { + return []AssignmentType{ + AssignmentTypeApplyAndAutoCorrect, + AssignmentTypeApplyAndMonitor, + AssignmentTypeAudit, + AssignmentTypeDeployAndAutoCorrect, + } +} + +// ToPtr returns a *AssignmentType pointing to the current value. +func (c AssignmentType) ToPtr() *AssignmentType { + return &c +} + +// ComplianceStatus - A value indicating compliance status of the machine for the assigned guest configuration. +type ComplianceStatus string + +const ( + ComplianceStatusCompliant ComplianceStatus = "Compliant" + ComplianceStatusNonCompliant ComplianceStatus = "NonCompliant" + ComplianceStatusPending ComplianceStatus = "Pending" +) + +// PossibleComplianceStatusValues returns the possible values for the ComplianceStatus const type. +func PossibleComplianceStatusValues() []ComplianceStatus { + return []ComplianceStatus{ + ComplianceStatusCompliant, + ComplianceStatusNonCompliant, + ComplianceStatusPending, + } +} + +// ToPtr returns a *ComplianceStatus pointing to the current value. +func (c ComplianceStatus) ToPtr() *ComplianceStatus { + return &c +} + +// ConfigurationMode - Specifies how the LCM(Local Configuration Manager) actually applies the configuration to the target nodes. Possible values are ApplyOnly, +// ApplyAndMonitor, and ApplyAndAutoCorrect. +type ConfigurationMode string + +const ( + ConfigurationModeApplyAndAutoCorrect ConfigurationMode = "ApplyAndAutoCorrect" + ConfigurationModeApplyAndMonitor ConfigurationMode = "ApplyAndMonitor" + ConfigurationModeApplyOnly ConfigurationMode = "ApplyOnly" +) + +// PossibleConfigurationModeValues returns the possible values for the ConfigurationMode const type. +func PossibleConfigurationModeValues() []ConfigurationMode { + return []ConfigurationMode{ + ConfigurationModeApplyAndAutoCorrect, + ConfigurationModeApplyAndMonitor, + ConfigurationModeApplyOnly, + } +} + +// ToPtr returns a *ConfigurationMode pointing to the current value. +func (c ConfigurationMode) ToPtr() *ConfigurationMode { + return &c +} + +// Kind - Kind of the guest configuration. For example:DSC +type Kind string + +const ( + KindDSC Kind = "DSC" +) + +// PossibleKindValues returns the possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{ + KindDSC, + } +} + +// ToPtr returns a *Kind pointing to the current value. +func (c Kind) ToPtr() *Kind { + return &c +} + +// ProvisioningState - The provisioning state, which only appears in the response. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateCreated, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// Type - Type of report, Consistency or Initial +type Type string + +const ( + TypeConsistency Type = "Consistency" + TypeInitial Type = "Initial" +) + +// PossibleTypeValues returns the possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ + TypeConsistency, + TypeInitial, + } +} + +// ToPtr returns a *Type pointing to the current value. +func (c Type) ToPtr() *Type { + return &c +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationassignmentreports_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationassignmentreports_client.go new file mode 100644 index 000000000000..081b3d07a085 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationassignmentreports_client.go @@ -0,0 +1,185 @@ +//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 armguestconfiguration + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GuestConfigurationAssignmentReportsClient contains the methods for the GuestConfigurationAssignmentReports group. +// Don't use this type directly, use NewGuestConfigurationAssignmentReportsClient() instead. +type GuestConfigurationAssignmentReportsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewGuestConfigurationAssignmentReportsClient creates a new instance of GuestConfigurationAssignmentReportsClient with the specified values. +func NewGuestConfigurationAssignmentReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GuestConfigurationAssignmentReportsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GuestConfigurationAssignmentReportsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get a report for the guest configuration assignment, by reportId. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentReportsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, reportID string, vmName string, options *GuestConfigurationAssignmentReportsGetOptions) (GuestConfigurationAssignmentReportsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, reportID, vmName, options) + if err != nil { + return GuestConfigurationAssignmentReportsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentReportsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationAssignmentReportsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GuestConfigurationAssignmentReportsClient) getCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, reportID string, vmName string, options *GuestConfigurationAssignmentReportsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if reportID == "" { + return nil, errors.New("parameter reportID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportId}", url.PathEscape(reportID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GuestConfigurationAssignmentReportsClient) getHandleResponse(resp *http.Response) (GuestConfigurationAssignmentReportsGetResponse, error) { + result := GuestConfigurationAssignmentReportsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentReport); err != nil { + return GuestConfigurationAssignmentReportsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GuestConfigurationAssignmentReportsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List all reports for the guest configuration assignment, latest report first. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentReportsClient) List(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *GuestConfigurationAssignmentReportsListOptions) (GuestConfigurationAssignmentReportsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, vmName, options) + if err != nil { + return GuestConfigurationAssignmentReportsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentReportsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationAssignmentReportsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *GuestConfigurationAssignmentReportsClient) listCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *GuestConfigurationAssignmentReportsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GuestConfigurationAssignmentReportsClient) listHandleResponse(resp *http.Response) (GuestConfigurationAssignmentReportsListResponse, error) { + result := GuestConfigurationAssignmentReportsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentReportList); err != nil { + return GuestConfigurationAssignmentReportsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *GuestConfigurationAssignmentReportsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationassignments_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationassignments_client.go new file mode 100644 index 000000000000..ea880f5aac46 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationassignments_client.go @@ -0,0 +1,424 @@ +//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 armguestconfiguration + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GuestConfigurationAssignmentsClient contains the methods for the GuestConfigurationAssignments group. +// Don't use this type directly, use NewGuestConfigurationAssignmentsClient() instead. +type GuestConfigurationAssignmentsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewGuestConfigurationAssignmentsClient creates a new instance of GuestConfigurationAssignmentsClient with the specified values. +func NewGuestConfigurationAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GuestConfigurationAssignmentsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GuestConfigurationAssignmentsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates an association between a VM and guest configuration +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, vmName string, parameters GuestConfigurationAssignment, options *GuestConfigurationAssignmentsCreateOrUpdateOptions) (GuestConfigurationAssignmentsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, guestConfigurationAssignmentName, resourceGroupName, vmName, parameters, options) + if err != nil { + return GuestConfigurationAssignmentsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return GuestConfigurationAssignmentsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GuestConfigurationAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, vmName string, parameters GuestConfigurationAssignment, options *GuestConfigurationAssignmentsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + 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 vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GuestConfigurationAssignmentsClient) createOrUpdateHandleResponse(resp *http.Response) (GuestConfigurationAssignmentsCreateOrUpdateResponse, error) { + result := GuestConfigurationAssignmentsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignment); err != nil { + return GuestConfigurationAssignmentsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GuestConfigurationAssignmentsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a guest configuration assignment +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *GuestConfigurationAssignmentsDeleteOptions) (GuestConfigurationAssignmentsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, vmName, options) + if err != nil { + return GuestConfigurationAssignmentsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationAssignmentsDeleteResponse{}, client.deleteHandleError(resp) + } + return GuestConfigurationAssignmentsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GuestConfigurationAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *GuestConfigurationAssignmentsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GuestConfigurationAssignmentsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get information about a guest configuration assignment +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *GuestConfigurationAssignmentsGetOptions) (GuestConfigurationAssignmentsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, vmName, options) + if err != nil { + return GuestConfigurationAssignmentsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationAssignmentsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GuestConfigurationAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *GuestConfigurationAssignmentsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GuestConfigurationAssignmentsClient) getHandleResponse(resp *http.Response) (GuestConfigurationAssignmentsGetResponse, error) { + result := GuestConfigurationAssignmentsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignment); err != nil { + return GuestConfigurationAssignmentsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GuestConfigurationAssignmentsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List all guest configuration assignments for a virtual machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentsClient) List(ctx context.Context, resourceGroupName string, vmName string, options *GuestConfigurationAssignmentsListOptions) (GuestConfigurationAssignmentsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, vmName, options) + if err != nil { + return GuestConfigurationAssignmentsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationAssignmentsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *GuestConfigurationAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, vmName string, options *GuestConfigurationAssignmentsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if vmName == "" { + return nil, errors.New("parameter vmName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GuestConfigurationAssignmentsClient) listHandleResponse(resp *http.Response) (GuestConfigurationAssignmentsListResponse, error) { + result := GuestConfigurationAssignmentsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentList); err != nil { + return GuestConfigurationAssignmentsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *GuestConfigurationAssignmentsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// RGList - List all guest configuration assignments for a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentsClient) RGList(ctx context.Context, resourceGroupName string, options *GuestConfigurationAssignmentsRGListOptions) (GuestConfigurationAssignmentsRGListResponse, error) { + req, err := client.rgListCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return GuestConfigurationAssignmentsRGListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentsRGListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return GuestConfigurationAssignmentsRGListResponse{}, client.rgListHandleError(resp) + } + return client.rgListHandleResponse(resp) +} + +// rgListCreateRequest creates the RGList request. +func (client *GuestConfigurationAssignmentsClient) rgListCreateRequest(ctx context.Context, resourceGroupName string, options *GuestConfigurationAssignmentsRGListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// rgListHandleResponse handles the RGList response. +func (client *GuestConfigurationAssignmentsClient) rgListHandleResponse(resp *http.Response) (GuestConfigurationAssignmentsRGListResponse, error) { + result := GuestConfigurationAssignmentsRGListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentList); err != nil { + return GuestConfigurationAssignmentsRGListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// rgListHandleError handles the RGList error response. +func (client *GuestConfigurationAssignmentsClient) rgListHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// SubscriptionList - List all guest configuration assignments for a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationAssignmentsClient) SubscriptionList(ctx context.Context, options *GuestConfigurationAssignmentsSubscriptionListOptions) (GuestConfigurationAssignmentsSubscriptionListResponse, error) { + req, err := client.subscriptionListCreateRequest(ctx, options) + if err != nil { + return GuestConfigurationAssignmentsSubscriptionListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationAssignmentsSubscriptionListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return GuestConfigurationAssignmentsSubscriptionListResponse{}, client.subscriptionListHandleError(resp) + } + return client.subscriptionListHandleResponse(resp) +} + +// subscriptionListCreateRequest creates the SubscriptionList request. +func (client *GuestConfigurationAssignmentsClient) subscriptionListCreateRequest(ctx context.Context, options *GuestConfigurationAssignmentsSubscriptionListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// subscriptionListHandleResponse handles the SubscriptionList response. +func (client *GuestConfigurationAssignmentsClient) subscriptionListHandleResponse(resp *http.Response) (GuestConfigurationAssignmentsSubscriptionListResponse, error) { + result := GuestConfigurationAssignmentsSubscriptionListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentList); err != nil { + return GuestConfigurationAssignmentsSubscriptionListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// subscriptionListHandleError handles the SubscriptionList error response. +func (client *GuestConfigurationAssignmentsClient) subscriptionListHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationhcrpassignmentreports_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationhcrpassignmentreports_client.go new file mode 100644 index 000000000000..3728ae819f18 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationhcrpassignmentreports_client.go @@ -0,0 +1,185 @@ +//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 armguestconfiguration + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GuestConfigurationHCRPAssignmentReportsClient contains the methods for the GuestConfigurationHCRPAssignmentReports group. +// Don't use this type directly, use NewGuestConfigurationHCRPAssignmentReportsClient() instead. +type GuestConfigurationHCRPAssignmentReportsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewGuestConfigurationHCRPAssignmentReportsClient creates a new instance of GuestConfigurationHCRPAssignmentReportsClient with the specified values. +func NewGuestConfigurationHCRPAssignmentReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GuestConfigurationHCRPAssignmentReportsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GuestConfigurationHCRPAssignmentReportsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get a report for the guest configuration assignment, by reportId. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationHCRPAssignmentReportsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, reportID string, machineName string, options *GuestConfigurationHCRPAssignmentReportsGetOptions) (GuestConfigurationHCRPAssignmentReportsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, reportID, machineName, options) + if err != nil { + return GuestConfigurationHCRPAssignmentReportsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationHCRPAssignmentReportsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationHCRPAssignmentReportsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GuestConfigurationHCRPAssignmentReportsClient) getCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, reportID string, machineName string, options *GuestConfigurationHCRPAssignmentReportsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports/{reportId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if reportID == "" { + return nil, errors.New("parameter reportID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reportId}", url.PathEscape(reportID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if machineName == "" { + return nil, errors.New("parameter machineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GuestConfigurationHCRPAssignmentReportsClient) getHandleResponse(resp *http.Response) (GuestConfigurationHCRPAssignmentReportsGetResponse, error) { + result := GuestConfigurationHCRPAssignmentReportsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentReport); err != nil { + return GuestConfigurationHCRPAssignmentReportsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GuestConfigurationHCRPAssignmentReportsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List all reports for the guest configuration assignment, latest report first. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationHCRPAssignmentReportsClient) List(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *GuestConfigurationHCRPAssignmentReportsListOptions) (GuestConfigurationHCRPAssignmentReportsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, machineName, options) + if err != nil { + return GuestConfigurationHCRPAssignmentReportsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationHCRPAssignmentReportsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationHCRPAssignmentReportsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *GuestConfigurationHCRPAssignmentReportsClient) listCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *GuestConfigurationHCRPAssignmentReportsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}/reports" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if machineName == "" { + return nil, errors.New("parameter machineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GuestConfigurationHCRPAssignmentReportsClient) listHandleResponse(resp *http.Response) (GuestConfigurationHCRPAssignmentReportsListResponse, error) { + result := GuestConfigurationHCRPAssignmentReportsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentReportList); err != nil { + return GuestConfigurationHCRPAssignmentReportsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *GuestConfigurationHCRPAssignmentReportsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationhcrpassignments_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationhcrpassignments_client.go new file mode 100644 index 000000000000..f9fcd57ab071 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_guestconfigurationhcrpassignments_client.go @@ -0,0 +1,306 @@ +//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 armguestconfiguration + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GuestConfigurationHCRPAssignmentsClient contains the methods for the GuestConfigurationHCRPAssignments group. +// Don't use this type directly, use NewGuestConfigurationHCRPAssignmentsClient() instead. +type GuestConfigurationHCRPAssignmentsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewGuestConfigurationHCRPAssignmentsClient creates a new instance of GuestConfigurationHCRPAssignmentsClient with the specified values. +func NewGuestConfigurationHCRPAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GuestConfigurationHCRPAssignmentsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &GuestConfigurationHCRPAssignmentsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates an association between a ARC machine and guest configuration +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationHCRPAssignmentsClient) CreateOrUpdate(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, machineName string, parameters GuestConfigurationAssignment, options *GuestConfigurationHCRPAssignmentsCreateOrUpdateOptions) (GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, guestConfigurationAssignmentName, resourceGroupName, machineName, parameters, options) + if err != nil { + return GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GuestConfigurationHCRPAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, machineName string, parameters GuestConfigurationAssignment, options *GuestConfigurationHCRPAssignmentsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + 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 machineName == "" { + return nil, errors.New("parameter machineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GuestConfigurationHCRPAssignmentsClient) createOrUpdateHandleResponse(resp *http.Response) (GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse, error) { + result := GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignment); err != nil { + return GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GuestConfigurationHCRPAssignmentsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete a guest configuration assignment +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationHCRPAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *GuestConfigurationHCRPAssignmentsDeleteOptions) (GuestConfigurationHCRPAssignmentsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, machineName, options) + if err != nil { + return GuestConfigurationHCRPAssignmentsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationHCRPAssignmentsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationHCRPAssignmentsDeleteResponse{}, client.deleteHandleError(resp) + } + return GuestConfigurationHCRPAssignmentsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GuestConfigurationHCRPAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *GuestConfigurationHCRPAssignmentsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if machineName == "" { + return nil, errors.New("parameter machineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GuestConfigurationHCRPAssignmentsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get information about a guest configuration assignment +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationHCRPAssignmentsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *GuestConfigurationHCRPAssignmentsGetOptions) (GuestConfigurationHCRPAssignmentsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, machineName, options) + if err != nil { + return GuestConfigurationHCRPAssignmentsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationHCRPAssignmentsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationHCRPAssignmentsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GuestConfigurationHCRPAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *GuestConfigurationHCRPAssignmentsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if guestConfigurationAssignmentName == "" { + return nil, errors.New("parameter guestConfigurationAssignmentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{guestConfigurationAssignmentName}", url.PathEscape(guestConfigurationAssignmentName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if machineName == "" { + return nil, errors.New("parameter machineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GuestConfigurationHCRPAssignmentsClient) getHandleResponse(resp *http.Response) (GuestConfigurationHCRPAssignmentsGetResponse, error) { + result := GuestConfigurationHCRPAssignmentsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignment); err != nil { + return GuestConfigurationHCRPAssignmentsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GuestConfigurationHCRPAssignmentsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List all guest configuration assignments for an ARC machine. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GuestConfigurationHCRPAssignmentsClient) List(ctx context.Context, resourceGroupName string, machineName string, options *GuestConfigurationHCRPAssignmentsListOptions) (GuestConfigurationHCRPAssignmentsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, machineName, options) + if err != nil { + return GuestConfigurationHCRPAssignmentsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GuestConfigurationHCRPAssignmentsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GuestConfigurationHCRPAssignmentsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *GuestConfigurationHCRPAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, machineName string, options *GuestConfigurationHCRPAssignmentsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if machineName == "" { + return nil, errors.New("parameter machineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GuestConfigurationHCRPAssignmentsClient) listHandleResponse(resp *http.Response) (GuestConfigurationHCRPAssignmentsListResponse, error) { + result := GuestConfigurationHCRPAssignmentsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestConfigurationAssignmentList); err != nil { + return GuestConfigurationHCRPAssignmentsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *GuestConfigurationHCRPAssignmentsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models.go new file mode 100644 index 000000000000..ecbbb9dbac6c --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models.go @@ -0,0 +1,799 @@ +//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 armguestconfiguration + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AssignmentInfo - Information about the guest configuration assignment. +type AssignmentInfo struct { + // Information about the configuration. + Configuration *ConfigurationInfo `json:"configuration,omitempty"` + + // READ-ONLY; Name of the guest configuration assignment. + Name *string `json:"name,omitempty" azure:"ro"` +} + +type AssignmentReport struct { + // Configuration details of the guest configuration assignment. + Assignment *AssignmentInfo `json:"assignment,omitempty"` + + // The list of resources for which guest configuration assignment compliance is checked. + Resources []*AssignmentReportResource `json:"resources,omitempty"` + + // Information about the VM. + VM *VMInfo `json:"vm,omitempty"` + + // READ-ONLY; A value indicating compliance status of the machine for the assigned guest configuration. + ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` + + // READ-ONLY; End date and time of the guest configuration assignment compliance status check. + EndTime *time.Time `json:"endTime,omitempty" azure:"ro"` + + // READ-ONLY; ARM resource id of the report for the guest configuration assignment. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Type of report, Consistency or Initial + OperationType *Type `json:"operationType,omitempty" azure:"ro"` + + // READ-ONLY; GUID that identifies the guest configuration assignment report under a subscription, resource group. + ReportID *string `json:"reportId,omitempty" azure:"ro"` + + // READ-ONLY; Start date and time of the guest configuration assignment compliance status check. + StartTime *time.Time `json:"startTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReport. +func (a AssignmentReport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "assignment", a.Assignment) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populate(objectMap, "id", a.ID) + populate(objectMap, "operationType", a.OperationType) + populate(objectMap, "reportId", a.ReportID) + populate(objectMap, "resources", a.Resources) + populateTimeRFC3339(objectMap, "startTime", a.StartTime) + populate(objectMap, "vm", a.VM) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReport. +func (a *AssignmentReport) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "assignment": + err = unpopulate(val, &a.Assignment) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, &a.ComplianceStatus) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, &a.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &a.ID) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, &a.OperationType) + delete(rawMsg, key) + case "reportId": + err = unpopulate(val, &a.ReportID) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, &a.Resources) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &a.StartTime) + delete(rawMsg, key) + case "vm": + err = unpopulate(val, &a.VM) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AssignmentReportDetails - Details of the guest configuration assignment report. +type AssignmentReportDetails struct { + // The list of resources for which guest configuration assignment compliance is checked. + Resources []*AssignmentReportResource `json:"resources,omitempty"` + + // READ-ONLY; A value indicating compliance status of the machine for the assigned guest configuration. + ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` + + // READ-ONLY; End date and time of the guest configuration assignment compliance status check. + EndTime *time.Time `json:"endTime,omitempty" azure:"ro"` + + // READ-ONLY; GUID of the report. + JobID *string `json:"jobId,omitempty" azure:"ro"` + + // READ-ONLY; Type of report, Consistency or Initial + OperationType *Type `json:"operationType,omitempty" azure:"ro"` + + // READ-ONLY; Start date and time of the guest configuration assignment compliance status check. + StartTime *time.Time `json:"startTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportDetails. +func (a AssignmentReportDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "operationType", a.OperationType) + populate(objectMap, "resources", a.Resources) + populateTimeRFC3339(objectMap, "startTime", a.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportDetails. +func (a *AssignmentReportDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceStatus": + err = unpopulate(val, &a.ComplianceStatus) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, &a.EndTime) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, &a.JobID) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, &a.OperationType) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, &a.Resources) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &a.StartTime) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AssignmentReportResource - The guest configuration assignment resource. +type AssignmentReportResource struct { + // Compliance reason and reason code for a resource. + Reasons []*AssignmentReportResourceComplianceReason `json:"reasons,omitempty"` + + // READ-ONLY; A value indicating compliance status of the machine for the assigned guest configuration. + ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` + + // READ-ONLY; Properties of a guest configuration assignment resource. + Properties map[string]interface{} `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; Name of the guest configuration assignment resource setting. + ResourceID *string `json:"resourceId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportResource. +func (a AssignmentReportResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "reasons", a.Reasons) + populate(objectMap, "resourceId", a.ResourceID) + return json.Marshal(objectMap) +} + +// AssignmentReportResourceComplianceReason - Reason and code for the compliance of the guest configuration assignment resource. +type AssignmentReportResourceComplianceReason struct { + // READ-ONLY; Code for the compliance of the guest configuration assignment resource. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Reason for the compliance of the guest configuration assignment resource. + Phrase *string `json:"phrase,omitempty" azure:"ro"` +} + +// ConfigurationInfo - Information about the configuration. +type ConfigurationInfo struct { + // READ-ONLY; Name of the configuration. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Version of the configuration. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// ConfigurationParameter - Represents a configuration parameter. +type ConfigurationParameter struct { + // Name of the configuration parameter. + Name *string `json:"name,omitempty"` + + // Value of the configuration parameter. + Value *string `json:"value,omitempty"` +} + +// ConfigurationSetting - Configuration setting of LCM (Local Configuration Manager). +type ConfigurationSetting struct { + // Specifies what happens after a reboot during the application of a configuration. The possible values are ContinueConfiguration and StopConfiguration + ActionAfterReboot *ActionAfterReboot `json:"actionAfterReboot,omitempty"` + + // If true - new configurations downloaded from the pull service are allowed to overwrite the old ones on the target node. Otherwise, false + AllowModuleOverwrite *bool `json:"allowModuleOverwrite,omitempty"` + + // Specifies how the LCM(Local Configuration Manager) actually applies the configuration to the target nodes. Possible values are ApplyOnly, ApplyAndMonitor, + // and ApplyAndAutoCorrect. + ConfigurationMode *ConfigurationMode `json:"configurationMode,omitempty"` + + // How often, in minutes, the current configuration is checked and applied. This property is ignored if the ConfigurationMode property is set to ApplyOnly. + // The default value is 15. + ConfigurationModeFrequencyMins *float32 `json:"configurationModeFrequencyMins,omitempty"` + + // Set this to true to automatically reboot the node after a configuration that requires reboot is applied. Otherwise, you will have to manually reboot + // the node for any configuration that requires it. + // The default value is false. To use this setting when a reboot condition is enacted by something other than DSC (such as Windows Installer), combine this + // setting with the xPendingReboot module. + RebootIfNeeded *bool `json:"rebootIfNeeded,omitempty"` + + // The time interval, in minutes, at which the LCM checks a pull service to get updated configurations. This value is ignored if the LCM is not configured + // in pull mode. The default value is 30. + RefreshFrequencyMins *float32 `json:"refreshFrequencyMins,omitempty"` +} + +// ErrorResponse - Error response of an operation failure +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + InnerError *ErrorResponseError `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +type ErrorResponseError struct { + // Error code. + Code *string `json:"code,omitempty"` + + // Detail error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// GuestConfigurationAssignment - Guest configuration assignment is an association between a machine and guest configuration. +type GuestConfigurationAssignment struct { + ProxyResource + // Properties of the Guest configuration assignment. + Properties *GuestConfigurationAssignmentProperties `json:"properties,omitempty"` +} + +// GuestConfigurationAssignmentList - The response of the list guest configuration assignment operation. +type GuestConfigurationAssignmentList struct { + // Result of the list guest configuration assignment operation. + Value []*GuestConfigurationAssignment `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GuestConfigurationAssignmentList. +func (g GuestConfigurationAssignmentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GuestConfigurationAssignmentProperties - Guest configuration assignment properties. +type GuestConfigurationAssignmentProperties struct { + // The source which initiated the guest configuration assignment. Ex: Azure Policy + Context *string `json:"context,omitempty"` + + // The guest configuration to assign. + GuestConfiguration *GuestConfigurationNavigation `json:"guestConfiguration,omitempty"` + + // Last reported guest configuration assignment report. + LatestAssignmentReport *AssignmentReport `json:"latestAssignmentReport,omitempty"` + + // The list of VM Compliance data for VMSS + VmssVMList []*VMSSVMInfo `json:"vmssVMList,omitempty"` + + // READ-ONLY; Combined hash of the configuration package and parameters. + AssignmentHash *string `json:"assignmentHash,omitempty" azure:"ro"` + + // READ-ONLY; A value indicating compliance status of the machine for the assigned guest configuration. + ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` + + // READ-ONLY; Date and time when last compliance status was checked. + LastComplianceStatusChecked *time.Time `json:"lastComplianceStatusChecked,omitempty" azure:"ro"` + + // READ-ONLY; Id of the latest report for the guest configuration assignment. + LatestReportID *string `json:"latestReportId,omitempty" azure:"ro"` + + // READ-ONLY; parameter hash for the guest configuration assignment. + ParameterHash *string `json:"parameterHash,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state, which only appears in the response. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Type of the resource - VMSS / VM + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; VM resource Id. + TargetResourceID *string `json:"targetResourceId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GuestConfigurationAssignmentProperties. +func (g GuestConfigurationAssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "assignmentHash", g.AssignmentHash) + populate(objectMap, "complianceStatus", g.ComplianceStatus) + populate(objectMap, "context", g.Context) + populate(objectMap, "guestConfiguration", g.GuestConfiguration) + populateTimeRFC3339(objectMap, "lastComplianceStatusChecked", g.LastComplianceStatusChecked) + populate(objectMap, "latestAssignmentReport", g.LatestAssignmentReport) + populate(objectMap, "latestReportId", g.LatestReportID) + populate(objectMap, "parameterHash", g.ParameterHash) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "resourceType", g.ResourceType) + populate(objectMap, "targetResourceId", g.TargetResourceID) + populate(objectMap, "vmssVMList", g.VmssVMList) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestConfigurationAssignmentProperties. +func (g *GuestConfigurationAssignmentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentHash": + err = unpopulate(val, &g.AssignmentHash) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, &g.ComplianceStatus) + delete(rawMsg, key) + case "context": + err = unpopulate(val, &g.Context) + delete(rawMsg, key) + case "guestConfiguration": + err = unpopulate(val, &g.GuestConfiguration) + delete(rawMsg, key) + case "lastComplianceStatusChecked": + err = unpopulateTimeRFC3339(val, &g.LastComplianceStatusChecked) + delete(rawMsg, key) + case "latestAssignmentReport": + err = unpopulate(val, &g.LatestAssignmentReport) + delete(rawMsg, key) + case "latestReportId": + err = unpopulate(val, &g.LatestReportID) + delete(rawMsg, key) + case "parameterHash": + err = unpopulate(val, &g.ParameterHash) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &g.ProvisioningState) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, &g.ResourceType) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, &g.TargetResourceID) + delete(rawMsg, key) + case "vmssVMList": + err = unpopulate(val, &g.VmssVMList) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// GuestConfigurationAssignmentReport - Report for the guest configuration assignment. Report contains information such as compliance status, reason, and +// more. +type GuestConfigurationAssignmentReport struct { + // Properties of the guest configuration report. + Properties *GuestConfigurationAssignmentReportProperties `json:"properties,omitempty"` + + // READ-ONLY; ARM resource id of the report for the guest configuration assignment. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; GUID that identifies the guest configuration assignment report under a subscription, resource group. + Name *string `json:"name,omitempty" azure:"ro"` +} + +// GuestConfigurationAssignmentReportList - List of guest configuration assignment reports. +type GuestConfigurationAssignmentReportList struct { + // List of reports for the guest configuration. Report contains information such as compliance status, reason and more. + Value []*GuestConfigurationAssignmentReport `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GuestConfigurationAssignmentReportList. +func (g GuestConfigurationAssignmentReportList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GuestConfigurationAssignmentReportProperties - Report for the guest configuration assignment. Report contains information such as compliance status, +// reason, and more. +type GuestConfigurationAssignmentReportProperties struct { + // Configuration details of the guest configuration assignment. + Assignment *AssignmentInfo `json:"assignment,omitempty"` + + // Details of the assignment report. + Details *AssignmentReportDetails `json:"details,omitempty"` + + // Information about the VM. + VM *VMInfo `json:"vm,omitempty"` + + // READ-ONLY; A value indicating compliance status of the machine for the assigned guest configuration. + ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` + + // READ-ONLY; End date and time of the guest configuration assignment compliance status check. + EndTime *time.Time `json:"endTime,omitempty" azure:"ro"` + + // READ-ONLY; GUID that identifies the guest configuration assignment report under a subscription, resource group. + ReportID *string `json:"reportId,omitempty" azure:"ro"` + + // READ-ONLY; Start date and time of the guest configuration assignment compliance status check. + StartTime *time.Time `json:"startTime,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource Id of the VMSS. + VmssResourceID *string `json:"vmssResourceId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GuestConfigurationAssignmentReportProperties. +func (g GuestConfigurationAssignmentReportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "assignment", g.Assignment) + populate(objectMap, "complianceStatus", g.ComplianceStatus) + populate(objectMap, "details", g.Details) + populateTimeRFC3339(objectMap, "endTime", g.EndTime) + populate(objectMap, "reportId", g.ReportID) + populateTimeRFC3339(objectMap, "startTime", g.StartTime) + populate(objectMap, "vm", g.VM) + populate(objectMap, "vmssResourceId", g.VmssResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestConfigurationAssignmentReportProperties. +func (g *GuestConfigurationAssignmentReportProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "assignment": + err = unpopulate(val, &g.Assignment) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, &g.ComplianceStatus) + delete(rawMsg, key) + case "details": + err = unpopulate(val, &g.Details) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, &g.EndTime) + delete(rawMsg, key) + case "reportId": + err = unpopulate(val, &g.ReportID) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &g.StartTime) + delete(rawMsg, key) + case "vm": + err = unpopulate(val, &g.VM) + delete(rawMsg, key) + case "vmssResourceId": + err = unpopulate(val, &g.VmssResourceID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// GuestConfigurationAssignmentReportsGetOptions contains the optional parameters for the GuestConfigurationAssignmentReports.Get method. +type GuestConfigurationAssignmentReportsGetOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentReportsListOptions contains the optional parameters for the GuestConfigurationAssignmentReports.List method. +type GuestConfigurationAssignmentReportsListOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentsCreateOrUpdateOptions contains the optional parameters for the GuestConfigurationAssignments.CreateOrUpdate method. +type GuestConfigurationAssignmentsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentsDeleteOptions contains the optional parameters for the GuestConfigurationAssignments.Delete method. +type GuestConfigurationAssignmentsDeleteOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentsGetOptions contains the optional parameters for the GuestConfigurationAssignments.Get method. +type GuestConfigurationAssignmentsGetOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentsListOptions contains the optional parameters for the GuestConfigurationAssignments.List method. +type GuestConfigurationAssignmentsListOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentsRGListOptions contains the optional parameters for the GuestConfigurationAssignments.RGList method. +type GuestConfigurationAssignmentsRGListOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationAssignmentsSubscriptionListOptions contains the optional parameters for the GuestConfigurationAssignments.SubscriptionList method. +type GuestConfigurationAssignmentsSubscriptionListOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationHCRPAssignmentReportsGetOptions contains the optional parameters for the GuestConfigurationHCRPAssignmentReports.Get method. +type GuestConfigurationHCRPAssignmentReportsGetOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationHCRPAssignmentReportsListOptions contains the optional parameters for the GuestConfigurationHCRPAssignmentReports.List method. +type GuestConfigurationHCRPAssignmentReportsListOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationHCRPAssignmentsCreateOrUpdateOptions contains the optional parameters for the GuestConfigurationHCRPAssignments.CreateOrUpdate method. +type GuestConfigurationHCRPAssignmentsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationHCRPAssignmentsDeleteOptions contains the optional parameters for the GuestConfigurationHCRPAssignments.Delete method. +type GuestConfigurationHCRPAssignmentsDeleteOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationHCRPAssignmentsGetOptions contains the optional parameters for the GuestConfigurationHCRPAssignments.Get method. +type GuestConfigurationHCRPAssignmentsGetOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationHCRPAssignmentsListOptions contains the optional parameters for the GuestConfigurationHCRPAssignments.List method. +type GuestConfigurationHCRPAssignmentsListOptions struct { + // placeholder for future optional parameters +} + +// GuestConfigurationNavigation - Guest configuration is an artifact that encapsulates DSC configuration and its dependencies. The artifact is a zip file +// containing DSC configuration (as MOF) and dependent resources and other +// dependencies like modules. +type GuestConfigurationNavigation struct { + // Specifies the assignment type and execution of the configuration. Possible values are Audit, DeployAndAutoCorrect, ApplyAndAutoCorrect and ApplyAndMonitor. + AssignmentType *AssignmentType `json:"assignmentType,omitempty"` + + // The configuration parameters for the guest configuration. + ConfigurationParameter []*ConfigurationParameter `json:"configurationParameter,omitempty"` + + // The protected configuration parameters for the guest configuration. + ConfigurationProtectedParameter []*ConfigurationParameter `json:"configurationProtectedParameter,omitempty"` + + // The configuration setting for the guest configuration. + ConfigurationSetting *ConfigurationSetting `json:"configurationSetting,omitempty"` + + // Combined hash of the guest configuration package and configuration parameters. + ContentHash *string `json:"contentHash,omitempty"` + + // Uri of the storage where guest configuration package is uploaded. + ContentURI *string `json:"contentUri,omitempty"` + + // Kind of the guest configuration. For example:DSC + Kind *Kind `json:"kind,omitempty"` + + // Name of the guest configuration. + Name *string `json:"name,omitempty"` + + // Version of the guest configuration. + Version *string `json:"version,omitempty"` + + // READ-ONLY; Specifies the content type of the configuration. Possible values could be Builtin or Custom. + ContentType *string `json:"contentType,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GuestConfigurationNavigation. +func (g GuestConfigurationNavigation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "assignmentType", g.AssignmentType) + populate(objectMap, "configurationParameter", g.ConfigurationParameter) + populate(objectMap, "configurationProtectedParameter", g.ConfigurationProtectedParameter) + populate(objectMap, "configurationSetting", g.ConfigurationSetting) + populate(objectMap, "contentHash", g.ContentHash) + populate(objectMap, "contentType", g.ContentType) + populate(objectMap, "contentUri", g.ContentURI) + populate(objectMap, "kind", g.Kind) + populate(objectMap, "name", g.Name) + populate(objectMap, "version", g.Version) + return json.Marshal(objectMap) +} + +// Operation - GuestConfiguration REST API operation +type Operation struct { + // Provider, Resource, Operation and description values. + Display *OperationDisplay `json:"display,omitempty"` + + // Operation name: For ex. providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/write or read + Name *string `json:"name,omitempty"` + + // Provider, Resource, Operation and description values. + Properties *OperationProperties `json:"properties,omitempty"` +} + +// OperationDisplay - Provider, Resource, Operation and description values. +type OperationDisplay struct { + // Description about operation. + Description *string `json:"description,omitempty"` + + // Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + + // Service provider: Microsoft.GuestConfiguration + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed: For ex. + Resource *string `json:"resource,omitempty"` +} + +// OperationList - The response model for the list of Automation operations +type OperationList struct { + // List of Automation operations supported by the Automation resource provider. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationProperties - Provider, Resource, Operation and description values. +type OperationProperties struct { + // Service provider: Microsoft.GuestConfiguration + StatusCode *string `json:"statusCode,omitempty"` +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - ARM proxy resource. +type ProxyResource struct { + Resource +} + +// Resource - The core properties of ARM resources +type Resource struct { + // Region where the VM is located. + Location *string `json:"location,omitempty"` + + // Name of the guest configuration assignment. + Name *string `json:"name,omitempty"` + + // READ-ONLY; ARM resource id of the guest configuration assignment. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VMInfo - Information about the VM. +type VMInfo struct { + // READ-ONLY; Azure resource Id of the VM. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; UUID(Universally Unique Identifier) of the VM. + UUID *string `json:"uuid,omitempty" azure:"ro"` +} + +// VMSSVMInfo - Information about VMSS VM +type VMSSVMInfo struct { + // READ-ONLY; A value indicating compliance status of the machine for the assigned guest configuration. + ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` + + // READ-ONLY; Date and time when last compliance status was checked. + LastComplianceChecked *time.Time `json:"lastComplianceChecked,omitempty" azure:"ro"` + + // READ-ONLY; Id of the latest report for the guest configuration assignment. + LatestReportID *string `json:"latestReportId,omitempty" azure:"ro"` + + // READ-ONLY; UUID of the VM. + VMID *string `json:"vmId,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource Id of the VM. + VMResourceID *string `json:"vmResourceId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type VMSSVMInfo. +func (v VMSSVMInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "complianceStatus", v.ComplianceStatus) + populateTimeRFC3339(objectMap, "lastComplianceChecked", v.LastComplianceChecked) + populate(objectMap, "latestReportId", v.LatestReportID) + populate(objectMap, "vmId", v.VMID) + populate(objectMap, "vmResourceId", v.VMResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMSSVMInfo. +func (v *VMSSVMInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceStatus": + err = unpopulate(val, &v.ComplianceStatus) + delete(rawMsg, key) + case "lastComplianceChecked": + err = unpopulateTimeRFC3339(val, &v.LastComplianceChecked) + delete(rawMsg, key) + case "latestReportId": + err = unpopulate(val, &v.LatestReportID) + delete(rawMsg, key) + case "vmId": + err = unpopulate(val, &v.VMID) + delete(rawMsg, key) + case "vmResourceId": + err = unpopulate(val, &v.VMResourceID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_operations_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_operations_client.go new file mode 100644 index 000000000000..454201255f76 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_operations_client.go @@ -0,0 +1,92 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armguestconfiguration + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available GuestConfiguration REST API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.GuestConfiguration/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-06-25") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationList); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_response_types.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_response_types.go new file mode 100644 index 000000000000..70f55d11bbc4 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_response_types.go @@ -0,0 +1,179 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armguestconfiguration + +import "net/http" + +// GuestConfigurationAssignmentReportsGetResponse contains the response from method GuestConfigurationAssignmentReports.Get. +type GuestConfigurationAssignmentReportsGetResponse struct { + GuestConfigurationAssignmentReportsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentReportsGetResult contains the result from method GuestConfigurationAssignmentReports.Get. +type GuestConfigurationAssignmentReportsGetResult struct { + GuestConfigurationAssignmentReport +} + +// GuestConfigurationAssignmentReportsListResponse contains the response from method GuestConfigurationAssignmentReports.List. +type GuestConfigurationAssignmentReportsListResponse struct { + GuestConfigurationAssignmentReportsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentReportsListResult contains the result from method GuestConfigurationAssignmentReports.List. +type GuestConfigurationAssignmentReportsListResult struct { + GuestConfigurationAssignmentReportList +} + +// GuestConfigurationAssignmentsCreateOrUpdateResponse contains the response from method GuestConfigurationAssignments.CreateOrUpdate. +type GuestConfigurationAssignmentsCreateOrUpdateResponse struct { + GuestConfigurationAssignmentsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentsCreateOrUpdateResult contains the result from method GuestConfigurationAssignments.CreateOrUpdate. +type GuestConfigurationAssignmentsCreateOrUpdateResult struct { + GuestConfigurationAssignment +} + +// GuestConfigurationAssignmentsDeleteResponse contains the response from method GuestConfigurationAssignments.Delete. +type GuestConfigurationAssignmentsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentsGetResponse contains the response from method GuestConfigurationAssignments.Get. +type GuestConfigurationAssignmentsGetResponse struct { + GuestConfigurationAssignmentsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentsGetResult contains the result from method GuestConfigurationAssignments.Get. +type GuestConfigurationAssignmentsGetResult struct { + GuestConfigurationAssignment +} + +// GuestConfigurationAssignmentsListResponse contains the response from method GuestConfigurationAssignments.List. +type GuestConfigurationAssignmentsListResponse struct { + GuestConfigurationAssignmentsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentsListResult contains the result from method GuestConfigurationAssignments.List. +type GuestConfigurationAssignmentsListResult struct { + GuestConfigurationAssignmentList +} + +// GuestConfigurationAssignmentsRGListResponse contains the response from method GuestConfigurationAssignments.RGList. +type GuestConfigurationAssignmentsRGListResponse struct { + GuestConfigurationAssignmentsRGListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentsRGListResult contains the result from method GuestConfigurationAssignments.RGList. +type GuestConfigurationAssignmentsRGListResult struct { + GuestConfigurationAssignmentList +} + +// GuestConfigurationAssignmentsSubscriptionListResponse contains the response from method GuestConfigurationAssignments.SubscriptionList. +type GuestConfigurationAssignmentsSubscriptionListResponse struct { + GuestConfigurationAssignmentsSubscriptionListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationAssignmentsSubscriptionListResult contains the result from method GuestConfigurationAssignments.SubscriptionList. +type GuestConfigurationAssignmentsSubscriptionListResult struct { + GuestConfigurationAssignmentList +} + +// GuestConfigurationHCRPAssignmentReportsGetResponse contains the response from method GuestConfigurationHCRPAssignmentReports.Get. +type GuestConfigurationHCRPAssignmentReportsGetResponse struct { + GuestConfigurationHCRPAssignmentReportsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationHCRPAssignmentReportsGetResult contains the result from method GuestConfigurationHCRPAssignmentReports.Get. +type GuestConfigurationHCRPAssignmentReportsGetResult struct { + GuestConfigurationAssignmentReport +} + +// GuestConfigurationHCRPAssignmentReportsListResponse contains the response from method GuestConfigurationHCRPAssignmentReports.List. +type GuestConfigurationHCRPAssignmentReportsListResponse struct { + GuestConfigurationHCRPAssignmentReportsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationHCRPAssignmentReportsListResult contains the result from method GuestConfigurationHCRPAssignmentReports.List. +type GuestConfigurationHCRPAssignmentReportsListResult struct { + GuestConfigurationAssignmentReportList +} + +// GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse contains the response from method GuestConfigurationHCRPAssignments.CreateOrUpdate. +type GuestConfigurationHCRPAssignmentsCreateOrUpdateResponse struct { + GuestConfigurationHCRPAssignmentsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationHCRPAssignmentsCreateOrUpdateResult contains the result from method GuestConfigurationHCRPAssignments.CreateOrUpdate. +type GuestConfigurationHCRPAssignmentsCreateOrUpdateResult struct { + GuestConfigurationAssignment +} + +// GuestConfigurationHCRPAssignmentsDeleteResponse contains the response from method GuestConfigurationHCRPAssignments.Delete. +type GuestConfigurationHCRPAssignmentsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationHCRPAssignmentsGetResponse contains the response from method GuestConfigurationHCRPAssignments.Get. +type GuestConfigurationHCRPAssignmentsGetResponse struct { + GuestConfigurationHCRPAssignmentsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationHCRPAssignmentsGetResult contains the result from method GuestConfigurationHCRPAssignments.Get. +type GuestConfigurationHCRPAssignmentsGetResult struct { + GuestConfigurationAssignment +} + +// GuestConfigurationHCRPAssignmentsListResponse contains the response from method GuestConfigurationHCRPAssignments.List. +type GuestConfigurationHCRPAssignmentsListResponse struct { + GuestConfigurationHCRPAssignmentsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GuestConfigurationHCRPAssignmentsListResult contains the result from method GuestConfigurationHCRPAssignments.List. +type GuestConfigurationHCRPAssignmentsListResult struct { + GuestConfigurationAssignmentList +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationList +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_time_rfc3339.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..93d2a7f0e22c --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armguestconfiguration + +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 +}