diff --git a/sdk/resourcemanager/aad/armaad/CHANGELOG.md b/sdk/resourcemanager/aad/armaad/CHANGELOG.md new file mode 100644 index 000000000000..8e0e243c25b7 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-22) diff --git a/sdk/resourcemanager/aad/armaad/LICENSE.txt b/sdk/resourcemanager/aad/armaad/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/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/aad/armaad/README.md b/sdk/resourcemanager/aad/armaad/README.md new file mode 100644 index 000000000000..9c24cd27eb54 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/README.md @@ -0,0 +1,75 @@ +# Azure Aad Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/aad/armaad)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/aad/armaad) + +The `armaad` module provides operations for working with Azure Aad. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/aad/armaad) + +# 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 Aad module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/aad/armaad +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Aad. 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 Aad 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 := armaad.(, 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 := armaad.(, 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 `Aad` 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/aad/armaad/autorest.md b/sdk/resourcemanager/aad/armaad/autorest.md new file mode 100644 index 000000000000..3125c9f053cf --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/azureactivedirectory/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/azureactivedirectory/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/aad/armaad/build.go b/sdk/resourcemanager/aad/armaad/build.go new file mode 100644 index 000000000000..7046a00945a7 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/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/aad/armaad + +package armaad diff --git a/sdk/resourcemanager/aad/armaad/ci.yml b/sdk/resourcemanager/aad/armaad/ci.yml new file mode 100644 index 000000000000..cb2ef0e575cf --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/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/aad/armaad/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/aad/armaad/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/aad/armaad' diff --git a/sdk/resourcemanager/aad/armaad/go.mod b/sdk/resourcemanager/aad/armaad/go.mod new file mode 100644 index 000000000000..8c044860fdcc --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/aad/armaad + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.3.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/aad/armaad/go.sum b/sdk/resourcemanager/aad/armaad/go.sum new file mode 100644 index 000000000000..76d3fa8fd576 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.3.0+incompatible h1:dPIm0BO4jsMXFcCI/sLTPkBtE7mk8WMuRHA0JeWhlcQ= +github.com/Azure/azure-sdk-for-go v59.3.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/aad/armaad/go_mod_tidy_hack.go b/sdk/resourcemanager/aad/armaad/go_mod_tidy_hack.go new file mode 100644 index 000000000000..cbd6dbe90d4b --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/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 armaad + +// 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/aad/armaad/zz_generated_constants.go b/sdk/resourcemanager/aad/armaad/zz_generated_constants.go new file mode 100644 index 000000000000..3169d02519dd --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/zz_generated_constants.go @@ -0,0 +1,55 @@ +//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 armaad + +const ( + module = "armaad" + version = "v0.1.0" +) + +// Category - Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, +// first perform a GET diagnostic settings operation. +type Category string + +const ( + CategoryAuditLogs Category = "AuditLogs" + CategorySignInLogs Category = "SignInLogs" +) + +// PossibleCategoryValues returns the possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{ + CategoryAuditLogs, + CategorySignInLogs, + } +} + +// ToPtr returns a *Category pointing to the current value. +func (c Category) ToPtr() *Category { + return &c +} + +// CategoryType - The type of the diagnostic settings category. +type CategoryType string + +const ( + CategoryTypeLogs CategoryType = "Logs" +) + +// PossibleCategoryTypeValues returns the possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{ + CategoryTypeLogs, + } +} + +// ToPtr returns a *CategoryType pointing to the current value. +func (c CategoryType) ToPtr() *CategoryType { + return &c +} diff --git a/sdk/resourcemanager/aad/armaad/zz_generated_diagnosticsettings_client.go b/sdk/resourcemanager/aad/armaad/zz_generated_diagnosticsettings_client.go new file mode 100644 index 000000000000..a74096352f96 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/zz_generated_diagnosticsettings_client.go @@ -0,0 +1,257 @@ +//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 armaad + +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" +) + +// DiagnosticSettingsClient contains the methods for the DiagnosticSettings group. +// Don't use this type directly, use NewDiagnosticSettingsClient() instead. +type DiagnosticSettingsClient struct { + ep string + pl runtime.Pipeline +} + +// NewDiagnosticSettingsClient creates a new instance of DiagnosticSettingsClient with the specified values. +func NewDiagnosticSettingsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *DiagnosticSettingsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DiagnosticSettingsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CreateOrUpdate - Creates or updates diagnostic settings for AadIam. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) CreateOrUpdate(ctx context.Context, name string, parameters DiagnosticSettingsResource, options *DiagnosticSettingsCreateOrUpdateOptions) (DiagnosticSettingsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, name, parameters, options) + if err != nil { + return DiagnosticSettingsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DiagnosticSettingsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DiagnosticSettingsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DiagnosticSettingsClient) createOrUpdateCreateRequest(ctx context.Context, name string, parameters DiagnosticSettingsResource, options *DiagnosticSettingsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.aadiam/diagnosticSettings/{name}" + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DiagnosticSettingsClient) createOrUpdateHandleResponse(resp *http.Response) (DiagnosticSettingsCreateOrUpdateResponse, error) { + result := DiagnosticSettingsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticSettingsResource); err != nil { + return DiagnosticSettingsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DiagnosticSettingsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Deletes existing diagnostic setting for AadIam. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) Delete(ctx context.Context, name string, options *DiagnosticSettingsDeleteOptions) (DiagnosticSettingsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, name, options) + if err != nil { + return DiagnosticSettingsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DiagnosticSettingsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return DiagnosticSettingsDeleteResponse{}, client.deleteHandleError(resp) + } + return DiagnosticSettingsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DiagnosticSettingsClient) deleteCreateRequest(ctx context.Context, name string, options *DiagnosticSettingsDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.aadiam/diagnosticSettings/{name}" + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DiagnosticSettingsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Gets the active diagnostic setting for AadIam. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) Get(ctx context.Context, name string, options *DiagnosticSettingsGetOptions) (DiagnosticSettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, name, options) + if err != nil { + return DiagnosticSettingsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DiagnosticSettingsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DiagnosticSettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DiagnosticSettingsClient) getCreateRequest(ctx context.Context, name string, options *DiagnosticSettingsGetOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.aadiam/diagnosticSettings/{name}" + if name == "" { + return nil, errors.New("parameter name cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DiagnosticSettingsClient) getHandleResponse(resp *http.Response) (DiagnosticSettingsGetResponse, error) { + result := DiagnosticSettingsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticSettingsResource); err != nil { + return DiagnosticSettingsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DiagnosticSettingsClient) 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 - Gets the active diagnostic settings list for AadIam. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsClient) List(ctx context.Context, options *DiagnosticSettingsListOptions) (DiagnosticSettingsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return DiagnosticSettingsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DiagnosticSettingsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DiagnosticSettingsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DiagnosticSettingsClient) listCreateRequest(ctx context.Context, options *DiagnosticSettingsListOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.aadiam/diagnosticSettings" + 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", "2017-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DiagnosticSettingsClient) listHandleResponse(resp *http.Response) (DiagnosticSettingsListResponse, error) { + result := DiagnosticSettingsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticSettingsResourceCollection); err != nil { + return DiagnosticSettingsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DiagnosticSettingsClient) 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/aad/armaad/zz_generated_diagnosticsettingscategory_client.go b/sdk/resourcemanager/aad/armaad/zz_generated_diagnosticsettingscategory_client.go new file mode 100644 index 000000000000..f2baf71a3dff --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/zz_generated_diagnosticsettingscategory_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 armaad + +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" +) + +// DiagnosticSettingsCategoryClient contains the methods for the DiagnosticSettingsCategory group. +// Don't use this type directly, use NewDiagnosticSettingsCategoryClient() instead. +type DiagnosticSettingsCategoryClient struct { + ep string + pl runtime.Pipeline +} + +// NewDiagnosticSettingsCategoryClient creates a new instance of DiagnosticSettingsCategoryClient with the specified values. +func NewDiagnosticSettingsCategoryClient(credential azcore.TokenCredential, options *arm.ClientOptions) *DiagnosticSettingsCategoryClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DiagnosticSettingsCategoryClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists the diagnostic settings categories for AadIam. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticSettingsCategoryClient) List(ctx context.Context, options *DiagnosticSettingsCategoryListOptions) (DiagnosticSettingsCategoryListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return DiagnosticSettingsCategoryListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DiagnosticSettingsCategoryListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DiagnosticSettingsCategoryListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *DiagnosticSettingsCategoryClient) listCreateRequest(ctx context.Context, options *DiagnosticSettingsCategoryListOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.aadiam/diagnosticSettingsCategories" + 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", "2017-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DiagnosticSettingsCategoryClient) listHandleResponse(resp *http.Response) (DiagnosticSettingsCategoryListResponse, error) { + result := DiagnosticSettingsCategoryListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DiagnosticSettingsCategoryResourceCollection); err != nil { + return DiagnosticSettingsCategoryListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DiagnosticSettingsCategoryClient) 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/aad/armaad/zz_generated_models.go b/sdk/resourcemanager/aad/armaad/zz_generated_models.go new file mode 100644 index 000000000000..6d4510e3ac80 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/zz_generated_models.go @@ -0,0 +1,276 @@ +//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 armaad + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// DiagnosticSettings - The diagnostic settings. +type DiagnosticSettings struct { + // The resource Id for the event hub authorization rule. + EventHubAuthorizationRuleID *string `json:"eventHubAuthorizationRuleId,omitempty"` + + // The name of the event hub. If none is specified, the default event hub will be selected. + EventHubName *string `json:"eventHubName,omitempty"` + + // The list of logs settings. + Logs []*LogSettings `json:"logs,omitempty"` + + // The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. + ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"` + + // The resource ID of the storage account to which you would like to send Diagnostic Logs. + StorageAccountID *string `json:"storageAccountId,omitempty"` + + // The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: + // /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + WorkspaceID *string `json:"workspaceId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticSettings. +func (d DiagnosticSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eventHubAuthorizationRuleId", d.EventHubAuthorizationRuleID) + populate(objectMap, "eventHubName", d.EventHubName) + populate(objectMap, "logs", d.Logs) + populate(objectMap, "serviceBusRuleId", d.ServiceBusRuleID) + populate(objectMap, "storageAccountId", d.StorageAccountID) + populate(objectMap, "workspaceId", d.WorkspaceID) + return json.Marshal(objectMap) +} + +// DiagnosticSettingsCategory - The diagnostic settings Category. +type DiagnosticSettingsCategory struct { + // The type of the diagnostic settings category. + CategoryType *CategoryType `json:"categoryType,omitempty"` +} + +// DiagnosticSettingsCategoryListOptions contains the optional parameters for the DiagnosticSettingsCategory.List method. +type DiagnosticSettingsCategoryListOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsCategoryResource - The diagnostic settings category resource. +type DiagnosticSettingsCategoryResource struct { + ProxyOnlyResource + // The properties of a Diagnostic Settings Category. + Properties *DiagnosticSettingsCategory `json:"properties,omitempty"` +} + +// DiagnosticSettingsCategoryResourceCollection - Represents a collection of diagnostic setting category resources. +type DiagnosticSettingsCategoryResourceCollection struct { + // The collection of diagnostic settings category resources. + Value []*DiagnosticSettingsCategoryResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticSettingsCategoryResourceCollection. +func (d DiagnosticSettingsCategoryResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DiagnosticSettingsCreateOrUpdateOptions contains the optional parameters for the DiagnosticSettings.CreateOrUpdate method. +type DiagnosticSettingsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsDeleteOptions contains the optional parameters for the DiagnosticSettings.Delete method. +type DiagnosticSettingsDeleteOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsGetOptions contains the optional parameters for the DiagnosticSettings.Get method. +type DiagnosticSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsListOptions contains the optional parameters for the DiagnosticSettings.List method. +type DiagnosticSettingsListOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticSettingsResource - The diagnostic setting resource. +type DiagnosticSettingsResource struct { + ProxyOnlyResource + // Properties of a Diagnostic Settings Resource. + Properties *DiagnosticSettings `json:"properties,omitempty"` +} + +// DiagnosticSettingsResourceCollection - Represents a collection of alert rule resources. +type DiagnosticSettingsResourceCollection struct { + // The collection of diagnostic settings resources. + Value []*DiagnosticSettingsResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticSettingsResourceCollection. +func (d DiagnosticSettingsResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// Display - Contains the localized display information for this particular operation / action. These value will be used by several clients for (1) custom +// role definitions for RBAC; (2) complex query filters for +// the event service; and (3) audit history / records for management operations. +type Display struct { + // The description. The localized friendly description for the operation, as it should be shown to the user. It should be thorough, yet concise – it will + // be used in tool tips and detailed views. + // Prescriptive guidance for namespaces: Read any 'display.provider' resource Create or Update any 'display.provider' resource Delete any 'display.provider' + // resource Perform any other action on any + // 'display.provider' resource Prescriptive guidance for namespaces: Read any 'display.resource' Create or Update any 'display.resource' Delete any 'display.resource' + // 'ActionName' any 'display.resources' + Description *string `json:"description,omitempty"` + + // The operation. The localized friendly name for the operation, as it should be shown to the user. It should be concise (to fit in drop downs) but clear + // (i.e. self-documenting). It should use Title + // Casing. Prescriptive guidance: Read Create or Update Delete 'ActionName' + Operation *string `json:"operation,omitempty"` + + // The provider. The localized friendly form of the resource provider name – it is expected to also include the publisher/company responsible. It should + // use Title Casing and begin with "Microsoft" for + // 1st party services. e.g. "Microsoft Monitoring Insights" or "Microsoft Compute." + Provider *string `json:"provider,omitempty"` + + // The publisher. The localized friendly form of the resource publisher name. + Publisher *string `json:"publisher,omitempty"` + + // The resource. The localized friendly form of the resource related to this action/operation – it should match the public documentation for the resource + // provider. It should use Title Casing. This value + // should be unique for a particular URL type (e.g. nested types should not reuse their parent’s display.resource field). e.g. "Virtual Machines" or "Scheduler + // Job Collections", or "Virtual Machine VM + // Sizes" or "Scheduler Jobs" + Resource *string `json:"resource,omitempty"` +} + +// ErrorDefinition - Error definition. +type ErrorDefinition struct { + // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Internal error details. + Details []*ErrorDefinition `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; Description of the error. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. +func (e ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// ErrorResponse - Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error details. + InnerError *ErrorDefinition `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// LogSettings - Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. +type LogSettings struct { + // REQUIRED; A value indicating whether this log is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first + // perform a GET diagnostic settings operation. + Category *Category `json:"category,omitempty"` + + // The retention policy for this log. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` +} + +// OperationsDiscovery - Operations discovery class. +type OperationsDiscovery struct { + // Object type + Display *Display `json:"display,omitempty"` + + // Indicates whether the operation applies to data-plane. Set the value to true for data-plane operations and false for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Name of the API. The name of the operation being performed on this particular object. It should match the action name that appears in RBAC / the event + // service. Examples of operations include: * + // Microsoft.Compute/virtualMachine/capture/action * Microsoft.Compute/virtualMachine/restart/action * Microsoft.Compute/virtualMachine/write * Microsoft.Compute/virtualMachine/read + // * + // Microsoft.Compute/virtualMachine/delete Each action should include, in order: (1) Resource Provider Namespace (2) Type hierarchy for which the action + // applies (e.g. server/databases for a SQL Azure + // database) (3) Read, Write, Action or Delete indicating which type applies. If it is a PUT/PATCH on a collection or named value, Write should be used. + // If it is a GET, Read should be used. If it is a + // DELETE, Delete should be used. If it is a POST, Action should be used. + Name *string `json:"name,omitempty"` + + // Origin. The intended executor of the operation; governs the display of the operation in the RBAC UX and the audit logs UX. Default value is "user,system" + Origin *string `json:"origin,omitempty"` + + // Properties. Reserved for future use. + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// OperationsDiscoveryCollection - Collection of ClientDiscovery details. +type OperationsDiscoveryCollection struct { + // The ClientDiscovery details. + Value []*OperationsDiscovery `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationsDiscoveryCollection. +func (o OperationsDiscoveryCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// ProxyOnlyResource - A proxy only azure resource object. +type ProxyOnlyResource struct { + // READ-ONLY; Azure resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// RetentionPolicy - Specifies the retention policy for the log. +type RetentionPolicy struct { + // REQUIRED; The number of days for the retention in days. A value of 0 will retain the events indefinitely. + Days *int32 `json:"days,omitempty"` + + // REQUIRED; A value indicating whether the retention policy is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +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 + } +} diff --git a/sdk/resourcemanager/aad/armaad/zz_generated_operations_client.go b/sdk/resourcemanager/aad/armaad/zz_generated_operations_client.go new file mode 100644 index 000000000000..4dc7e60c21c6 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/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 armaad + +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 - Operation to return the list of available 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.aadiam/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", "2017-04-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationsDiscoveryCollection); 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/aad/armaad/zz_generated_response_types.go b/sdk/resourcemanager/aad/armaad/zz_generated_response_types.go new file mode 100644 index 000000000000..f1b86bf07af9 --- /dev/null +++ b/sdk/resourcemanager/aad/armaad/zz_generated_response_types.go @@ -0,0 +1,77 @@ +//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 armaad + +import "net/http" + +// DiagnosticSettingsCategoryListResponse contains the response from method DiagnosticSettingsCategory.List. +type DiagnosticSettingsCategoryListResponse struct { + DiagnosticSettingsCategoryListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsCategoryListResult contains the result from method DiagnosticSettingsCategory.List. +type DiagnosticSettingsCategoryListResult struct { + DiagnosticSettingsCategoryResourceCollection +} + +// DiagnosticSettingsCreateOrUpdateResponse contains the response from method DiagnosticSettings.CreateOrUpdate. +type DiagnosticSettingsCreateOrUpdateResponse struct { + DiagnosticSettingsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsCreateOrUpdateResult contains the result from method DiagnosticSettings.CreateOrUpdate. +type DiagnosticSettingsCreateOrUpdateResult struct { + DiagnosticSettingsResource +} + +// DiagnosticSettingsDeleteResponse contains the response from method DiagnosticSettings.Delete. +type DiagnosticSettingsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsGetResponse contains the response from method DiagnosticSettings.Get. +type DiagnosticSettingsGetResponse struct { + DiagnosticSettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsGetResult contains the result from method DiagnosticSettings.Get. +type DiagnosticSettingsGetResult struct { + DiagnosticSettingsResource +} + +// DiagnosticSettingsListResponse contains the response from method DiagnosticSettings.List. +type DiagnosticSettingsListResponse struct { + DiagnosticSettingsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticSettingsListResult contains the result from method DiagnosticSettings.List. +type DiagnosticSettingsListResult struct { + DiagnosticSettingsResourceCollection +} + +// 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 { + OperationsDiscoveryCollection +}