From 07d721ea1fae568e65758ad1b5c8dab4fe3b69ec Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 5 Dec 2022 09:41:11 +0000 Subject: [PATCH] CodeGen from PR 21588 in Azure/azure-rest-api-specs Merge 4d24564a74d2d9746fb5539400667d1d1d328736 into 5dedb96183ff83552172039606e67eccf0b7ee20 --- .../armresourcehealth/CHANGELOG.md | 64 + .../armresourcehealth/autorest.md | 6 +- ...ient.go => availabilitystatuses_client.go} | 23 +- .../armresourcehealth/constants.go | 198 +++ .../armresourcehealth/event_client.go | 168 ++ .../armresourcehealth/events_client.go | 245 +++ .../resourcehealth/armresourcehealth/go.mod | 16 +- .../resourcehealth/armresourcehealth/go.sum | 24 +- .../impactedresources_client.go | 179 ++ .../armresourcehealth/models.go | 689 ++++++++ .../armresourcehealth/models_serde.go | 1481 +++++++++++++++++ ...rations_client.go => operations_client.go} | 5 +- ...ed_response_types.go => response_types.go} | 36 + ...erated_time_rfc3339.go => time_rfc3339.go} | 1 + ...xample_availabilitystatuses_client_test.go | 95 -- ...enerated_example_operations_client_test.go | 37 - .../zz_generated_constants.go | 69 - .../armresourcehealth/zz_generated_models.go | 320 ---- .../zz_generated_models_serde.go | 211 --- 19 files changed, 3084 insertions(+), 783 deletions(-) rename sdk/resourcemanager/resourcehealth/armresourcehealth/{zz_generated_availabilitystatuses_client.go => availabilitystatuses_client.go} (95%) create mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/constants.go create mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/event_client.go create mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/events_client.go create mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/impactedresources_client.go create mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/models.go create mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/models_serde.go rename sdk/resourcemanager/resourcehealth/armresourcehealth/{zz_generated_operations_client.go => operations_client.go} (97%) rename sdk/resourcemanager/resourcehealth/armresourcehealth/{zz_generated_response_types.go => response_types.go} (50%) rename sdk/resourcemanager/resourcehealth/armresourcehealth/{zz_generated_time_rfc3339.go => time_rfc3339.go} (99%) delete mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_availabilitystatuses_client_test.go delete mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_operations_client_test.go delete mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_constants.go delete mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models.go delete mode 100644 sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models_serde.go diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md b/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md index 570333ada84b..34933a2bcfbe 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/CHANGELOG.md @@ -1,5 +1,69 @@ # Release History +## 2.0.0 (2022-12-05) +### Breaking Changes + +- Struct `ErrorResponseError` has been removed +- Field `OccurredTime` of struct `AvailabilityStatusProperties` has been removed +- Field `UnavailabilitySummary` of struct `AvailabilityStatusPropertiesRecentlyResolved` has been removed +- Field `UnavailableOccurredTime` of struct `AvailabilityStatusPropertiesRecentlyResolved` has been removed +- Field `Error` of struct `ErrorResponse` has been removed + +### Features Added + +- New type alias `CreatedByType` with values `CreatedByTypeApplication`, `CreatedByTypeKey`, `CreatedByTypeManagedIdentity`, `CreatedByTypeUser` +- New type alias `EventLevelValues` with values `EventLevelValuesCritical`, `EventLevelValuesError`, `EventLevelValuesInformational`, `EventLevelValuesWarning` +- New type alias `EventSourceValues` with values `EventSourceValuesResourceHealth`, `EventSourceValuesServiceHealth` +- New type alias `EventStatusValues` with values `EventStatusValuesActive`, `EventStatusValuesResolved` +- New type alias `EventTypeValues` with values `EventTypeValuesEmergingIssues`, `EventTypeValuesHealthAdvisory`, `EventTypeValuesPlannedMaintenance`, `EventTypeValuesRCA`, `EventTypeValuesSecurityAdvisory`, `EventTypeValuesServiceIssue` +- New type alias `LevelValues` with values `LevelValuesCritical`, `LevelValuesWarning` +- New type alias `LinkTypeValues` with values `LinkTypeValuesButton`, `LinkTypeValuesHyperlink` +- New function `NewEventClient(string, azcore.TokenCredential, *arm.ClientOptions) (*EventClient, error)` +- New function `*EventClient.GetBySubscriptionIDAndTrackingID(context.Context, string, *EventClientGetBySubscriptionIDAndTrackingIDOptions) (EventClientGetBySubscriptionIDAndTrackingIDResponse, error)` +- New function `*EventClient.GetByTenantIDAndTrackingID(context.Context, string, *EventClientGetByTenantIDAndTrackingIDOptions) (EventClientGetByTenantIDAndTrackingIDResponse, error)` +- New function `NewEventsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*EventsClient, error)` +- New function `*EventsClient.NewListBySingleResourcePager(string, *EventsClientListBySingleResourceOptions) *runtime.Pager[EventsClientListBySingleResourceResponse]` +- New function `*EventsClient.NewListBySubscriptionIDPager(*EventsClientListBySubscriptionIDOptions) *runtime.Pager[EventsClientListBySubscriptionIDResponse]` +- New function `*EventsClient.NewListByTenantIDPager(*EventsClientListByTenantIDOptions) *runtime.Pager[EventsClientListByTenantIDResponse]` +- New function `NewImpactedResourcesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ImpactedResourcesClient, error)` +- New function `*ImpactedResourcesClient.Get(context.Context, string, string, *ImpactedResourcesClientGetOptions) (ImpactedResourcesClientGetResponse, error)` +- New function `*ImpactedResourcesClient.NewListBySubscriptionIDAndEventIDPager(string, *ImpactedResourcesClientListBySubscriptionIDAndEventIDOptions) *runtime.Pager[ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse]` +- New struct `Event` +- New struct `EventClient` +- New struct `EventImpactedResource` +- New struct `EventImpactedResourceListResult` +- New struct `EventImpactedResourceProperties` +- New struct `EventProperties` +- New struct `EventPropertiesAdditionalInformation` +- New struct `EventPropertiesArticle` +- New struct `EventPropertiesRecommendedActions` +- New struct `EventPropertiesRecommendedActionsItem` +- New struct `Events` +- New struct `EventsClient` +- New struct `EventsClientListBySingleResourceResponse` +- New struct `EventsClientListBySubscriptionIDResponse` +- New struct `EventsClientListByTenantIDResponse` +- New struct `Faq` +- New struct `Impact` +- New struct `ImpactedResourcesClient` +- New struct `ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse` +- New struct `ImpactedServiceRegion` +- New struct `KeyValueItem` +- New struct `Link` +- New struct `LinkDisplayText` +- New struct `ProxyResource` +- New struct `SystemData` +- New struct `Update` +- New field `OccuredTime` in struct `AvailabilityStatusProperties` +- New field `UnavailableOccuredTime` in struct `AvailabilityStatusPropertiesRecentlyResolved` +- New field `UnavailableSummary` in struct `AvailabilityStatusPropertiesRecentlyResolved` +- New field `Code` in struct `ErrorResponse` +- New field `Details` in struct `ErrorResponse` +- New field `Message` in struct `ErrorResponse` +- New field `SystemData` in struct `ImpactedResourceStatus` +- New field `SystemData` in struct `Resource` + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/autorest.md b/sdk/resourcemanager/resourcehealth/armresourcehealth/autorest.md index a8f55772a85d..d9103f7cb933 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/autorest.md +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/autorest.md @@ -5,8 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcehealth/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resourcehealth/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resourcehealth/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resourcehealth/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 2.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_availabilitystatuses_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/availabilitystatuses_client.go similarity index 95% rename from sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_availabilitystatuses_client.go rename to sdk/resourcemanager/resourcehealth/armresourcehealth/availabilitystatuses_client.go index c47731e5702b..1e1ad7d39c73 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_availabilitystatuses_client.go +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/availabilitystatuses_client.go @@ -5,6 +5,7 @@ // 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. +// DO NOT EDIT. package armresourcehealth @@ -31,8 +32,7 @@ type AvailabilityStatusesClient struct { } // NewAvailabilityStatusesClient creates a new instance of AvailabilityStatusesClient with the specified values. -// subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms -// part of the URI for every service call. +// subscriptionID - The ID of the target subscription. // credential - used to authorize requests. Usually a credential from azidentity. // options - pass nil to accept the default values. func NewAvailabilityStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvailabilityStatusesClient, error) { @@ -57,7 +57,7 @@ func NewAvailabilityStatusesClient(subscriptionID string, credential azcore.Toke // GetByResource - Gets current availability status for a single resource // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-05-01 +// Generated from API version 2022-05-01 // resourceURI - The fully qualified ID of the resource, including the resource name and resource type. Currently the API // support not nested and one nesting level resource types : // /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} @@ -89,7 +89,7 @@ func (client *AvailabilityStatusesClient) getByResourceCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2022-05-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -111,8 +111,7 @@ func (client *AvailabilityStatusesClient) getByResourceHandleResponse(resp *http } // NewListPager - Lists all historical availability transitions and impacting events for a single resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-05-01 +// Generated from API version 2022-05-01 // resourceURI - The fully qualified ID of the resource, including the resource name and resource type. Currently the API // support not nested and one nesting level resource types : // /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} @@ -157,7 +156,7 @@ func (client *AvailabilityStatusesClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2022-05-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -179,8 +178,7 @@ func (client *AvailabilityStatusesClient) listHandleResponse(resp *http.Response } // NewListByResourceGroupPager - Lists the current availability status for all the resources in the resource group. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-05-01 +// Generated from API version 2022-05-01 // resourceGroupName - The name of the resource group. // options - AvailabilityStatusesClientListByResourceGroupOptions contains the optional parameters for the AvailabilityStatusesClient.ListByResourceGroup // method. @@ -228,7 +226,7 @@ func (client *AvailabilityStatusesClient) listByResourceGroupCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2022-05-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -250,8 +248,7 @@ func (client *AvailabilityStatusesClient) listByResourceGroupHandleResponse(resp } // NewListBySubscriptionIDPager - Lists the current availability status for all the resources in the subscription. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-05-01 +// Generated from API version 2022-05-01 // options - AvailabilityStatusesClientListBySubscriptionIDOptions contains the optional parameters for the AvailabilityStatusesClient.ListBySubscriptionID // method. func (client *AvailabilityStatusesClient) NewListBySubscriptionIDPager(options *AvailabilityStatusesClientListBySubscriptionIDOptions) *runtime.Pager[AvailabilityStatusesClientListBySubscriptionIDResponse] { @@ -294,7 +291,7 @@ func (client *AvailabilityStatusesClient) listBySubscriptionIDCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2022-05-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/constants.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/constants.go new file mode 100644 index 000000000000..67ea4119706b --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/constants.go @@ -0,0 +1,198 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armresourcehealth + +const ( + moduleName = "armresourcehealth" + moduleVersion = "v2.0.0" +) + +// AvailabilityStateValues - Impacted resource status of the resource. +type AvailabilityStateValues string + +const ( + AvailabilityStateValuesAvailable AvailabilityStateValues = "Available" + AvailabilityStateValuesDegraded AvailabilityStateValues = "Degraded" + AvailabilityStateValuesUnavailable AvailabilityStateValues = "Unavailable" + AvailabilityStateValuesUnknown AvailabilityStateValues = "Unknown" +) + +// PossibleAvailabilityStateValuesValues returns the possible values for the AvailabilityStateValues const type. +func PossibleAvailabilityStateValuesValues() []AvailabilityStateValues { + return []AvailabilityStateValues{ + AvailabilityStateValuesAvailable, + AvailabilityStateValuesDegraded, + AvailabilityStateValuesUnavailable, + AvailabilityStateValuesUnknown, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// EventLevelValues - Level of event. +type EventLevelValues string + +const ( + EventLevelValuesCritical EventLevelValues = "Critical" + EventLevelValuesError EventLevelValues = "Error" + EventLevelValuesInformational EventLevelValues = "Informational" + EventLevelValuesWarning EventLevelValues = "Warning" +) + +// PossibleEventLevelValuesValues returns the possible values for the EventLevelValues const type. +func PossibleEventLevelValuesValues() []EventLevelValues { + return []EventLevelValues{ + EventLevelValuesCritical, + EventLevelValuesError, + EventLevelValuesInformational, + EventLevelValuesWarning, + } +} + +// EventSourceValues - Source of event. +type EventSourceValues string + +const ( + EventSourceValuesResourceHealth EventSourceValues = "ResourceHealth" + EventSourceValuesServiceHealth EventSourceValues = "ServiceHealth" +) + +// PossibleEventSourceValuesValues returns the possible values for the EventSourceValues const type. +func PossibleEventSourceValuesValues() []EventSourceValues { + return []EventSourceValues{ + EventSourceValuesResourceHealth, + EventSourceValuesServiceHealth, + } +} + +// EventStatusValues - Current status of event. +type EventStatusValues string + +const ( + EventStatusValuesActive EventStatusValues = "Active" + EventStatusValuesResolved EventStatusValues = "Resolved" +) + +// PossibleEventStatusValuesValues returns the possible values for the EventStatusValues const type. +func PossibleEventStatusValuesValues() []EventStatusValues { + return []EventStatusValues{ + EventStatusValuesActive, + EventStatusValuesResolved, + } +} + +// EventTypeValues - Type of event. +type EventTypeValues string + +const ( + EventTypeValuesEmergingIssues EventTypeValues = "EmergingIssues" + EventTypeValuesHealthAdvisory EventTypeValues = "HealthAdvisory" + EventTypeValuesPlannedMaintenance EventTypeValues = "PlannedMaintenance" + EventTypeValuesRCA EventTypeValues = "RCA" + EventTypeValuesSecurityAdvisory EventTypeValues = "SecurityAdvisory" + EventTypeValuesServiceIssue EventTypeValues = "ServiceIssue" +) + +// PossibleEventTypeValuesValues returns the possible values for the EventTypeValues const type. +func PossibleEventTypeValuesValues() []EventTypeValues { + return []EventTypeValues{ + EventTypeValuesEmergingIssues, + EventTypeValuesHealthAdvisory, + EventTypeValuesPlannedMaintenance, + EventTypeValuesRCA, + EventTypeValuesSecurityAdvisory, + EventTypeValuesServiceIssue, + } +} + +// LevelValues - Level of insight. +type LevelValues string + +const ( + LevelValuesCritical LevelValues = "Critical" + LevelValuesWarning LevelValues = "Warning" +) + +// PossibleLevelValuesValues returns the possible values for the LevelValues const type. +func PossibleLevelValuesValues() []LevelValues { + return []LevelValues{ + LevelValuesCritical, + LevelValuesWarning, + } +} + +// LinkTypeValues - Type of link. +type LinkTypeValues string + +const ( + LinkTypeValuesButton LinkTypeValues = "Button" + LinkTypeValuesHyperlink LinkTypeValues = "Hyperlink" +) + +// PossibleLinkTypeValuesValues returns the possible values for the LinkTypeValues const type. +func PossibleLinkTypeValuesValues() []LinkTypeValues { + return []LinkTypeValues{ + LinkTypeValuesButton, + LinkTypeValuesHyperlink, + } +} + +// ReasonChronicityTypes - Chronicity of the availability transition. +type ReasonChronicityTypes string + +const ( + ReasonChronicityTypesPersistent ReasonChronicityTypes = "Persistent" + ReasonChronicityTypesTransient ReasonChronicityTypes = "Transient" +) + +// PossibleReasonChronicityTypesValues returns the possible values for the ReasonChronicityTypes const type. +func PossibleReasonChronicityTypesValues() []ReasonChronicityTypes { + return []ReasonChronicityTypes{ + ReasonChronicityTypesPersistent, + ReasonChronicityTypesTransient, + } +} + +// ReasonTypeValues - When the resource's availabilityState is Unavailable, it describes where the health impacting event +// was originated. +type ReasonTypeValues string + +const ( + ReasonTypeValuesPlanned ReasonTypeValues = "Planned" + ReasonTypeValuesUnplanned ReasonTypeValues = "Unplanned" + ReasonTypeValuesUserInitiated ReasonTypeValues = "UserInitiated" +) + +// PossibleReasonTypeValuesValues returns the possible values for the ReasonTypeValues const type. +func PossibleReasonTypeValuesValues() []ReasonTypeValues { + return []ReasonTypeValues{ + ReasonTypeValuesPlanned, + ReasonTypeValuesUnplanned, + ReasonTypeValuesUserInitiated, + } +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/event_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/event_client.go new file mode 100644 index 000000000000..de1b9498e0b4 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/event_client.go @@ -0,0 +1,168 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armresourcehealth + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// EventClient contains the methods for the Event group. +// Don't use this type directly, use NewEventClient() instead. +type EventClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewEventClient creates a new instance of EventClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewEventClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EventClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &EventClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// GetBySubscriptionIDAndTrackingID - Service health event in the subscription by event tracking id +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +// eventTrackingID - Event Id which uniquely identifies ServiceHealth event. +// options - EventClientGetBySubscriptionIDAndTrackingIDOptions contains the optional parameters for the EventClient.GetBySubscriptionIDAndTrackingID +// method. +func (client *EventClient) GetBySubscriptionIDAndTrackingID(ctx context.Context, eventTrackingID string, options *EventClientGetBySubscriptionIDAndTrackingIDOptions) (EventClientGetBySubscriptionIDAndTrackingIDResponse, error) { + req, err := client.getBySubscriptionIDAndTrackingIDCreateRequest(ctx, eventTrackingID, options) + if err != nil { + return EventClientGetBySubscriptionIDAndTrackingIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EventClientGetBySubscriptionIDAndTrackingIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EventClientGetBySubscriptionIDAndTrackingIDResponse{}, runtime.NewResponseError(resp) + } + return client.getBySubscriptionIDAndTrackingIDHandleResponse(resp) +} + +// getBySubscriptionIDAndTrackingIDCreateRequest creates the GetBySubscriptionIDAndTrackingID request. +func (client *EventClient) getBySubscriptionIDAndTrackingIDCreateRequest(ctx context.Context, eventTrackingID string, options *EventClientGetBySubscriptionIDAndTrackingIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if eventTrackingID == "" { + return nil, errors.New("parameter eventTrackingID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{eventTrackingId}", url.PathEscape(eventTrackingID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.QueryStartTime != nil { + reqQP.Set("queryStartTime", *options.QueryStartTime) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBySubscriptionIDAndTrackingIDHandleResponse handles the GetBySubscriptionIDAndTrackingID response. +func (client *EventClient) getBySubscriptionIDAndTrackingIDHandleResponse(resp *http.Response) (EventClientGetBySubscriptionIDAndTrackingIDResponse, error) { + result := EventClientGetBySubscriptionIDAndTrackingIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Event); err != nil { + return EventClientGetBySubscriptionIDAndTrackingIDResponse{}, err + } + return result, nil +} + +// GetByTenantIDAndTrackingID - Service health event in the tenant by event tracking id +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +// eventTrackingID - Event Id which uniquely identifies ServiceHealth event. +// options - EventClientGetByTenantIDAndTrackingIDOptions contains the optional parameters for the EventClient.GetByTenantIDAndTrackingID +// method. +func (client *EventClient) GetByTenantIDAndTrackingID(ctx context.Context, eventTrackingID string, options *EventClientGetByTenantIDAndTrackingIDOptions) (EventClientGetByTenantIDAndTrackingIDResponse, error) { + req, err := client.getByTenantIDAndTrackingIDCreateRequest(ctx, eventTrackingID, options) + if err != nil { + return EventClientGetByTenantIDAndTrackingIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EventClientGetByTenantIDAndTrackingIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EventClientGetByTenantIDAndTrackingIDResponse{}, runtime.NewResponseError(resp) + } + return client.getByTenantIDAndTrackingIDHandleResponse(resp) +} + +// getByTenantIDAndTrackingIDCreateRequest creates the GetByTenantIDAndTrackingID request. +func (client *EventClient) getByTenantIDAndTrackingIDCreateRequest(ctx context.Context, eventTrackingID string, options *EventClientGetByTenantIDAndTrackingIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceHealth/events/{eventTrackingId}" + if eventTrackingID == "" { + return nil, errors.New("parameter eventTrackingID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{eventTrackingId}", url.PathEscape(eventTrackingID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.QueryStartTime != nil { + reqQP.Set("queryStartTime", *options.QueryStartTime) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByTenantIDAndTrackingIDHandleResponse handles the GetByTenantIDAndTrackingID response. +func (client *EventClient) getByTenantIDAndTrackingIDHandleResponse(resp *http.Response) (EventClientGetByTenantIDAndTrackingIDResponse, error) { + result := EventClientGetByTenantIDAndTrackingIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Event); err != nil { + return EventClientGetByTenantIDAndTrackingIDResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/events_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/events_client.go new file mode 100644 index 000000000000..3fe7e5ee8bcb --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/events_client.go @@ -0,0 +1,245 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armresourcehealth + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// EventsClient contains the methods for the Events group. +// Don't use this type directly, use NewEventsClient() instead. +type EventsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewEventsClient creates a new instance of EventsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewEventsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EventsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &EventsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListBySingleResourcePager - Lists current service health events for given resource. +// Generated from API version 2022-05-01 +// resourceURI - The fully qualified ID of the resource, including the resource name and resource type. Currently the API +// support not nested and one nesting level resource types : +// /subscriptions/{subscriptionId}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}/{resource-type}/{resource-name} +// and +// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource-provider-name}/{parentResourceType}/{parentResourceName}/{resourceType}/{resourceName} +// options - EventsClientListBySingleResourceOptions contains the optional parameters for the EventsClient.ListBySingleResource +// method. +func (client *EventsClient) NewListBySingleResourcePager(resourceURI string, options *EventsClientListBySingleResourceOptions) *runtime.Pager[EventsClientListBySingleResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[EventsClientListBySingleResourceResponse]{ + More: func(page EventsClientListBySingleResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EventsClientListBySingleResourceResponse) (EventsClientListBySingleResourceResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySingleResourceCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EventsClientListBySingleResourceResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EventsClientListBySingleResourceResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EventsClientListBySingleResourceResponse{}, runtime.NewResponseError(resp) + } + return client.listBySingleResourceHandleResponse(resp) + }, + }) +} + +// listBySingleResourceCreateRequest creates the ListBySingleResource request. +func (client *EventsClient) listBySingleResourceCreateRequest(ctx context.Context, resourceURI string, options *EventsClientListBySingleResourceOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ResourceHealth/events" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySingleResourceHandleResponse handles the ListBySingleResource response. +func (client *EventsClient) listBySingleResourceHandleResponse(resp *http.Response) (EventsClientListBySingleResourceResponse, error) { + result := EventsClientListBySingleResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Events); err != nil { + return EventsClientListBySingleResourceResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionIDPager - Lists service health events in the subscription. +// Generated from API version 2022-05-01 +// options - EventsClientListBySubscriptionIDOptions contains the optional parameters for the EventsClient.ListBySubscriptionID +// method. +func (client *EventsClient) NewListBySubscriptionIDPager(options *EventsClientListBySubscriptionIDOptions) *runtime.Pager[EventsClientListBySubscriptionIDResponse] { + return runtime.NewPager(runtime.PagingHandler[EventsClientListBySubscriptionIDResponse]{ + More: func(page EventsClientListBySubscriptionIDResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EventsClientListBySubscriptionIDResponse) (EventsClientListBySubscriptionIDResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionIDCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EventsClientListBySubscriptionIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EventsClientListBySubscriptionIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EventsClientListBySubscriptionIDResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionIDHandleResponse(resp) + }, + }) +} + +// listBySubscriptionIDCreateRequest creates the ListBySubscriptionID request. +func (client *EventsClient) listBySubscriptionIDCreateRequest(ctx context.Context, options *EventsClientListBySubscriptionIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.QueryStartTime != nil { + reqQP.Set("queryStartTime", *options.QueryStartTime) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionIDHandleResponse handles the ListBySubscriptionID response. +func (client *EventsClient) listBySubscriptionIDHandleResponse(resp *http.Response) (EventsClientListBySubscriptionIDResponse, error) { + result := EventsClientListBySubscriptionIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Events); err != nil { + return EventsClientListBySubscriptionIDResponse{}, err + } + return result, nil +} + +// NewListByTenantIDPager - Lists current service health events in the tenant. +// Generated from API version 2022-05-01 +// options - EventsClientListByTenantIDOptions contains the optional parameters for the EventsClient.ListByTenantID method. +func (client *EventsClient) NewListByTenantIDPager(options *EventsClientListByTenantIDOptions) *runtime.Pager[EventsClientListByTenantIDResponse] { + return runtime.NewPager(runtime.PagingHandler[EventsClientListByTenantIDResponse]{ + More: func(page EventsClientListByTenantIDResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EventsClientListByTenantIDResponse) (EventsClientListByTenantIDResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByTenantIDCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EventsClientListByTenantIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EventsClientListByTenantIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EventsClientListByTenantIDResponse{}, runtime.NewResponseError(resp) + } + return client.listByTenantIDHandleResponse(resp) + }, + }) +} + +// listByTenantIDCreateRequest creates the ListByTenantID request. +func (client *EventsClient) listByTenantIDCreateRequest(ctx context.Context, options *EventsClientListByTenantIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceHealth/events" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.QueryStartTime != nil { + reqQP.Set("queryStartTime", *options.QueryStartTime) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByTenantIDHandleResponse handles the ListByTenantID response. +func (client *EventsClient) listByTenantIDHandleResponse(resp *http.Response) (EventsClientListByTenantIDResponse, error) { + result := EventsClientListByTenantIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Events); err != nil { + return EventsClientListByTenantIDResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod index 46c7a9f8484b..5900b76aa31e 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.mod @@ -1,21 +1,13 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth/v2 go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum index ed5b814680ee..3afb578030a5 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/go.sum @@ -1,33 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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/impactedresources_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/impactedresources_client.go new file mode 100644 index 000000000000..e5f65be10524 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/impactedresources_client.go @@ -0,0 +1,179 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armresourcehealth + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ImpactedResourcesClient contains the methods for the ImpactedResources group. +// Don't use this type directly, use NewImpactedResourcesClient() instead. +type ImpactedResourcesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewImpactedResourcesClient creates a new instance of ImpactedResourcesClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewImpactedResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ImpactedResourcesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ImpactedResourcesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Gets the specific impacted resource in the subscription by an event. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +// eventTrackingID - Event Id which uniquely identifies ServiceHealth event. +// impactedResourceName - Name of the Impacted Resource. +// options - ImpactedResourcesClientGetOptions contains the optional parameters for the ImpactedResourcesClient.Get method. +func (client *ImpactedResourcesClient) Get(ctx context.Context, eventTrackingID string, impactedResourceName string, options *ImpactedResourcesClientGetOptions) (ImpactedResourcesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, eventTrackingID, impactedResourceName, options) + if err != nil { + return ImpactedResourcesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImpactedResourcesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImpactedResourcesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ImpactedResourcesClient) getCreateRequest(ctx context.Context, eventTrackingID string, impactedResourceName string, options *ImpactedResourcesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources/{impactedResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if eventTrackingID == "" { + return nil, errors.New("parameter eventTrackingID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{eventTrackingId}", url.PathEscape(eventTrackingID)) + if impactedResourceName == "" { + return nil, errors.New("parameter impactedResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{impactedResourceName}", url.PathEscape(impactedResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ImpactedResourcesClient) getHandleResponse(resp *http.Response) (ImpactedResourcesClientGetResponse, error) { + result := ImpactedResourcesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EventImpactedResource); err != nil { + return ImpactedResourcesClientGetResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionIDAndEventIDPager - Lists impacted resources in the subscription by an event. +// Generated from API version 2022-05-01 +// eventTrackingID - Event Id which uniquely identifies ServiceHealth event. +// options - ImpactedResourcesClientListBySubscriptionIDAndEventIDOptions contains the optional parameters for the ImpactedResourcesClient.ListBySubscriptionIDAndEventID +// method. +func (client *ImpactedResourcesClient) NewListBySubscriptionIDAndEventIDPager(eventTrackingID string, options *ImpactedResourcesClientListBySubscriptionIDAndEventIDOptions) *runtime.Pager[ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse] { + return runtime.NewPager(runtime.PagingHandler[ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse]{ + More: func(page ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse) (ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionIDAndEventIDCreateRequest(ctx, eventTrackingID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionIDAndEventIDHandleResponse(resp) + }, + }) +} + +// listBySubscriptionIDAndEventIDCreateRequest creates the ListBySubscriptionIDAndEventID request. +func (client *ImpactedResourcesClient) listBySubscriptionIDAndEventIDCreateRequest(ctx context.Context, eventTrackingID string, options *ImpactedResourcesClientListBySubscriptionIDAndEventIDOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/events/{eventTrackingId}/impactedResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if eventTrackingID == "" { + return nil, errors.New("parameter eventTrackingID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{eventTrackingId}", url.PathEscape(eventTrackingID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionIDAndEventIDHandleResponse handles the ListBySubscriptionIDAndEventID response. +func (client *ImpactedResourcesClient) listBySubscriptionIDAndEventIDHandleResponse(resp *http.Response) (ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse, error) { + result := ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EventImpactedResourceListResult); err != nil { + return ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/models.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/models.go new file mode 100644 index 000000000000..cf979a8231d0 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/models.go @@ -0,0 +1,689 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armresourcehealth + +import "time" + +// 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"` +} + +// 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 + RecentlyResolved *AvailabilityStatusPropertiesRecentlyResolved `json:"recentlyResolved,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"` + + // Title description of the availability status. + Title *string `json:"title,omitempty"` +} + +// AvailabilityStatusPropertiesRecentlyResolved - An annotation describing a change in the availabilityState to Available +// from Unavailable with a reasonType of type Unplanned +type AvailabilityStatusPropertiesRecentlyResolved struct { + // Timestamp when the availabilityState changes to Available. + ResolvedTime *time.Time `json:"resolvedTime,omitempty"` + + // Timestamp for when the availabilityState changed to Unavailable + UnavailableOccuredTime *time.Time `json:"unavailableOccuredTime,omitempty"` + + // Brief description of cause of the resource becoming unavailable. + UnavailableSummary *string `json:"unavailableSummary,omitempty"` +} + +// AvailabilityStatusesClientGetByResourceOptions contains the optional parameters for the AvailabilityStatusesClient.GetByResource +// method. +type AvailabilityStatusesClientGetByResourceOptions 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 +} + +// AvailabilityStatusesClientListByResourceGroupOptions contains the optional parameters for the AvailabilityStatusesClient.ListByResourceGroup +// method. +type AvailabilityStatusesClientListByResourceGroupOptions 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 +} + +// AvailabilityStatusesClientListBySubscriptionIDOptions contains the optional parameters for the AvailabilityStatusesClient.ListBySubscriptionID +// method. +type AvailabilityStatusesClientListBySubscriptionIDOptions 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 +} + +// AvailabilityStatusesClientListOptions contains the optional parameters for the AvailabilityStatusesClient.List method. +type AvailabilityStatusesClientListOptions 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 +} + +// ErrorResponse - Error details. +type ErrorResponse struct { + // 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"` +} + +// Event - Service health event +type Event struct { + // Properties of event. + Properties *EventProperties `json:"properties,omitempty"` + + // 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,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"` +} + +// EventClientGetBySubscriptionIDAndTrackingIDOptions contains the optional parameters for the EventClient.GetBySubscriptionIDAndTrackingID +// method. +type EventClientGetBySubscriptionIDAndTrackingIDOptions struct { + // 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 + // Specifies from when to return events, based on the lastUpdateTime property. For example, queryStartTime = 7/24/2020 OR + // queryStartTime=7%2F24%2F2020 + QueryStartTime *string +} + +// EventClientGetByTenantIDAndTrackingIDOptions contains the optional parameters for the EventClient.GetByTenantIDAndTrackingID +// method. +type EventClientGetByTenantIDAndTrackingIDOptions struct { + // 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 + // Specifies from when to return events, based on the lastUpdateTime property. For example, queryStartTime = 7/24/2020 OR + // queryStartTime=7%2F24%2F2020 + QueryStartTime *string +} + +// EventImpactedResource - Impacted resource for an event. +type EventImpactedResource struct { + // Properties of impacted resource. + Properties *EventImpactedResourceProperties `json:"properties,omitempty"` + + // 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,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"` +} + +// EventImpactedResourceListResult - The List of eventImpactedResources operation response. +type EventImpactedResourceListResult struct { + // REQUIRED; The list of eventImpactedResources. + Value []*EventImpactedResource `json:"value,omitempty"` + + // The URI to fetch the next page of events. Call ListNext() with this URI to fetch the next page of impacted resource. + NextLink *string `json:"nextLink,omitempty"` +} + +// EventImpactedResourceProperties - Properties of impacted resource. +type EventImpactedResourceProperties struct { + // Additional information. + Info []*KeyValueItem `json:"info,omitempty"` + + // READ-ONLY; Impacted resource region name. + TargetRegion *string `json:"targetRegion,omitempty" azure:"ro"` + + // READ-ONLY; Identity for resource within Microsoft cloud. + TargetResourceID *string `json:"targetResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Resource type within Microsoft cloud. + TargetResourceType *string `json:"targetResourceType,omitempty" azure:"ro"` +} + +// EventProperties - Properties of event. +type EventProperties struct { + // Additional information + AdditionalInformation *EventPropertiesAdditionalInformation `json:"additionalInformation,omitempty"` + + // Article of event. + Article *EventPropertiesArticle `json:"article,omitempty"` + + // Contains the communication message for the event, that could include summary, root cause and other details. + Description *string `json:"description,omitempty"` + + // duration in seconds + Duration *int32 `json:"duration,omitempty"` + + // Tells if we want to enable or disable Microsoft Support for this event. + EnableChatWithUs *bool `json:"enableChatWithUs,omitempty"` + + // Tells if we want to enable or disable Microsoft Support for this event. + EnableMicrosoftSupport *bool `json:"enableMicrosoftSupport,omitempty"` + + // Level of event. + EventLevel *EventLevelValues `json:"eventLevel,omitempty"` + + // Source of event. + EventSource *EventSourceValues `json:"eventSource,omitempty"` + + // Type of event. + EventType *EventTypeValues `json:"eventType,omitempty"` + + // The id of the Incident + ExternalIncidentID *string `json:"externalIncidentId,omitempty"` + + // Frequently asked questions for the service health event. + Faqs []*Faq `json:"faqs,omitempty"` + + // Header text of event. + Header *string `json:"header,omitempty"` + + // Stage for HIR Document + HirStage *string `json:"hirStage,omitempty"` + + // List services impacted by the service health event. + Impact []*Impact `json:"impact,omitempty"` + + // It provides the Timestamp for when the health impacting event resolved. + ImpactMitigationTime *time.Time `json:"impactMitigationTime,omitempty"` + + // It provides the Timestamp for when the health impacting event started. + ImpactStartTime *time.Time `json:"impactStartTime,omitempty"` + + // The type of the impact + ImpactType *string `json:"impactType,omitempty"` + + // It provides information if the event is High incident rate event or not. + IsHIR *bool `json:"isHIR,omitempty"` + + // It provides the Timestamp for when the health impacting event was last updated. + LastUpdateTime *time.Time `json:"lastUpdateTime,omitempty"` + + // Level of insight. + Level *LevelValues `json:"level,omitempty"` + + // Useful links of event. + Links []*Link `json:"links,omitempty"` + + // Is true if the event is platform initiated. + PlatformInitiated *bool `json:"platformInitiated,omitempty"` + + // Priority level of the event. Has value from 0 to 23. 0 is the highest priority. Service issue events have higher priority + // followed by planned maintenance and health advisory. Critical events have + // higher priority followed by error, warning and informational. Furthermore, active events have higher priority than resolved. + Priority *int32 `json:"priority,omitempty"` + + // Recommended actions of event. + RecommendedActions *EventPropertiesRecommendedActions `json:"recommendedActions,omitempty"` + + // Current status of event. + Status *EventStatusValues `json:"status,omitempty"` + + // Summary text of event. + Summary *string `json:"summary,omitempty"` + + // Title text of event. + Title *string `json:"title,omitempty"` +} + +// EventPropertiesAdditionalInformation - Additional information +type EventPropertiesAdditionalInformation struct { + // Additional information Message + Message *string `json:"message,omitempty"` +} + +// EventPropertiesArticle - Article of event. +type EventPropertiesArticle struct { + // Article content of event. + ArticleContent *string `json:"articleContent,omitempty"` +} + +// EventPropertiesRecommendedActions - Recommended actions of event. +type EventPropertiesRecommendedActions struct { + // Recommended actions for the service health event. + Actions []*EventPropertiesRecommendedActionsItem `json:"actions,omitempty"` + + // Recommended action locale for the service health event. + LocaleCode *string `json:"localeCode,omitempty"` + + // Recommended action title for the service health event. + Message *string `json:"message,omitempty"` +} + +// EventPropertiesRecommendedActionsItem - Recommended action for the service health event. +type EventPropertiesRecommendedActionsItem struct { + // Recommended action text + ActionText *string `json:"actionText,omitempty"` + + // Recommended action group Id for the service health event. + GroupID *int32 `json:"groupId,omitempty"` +} + +// Events - The List events operation response. +type Events struct { + // REQUIRED; The list of event. + Value []*Event `json:"value,omitempty"` + + // The URI to fetch the next page of events. Call ListNext() with this URI to fetch the next page of events. + NextLink *string `json:"nextLink,omitempty"` +} + +// EventsClientListBySingleResourceOptions contains the optional parameters for the EventsClient.ListBySingleResource method. +type EventsClientListBySingleResourceOptions struct { + // 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 +} + +// EventsClientListBySubscriptionIDOptions contains the optional parameters for the EventsClient.ListBySubscriptionID method. +type EventsClientListBySubscriptionIDOptions struct { + // 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 + // Specifies from when to return events, based on the lastUpdateTime property. For example, queryStartTime = 7/24/2020 OR + // queryStartTime=7%2F24%2F2020 + QueryStartTime *string +} + +// EventsClientListByTenantIDOptions contains the optional parameters for the EventsClient.ListByTenantID method. +type EventsClientListByTenantIDOptions struct { + // 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 + // Specifies from when to return events, based on the lastUpdateTime property. For example, queryStartTime = 7/24/2020 OR + // queryStartTime=7%2F24%2F2020 + QueryStartTime *string +} + +// Faq - Frequently asked question for the service health event +type Faq struct { + // FAQ answer for the service health event. + Answer *string `json:"answer,omitempty"` + + // FAQ locale for the service health event. + LocaleCode *string `json:"localeCode,omitempty"` + + // FAQ question for the service health event. + Question *string `json:"question,omitempty"` +} + +// Impact - Azure service impacted by the service health event. +type Impact struct { + // List regions impacted by the service health event. + ImpactedRegions []*ImpactedServiceRegion `json:"impactedRegions,omitempty"` + + // Impacted service name. + ImpactedService *string `json:"impactedService,omitempty"` +} + +// 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"` +} + +// ImpactedResourceStatus - impactedResource with health status +type ImpactedResourceStatus struct { + // Properties of impacted resource status. + Properties *ImpactedResourceStatusProperties `json:"properties,omitempty"` + + // 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,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"` +} + +// ImpactedResourceStatusProperties - Properties of impacted resource status. +type ImpactedResourceStatusProperties struct { + // Impacted resource status of the resource. + AvailabilityState *AvailabilityStateValues `json:"availabilityState,omitempty"` + + // Timestamp for when last change in health status occurred. + OccurredTime *time.Time `json:"occurredTime,omitempty"` + + // When the resource's availabilityState is Unavailable, it describes where the health impacting event was originated. + ReasonType *ReasonTypeValues `json:"reasonType,omitempty"` + + // Summary description of the impacted resource status. + Summary *string `json:"summary,omitempty"` + + // Title description of the impacted resource status. + Title *string `json:"title,omitempty"` +} + +// ImpactedResourcesClientGetOptions contains the optional parameters for the ImpactedResourcesClient.Get method. +type ImpactedResourcesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ImpactedResourcesClientListBySubscriptionIDAndEventIDOptions contains the optional parameters for the ImpactedResourcesClient.ListBySubscriptionIDAndEventID +// method. +type ImpactedResourcesClientListBySubscriptionIDAndEventIDOptions struct { + // 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 +} + +// ImpactedServiceRegion - Azure region impacted by the service health event. +type ImpactedServiceRegion struct { + // Impacted region name. + ImpactedRegion *string `json:"impactedRegion,omitempty"` + + // List subscription impacted by the service health event. + ImpactedSubscriptions []*string `json:"impactedSubscriptions,omitempty"` + + // List tenant impacted by the service health event. + ImpactedTenants []*string `json:"impactedTenants,omitempty"` + + // It provides the Timestamp for when the last update for the service health event. + LastUpdateTime *time.Time `json:"lastUpdateTime,omitempty"` + + // Current status of event in the region. + Status *EventStatusValues `json:"status,omitempty"` + + // List of updates for given service health event. + Updates []*Update `json:"updates,omitempty"` +} + +// KeyValueItem - Key value tuple. +type KeyValueItem struct { + // READ-ONLY; Key of tuple. + Key *string `json:"key,omitempty" azure:"ro"` + + // READ-ONLY; Value of tuple. + Value *string `json:"value,omitempty" azure:"ro"` +} + +// Link - Useful links for service health event. +type Link struct { + // It provides the name of portal extension blade to produce link for given service health event. + BladeName *string `json:"bladeName,omitempty"` + + // Display text of link. + DisplayText *LinkDisplayText `json:"displayText,omitempty"` + + // It provides the name of portal extension to produce link for given service health event. + ExtensionName *string `json:"extensionName,omitempty"` + + // It provides a map of parameter name and value for portal extension blade to produce lik for given service health event. + Parameters interface{} `json:"parameters,omitempty"` + + // Type of link. + Type *LinkTypeValues `json:"type,omitempty"` +} + +// LinkDisplayText - Display text of link. +type LinkDisplayText struct { + // Localized display text of link. + LocalizedValue *string `json:"localizedValue,omitempty"` + + // Display text of link. + Value *string `json:"value,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"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,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"` +} + +// 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,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"` +} + +// 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"` +} + +// 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"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// Update for service health event. +type Update struct { + // Summary text for the given update for the service health event. + Summary *string `json:"summary,omitempty"` + + // It provides the Timestamp for the given update for the service health event. + UpdateDateTime *time.Time `json:"updateDateTime,omitempty"` +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/models_serde.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/models_serde.go new file mode 100644 index 000000000000..fbee153f17e8 --- /dev/null +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/models_serde.go @@ -0,0 +1,1481 @@ +//go:build go1.18 +// +build go1.18 + +// 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. +// DO NOT EDIT. + +package armresourcehealth + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AvailabilityStatus. +func (a AvailabilityStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityStatus. +func (a *AvailabilityStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// 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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityStatusListResult. +func (a *AvailabilityStatusListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// 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) + populateTimeRFC3339(objectMap, "occuredTime", a.OccuredTime) + populate(objectMap, "reasonChronicity", a.ReasonChronicity) + populate(objectMap, "reasonType", a.ReasonType) + populate(objectMap, "recentlyResolved", a.RecentlyResolved) + populate(objectMap, "recommendedActions", a.RecommendedActions) + populateTimeRFC3339(objectMap, "reportedTime", a.ReportedTime) + populateTimeRFC3339(objectMap, "resolutionETA", a.ResolutionETA) + populateTimeRFC3339(objectMap, "rootCauseAttributionTime", a.RootCauseAttributionTime) + populate(objectMap, "serviceImpactingEvents", a.ServiceImpactingEvents) + populate(objectMap, "summary", a.Summary) + populate(objectMap, "title", a.Title) + 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 fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availabilityState": + err = unpopulate(val, "AvailabilityState", &a.AvailabilityState) + delete(rawMsg, key) + case "detailedStatus": + err = unpopulate(val, "DetailedStatus", &a.DetailedStatus) + delete(rawMsg, key) + case "healthEventCategory": + err = unpopulate(val, "HealthEventCategory", &a.HealthEventCategory) + delete(rawMsg, key) + case "healthEventCause": + err = unpopulate(val, "HealthEventCause", &a.HealthEventCause) + delete(rawMsg, key) + case "healthEventId": + err = unpopulate(val, "HealthEventID", &a.HealthEventID) + delete(rawMsg, key) + case "healthEventType": + err = unpopulate(val, "HealthEventType", &a.HealthEventType) + delete(rawMsg, key) + case "occuredTime": + err = unpopulateTimeRFC3339(val, "OccuredTime", &a.OccuredTime) + delete(rawMsg, key) + case "reasonChronicity": + err = unpopulate(val, "ReasonChronicity", &a.ReasonChronicity) + delete(rawMsg, key) + case "reasonType": + err = unpopulate(val, "ReasonType", &a.ReasonType) + delete(rawMsg, key) + case "recentlyResolved": + err = unpopulate(val, "RecentlyResolved", &a.RecentlyResolved) + delete(rawMsg, key) + case "recommendedActions": + err = unpopulate(val, "RecommendedActions", &a.RecommendedActions) + delete(rawMsg, key) + case "reportedTime": + err = unpopulateTimeRFC3339(val, "ReportedTime", &a.ReportedTime) + delete(rawMsg, key) + case "resolutionETA": + err = unpopulateTimeRFC3339(val, "ResolutionETA", &a.ResolutionETA) + delete(rawMsg, key) + case "rootCauseAttributionTime": + err = unpopulateTimeRFC3339(val, "RootCauseAttributionTime", &a.RootCauseAttributionTime) + delete(rawMsg, key) + case "serviceImpactingEvents": + err = unpopulate(val, "ServiceImpactingEvents", &a.ServiceImpactingEvents) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &a.Summary) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &a.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvailabilityStatusPropertiesRecentlyResolved. +func (a AvailabilityStatusPropertiesRecentlyResolved) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "resolvedTime", a.ResolvedTime) + populateTimeRFC3339(objectMap, "unavailableOccuredTime", a.UnavailableOccuredTime) + populate(objectMap, "unavailableSummary", a.UnavailableSummary) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityStatusPropertiesRecentlyResolved. +func (a *AvailabilityStatusPropertiesRecentlyResolved) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resolvedTime": + err = unpopulateTimeRFC3339(val, "ResolvedTime", &a.ResolvedTime) + delete(rawMsg, key) + case "unavailableOccuredTime": + err = unpopulateTimeRFC3339(val, "UnavailableOccuredTime", &a.UnavailableOccuredTime) + delete(rawMsg, key) + case "unavailableSummary": + err = unpopulate(val, "UnavailableSummary", &a.UnavailableSummary) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Event. +func (e Event) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Event. +func (e *Event) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventImpactedResource. +func (e EventImpactedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventImpactedResource. +func (e *EventImpactedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventImpactedResourceListResult. +func (e EventImpactedResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventImpactedResourceListResult. +func (e *EventImpactedResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventImpactedResourceProperties. +func (e EventImpactedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "info", e.Info) + populate(objectMap, "targetRegion", e.TargetRegion) + populate(objectMap, "targetResourceId", e.TargetResourceID) + populate(objectMap, "targetResourceType", e.TargetResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventImpactedResourceProperties. +func (e *EventImpactedResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "targetRegion": + err = unpopulate(val, "TargetRegion", &e.TargetRegion) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &e.TargetResourceID) + delete(rawMsg, key) + case "targetResourceType": + err = unpopulate(val, "TargetResourceType", &e.TargetResourceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventProperties. +func (e EventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInformation", e.AdditionalInformation) + populate(objectMap, "article", e.Article) + populate(objectMap, "description", e.Description) + populate(objectMap, "duration", e.Duration) + populate(objectMap, "enableChatWithUs", e.EnableChatWithUs) + populate(objectMap, "enableMicrosoftSupport", e.EnableMicrosoftSupport) + populate(objectMap, "eventLevel", e.EventLevel) + populate(objectMap, "eventSource", e.EventSource) + populate(objectMap, "eventType", e.EventType) + populate(objectMap, "externalIncidentId", e.ExternalIncidentID) + populate(objectMap, "faqs", e.Faqs) + populate(objectMap, "header", e.Header) + populate(objectMap, "hirStage", e.HirStage) + populate(objectMap, "impact", e.Impact) + populateTimeRFC3339(objectMap, "impactMitigationTime", e.ImpactMitigationTime) + populateTimeRFC3339(objectMap, "impactStartTime", e.ImpactStartTime) + populate(objectMap, "impactType", e.ImpactType) + populate(objectMap, "isHIR", e.IsHIR) + populateTimeRFC3339(objectMap, "lastUpdateTime", e.LastUpdateTime) + populate(objectMap, "level", e.Level) + populate(objectMap, "links", e.Links) + populate(objectMap, "platformInitiated", e.PlatformInitiated) + populate(objectMap, "priority", e.Priority) + populate(objectMap, "recommendedActions", e.RecommendedActions) + populate(objectMap, "status", e.Status) + populate(objectMap, "summary", e.Summary) + populate(objectMap, "title", e.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventProperties. +func (e *EventProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInformation": + err = unpopulate(val, "AdditionalInformation", &e.AdditionalInformation) + delete(rawMsg, key) + case "article": + err = unpopulate(val, "Article", &e.Article) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "duration": + err = unpopulate(val, "Duration", &e.Duration) + delete(rawMsg, key) + case "enableChatWithUs": + err = unpopulate(val, "EnableChatWithUs", &e.EnableChatWithUs) + delete(rawMsg, key) + case "enableMicrosoftSupport": + err = unpopulate(val, "EnableMicrosoftSupport", &e.EnableMicrosoftSupport) + delete(rawMsg, key) + case "eventLevel": + err = unpopulate(val, "EventLevel", &e.EventLevel) + delete(rawMsg, key) + case "eventSource": + err = unpopulate(val, "EventSource", &e.EventSource) + delete(rawMsg, key) + case "eventType": + err = unpopulate(val, "EventType", &e.EventType) + delete(rawMsg, key) + case "externalIncidentId": + err = unpopulate(val, "ExternalIncidentID", &e.ExternalIncidentID) + delete(rawMsg, key) + case "faqs": + err = unpopulate(val, "Faqs", &e.Faqs) + delete(rawMsg, key) + case "header": + err = unpopulate(val, "Header", &e.Header) + delete(rawMsg, key) + case "hirStage": + err = unpopulate(val, "HirStage", &e.HirStage) + delete(rawMsg, key) + case "impact": + err = unpopulate(val, "Impact", &e.Impact) + delete(rawMsg, key) + case "impactMitigationTime": + err = unpopulateTimeRFC3339(val, "ImpactMitigationTime", &e.ImpactMitigationTime) + delete(rawMsg, key) + case "impactStartTime": + err = unpopulateTimeRFC3339(val, "ImpactStartTime", &e.ImpactStartTime) + delete(rawMsg, key) + case "impactType": + err = unpopulate(val, "ImpactType", &e.ImpactType) + delete(rawMsg, key) + case "isHIR": + err = unpopulate(val, "IsHIR", &e.IsHIR) + delete(rawMsg, key) + case "lastUpdateTime": + err = unpopulateTimeRFC3339(val, "LastUpdateTime", &e.LastUpdateTime) + delete(rawMsg, key) + case "level": + err = unpopulate(val, "Level", &e.Level) + delete(rawMsg, key) + case "links": + err = unpopulate(val, "Links", &e.Links) + delete(rawMsg, key) + case "platformInitiated": + err = unpopulate(val, "PlatformInitiated", &e.PlatformInitiated) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &e.Priority) + delete(rawMsg, key) + case "recommendedActions": + err = unpopulate(val, "RecommendedActions", &e.RecommendedActions) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &e.Summary) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &e.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventPropertiesAdditionalInformation. +func (e EventPropertiesAdditionalInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventPropertiesAdditionalInformation. +func (e *EventPropertiesAdditionalInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventPropertiesArticle. +func (e EventPropertiesArticle) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "articleContent", e.ArticleContent) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventPropertiesArticle. +func (e *EventPropertiesArticle) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "articleContent": + err = unpopulate(val, "ArticleContent", &e.ArticleContent) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventPropertiesRecommendedActions. +func (e EventPropertiesRecommendedActions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", e.Actions) + populate(objectMap, "localeCode", e.LocaleCode) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventPropertiesRecommendedActions. +func (e *EventPropertiesRecommendedActions) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, "Actions", &e.Actions) + delete(rawMsg, key) + case "localeCode": + err = unpopulate(val, "LocaleCode", &e.LocaleCode) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EventPropertiesRecommendedActionsItem. +func (e EventPropertiesRecommendedActionsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionText", e.ActionText) + populate(objectMap, "groupId", e.GroupID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventPropertiesRecommendedActionsItem. +func (e *EventPropertiesRecommendedActionsItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionText": + err = unpopulate(val, "ActionText", &e.ActionText) + delete(rawMsg, key) + case "groupId": + err = unpopulate(val, "GroupID", &e.GroupID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Events. +func (e Events) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Events. +func (e *Events) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Faq. +func (f Faq) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "answer", f.Answer) + populate(objectMap, "localeCode", f.LocaleCode) + populate(objectMap, "question", f.Question) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Faq. +func (f *Faq) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "answer": + err = unpopulate(val, "Answer", &f.Answer) + delete(rawMsg, key) + case "localeCode": + err = unpopulate(val, "LocaleCode", &f.LocaleCode) + delete(rawMsg, key) + case "question": + err = unpopulate(val, "Question", &f.Question) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Impact. +func (i Impact) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "impactedRegions", i.ImpactedRegions) + populate(objectMap, "impactedService", i.ImpactedService) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Impact. +func (i *Impact) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "impactedRegions": + err = unpopulate(val, "ImpactedRegions", &i.ImpactedRegions) + delete(rawMsg, key) + case "impactedService": + err = unpopulate(val, "ImpactedService", &i.ImpactedService) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImpactedRegion. +func (i ImpactedRegion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImpactedRegion. +func (i *ImpactedRegion) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImpactedResourceStatus. +func (i ImpactedResourceStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImpactedResourceStatus. +func (i *ImpactedResourceStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImpactedResourceStatusProperties. +func (i ImpactedResourceStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityState", i.AvailabilityState) + populateTimeRFC3339(objectMap, "occurredTime", i.OccurredTime) + populate(objectMap, "reasonType", i.ReasonType) + populate(objectMap, "summary", i.Summary) + populate(objectMap, "title", i.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImpactedResourceStatusProperties. +func (i *ImpactedResourceStatusProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availabilityState": + err = unpopulate(val, "AvailabilityState", &i.AvailabilityState) + delete(rawMsg, key) + case "occurredTime": + err = unpopulateTimeRFC3339(val, "OccurredTime", &i.OccurredTime) + delete(rawMsg, key) + case "reasonType": + err = unpopulate(val, "ReasonType", &i.ReasonType) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &i.Summary) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &i.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImpactedServiceRegion. +func (i ImpactedServiceRegion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "impactedRegion", i.ImpactedRegion) + populate(objectMap, "impactedSubscriptions", i.ImpactedSubscriptions) + populate(objectMap, "impactedTenants", i.ImpactedTenants) + populateTimeRFC3339(objectMap, "lastUpdateTime", i.LastUpdateTime) + populate(objectMap, "status", i.Status) + populate(objectMap, "updates", i.Updates) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImpactedServiceRegion. +func (i *ImpactedServiceRegion) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "impactedRegion": + err = unpopulate(val, "ImpactedRegion", &i.ImpactedRegion) + delete(rawMsg, key) + case "impactedSubscriptions": + err = unpopulate(val, "ImpactedSubscriptions", &i.ImpactedSubscriptions) + delete(rawMsg, key) + case "impactedTenants": + err = unpopulate(val, "ImpactedTenants", &i.ImpactedTenants) + delete(rawMsg, key) + case "lastUpdateTime": + err = unpopulateTimeRFC3339(val, "LastUpdateTime", &i.LastUpdateTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &i.Status) + delete(rawMsg, key) + case "updates": + err = unpopulate(val, "Updates", &i.Updates) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyValueItem. +func (k KeyValueItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "key", k.Key) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyValueItem. +func (k *KeyValueItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "key": + err = unpopulate(val, "Key", &k.Key) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Link. +func (l Link) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "bladeName", l.BladeName) + populate(objectMap, "displayText", l.DisplayText) + populate(objectMap, "extensionName", l.ExtensionName) + populate(objectMap, "parameters", &l.Parameters) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Link. +func (l *Link) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "bladeName": + err = unpopulate(val, "BladeName", &l.BladeName) + delete(rawMsg, key) + case "displayText": + err = unpopulate(val, "DisplayText", &l.DisplayText) + delete(rawMsg, key) + case "extensionName": + err = unpopulate(val, "ExtensionName", &l.ExtensionName) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &l.Parameters) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinkDisplayText. +func (l LinkDisplayText) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "localizedValue", l.LocalizedValue) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinkDisplayText. +func (l *LinkDisplayText) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "localizedValue": + err = unpopulate(val, "LocalizedValue", &l.LocalizedValue) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// 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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecommendedAction. +func (r RecommendedAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "action", r.Action) + populate(objectMap, "actionUrl", r.ActionURL) + populate(objectMap, "actionUrlText", r.ActionURLText) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendedAction. +func (r *RecommendedAction) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &r.Action) + delete(rawMsg, key) + case "actionUrl": + err = unpopulate(val, "ActionURL", &r.ActionURL) + delete(rawMsg, key) + case "actionUrlText": + err = unpopulate(val, "ActionURLText", &r.ActionURLText) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// 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) + populateTimeRFC3339(objectMap, "eventStartTime", s.EventStartTime) + populateTimeRFC3339(objectMap, "eventStatusLastModifiedTime", 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 fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "correlationId": + err = unpopulate(val, "CorrelationID", &s.CorrelationID) + delete(rawMsg, key) + case "eventStartTime": + err = unpopulateTimeRFC3339(val, "EventStartTime", &s.EventStartTime) + delete(rawMsg, key) + case "eventStatusLastModifiedTime": + err = unpopulateTimeRFC3339(val, "EventStatusLastModifiedTime", &s.EventStatusLastModifiedTime) + delete(rawMsg, key) + case "incidentProperties": + err = unpopulate(val, "IncidentProperties", &s.IncidentProperties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceImpactingEventIncidentProperties. +func (s ServiceImpactingEventIncidentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "incidentType", s.IncidentType) + populate(objectMap, "region", s.Region) + populate(objectMap, "service", s.Service) + populate(objectMap, "title", s.Title) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceImpactingEventIncidentProperties. +func (s *ServiceImpactingEventIncidentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "incidentType": + err = unpopulate(val, "IncidentType", &s.IncidentType) + delete(rawMsg, key) + case "region": + err = unpopulate(val, "Region", &s.Region) + delete(rawMsg, key) + case "service": + err = unpopulate(val, "Service", &s.Service) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &s.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceImpactingEventStatus. +func (s ServiceImpactingEventStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceImpactingEventStatus. +func (s *ServiceImpactingEventStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// 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) + populateTimeRFC3339(objectMap, "lastModifiedTime", 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 fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cloud": + err = unpopulate(val, "Cloud", &s.Cloud) + delete(rawMsg, key) + case "lastModifiedTime": + err = unpopulateTimeRFC3339(val, "LastModifiedTime", &s.LastModifiedTime) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &s.Message) + delete(rawMsg, key) + case "title": + err = unpopulate(val, "Title", &s.Title) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Update. +func (u Update) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "summary", u.Summary) + populateTimeRFC3339(objectMap, "updateDateTime", u.UpdateDateTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Update. +func (u *Update) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "summary": + err = unpopulate(val, "Summary", &u.Summary) + delete(rawMsg, key) + case "updateDateTime": + err = unpopulateTimeRFC3339(val, "UpdateDateTime", &u.UpdateDateTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, 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, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_operations_client.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/operations_client.go similarity index 97% rename from sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_operations_client.go rename to sdk/resourcemanager/resourcehealth/armresourcehealth/operations_client.go index 0510bd4c2660..de082d6ede8c 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_operations_client.go +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/operations_client.go @@ -5,6 +5,7 @@ // 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. +// DO NOT EDIT. package armresourcehealth @@ -50,7 +51,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // List - Lists available operations for the resourcehealth resource provider // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2020-05-01 +// Generated from API version 2022-05-01 // options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) @@ -75,7 +76,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-05-01") + reqQP.Set("api-version", "2022-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_response_types.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/response_types.go similarity index 50% rename from sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_response_types.go rename to sdk/resourcemanager/resourcehealth/armresourcehealth/response_types.go index cb0914110abb..aec637c8a464 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_response_types.go +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/response_types.go @@ -5,6 +5,7 @@ // 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. +// DO NOT EDIT. package armresourcehealth @@ -28,6 +29,41 @@ type AvailabilityStatusesClientListResponse struct { AvailabilityStatusListResult } +// EventClientGetBySubscriptionIDAndTrackingIDResponse contains the response from method EventClient.GetBySubscriptionIDAndTrackingID. +type EventClientGetBySubscriptionIDAndTrackingIDResponse struct { + Event +} + +// EventClientGetByTenantIDAndTrackingIDResponse contains the response from method EventClient.GetByTenantIDAndTrackingID. +type EventClientGetByTenantIDAndTrackingIDResponse struct { + Event +} + +// EventsClientListBySingleResourceResponse contains the response from method EventsClient.ListBySingleResource. +type EventsClientListBySingleResourceResponse struct { + Events +} + +// EventsClientListBySubscriptionIDResponse contains the response from method EventsClient.ListBySubscriptionID. +type EventsClientListBySubscriptionIDResponse struct { + Events +} + +// EventsClientListByTenantIDResponse contains the response from method EventsClient.ListByTenantID. +type EventsClientListByTenantIDResponse struct { + Events +} + +// ImpactedResourcesClientGetResponse contains the response from method ImpactedResourcesClient.Get. +type ImpactedResourcesClientGetResponse struct { + EventImpactedResource +} + +// ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse contains the response from method ImpactedResourcesClient.ListBySubscriptionIDAndEventID. +type ImpactedResourcesClientListBySubscriptionIDAndEventIDResponse struct { + EventImpactedResourceListResult +} + // OperationsClientListResponse contains the response from method OperationsClient.List. type OperationsClientListResponse struct { OperationListResult diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_time_rfc3339.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/resourcehealth/armresourcehealth/time_rfc3339.go index f91b092d0d2d..b6cacc35aee6 100644 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/resourcehealth/armresourcehealth/time_rfc3339.go @@ -5,6 +5,7 @@ // 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. +// DO NOT EDIT. package armresourcehealth diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_availabilitystatuses_client_test.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_availabilitystatuses_client_test.go deleted file mode 100644 index a64a4fece520..000000000000 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_availabilitystatuses_client_test.go +++ /dev/null @@ -1,95 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2020-05-01/examples/AvailabilityStatuses_ListByResourceGroup.json -func ExampleAvailabilityStatusesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armresourcehealth.NewAvailabilityStatusesClient("subscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("resourceGroupName", - &armresourcehealth.AvailabilityStatusesClientListByResourceGroupOptions{Filter: nil, - Expand: to.Ptr("recommendedactions"), - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2020-05-01/examples/AvailabilityStatus_GetByResource.json -func ExampleAvailabilityStatusesClient_GetByResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armresourcehealth.NewAvailabilityStatusesClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByResource(ctx, - "resourceUri", - &armresourcehealth.AvailabilityStatusesClientGetByResourceOptions{Filter: nil, - Expand: to.Ptr("recommendedactions"), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2020-05-01/examples/AvailabilityStatuses_List.json -func ExampleAvailabilityStatusesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armresourcehealth.NewAvailabilityStatusesClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("resourceUri", - &armresourcehealth.AvailabilityStatusesClientListOptions{Filter: nil, - Expand: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_operations_client_test.go deleted file mode 100644 index a61191d017b8..000000000000 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/stable/2020-05-01/examples/Operations_List.json -func ExampleOperationsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armresourcehealth.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_constants.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_constants.go deleted file mode 100644 index 840fb1a1656c..000000000000 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_constants.go +++ /dev/null @@ -1,69 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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 ( - moduleName = "armresourcehealth" - moduleVersion = "v1.0.0" -) - -// AvailabilityStateValues - Impacted resource status of the resource. -type AvailabilityStateValues string - -const ( - AvailabilityStateValuesAvailable AvailabilityStateValues = "Available" - AvailabilityStateValuesDegraded AvailabilityStateValues = "Degraded" - AvailabilityStateValuesUnavailable AvailabilityStateValues = "Unavailable" - AvailabilityStateValuesUnknown AvailabilityStateValues = "Unknown" -) - -// PossibleAvailabilityStateValuesValues returns the possible values for the AvailabilityStateValues const type. -func PossibleAvailabilityStateValuesValues() []AvailabilityStateValues { - return []AvailabilityStateValues{ - AvailabilityStateValuesAvailable, - AvailabilityStateValuesDegraded, - AvailabilityStateValuesUnavailable, - AvailabilityStateValuesUnknown, - } -} - -// ReasonChronicityTypes - Chronicity of the availability transition. -type ReasonChronicityTypes string - -const ( - ReasonChronicityTypesPersistent ReasonChronicityTypes = "Persistent" - ReasonChronicityTypesTransient ReasonChronicityTypes = "Transient" -) - -// PossibleReasonChronicityTypesValues returns the possible values for the ReasonChronicityTypes const type. -func PossibleReasonChronicityTypesValues() []ReasonChronicityTypes { - return []ReasonChronicityTypes{ - ReasonChronicityTypesPersistent, - ReasonChronicityTypesTransient, - } -} - -// ReasonTypeValues - When the resource's availabilityState is Unavailable, it describes where the health impacting event -// was originated. -type ReasonTypeValues string - -const ( - ReasonTypeValuesPlanned ReasonTypeValues = "Planned" - ReasonTypeValuesUnplanned ReasonTypeValues = "Unplanned" - ReasonTypeValuesUserInitiated ReasonTypeValues = "UserInitiated" -) - -// PossibleReasonTypeValuesValues returns the possible values for the ReasonTypeValues const type. -func PossibleReasonTypeValuesValues() []ReasonTypeValues { - return []ReasonTypeValues{ - ReasonTypeValuesPlanned, - ReasonTypeValuesUnplanned, - ReasonTypeValuesUserInitiated, - } -} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models.go deleted file mode 100644 index fb6d2706168c..000000000000 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models.go +++ /dev/null @@ -1,320 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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 "time" - -// 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"` -} - -// 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. - OccurredTime *time.Time `json:"occurredTime,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 - RecentlyResolved *AvailabilityStatusPropertiesRecentlyResolved `json:"recentlyResolved,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"` - - // Title description of the availability status. - Title *string `json:"title,omitempty"` -} - -// AvailabilityStatusPropertiesRecentlyResolved - An annotation describing a change in the availabilityState to Available -// from Unavailable with a reasonType of type Unplanned -type AvailabilityStatusPropertiesRecentlyResolved 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"` -} - -// AvailabilityStatusesClientGetByResourceOptions contains the optional parameters for the AvailabilityStatusesClient.GetByResource -// method. -type AvailabilityStatusesClientGetByResourceOptions 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 -} - -// AvailabilityStatusesClientListByResourceGroupOptions contains the optional parameters for the AvailabilityStatusesClient.ListByResourceGroup -// method. -type AvailabilityStatusesClientListByResourceGroupOptions 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 -} - -// AvailabilityStatusesClientListBySubscriptionIDOptions contains the optional parameters for the AvailabilityStatusesClient.ListBySubscriptionID -// method. -type AvailabilityStatusesClientListBySubscriptionIDOptions 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 -} - -// AvailabilityStatusesClientListOptions contains the optional parameters for the AvailabilityStatusesClient.List method. -type AvailabilityStatusesClientListOptions 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 -} - -// ErrorResponse - Error details. -type ErrorResponse struct { - // The error object. - Error *ErrorResponseError `json:"error,omitempty"` -} - -// ErrorResponseError - The error object. -type ErrorResponseError struct { - // 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"` -} - -// 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"` -} - -// ImpactedResourceStatus - impactedResource with health status -type ImpactedResourceStatus struct { - // Properties of impacted resource status. - Properties *ImpactedResourceStatusProperties `json:"properties,omitempty"` - - // 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"` -} - -// ImpactedResourceStatusProperties - Properties of impacted resource status. -type ImpactedResourceStatusProperties struct { - // Impacted resource status of the resource. - AvailabilityState *AvailabilityStateValues `json:"availabilityState,omitempty"` - - // Timestamp for when last change in health status occurred. - OccurredTime *time.Time `json:"occurredTime,omitempty"` - - // When the resource's availabilityState is Unavailable, it describes where the health impacting event was originated. - ReasonType *ReasonTypeValues `json:"reasonType,omitempty"` - - // Summary description of the impacted resource status. - Summary *string `json:"summary,omitempty"` - - // Title description of the impacted resource status. - Title *string `json:"title,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"` -} - -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -type OperationsClientListOptions 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"` -} - -// 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"` -} - -// 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"` -} diff --git a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models_serde.go b/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models_serde.go deleted file mode 100644 index 5eabfd5e0aa4..000000000000 --- a/sdk/resourcemanager/resourcehealth/armresourcehealth/zz_generated_models_serde.go +++ /dev/null @@ -1,211 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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" - "fmt" -) - -// 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 fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "availabilityState": - err = unpopulate(val, "AvailabilityState", &a.AvailabilityState) - delete(rawMsg, key) - case "detailedStatus": - err = unpopulate(val, "DetailedStatus", &a.DetailedStatus) - delete(rawMsg, key) - case "healthEventCategory": - err = unpopulate(val, "HealthEventCategory", &a.HealthEventCategory) - delete(rawMsg, key) - case "healthEventCause": - err = unpopulate(val, "HealthEventCause", &a.HealthEventCause) - delete(rawMsg, key) - case "healthEventId": - err = unpopulate(val, "HealthEventID", &a.HealthEventID) - delete(rawMsg, key) - case "healthEventType": - err = unpopulate(val, "HealthEventType", &a.HealthEventType) - delete(rawMsg, key) - case "occurredTime": - err = unpopulateTimeRFC3339(val, "OccurredTime", &a.OccurredTime) - delete(rawMsg, key) - case "reasonChronicity": - err = unpopulate(val, "ReasonChronicity", &a.ReasonChronicity) - delete(rawMsg, key) - case "reasonType": - err = unpopulate(val, "ReasonType", &a.ReasonType) - delete(rawMsg, key) - case "recentlyResolved": - err = unpopulate(val, "RecentlyResolved", &a.RecentlyResolved) - delete(rawMsg, key) - case "recommendedActions": - err = unpopulate(val, "RecommendedActions", &a.RecommendedActions) - delete(rawMsg, key) - case "reportedTime": - err = unpopulateTimeRFC3339(val, "ReportedTime", &a.ReportedTime) - delete(rawMsg, key) - case "resolutionETA": - err = unpopulateTimeRFC3339(val, "ResolutionETA", &a.ResolutionETA) - delete(rawMsg, key) - case "rootCauseAttributionTime": - err = unpopulateTimeRFC3339(val, "RootCauseAttributionTime", &a.RootCauseAttributionTime) - delete(rawMsg, key) - case "serviceImpactingEvents": - err = unpopulate(val, "ServiceImpactingEvents", &a.ServiceImpactingEvents) - delete(rawMsg, key) - case "summary": - err = unpopulate(val, "Summary", &a.Summary) - delete(rawMsg, key) - case "title": - err = unpopulate(val, "Title", &a.Title) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityStatusPropertiesRecentlyResolved. -func (a *AvailabilityStatusPropertiesRecentlyResolved) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "resolvedTime": - err = unpopulateTimeRFC3339(val, "ResolvedTime", &a.ResolvedTime) - delete(rawMsg, key) - case "unavailabilitySummary": - err = unpopulate(val, "UnavailabilitySummary", &a.UnavailabilitySummary) - delete(rawMsg, key) - case "unavailableOccurredTime": - err = unpopulateTimeRFC3339(val, "UnavailableOccurredTime", &a.UnavailableOccurredTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ImpactedResourceStatusProperties. -func (i *ImpactedResourceStatusProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "availabilityState": - err = unpopulate(val, "AvailabilityState", &i.AvailabilityState) - delete(rawMsg, key) - case "occurredTime": - err = unpopulateTimeRFC3339(val, "OccurredTime", &i.OccurredTime) - delete(rawMsg, key) - case "reasonType": - err = unpopulate(val, "ReasonType", &i.ReasonType) - delete(rawMsg, key) - case "summary": - err = unpopulate(val, "Summary", &i.Summary) - delete(rawMsg, key) - case "title": - err = unpopulate(val, "Title", &i.Title) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) - } - } - return nil -} - -// 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 fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "correlationId": - err = unpopulate(val, "CorrelationID", &s.CorrelationID) - delete(rawMsg, key) - case "eventStartTime": - err = unpopulateTimeRFC3339(val, "EventStartTime", &s.EventStartTime) - delete(rawMsg, key) - case "eventStatusLastModifiedTime": - err = unpopulateTimeRFC3339(val, "EventStatusLastModifiedTime", &s.EventStatusLastModifiedTime) - delete(rawMsg, key) - case "incidentProperties": - err = unpopulate(val, "IncidentProperties", &s.IncidentProperties) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &s.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// 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 fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "cloud": - err = unpopulate(val, "Cloud", &s.Cloud) - delete(rawMsg, key) - case "lastModifiedTime": - err = unpopulateTimeRFC3339(val, "LastModifiedTime", &s.LastModifiedTime) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &s.Message) - delete(rawMsg, key) - case "title": - err = unpopulate(val, "Title", &s.Title) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -}