diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md b/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md new file mode 100644 index 000000000000..f3d80a0b8362 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-10-26) + +- Initial preview release. diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/LICENSE.txt b/sdk/resourcemanager/resourcehealth/armresourcehealth/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/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/resourcehealth/armresourcehealth/README.md b/sdk/resourcemanager/resourcehealth/armresourcehealth/README.md new file mode 100644 index 000000000000..86c018ee9e4d --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/README.md @@ -0,0 +1,76 @@ +# Azure Resource Health Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth) + +The `armresourcehealth` module provides operations for working with Azure Resource Health. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/resourcehealth/armresourcehealth) + +# 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 Resource Health module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Resource Health. 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). + +## Connecting to Azure Resource Health + +Once you have a credential, create a connection to the desired ARM endpoint. The `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := arm.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, 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). + +## Clients + +Azure Resource Health 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 `arm.Connection`. + +```go +client := armresourcehealth.NewAvailabilityStatusesClient(con, "") +``` + +## 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 `Resource Health` 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/resourcehealth/armresourcehealth/autorest.md b/sdk/resourcemanager/resourcehealth/armresourcehealth/autorest.md new file mode 100644 index 000000000000..c794d32758ab --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/4aebac1bd77282ae8efe3dd2886e864537d31762/specification/resourcehealth/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/4aebac1bd77282ae8efe3dd2886e864537d31762/specification/resourcehealth/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/resourcehealth/armresourcehealth/build.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/build.go new file mode 100644 index 000000000000..3f5b8a7de2e0 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/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/resourcehealth/armresourcehealth + +package armresourcehealth diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/ci.yml b/sdk/resourcemanager/resourcehealth/armresourcehealth/ci.yml new file mode 100644 index 000000000000..ffbdaf25a020 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/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/resourcehealth/armresourcehealth/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/resourcehealth/armresourcehealth/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/resourcehealth/armresourcehealth' diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod new file mode 100644 index 000000000000..0d01c484e8f6 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v58.3.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 +) diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum new file mode 100644 index 000000000000..af10d0f1292e --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go v58.3.0+incompatible h1:lb9OWePNuJMiibdxg9XvdbiOldR0Yifge37L4LoOxIs= +github.com/Azure/azure-sdk-for-go v58.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +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/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-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.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.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/go_mod_tidy_hack.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/go_mod_tidy_hack.go new file mode 100644 index 000000000000..8681f562c371 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/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 armresourcehealth + +// 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/resourcehealth/armresourcehealth/zz_generated_availabilitystatuses_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_availabilitystatuses_client.go new file mode 100644 index 000000000000..3b84fa8bb57b --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_availabilitystatuses_client.go @@ -0,0 +1,285 @@ +//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 armresourcehealth + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// AvailabilityStatusesClient contains the methods for the AvailabilityStatuses group. +// Don't use this type directly, use NewAvailabilityStatusesClient() instead. +type AvailabilityStatusesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewAvailabilityStatusesClient creates a new instance of AvailabilityStatusesClient with the specified values. +func NewAvailabilityStatusesClient(con *arm.Connection, subscriptionID string) *AvailabilityStatusesClient { + return &AvailabilityStatusesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// GetByResource - Gets current availability status for a single resource +// If the operation fails it returns the *ErrorResponse error type. +func (client *AvailabilityStatusesClient) GetByResource(ctx context.Context, resourceURI string, options *AvailabilityStatusesGetByResourceOptions) (AvailabilityStatusesGetByResourceResponse, error) { + req, err := client.getByResourceCreateRequest(ctx, resourceURI, options) + if err != nil { + return AvailabilityStatusesGetByResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AvailabilityStatusesGetByResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AvailabilityStatusesGetByResourceResponse{}, client.getByResourceHandleError(resp) + } + return client.getByResourceHandleResponse(resp) +} + +// getByResourceCreateRequest creates the GetByResource request. +func (client *AvailabilityStatusesClient) getByResourceCreateRequest(ctx context.Context, resourceURI string, options *AvailabilityStatusesGetByResourceOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getByResourceHandleResponse handles the GetByResource response. +func (client *AvailabilityStatusesClient) getByResourceHandleResponse(resp *http.Response) (AvailabilityStatusesGetByResourceResponse, error) { + result := AvailabilityStatusesGetByResourceResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatus); err != nil { + return AvailabilityStatusesGetByResourceResponse{}, err + } + return result, nil +} + +// getByResourceHandleError handles the GetByResource error response. +func (client *AvailabilityStatusesClient) getByResourceHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Lists all historical availability transitions and impacting events for a single resource. Use the nextLink property in the response to get the +// next page of availability status +// If the operation fails it returns the *ErrorResponse error type. +func (client *AvailabilityStatusesClient) List(resourceURI string, options *AvailabilityStatusesListOptions) *AvailabilityStatusesListPager { + return &AvailabilityStatusesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, + advancer: func(ctx context.Context, resp AvailabilityStatusesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AvailabilityStatusListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *AvailabilityStatusesClient) listCreateRequest(ctx context.Context, resourceURI string, options *AvailabilityStatusesListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AvailabilityStatusesClient) listHandleResponse(resp *http.Response) (AvailabilityStatusesListResponse, error) { + result := AvailabilityStatusesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatusListResult); err != nil { + return AvailabilityStatusesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *AvailabilityStatusesClient) 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) +} + +// ListByResourceGroup - Lists the current availability status for all the resources in the resource group. Use the nextLink property in the response to +// get the next page of availability statuses. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AvailabilityStatusesClient) ListByResourceGroup(resourceGroupName string, options *AvailabilityStatusesListByResourceGroupOptions) *AvailabilityStatusesListByResourceGroupPager { + return &AvailabilityStatusesListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp AvailabilityStatusesListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AvailabilityStatusListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AvailabilityStatusesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AvailabilityStatusesListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AvailabilityStatusesClient) listByResourceGroupHandleResponse(resp *http.Response) (AvailabilityStatusesListByResourceGroupResponse, error) { + result := AvailabilityStatusesListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatusListResult); err != nil { + return AvailabilityStatusesListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *AvailabilityStatusesClient) listByResourceGroupHandleError(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) +} + +// ListBySubscriptionID - Lists the current availability status for all the resources in the subscription. Use the nextLink property in the response to +// get the next page of availability statuses. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AvailabilityStatusesClient) ListBySubscriptionID(options *AvailabilityStatusesListBySubscriptionIDOptions) *AvailabilityStatusesListBySubscriptionIDPager { + return &AvailabilityStatusesListBySubscriptionIDPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionIDCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp AvailabilityStatusesListBySubscriptionIDResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AvailabilityStatusListResult.NextLink) + }, + } +} + +// listBySubscriptionIDCreateRequest creates the ListBySubscriptionID request. +func (client *AvailabilityStatusesClient) listBySubscriptionIDCreateRequest(ctx context.Context, options *AvailabilityStatusesListBySubscriptionIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses" + 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", "2017-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionIDHandleResponse handles the ListBySubscriptionID response. +func (client *AvailabilityStatusesClient) listBySubscriptionIDHandleResponse(resp *http.Response) (AvailabilityStatusesListBySubscriptionIDResponse, error) { + result := AvailabilityStatusesListBySubscriptionIDResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatusListResult); err != nil { + return AvailabilityStatusesListBySubscriptionIDResponse{}, err + } + return result, nil +} + +// listBySubscriptionIDHandleError handles the ListBySubscriptionID error response. +func (client *AvailabilityStatusesClient) listBySubscriptionIDHandleError(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/resourcehealth/armresourcehealth/zz_generated_childavailabilitystatuses_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_childavailabilitystatuses_client.go new file mode 100644 index 000000000000..8c4ac18570e8 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_childavailabilitystatuses_client.go @@ -0,0 +1,157 @@ +//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 armresourcehealth + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// ChildAvailabilityStatusesClient contains the methods for the ChildAvailabilityStatuses group. +// Don't use this type directly, use NewChildAvailabilityStatusesClient() instead. +type ChildAvailabilityStatusesClient struct { + ep string + pl runtime.Pipeline +} + +// NewChildAvailabilityStatusesClient creates a new instance of ChildAvailabilityStatusesClient with the specified values. +func NewChildAvailabilityStatusesClient(con *arm.Connection) *ChildAvailabilityStatusesClient { + return &ChildAvailabilityStatusesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// GetByResource - Gets current availability status for a single resource +// If the operation fails it returns the *ErrorResponse error type. +func (client *ChildAvailabilityStatusesClient) GetByResource(ctx context.Context, resourceURI string, options *ChildAvailabilityStatusesGetByResourceOptions) (ChildAvailabilityStatusesGetByResourceResponse, error) { + req, err := client.getByResourceCreateRequest(ctx, resourceURI, options) + if err != nil { + return ChildAvailabilityStatusesGetByResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ChildAvailabilityStatusesGetByResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ChildAvailabilityStatusesGetByResourceResponse{}, client.getByResourceHandleError(resp) + } + return client.getByResourceHandleResponse(resp) +} + +// getByResourceCreateRequest creates the GetByResource request. +func (client *ChildAvailabilityStatusesClient) getByResourceCreateRequest(ctx context.Context, resourceURI string, options *ChildAvailabilityStatusesGetByResourceOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getByResourceHandleResponse handles the GetByResource response. +func (client *ChildAvailabilityStatusesClient) getByResourceHandleResponse(resp *http.Response) (ChildAvailabilityStatusesGetByResourceResponse, error) { + result := ChildAvailabilityStatusesGetByResourceResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatus); err != nil { + return ChildAvailabilityStatusesGetByResourceResponse{}, err + } + return result, nil +} + +// getByResourceHandleError handles the GetByResource error response. +func (client *ChildAvailabilityStatusesClient) getByResourceHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Lists the historical availability statuses for a single child resource. Use the nextLink property in the response to get the next page of availability +// status +// If the operation fails it returns the *ErrorResponse error type. +func (client *ChildAvailabilityStatusesClient) List(resourceURI string, options *ChildAvailabilityStatusesListOptions) *ChildAvailabilityStatusesListPager { + return &ChildAvailabilityStatusesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, + advancer: func(ctx context.Context, resp ChildAvailabilityStatusesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AvailabilityStatusListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ChildAvailabilityStatusesClient) listCreateRequest(ctx context.Context, resourceURI string, options *ChildAvailabilityStatusesListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ChildAvailabilityStatusesClient) listHandleResponse(resp *http.Response) (ChildAvailabilityStatusesListResponse, error) { + result := ChildAvailabilityStatusesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatusListResult); err != nil { + return ChildAvailabilityStatusesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ChildAvailabilityStatusesClient) 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/resourcehealth/armresourcehealth/zz_generated_childresources_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_childresources_client.go new file mode 100644 index 000000000000..6d5836be0596 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_childresources_client.go @@ -0,0 +1,94 @@ +//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 armresourcehealth + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// ChildResourcesClient contains the methods for the ChildResources group. +// Don't use this type directly, use NewChildResourcesClient() instead. +type ChildResourcesClient struct { + ep string + pl runtime.Pipeline +} + +// NewChildResourcesClient creates a new instance of ChildResourcesClient with the specified values. +func NewChildResourcesClient(con *arm.Connection) *ChildResourcesClient { + return &ChildResourcesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// List - Lists the all the children and its current health status for a parent resource. Use the nextLink property in the response to get the next page +// of children current health +// If the operation fails it returns the *ErrorResponse error type. +func (client *ChildResourcesClient) List(resourceURI string, options *ChildResourcesListOptions) *ChildResourcesListPager { + return &ChildResourcesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, + advancer: func(ctx context.Context, resp ChildResourcesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.AvailabilityStatusListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ChildResourcesClient) listCreateRequest(ctx context.Context, resourceURI string, options *ChildResourcesListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ResourceHealth/childResources" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-07-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ChildResourcesClient) listHandleResponse(resp *http.Response) (ChildResourcesListResponse, error) { + result := ChildResourcesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityStatusListResult); err != nil { + return ChildResourcesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ChildResourcesClient) 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/resourcehealth/armresourcehealth/zz_generated_constants.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_constants.go new file mode 100644 index 000000000000..5020d585370b --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_constants.go @@ -0,0 +1,122 @@ +//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 armresourcehealth + +const ( + module = "armresourcehealth" + version = "v0.1.0" +) + +// AvailabilityStateValues - Availability status of the resource. When it is null, this availabilityStatus object represents an availability impacting event +type AvailabilityStateValues string + +const ( + AvailabilityStateValuesAvailable AvailabilityStateValues = "Available" + AvailabilityStateValuesUnavailable AvailabilityStateValues = "Unavailable" + AvailabilityStateValuesUnknown AvailabilityStateValues = "Unknown" +) + +// PossibleAvailabilityStateValuesValues returns the possible values for the AvailabilityStateValues const type. +func PossibleAvailabilityStateValuesValues() []AvailabilityStateValues { + return []AvailabilityStateValues{ + AvailabilityStateValuesAvailable, + AvailabilityStateValuesUnavailable, + AvailabilityStateValuesUnknown, + } +} + +// ToPtr returns a *AvailabilityStateValues pointing to the current value. +func (c AvailabilityStateValues) ToPtr() *AvailabilityStateValues { + return &c +} + +type Enum0 string + +const ( + Enum0Default Enum0 = "default" +) + +// PossibleEnum0Values returns the possible values for the Enum0 const type. +func PossibleEnum0Values() []Enum0 { + return []Enum0{ + Enum0Default, + } +} + +// ToPtr returns a *Enum0 pointing to the current value. +func (c Enum0) ToPtr() *Enum0 { + return &c +} + +// ReasonChronicityTypes - Chronicity of the availability transition. +type ReasonChronicityTypes string + +const ( + ReasonChronicityTypesTransient ReasonChronicityTypes = "Transient" + ReasonChronicityTypesPersistent ReasonChronicityTypes = "Persistent" +) + +// PossibleReasonChronicityTypesValues returns the possible values for the ReasonChronicityTypes const type. +func PossibleReasonChronicityTypesValues() []ReasonChronicityTypes { + return []ReasonChronicityTypes{ + ReasonChronicityTypesTransient, + ReasonChronicityTypesPersistent, + } +} + +// ToPtr returns a *ReasonChronicityTypes pointing to the current value. +func (c ReasonChronicityTypes) ToPtr() *ReasonChronicityTypes { + return &c +} + +// SeverityValues - The severity level of this active event. +type SeverityValues string + +const ( + SeverityValuesError SeverityValues = "Error" + SeverityValuesInformation SeverityValues = "Information" + SeverityValuesWarning SeverityValues = "Warning" +) + +// PossibleSeverityValuesValues returns the possible values for the SeverityValues const type. +func PossibleSeverityValuesValues() []SeverityValues { + return []SeverityValues{ + SeverityValuesError, + SeverityValuesInformation, + SeverityValuesWarning, + } +} + +// ToPtr returns a *SeverityValues pointing to the current value. +func (c SeverityValues) ToPtr() *SeverityValues { + return &c +} + +// StageValues - The stage of this active event. +type StageValues string + +const ( + StageValuesActive StageValues = "Active" + StageValuesArchived StageValues = "Archived" + StageValuesResolve StageValues = "Resolve" +) + +// PossibleStageValuesValues returns the possible values for the StageValues const type. +func PossibleStageValuesValues() []StageValues { + return []StageValues{ + StageValuesActive, + StageValuesArchived, + StageValuesResolve, + } +} + +// ToPtr returns a *StageValues pointing to the current value. +func (c StageValues) ToPtr() *StageValues { + return &c +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_emergingissues_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_emergingissues_client.go new file mode 100644 index 000000000000..e9777422c68a --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_emergingissues_client.go @@ -0,0 +1,141 @@ +//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 armresourcehealth + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// EmergingIssuesClient contains the methods for the EmergingIssues group. +// Don't use this type directly, use NewEmergingIssuesClient() instead. +type EmergingIssuesClient struct { + ep string + pl runtime.Pipeline +} + +// NewEmergingIssuesClient creates a new instance of EmergingIssuesClient with the specified values. +func NewEmergingIssuesClient(con *arm.Connection) *EmergingIssuesClient { + return &EmergingIssuesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// Get - Gets Azure services' emerging issues. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmergingIssuesClient) Get(ctx context.Context, issueName Enum0, options *EmergingIssuesGetOptions) (EmergingIssuesGetResponse, error) { + req, err := client.getCreateRequest(ctx, issueName, options) + if err != nil { + return EmergingIssuesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EmergingIssuesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EmergingIssuesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *EmergingIssuesClient) getCreateRequest(ctx context.Context, issueName Enum0, options *EmergingIssuesGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceHealth/emergingIssues/{issueName}" + if issueName == "" { + return nil, errors.New("parameter issueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueName}", url.PathEscape(string(issueName))) + 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-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EmergingIssuesClient) getHandleResponse(resp *http.Response) (EmergingIssuesGetResponse, error) { + result := EmergingIssuesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EmergingIssuesGetResult); err != nil { + return EmergingIssuesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *EmergingIssuesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Lists Azure services' emerging issues. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmergingIssuesClient) List(options *EmergingIssuesListOptions) *EmergingIssuesListPager { + return &EmergingIssuesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp EmergingIssuesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.EmergingIssueListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *EmergingIssuesClient) listCreateRequest(ctx context.Context, options *EmergingIssuesListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceHealth/emergingIssues" + 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-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EmergingIssuesClient) listHandleResponse(resp *http.Response) (EmergingIssuesListResponse, error) { + result := EmergingIssuesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EmergingIssueListResult); err != nil { + return EmergingIssuesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *EmergingIssuesClient) 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/resourcehealth/armresourcehealth/zz_generated_models.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models.go new file mode 100644 index 000000000000..20766eeadbe3 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models.go @@ -0,0 +1,769 @@ +//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 armresourcehealth + +import ( + "encoding/json" + "reflect" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// AvailabilityStatus - availabilityStatus of a resource. +type AvailabilityStatus struct { + // Azure Resource Manager Identity for the availabilityStatuses resource. + ID *string `json:"id,omitempty"` + + // Azure Resource Manager geo location of the resource. + Location *string `json:"location,omitempty"` + + // current. + Name *string `json:"name,omitempty"` + + // Properties of availability state. + Properties *AvailabilityStatusProperties `json:"properties,omitempty"` + + // Microsoft.ResourceHealth/AvailabilityStatuses. + Type *string `json:"type,omitempty"` +} + +// AvailabilityStatusListResult - The List availabilityStatus operation response. +type AvailabilityStatusListResult struct { + // REQUIRED; The list of availabilityStatuses. + Value []*AvailabilityStatus `json:"value,omitempty"` + + // The URI to fetch the next page of availabilityStatuses. Call ListNext() with this URI to fetch the next page of availabilityStatuses. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AvailabilityStatusListResult. +func (a AvailabilityStatusListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AvailabilityStatusProperties - Properties of availability state. +type AvailabilityStatusProperties struct { + // Availability status of the resource. When it is null, this availabilityStatus object represents an availability impacting event + AvailabilityState *AvailabilityStateValues `json:"availabilityState,omitempty"` + + // Details of the availability status. + DetailedStatus *string `json:"detailedStatus,omitempty"` + + // In case of an availability impacting event, it describes the category of a PlatformInitiated health impacting event. Examples are Planned, Unplanned + // etc. + HealthEventCategory *string `json:"healthEventCategory,omitempty"` + + // In case of an availability impacting event, it describes where the health impacting event was originated. Examples are PlatformInitiated, UserInitiated + // etc. + HealthEventCause *string `json:"healthEventCause,omitempty"` + + // It is a unique Id that identifies the event + HealthEventID *string `json:"healthEventId,omitempty"` + + // In case of an availability impacting event, it describes when the health impacting event was originated. Examples are Lifecycle, Downtime, Fault Analysis + // etc. + HealthEventType *string `json:"healthEventType,omitempty"` + + // Timestamp for when last change in health status occurred. + OccuredTime *time.Time `json:"occuredTime,omitempty"` + + // Chronicity of the availability transition. + ReasonChronicity *ReasonChronicityTypes `json:"reasonChronicity,omitempty"` + + // When the resource's availabilityState is Unavailable, it describes where the health impacting event was originated. Examples are planned, unplanned, + // user initiated or an outage etc. + ReasonType *string `json:"reasonType,omitempty"` + + // An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType of type Unplanned + RecentlyResolvedState *AvailabilityStatusPropertiesRecentlyResolvedState `json:"recentlyResolvedState,omitempty"` + + // Lists actions the user can take based on the current availabilityState of the resource. + RecommendedActions []*RecommendedAction `json:"recommendedActions,omitempty"` + + // Timestamp for when the health was last checked. + ReportedTime *time.Time `json:"reportedTime,omitempty"` + + // When the resource's availabilityState is Unavailable and the reasonType is not User Initiated, it provides the date and time for when the issue is expected + // to be resolved. + ResolutionETA *time.Time `json:"resolutionETA,omitempty"` + + // When the resource's availabilityState is Unavailable, it provides the Timestamp for when the health impacting event was received. + RootCauseAttributionTime *time.Time `json:"rootCauseAttributionTime,omitempty"` + + // Lists the service impacting events that may be affecting the health of the resource. + ServiceImpactingEvents []*ServiceImpactingEvent `json:"serviceImpactingEvents,omitempty"` + + // Summary description of the availability status. + Summary *string `json:"summary,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AvailabilityStatusProperties. +func (a AvailabilityStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityState", a.AvailabilityState) + populate(objectMap, "detailedStatus", a.DetailedStatus) + populate(objectMap, "healthEventCategory", a.HealthEventCategory) + populate(objectMap, "healthEventCause", a.HealthEventCause) + populate(objectMap, "healthEventId", a.HealthEventID) + populate(objectMap, "healthEventType", a.HealthEventType) + populate(objectMap, "occuredTime", (*timeRFC3339)(a.OccuredTime)) + populate(objectMap, "reasonChronicity", a.ReasonChronicity) + populate(objectMap, "reasonType", a.ReasonType) + populate(objectMap, "recentlyResolvedState", a.RecentlyResolvedState) + populate(objectMap, "recommendedActions", a.RecommendedActions) + populate(objectMap, "reportedTime", (*timeRFC3339)(a.ReportedTime)) + populate(objectMap, "resolutionETA", (*timeRFC3339)(a.ResolutionETA)) + populate(objectMap, "rootCauseAttributionTime", (*timeRFC3339)(a.RootCauseAttributionTime)) + populate(objectMap, "serviceImpactingEvents", a.ServiceImpactingEvents) + populate(objectMap, "summary", a.Summary) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityStatusProperties. +func (a *AvailabilityStatusProperties) 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 "availabilityState": + err = unpopulate(val, &a.AvailabilityState) + delete(rawMsg, key) + case "detailedStatus": + err = unpopulate(val, &a.DetailedStatus) + delete(rawMsg, key) + case "healthEventCategory": + err = unpopulate(val, &a.HealthEventCategory) + delete(rawMsg, key) + case "healthEventCause": + err = unpopulate(val, &a.HealthEventCause) + delete(rawMsg, key) + case "healthEventId": + err = unpopulate(val, &a.HealthEventID) + delete(rawMsg, key) + case "healthEventType": + err = unpopulate(val, &a.HealthEventType) + delete(rawMsg, key) + case "occuredTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.OccuredTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "reasonChronicity": + err = unpopulate(val, &a.ReasonChronicity) + delete(rawMsg, key) + case "reasonType": + err = unpopulate(val, &a.ReasonType) + delete(rawMsg, key) + case "recentlyResolvedState": + err = unpopulate(val, &a.RecentlyResolvedState) + delete(rawMsg, key) + case "recommendedActions": + err = unpopulate(val, &a.RecommendedActions) + delete(rawMsg, key) + case "reportedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.ReportedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "resolutionETA": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.ResolutionETA = (*time.Time)(&aux) + delete(rawMsg, key) + case "rootCauseAttributionTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.RootCauseAttributionTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "serviceImpactingEvents": + err = unpopulate(val, &a.ServiceImpactingEvents) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, &a.Summary) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AvailabilityStatusPropertiesRecentlyResolvedState - An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType +// of type Unplanned +type AvailabilityStatusPropertiesRecentlyResolvedState struct { + // Timestamp when the availabilityState changes to Available. + ResolvedTime *time.Time `json:"resolvedTime,omitempty"` + + // Brief description of cause of the resource becoming unavailable. + UnavailabilitySummary *string `json:"unavailabilitySummary,omitempty"` + + // Timestamp for when the availabilityState changed to Unavailable + UnavailableOccurredTime *time.Time `json:"unavailableOccurredTime,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AvailabilityStatusPropertiesRecentlyResolvedState. +func (a AvailabilityStatusPropertiesRecentlyResolvedState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "resolvedTime", (*timeRFC3339)(a.ResolvedTime)) + populate(objectMap, "unavailabilitySummary", a.UnavailabilitySummary) + populate(objectMap, "unavailableOccurredTime", (*timeRFC3339)(a.UnavailableOccurredTime)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityStatusPropertiesRecentlyResolvedState. +func (a *AvailabilityStatusPropertiesRecentlyResolvedState) 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 "resolvedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.ResolvedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "unavailabilitySummary": + err = unpopulate(val, &a.UnavailabilitySummary) + delete(rawMsg, key) + case "unavailableOccurredTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.UnavailableOccurredTime = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// AvailabilityStatusesGetByResourceOptions contains the optional parameters for the AvailabilityStatuses.GetByResource method. +type AvailabilityStatusesGetByResourceOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// AvailabilityStatusesListByResourceGroupOptions contains the optional parameters for the AvailabilityStatuses.ListByResourceGroup method. +type AvailabilityStatusesListByResourceGroupOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// AvailabilityStatusesListBySubscriptionIDOptions contains the optional parameters for the AvailabilityStatuses.ListBySubscriptionID method. +type AvailabilityStatusesListBySubscriptionIDOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// AvailabilityStatusesListOptions contains the optional parameters for the AvailabilityStatuses.List method. +type AvailabilityStatusesListOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// ChildAvailabilityStatusesGetByResourceOptions contains the optional parameters for the ChildAvailabilityStatuses.GetByResource method. +type ChildAvailabilityStatusesGetByResourceOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// ChildAvailabilityStatusesListOptions contains the optional parameters for the ChildAvailabilityStatuses.List method. +type ChildAvailabilityStatusesListOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// ChildResourcesListOptions contains the optional parameters for the ChildResources.List method. +type ChildResourcesListOptions struct { + // Setting $expand=recommendedactions in url query expands the recommendedactions in the response. + Expand *string + // The filter to apply on the operation. For more information please see https://docs.microsoft.com/en-us/rest/api/apimanagement/apis?redirectedfrom=MSDN + Filter *string +} + +// EmergingIssue - On-going emerging issue from azure status. +type EmergingIssue struct { + // Timestamp for when last time refreshed for ongoing emerging issue. + RefreshTimestamp *time.Time `json:"refreshTimestamp,omitempty"` + + // The list of emerging issues of active event type. + StatusActiveEvents []*StatusActiveEvent `json:"statusActiveEvents,omitempty"` + + // The list of emerging issues of banner type. + StatusBanners []*StatusBanner `json:"statusBanners,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmergingIssue. +func (e EmergingIssue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "refreshTimestamp", (*timeRFC3339)(e.RefreshTimestamp)) + populate(objectMap, "statusActiveEvents", e.StatusActiveEvents) + populate(objectMap, "statusBanners", e.StatusBanners) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmergingIssue. +func (e *EmergingIssue) 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 "refreshTimestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + e.RefreshTimestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "statusActiveEvents": + err = unpopulate(val, &e.StatusActiveEvents) + delete(rawMsg, key) + case "statusBanners": + err = unpopulate(val, &e.StatusBanners) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EmergingIssueImpact - Object of the emerging issue impact on services and regions. +type EmergingIssueImpact struct { + // The impacted service id. + ID *string `json:"id,omitempty"` + + // The impacted service name. + Name *string `json:"name,omitempty"` + + // The list of impacted regions for corresponding emerging issues. + Regions []*ImpactedRegion `json:"regions,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmergingIssueImpact. +func (e EmergingIssueImpact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "regions", e.Regions) + return json.Marshal(objectMap) +} + +// EmergingIssueListResult - The list of emerging issues. +type EmergingIssueListResult struct { + // The link used to get the next page of emerging issues. + NextLink *string `json:"nextLink,omitempty"` + + // The list of emerging issues. + Value []*EmergingIssuesGetResult `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmergingIssueListResult. +func (e EmergingIssueListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// EmergingIssuesGetOptions contains the optional parameters for the EmergingIssues.Get method. +type EmergingIssuesGetOptions struct { + // placeholder for future optional parameters +} + +// EmergingIssuesGetResult - The Get EmergingIssues operation response. +type EmergingIssuesGetResult struct { + Resource + // The emerging issue entity properties. + Properties *EmergingIssue `json:"properties,omitempty"` +} + +// EmergingIssuesListOptions contains the optional parameters for the EmergingIssues.List method. +type EmergingIssuesListOptions struct { + // placeholder for future optional parameters +} + +// ErrorResponse - Error details. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details *string `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// 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 +} + +// ImpactedRegion - Object of impacted region. +type ImpactedRegion struct { + // The impacted region id. + ID *string `json:"id,omitempty"` + + // The impacted region name. + Name *string `json:"name,omitempty"` +} + +// Operation available in the resourcehealth resource provider. +type Operation struct { + // Properties of the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Name of the operation. + Name *string `json:"name,omitempty"` +} + +// OperationDisplay - Properties of the operation. +type OperationDisplay struct { + // Description of the operation. + Description *string `json:"description,omitempty"` + + // Operation name. + Operation *string `json:"operation,omitempty"` + + // Provider name. + Provider *string `json:"provider,omitempty"` + + // Resource name. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - Lists the operations response. +type OperationListResult struct { + // REQUIRED; List of operations available in the resourcehealth resource provider. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) 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 +} + +// RecommendedAction - Lists actions the user can take based on the current availabilityState of the resource. +type RecommendedAction struct { + // Recommended action. + Action *string `json:"action,omitempty"` + + // Link to the action + ActionURL *string `json:"actionUrl,omitempty"` + + // Substring of action, it describes which text should host the action url. + ActionURLText *string `json:"actionUrlText,omitempty"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ServiceImpactingEvent - Lists the service impacting events that may be affecting the health of the resource. +type ServiceImpactingEvent struct { + // Correlation id for the event + CorrelationID *string `json:"correlationId,omitempty"` + + // Timestamp for when the event started. + EventStartTime *time.Time `json:"eventStartTime,omitempty"` + + // Timestamp for when event was submitted/detected. + EventStatusLastModifiedTime *time.Time `json:"eventStatusLastModifiedTime,omitempty"` + + // Properties of the service impacting event. + IncidentProperties *ServiceImpactingEventIncidentProperties `json:"incidentProperties,omitempty"` + + // Status of the service impacting event. + Status *ServiceImpactingEventStatus `json:"status,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceImpactingEvent. +func (s ServiceImpactingEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "correlationId", s.CorrelationID) + populate(objectMap, "eventStartTime", (*timeRFC3339)(s.EventStartTime)) + populate(objectMap, "eventStatusLastModifiedTime", (*timeRFC3339)(s.EventStatusLastModifiedTime)) + populate(objectMap, "incidentProperties", s.IncidentProperties) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceImpactingEvent. +func (s *ServiceImpactingEvent) 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 "correlationId": + err = unpopulate(val, &s.CorrelationID) + delete(rawMsg, key) + case "eventStartTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.EventStartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "eventStatusLastModifiedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.EventStatusLastModifiedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "incidentProperties": + err = unpopulate(val, &s.IncidentProperties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &s.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ServiceImpactingEventIncidentProperties - Properties of the service impacting event. +type ServiceImpactingEventIncidentProperties struct { + // Type of Event. + IncidentType *string `json:"incidentType,omitempty"` + + // Region impacted by the event. + Region *string `json:"region,omitempty"` + + // Service impacted by the event. + Service *string `json:"service,omitempty"` + + // Title of the incident. + Title *string `json:"title,omitempty"` +} + +// ServiceImpactingEventStatus - Status of the service impacting event. +type ServiceImpactingEventStatus struct { + // Current status of the event + Value *string `json:"value,omitempty"` +} + +// StatusActiveEvent - Active event type of emerging issue. +type StatusActiveEvent struct { + // The cloud type of this active event. + Cloud *string `json:"cloud,omitempty"` + + // The details of active event. + Description *string `json:"description,omitempty"` + + // The list of emerging issues impacts. + Impacts []*EmergingIssueImpact `json:"impacts,omitempty"` + + // The last time modified on this banner. + LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty"` + + // The boolean value of this active event if published or not. + Published *bool `json:"published,omitempty"` + + // The severity level of this active event. + Severity *SeverityValues `json:"severity,omitempty"` + + // The stage of this active event. + Stage *StageValues `json:"stage,omitempty"` + + // The impact start time on this active event. + StartTime *time.Time `json:"startTime,omitempty"` + + // The active event title. + Title *string `json:"title,omitempty"` + + // The tracking id of this active event. + TrackingID *string `json:"trackingId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StatusActiveEvent. +func (s StatusActiveEvent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cloud", s.Cloud) + populate(objectMap, "description", s.Description) + populate(objectMap, "impacts", s.Impacts) + populate(objectMap, "lastModifiedTime", (*timeRFC3339)(s.LastModifiedTime)) + populate(objectMap, "published", s.Published) + populate(objectMap, "severity", s.Severity) + populate(objectMap, "stage", s.Stage) + populate(objectMap, "startTime", (*timeRFC3339)(s.StartTime)) + populate(objectMap, "title", s.Title) + populate(objectMap, "trackingId", s.TrackingID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusActiveEvent. +func (s *StatusActiveEvent) 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 "cloud": + err = unpopulate(val, &s.Cloud) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &s.Description) + delete(rawMsg, key) + case "impacts": + err = unpopulate(val, &s.Impacts) + delete(rawMsg, key) + case "lastModifiedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastModifiedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "published": + err = unpopulate(val, &s.Published) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, &s.Severity) + delete(rawMsg, key) + case "stage": + err = unpopulate(val, &s.Stage) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "title": + err = unpopulate(val, &s.Title) + delete(rawMsg, key) + case "trackingId": + err = unpopulate(val, &s.TrackingID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// StatusBanner - Banner type of emerging issue. +type StatusBanner struct { + // The cloud type of this banner. + Cloud *string `json:"cloud,omitempty"` + + // The last time modified on this banner. + LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty"` + + // The details of banner. + Message *string `json:"message,omitempty"` + + // The banner title. + Title *string `json:"title,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StatusBanner. +func (s StatusBanner) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "cloud", s.Cloud) + populate(objectMap, "lastModifiedTime", (*timeRFC3339)(s.LastModifiedTime)) + populate(objectMap, "message", s.Message) + populate(objectMap, "title", s.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusBanner. +func (s *StatusBanner) 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 "cloud": + err = unpopulate(val, &s.Cloud) + delete(rawMsg, key) + case "lastModifiedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastModifiedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "message": + err = unpopulate(val, &s.Message) + delete(rawMsg, key) + case "title": + err = unpopulate(val, &s.Title) + 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/resourcehealth/armresourcehealth/zz_generated_operations_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_operations_client.go new file mode 100644 index 000000000000..dbee200bf524 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_operations_client.go @@ -0,0 +1,84 @@ +//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 armresourcehealth + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// 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(con *arm.Connection) *OperationsClient { + return &OperationsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// List - Lists available operations for the resourcehealth resource provider +// 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.ResourceHealth/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-07-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + 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/resourcehealth/armresourcehealth/zz_generated_pagers.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_pagers.go new file mode 100644 index 000000000000..6be3c50497ca --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_pagers.go @@ -0,0 +1,342 @@ +//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 armresourcehealth + +import ( + "context" + "net/http" + "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// AvailabilityStatusesListByResourceGroupPager provides operations for iterating over paged responses. +type AvailabilityStatusesListByResourceGroupPager struct { + client *AvailabilityStatusesClient + current AvailabilityStatusesListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AvailabilityStatusesListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AvailabilityStatusesListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AvailabilityStatusesListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AvailabilityStatusListResult.NextLink == nil || len(*p.current.AvailabilityStatusListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AvailabilityStatusesListByResourceGroupResponse page. +func (p *AvailabilityStatusesListByResourceGroupPager) PageResponse() AvailabilityStatusesListByResourceGroupResponse { + return p.current +} + +// AvailabilityStatusesListBySubscriptionIDPager provides operations for iterating over paged responses. +type AvailabilityStatusesListBySubscriptionIDPager struct { + client *AvailabilityStatusesClient + current AvailabilityStatusesListBySubscriptionIDResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AvailabilityStatusesListBySubscriptionIDResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AvailabilityStatusesListBySubscriptionIDPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AvailabilityStatusesListBySubscriptionIDPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AvailabilityStatusListResult.NextLink == nil || len(*p.current.AvailabilityStatusListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionIDHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionIDHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AvailabilityStatusesListBySubscriptionIDResponse page. +func (p *AvailabilityStatusesListBySubscriptionIDPager) PageResponse() AvailabilityStatusesListBySubscriptionIDResponse { + return p.current +} + +// AvailabilityStatusesListPager provides operations for iterating over paged responses. +type AvailabilityStatusesListPager struct { + client *AvailabilityStatusesClient + current AvailabilityStatusesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, AvailabilityStatusesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *AvailabilityStatusesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *AvailabilityStatusesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AvailabilityStatusListResult.NextLink == nil || len(*p.current.AvailabilityStatusListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current AvailabilityStatusesListResponse page. +func (p *AvailabilityStatusesListPager) PageResponse() AvailabilityStatusesListResponse { + return p.current +} + +// ChildAvailabilityStatusesListPager provides operations for iterating over paged responses. +type ChildAvailabilityStatusesListPager struct { + client *ChildAvailabilityStatusesClient + current ChildAvailabilityStatusesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ChildAvailabilityStatusesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ChildAvailabilityStatusesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ChildAvailabilityStatusesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AvailabilityStatusListResult.NextLink == nil || len(*p.current.AvailabilityStatusListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ChildAvailabilityStatusesListResponse page. +func (p *ChildAvailabilityStatusesListPager) PageResponse() ChildAvailabilityStatusesListResponse { + return p.current +} + +// ChildResourcesListPager provides operations for iterating over paged responses. +type ChildResourcesListPager struct { + client *ChildResourcesClient + current ChildResourcesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ChildResourcesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ChildResourcesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ChildResourcesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AvailabilityStatusListResult.NextLink == nil || len(*p.current.AvailabilityStatusListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ChildResourcesListResponse page. +func (p *ChildResourcesListPager) PageResponse() ChildResourcesListResponse { + return p.current +} + +// EmergingIssuesListPager provides operations for iterating over paged responses. +type EmergingIssuesListPager struct { + client *EmergingIssuesClient + current EmergingIssuesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, EmergingIssuesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *EmergingIssuesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *EmergingIssuesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EmergingIssueListResult.NextLink == nil || len(*p.current.EmergingIssueListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current EmergingIssuesListResponse page. +func (p *EmergingIssuesListPager) PageResponse() EmergingIssuesListResponse { + return p.current +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_response_types.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_response_types.go new file mode 100644 index 000000000000..f387c5361975 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_response_types.go @@ -0,0 +1,131 @@ +//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 armresourcehealth + +import "net/http" + +// AvailabilityStatusesGetByResourceResponse contains the response from method AvailabilityStatuses.GetByResource. +type AvailabilityStatusesGetByResourceResponse struct { + AvailabilityStatusesGetByResourceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailabilityStatusesGetByResourceResult contains the result from method AvailabilityStatuses.GetByResource. +type AvailabilityStatusesGetByResourceResult struct { + AvailabilityStatus +} + +// AvailabilityStatusesListByResourceGroupResponse contains the response from method AvailabilityStatuses.ListByResourceGroup. +type AvailabilityStatusesListByResourceGroupResponse struct { + AvailabilityStatusesListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailabilityStatusesListByResourceGroupResult contains the result from method AvailabilityStatuses.ListByResourceGroup. +type AvailabilityStatusesListByResourceGroupResult struct { + AvailabilityStatusListResult +} + +// AvailabilityStatusesListBySubscriptionIDResponse contains the response from method AvailabilityStatuses.ListBySubscriptionID. +type AvailabilityStatusesListBySubscriptionIDResponse struct { + AvailabilityStatusesListBySubscriptionIDResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailabilityStatusesListBySubscriptionIDResult contains the result from method AvailabilityStatuses.ListBySubscriptionID. +type AvailabilityStatusesListBySubscriptionIDResult struct { + AvailabilityStatusListResult +} + +// AvailabilityStatusesListResponse contains the response from method AvailabilityStatuses.List. +type AvailabilityStatusesListResponse struct { + AvailabilityStatusesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AvailabilityStatusesListResult contains the result from method AvailabilityStatuses.List. +type AvailabilityStatusesListResult struct { + AvailabilityStatusListResult +} + +// ChildAvailabilityStatusesGetByResourceResponse contains the response from method ChildAvailabilityStatuses.GetByResource. +type ChildAvailabilityStatusesGetByResourceResponse struct { + ChildAvailabilityStatusesGetByResourceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ChildAvailabilityStatusesGetByResourceResult contains the result from method ChildAvailabilityStatuses.GetByResource. +type ChildAvailabilityStatusesGetByResourceResult struct { + AvailabilityStatus +} + +// ChildAvailabilityStatusesListResponse contains the response from method ChildAvailabilityStatuses.List. +type ChildAvailabilityStatusesListResponse struct { + ChildAvailabilityStatusesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ChildAvailabilityStatusesListResult contains the result from method ChildAvailabilityStatuses.List. +type ChildAvailabilityStatusesListResult struct { + AvailabilityStatusListResult +} + +// ChildResourcesListResponse contains the response from method ChildResources.List. +type ChildResourcesListResponse struct { + ChildResourcesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ChildResourcesListResult contains the result from method ChildResources.List. +type ChildResourcesListResult struct { + AvailabilityStatusListResult +} + +// EmergingIssuesGetResponse contains the response from method EmergingIssues.Get. +type EmergingIssuesGetResponse struct { + EmergingIssuesGetResultEnvelope + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmergingIssuesGetResultEnvelope contains the result from method EmergingIssues.Get. +type EmergingIssuesGetResultEnvelope struct { + EmergingIssuesGetResult +} + +// EmergingIssuesListResponse contains the response from method EmergingIssues.List. +type EmergingIssuesListResponse struct { + EmergingIssuesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmergingIssuesListResult contains the result from method EmergingIssues.List. +type EmergingIssuesListResult struct { + EmergingIssueListResult +} + +// 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 { + OperationListResult +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_time_rfc3339.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..935a5d0bcb49 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_time_rfc3339.go @@ -0,0 +1,58 @@ +//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 armresourcehealth + +import ( + "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 +}