// 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) Go Code Generator. DO NOT EDIT.

package armresourcehealth_test

import (
	"context"
	"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"
	"log"
)

// Generated from example definition: 2025-05-01/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()
	clientFactory, err := armresourcehealth.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewAvailabilityStatusesClient().GetByResource(ctx, "resourceUri", &armresourcehealth.AvailabilityStatusesClientGetByResourceOptions{
		Expand: to.Ptr("recommendedactions")})
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res = armresourcehealth.AvailabilityStatusesClientGetByResourceResponse{
	// 	AvailabilityStatus: armresourcehealth.AvailabilityStatus{
	// 		Name: to.Ptr("current"),
	// 		Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
	// 		ID: to.Ptr("/subscriptions/4abcdefgh-ijkl-mnop-qrstuvwxyz/resourceGroups/rhctestenv/providers/Microsoft.ClassicCompute/virtualMachines /rhctestenvV1PI/providers/Microsoft.ResourceHealth/availabilityStatuses/current"),
	// 		Location: to.Ptr("eastus"),
	// 		Properties: &armresourcehealth.AvailabilityStatusProperties{
	// 			AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesUnavailable),
	// 			Category: to.Ptr("Unplanned"),
	// 			Context: to.Ptr("Platform Initiated"),
	// 			DetailedStatus: to.Ptr("Disk problems are preventing us from automatically recovering your virtual machine"),
	// 			OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:12:00Z"); return t}()),
	// 			ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
	// 			ReasonType: to.Ptr("Unplanned"),
	// 			RecommendedActions: []*armresourcehealth.RecommendedAction{
	// 				{
	// 					Action: to.Ptr("To start this virtual machine, open the resource blade and click Start"),
	// 					ActionURL: to.Ptr("<#ResourceBlade>"),
	// 					ActionURLText: to.Ptr("resource blade"),
	// 				},
	// 				{
	// 					Action: to.Ptr("If you are experiencing problems you believe are caused by Azure, contact support"),
	// 					ActionURL: to.Ptr("<#SupportCase>"),
	// 					ActionURLText: to.Ptr("contact support"),
	// 				},
	// 			},
	// 			ReportedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-04T14:11:29.7598931Z"); return t}()),
	// 			ResolutionETA: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:37:00Z"); return t}()),
	// 			RootCauseAttributionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:13:00Z"); return t}()),
	// 			Summary: to.Ptr("We're sorry, we couldn't automatically recover your virtual machine"),
	// 			Title: to.Ptr("Unavailable"),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-05-01/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()
	clientFactory, err := armresourcehealth.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAvailabilityStatusesClient().NewListPager("resourceUri", nil)
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page = armresourcehealth.AvailabilityStatusesClientListResponse{
		// 	AvailabilityStatusListResult: armresourcehealth.AvailabilityStatusListResult{
		// 		Value: []*armresourcehealth.AvailabilityStatus{
		// 			{
		// 				ID: to.Ptr("/subscriptions/4abcdefgh-ijkl-mnop-qrstuvwxyz/resourceGroups/rhctestenv/providers/Microsoft.ClassicCompute/virtualMachines/rhctes tenvV1PI/providers/Microsoft.ResourceHealth/availabilityStatuses/current"),
		// 				Name: to.Ptr("current"),
		// 				Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armresourcehealth.AvailabilityStatusProperties{
		// 					AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesUnavailable),
		// 					Title: to.Ptr("Unavailable"),
		// 					Summary: to.Ptr("We're sorry, we couldn't automatically recover your virtual machine"),
		// 					ReasonType: to.Ptr("Unplanned"),
		// 					Context: to.Ptr("Platform Initiated"),
		// 					Category: to.Ptr("Unplanned"),
		// 					ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
		// 					DetailedStatus: to.Ptr("Disk problems are preventing us from automatically recovering your virtual machine"),
		// 					OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:12:00Z"); return t}()),
		// 					ReportedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-04T14:11:29.7598931Z"); return t}()),
		// 					RootCauseAttributionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:13:00Z"); return t}()),
		// 					ResolutionETA: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:37:00Z"); return t}()),
		// 					ServiceImpactingEvents: []*armresourcehealth.ServiceImpactingEvent{
		// 						{
		// 							EventStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-02T19:23:13.7115125Z"); return t}()),
		// 							EventStatusLastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-02T19:27:04.9543491Z"); return t}()),
		// 							CorrelationID: to.Ptr("b56d0180-2d6c-4f7b-b750-c1eca681874c"),
		// 							Status: &armresourcehealth.ServiceImpactingEventStatus{
		// 								Value: to.Ptr("Resolved"),
		// 							},
		// 							IncidentProperties: &armresourcehealth.ServiceImpactingEventIncidentProperties{
		// 								Title: to.Ptr("Virtual Machines - West Europe [West Europe]"),
		// 								Service: to.Ptr("Virtual Machines"),
		// 								Region: to.Ptr("East US"),
		// 								IncidentType: to.Ptr("outage"),
		// 							},
		// 						},
		// 					},
		// 				},
		// 			},
		// 			{
		// 				ID: to.Ptr("/subscriptions/4abcdefgh-ijkl-mnop-qrstuvwxyz/resourceGroups/rhctestenv/providers/Microsoft.ClassicCompute/virtualMachines/rhctes tenvV1PI/providers/Microsoft.ResourceHealth/availabilityStatuses/2016-03-28+16%3a23%3a00Z"),
		// 				Name: to.Ptr("2016-03-28+16%3a23%3a00Z"),
		// 				Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armresourcehealth.AvailabilityStatusProperties{
		// 					AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesAvailable),
		// 					Summary: to.Ptr("This virtual machine is running normally"),
		// 					ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
		// 					DetailedStatus: to.Ptr("There aren’t any known Azure platform problems affecting this virtual machine"),
		// 					OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-28T16:23:00Z"); return t}()),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2025-05-01/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()
	clientFactory, err := armresourcehealth.NewClientFactory("subscriptionId", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAvailabilityStatusesClient().NewListByResourceGroupPager("resourceGroupName", &armresourcehealth.AvailabilityStatusesClientListByResourceGroupOptions{
		Expand: to.Ptr("recommendedactions")})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page = armresourcehealth.AvailabilityStatusesClientListByResourceGroupResponse{
		// 	AvailabilityStatusListResult: armresourcehealth.AvailabilityStatusListResult{
		// 		Value: []*armresourcehealth.AvailabilityStatus{
		// 			{
		// 				ID: to.Ptr("/subscriptions/227b734f-e14f-4de6-b7fc-3190c21e69f6/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/virtualMachineName/providers/Microsoft.ResourceHealth/availabilityStatuses/current"),
		// 				Name: to.Ptr("current"),
		// 				Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armresourcehealth.AvailabilityStatusProperties{
		// 					AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesAvailable),
		// 					Title: to.Ptr("Available"),
		// 					Summary: to.Ptr("Vm is available"),
		// 					ReasonType: to.Ptr("Unplanned"),
		// 					Context: to.Ptr("Platform Initiated"),
		// 					Category: to.Ptr("Unplanned"),
		// 					ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
		// 					DetailedStatus: to.Ptr("We have not seen any issues with your virtual machine"),
		// 					OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:12:00Z"); return t}()),
		// 					ReportedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-04T14:11:29.7598931Z"); return t}()),
		// 					RecentlyResolved: &armresourcehealth.AvailabilityStatusPropertiesRecentlyResolved{
		// 						UnavailableOccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-28T00:48:00Z"); return t}()),
		// 						ResolvedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-28T00:49:00Z"); return t}()),
		// 						UnavailabilitySummary: to.Ptr("We are sorry your SQL database is unavailable"),
		// 					},
		// 					RecommendedActions: []*armresourcehealth.RecommendedAction{
		// 						{
		// 							Action: to.Ptr("To start this virtualmachine, open the resource blade and click Start"),
		// 							ActionURL: to.Ptr("<#ResourceBlade>"),
		// 							ActionURLText: to.Ptr("resourceblade"),
		// 						},
		// 					},
		// 				},
		// 			},
		// 			{
		// 				ID: to.Ptr("/subscriptions/227b734f-e14f-4de6-b7fc-3190c21e69f6/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/virtualMachineName/providers/Microsoft.ResourceHealth/availabilityStatuses/current"),
		// 				Name: to.Ptr("current"),
		// 				Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armresourcehealth.AvailabilityStatusProperties{
		// 					AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesUnavailable),
		// 					Title: to.Ptr("Unavailable"),
		// 					Summary: to.Ptr("We are sorry, we couldn't automatically recovery our virtualmachine"),
		// 					ReasonType: to.Ptr("Unplanned"),
		// 					ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
		// 					DetailedStatus: to.Ptr("Diskproblemsarepreventingusfromautomaticallyrecoveringyourvirtualmachine"),
		// 					OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:12:00Z"); return t}()),
		// 					ReportedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-04T14:11:29.7598931Z"); return t}()),
		// 					RootCauseAttributionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:13:00Z"); return t}()),
		// 					ResolutionETA: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:37:00Z"); return t}()),
		// 					RecommendedActions: []*armresourcehealth.RecommendedAction{
		// 						{
		// 							Action: to.Ptr("To start this virtualmachine, open the resource blade"),
		// 							ActionURL: to.Ptr("<#ResourceBlade>"),
		// 							ActionURLText: to.Ptr("resourceblade"),
		// 						},
		// 						{
		// 							Action: to.Ptr("If you are experiencing problems you believe are caused by Azure, contact support"),
		// 							ActionURL: to.Ptr("<#SupportCase>"),
		// 							ActionURLText: to.Ptr("contactsupport"),
		// 						},
		// 					},
		// 				},
		// 			},
		// 		},
		// 		NextLink: to.Ptr("https://management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2025-05-01&$skipToken=OpaquePageNumber"),
		// 	},
		// }
	}
}

// Generated from example definition: 2025-05-01/AvailabilityStatuses_ListBySubscriptionId.json
func ExampleAvailabilityStatusesClient_NewListBySubscriptionIDPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcehealth.NewClientFactory("subscriptionId", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewAvailabilityStatusesClient().NewListBySubscriptionIDPager(&armresourcehealth.AvailabilityStatusesClientListBySubscriptionIDOptions{
		Expand: to.Ptr("recommendedactions")})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page = armresourcehealth.AvailabilityStatusesClientListBySubscriptionIDResponse{
		// 	AvailabilityStatusListResult: armresourcehealth.AvailabilityStatusListResult{
		// 		NextLink: to.Ptr("https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2025-05-01&$skipToken=OpaquePageNumber"),
		// 		Value: []*armresourcehealth.AvailabilityStatus{
		// 			{
		// 				Name: to.Ptr("current"),
		// 				Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
		// 				ID: to.Ptr("/subscriptions/227b734f-e14f-4de6-b7fc-3190c21e69f6/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/virtualMachineName/providers/Microsoft.ResourceHealth/availabilityStatuses/current"),
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armresourcehealth.AvailabilityStatusProperties{
		// 					AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesAvailable),
		// 					Category: to.Ptr("Unplanned"),
		// 					Context: to.Ptr("Platform Initiated"),
		// 					DetailedStatus: to.Ptr("We have not seen any issues with your virtual machine"),
		// 					OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:12:00Z"); return t}()),
		// 					ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
		// 					ReasonType: to.Ptr("Unplanned"),
		// 					RecentlyResolved: &armresourcehealth.AvailabilityStatusPropertiesRecentlyResolved{
		// 						ResolvedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-28T00:49:00Z"); return t}()),
		// 						UnavailableOccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-28T00:48:00Z"); return t}()),
		// 						UnavailabilitySummary: to.Ptr("We are sorry your SQL database is unavailable"),
		// 					},
		// 					RecommendedActions: []*armresourcehealth.RecommendedAction{
		// 						{
		// 							Action: to.Ptr("To start this virtualmachine, open the resource blade and click Start"),
		// 							ActionURL: to.Ptr("<#ResourceBlade>"),
		// 							ActionURLText: to.Ptr("resourceblade"),
		// 						},
		// 					},
		// 					ReportedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-04T14:11:29.7598931Z"); return t}()),
		// 					Summary: to.Ptr("Vm is available"),
		// 					Title: to.Ptr("Available"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("current"),
		// 				Type: to.Ptr("Microsoft.ResourceHealth/AvailabilityStatuses"),
		// 				ID: to.Ptr("/subscriptions/227b734f-e14f-4de6-b7fc-3190c21e69f6/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/virtualMachineName/providers/Microsoft.ResourceHealth/availabilityStatuses/current"),
		// 				Location: to.Ptr("eastus"),
		// 				Properties: &armresourcehealth.AvailabilityStatusProperties{
		// 					AvailabilityState: to.Ptr(armresourcehealth.AvailabilityStateValuesUnavailable),
		// 					DetailedStatus: to.Ptr("Diskproblemsarepreventingusfromautomaticallyrecoveringyourvirtualmachine"),
		// 					OccurredTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:12:00Z"); return t}()),
		// 					ReasonChronicity: to.Ptr(armresourcehealth.ReasonChronicityTypesPersistent),
		// 					ReasonType: to.Ptr("Unplanned"),
		// 					RecommendedActions: []*armresourcehealth.RecommendedAction{
		// 						{
		// 							Action: to.Ptr("To start this virtualmachine, open the resource blade"),
		// 							ActionURL: to.Ptr("<#ResourceBlade>"),
		// 							ActionURLText: to.Ptr("resourceblade"),
		// 						},
		// 						{
		// 							Action: to.Ptr("If you are experiencing problems you believe are caused by Azure, contact support"),
		// 							ActionURL: to.Ptr("<#SupportCase>"),
		// 							ActionURLText: to.Ptr("contactsupport"),
		// 						},
		// 					},
		// 					ReportedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-05-04T14:11:29.7598931Z"); return t}()),
		// 					ResolutionETA: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:37:00Z"); return t}()),
		// 					RootCauseAttributionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-03-29T09:13:00Z"); return t}()),
		// 					Summary: to.Ptr("We are sorry, we couldn't automatically recovery our virtualmachine"),
		// 					Title: to.Ptr("Unavailable"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}
