// 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 armmaintenance_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/maintenance/armmaintenance"
	"log"
)

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_CreateOrUpdate.json
func ExampleApplyUpdatesClient_CreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdate(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", nil)
	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 = armmaintenance.ApplyUpdatesClientCreateOrUpdateResponse{
	// 	ApplyUpdate: armmaintenance.ApplyUpdate{
	// 		Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
	// 		ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Properties: &armmaintenance.ApplyUpdateProperties{
	// 			ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"),
	// 			Status: to.Ptr(armmaintenance.UpdateStatusPending),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_CreateOrUpdateOnly_NoCancellation.json
func ExampleApplyUpdatesClient_CreateOrUpdateOrCancel_applyUpdatesCreateOrUpdateOnlyNoCancellation() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdateOrCancel(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "20230901121200", armmaintenance.ApplyUpdate{}, nil)
	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 = armmaintenance.ApplyUpdatesClientCreateOrUpdateOrCancelResponse{
	// 	ApplyUpdate: armmaintenance.ApplyUpdate{
	// 		Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
	// 		ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Properties: &armmaintenance.ApplyUpdateProperties{
	// 			ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"),
	// 			Status: to.Ptr(armmaintenance.UpdateStatusPending),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_CreateOrUpdate_CancelMaintenance.json
func ExampleApplyUpdatesClient_CreateOrUpdateOrCancel_applyUpdatesCreateOrUpdateOrCancel() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdateOrCancel(ctx, "examplerg", "Microsoft.Maintenance", "maintenanceConfigurations", "maintenanceConfig1", "20230901121200", armmaintenance.ApplyUpdate{
		Properties: &armmaintenance.ApplyUpdateProperties{
			Status: to.Ptr(armmaintenance.UpdateStatusCancel),
		},
	}, nil)
	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 = armmaintenance.ApplyUpdatesClientCreateOrUpdateOrCancelResponse{
	// 	ApplyUpdate: armmaintenance.ApplyUpdate{
	// 		Name: to.Ptr("maintenanceConfig1"),
	// 		Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
	// 		ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/microsoft.maintenance/maintenanceconfigurations/maintenanceconfig1/providers/microsoft.maintenance/applyupdates/20230901121200"),
	// 		Properties: &armmaintenance.ApplyUpdateProperties{
	// 			ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/microsoft.maintenance/maintenanceconfigurations/maintenanceconfig1"),
	// 			Status: to.Ptr(armmaintenance.UpdateStatusCancelled),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_CreateOrUpdateParent.json
func ExampleApplyUpdatesClient_CreateOrUpdateParent() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdateParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", nil)
	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 = armmaintenance.ApplyUpdatesClientCreateOrUpdateParentResponse{
	// 	ApplyUpdate: armmaintenance.ApplyUpdate{
	// 		Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
	// 		ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Properties: &armmaintenance.ApplyUpdateProperties{
	// 			ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1"),
	// 			Status: to.Ptr(armmaintenance.UpdateStatusPending),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_Get.json
func ExampleApplyUpdatesClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewApplyUpdatesClient().Get(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "e9b9685d-78e4-44c4-a81c-64a14f9b87b6", nil)
	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 = armmaintenance.ApplyUpdatesClientGetResponse{
	// 	ApplyUpdate: armmaintenance.ApplyUpdate{
	// 		Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
	// 		ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Properties: &armmaintenance.ApplyUpdateProperties{
	// 			ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"),
	// 			Status: to.Ptr(armmaintenance.UpdateStatusCompleted),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_GetParent.json
func ExampleApplyUpdatesClient_GetParent() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewApplyUpdatesClient().GetParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", "e9b9685d-78e4-44c4-a81c-64a14f9b87b6", nil)
	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 = armmaintenance.ApplyUpdatesClientGetParentResponse{
	// 	ApplyUpdate: armmaintenance.ApplyUpdate{
	// 		Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
	// 		ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
	// 		Properties: &armmaintenance.ApplyUpdateProperties{
	// 			ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1"),
	// 			Status: to.Ptr(armmaintenance.UpdateStatusCompleted),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2023-10-01-preview/ApplyUpdates_List.json
func ExampleApplyUpdatesClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armmaintenance.NewClientFactory("5b4b650e-28b9-4790-b3ab-ddbd88d727c4", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewApplyUpdatesClient().NewListPager(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 = armmaintenance.ApplyUpdatesClientListResponse{
		// 	ListApplyUpdate: armmaintenance.ListApplyUpdate{
		// 		Value: []*armmaintenance.ApplyUpdate{
		// 			{
		// 				Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
		// 				Type: to.Ptr("Microsoft.Maintenance/applyUpdates"),
		// 				ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"),
		// 				Properties: &armmaintenance.ApplyUpdateProperties{
		// 					ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"),
		// 					Status: to.Ptr(armmaintenance.UpdateStatusCompleted),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}
