//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 armproviderhub_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/providerhub/armproviderhub/v2"
)

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7611bb6c9bad11244f4351eecfc50b2c46a86fde/specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2024-09-01/examples/Operations_List.json
func ExampleOperationsClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armproviderhub.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewOperationsClient().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.OperationsDefinitionArrayResponseWithContinuation = armproviderhub.OperationsDefinitionArrayResponseWithContinuation{
		// 	Value: []*armproviderhub.OperationsDefinition{
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/register/action"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Registers the specified subscription with Microsoft.ProviderHub resource provider"),
		// 				Operation: to.Ptr("Register for Microsoft.ProviderHub"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("register"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 		},
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/defaultRollouts/write"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Creates or Updates any rollout"),
		// 				Operation: to.Ptr("Create or Update rollout"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("defaultRollouts"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 		},
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/defaultRollouts/read"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Reads any rollout"),
		// 				Operation: to.Ptr("Read rollout"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("defaultRollouts"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 		},
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/defaultRollouts/delete"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Deletes any rollout"),
		// 				Operation: to.Ptr("Delete rollout"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("defaultRollouts"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 		},
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/defaultRollouts/stop/action"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Deletes any rollout"),
		// 				Operation: to.Ptr("Delete rollout"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("defaultRollouts"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 		},
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/customRollouts/write"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Creates or Updates any rollout"),
		// 				Operation: to.Ptr("Create or Update rollout"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("customRollouts"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 		},
		// 		{
		// 			Name: to.Ptr("Microsoft.ProviderHub/customRollouts/read"),
		// 			Display: &armproviderhub.OperationsDefinitionDisplay{
		// 				Description: to.Ptr("Reads any rollout"),
		// 				Operation: to.Ptr("Read rollout"),
		// 				Provider: to.Ptr("Microsoft ProviderHub"),
		// 				Resource: to.Ptr("customRollouts"),
		// 			},
		// 			IsDataAction: to.Ptr(false),
		// 	}},
		// }
	}
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7611bb6c9bad11244f4351eecfc50b2c46a86fde/specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2024-09-01/examples/Operations_ListByProviderRegistration.json
func ExampleOperationsClient_ListByProviderRegistration() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armproviderhub.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewOperationsClient().ListByProviderRegistration(ctx, "Microsoft.Contoso", 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.OperationsDefinitionArray = []*armproviderhub.OperationsDefinition{
	// 	{
	// 		Name: to.Ptr("Microsoft.Contoso/Employees/Read"),
	// 		Display: &armproviderhub.OperationsDefinitionDisplay{
	// 			Description: to.Ptr("Read employees"),
	// 			Operation: to.Ptr("Gets/List employee resources"),
	// 			Provider: to.Ptr("Microsoft.Contoso"),
	// 			Resource: to.Ptr("Employees"),
	// 		},
	// 		IsDataAction: to.Ptr(false),
	// 	},
	// 	{
	// 		Name: to.Ptr("Microsoft.Contoso/Employees/Write"),
	// 		Display: &armproviderhub.OperationsDefinitionDisplay{
	// 			Description: to.Ptr("Writes employees"),
	// 			Operation: to.Ptr("Create/update employee resources"),
	// 			Provider: to.Ptr("Microsoft.Contoso"),
	// 			Resource: to.Ptr("Employees"),
	// 		},
	// 		IsDataAction: to.Ptr(false),
	// 	},
	// 	{
	// 		Name: to.Ptr("Microsoft.Contoso/Employees/Delete"),
	// 		Display: &armproviderhub.OperationsDefinitionDisplay{
	// 			Description: to.Ptr("Deletes employees"),
	// 			Operation: to.Ptr("Deletes employee resource"),
	// 			Provider: to.Ptr("Microsoft.Contoso"),
	// 			Resource: to.Ptr("Employees"),
	// 		},
	// 		IsDataAction: to.Ptr(false),
	// 		Origin: to.Ptr(armproviderhub.OperationOriginsUser),
	// 	},
	// 	{
	// 		Name: to.Ptr("Microsoft.Contoso/Employees/Action"),
	// 		Display: &armproviderhub.OperationsDefinitionDisplay{
	// 			Description: to.Ptr("Writes employees"),
	// 			Operation: to.Ptr("Create/update employee resources"),
	// 			Provider: to.Ptr("Microsoft.Contoso"),
	// 			Resource: to.Ptr("Employees"),
	// 		},
	// 		IsDataAction: to.Ptr(true),
	// 		Origin: to.Ptr(armproviderhub.OperationOriginsSystem),
	// }}
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7611bb6c9bad11244f4351eecfc50b2c46a86fde/specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2024-09-01/examples/Operations_CreateOrUpdate.json
func ExampleOperationsClient_CreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armproviderhub.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewOperationsClient().CreateOrUpdate(ctx, "Microsoft.Contoso", armproviderhub.OperationsPutContent{
		Properties: &armproviderhub.OperationsPutContentProperties{
			Contents: []*armproviderhub.LocalizedOperationDefinition{
				{
					Name:       to.Ptr("RP.69C09791/register/action"),
					ActionType: to.Ptr(armproviderhub.OperationActionTypeInternal),
					Display: &armproviderhub.LocalizedOperationDefinitionDisplay{
						Default: &armproviderhub.LocalizedOperationDisplayDefinitionDefault{
							Description: to.Ptr("Registers the subscription for the RP.69C09791 resource provider and enables the creation of RP.69C09791."),
							Operation:   to.Ptr("Registers the RP.69C09791 Resource Provider"),
							Provider:    to.Ptr("RP.69C09791"),
							Resource:    to.Ptr("Register"),
						},
					},
					IsDataAction: to.Ptr(true),
				},
				{
					Name: to.Ptr("RP.69C09791/unregister/action"),
					Display: &armproviderhub.LocalizedOperationDefinitionDisplay{
						Default: &armproviderhub.LocalizedOperationDisplayDefinitionDefault{
							Description: to.Ptr("Unregisters the subscription for the RP.69C09791 resource provider and enables the creation of RP.69C09791."),
							Operation:   to.Ptr("Unregisters the RP.69C09791 Resource Provider"),
							Provider:    to.Ptr("RP.69C09791"),
							Resource:    to.Ptr("Unregister"),
						},
						En: &armproviderhub.LocalizedOperationDisplayDefinitionEn{
							Description: to.Ptr("ece249f5-b5b9-492d-ac68-b4e1be1677bc"),
							Operation:   to.Ptr("d31623d6-8765-42fb-aca2-5a58303e52dd"),
							Provider:    to.Ptr("RP.69C09791"),
							Resource:    to.Ptr("2e1803d4-417f-492c-b305-148da38b211e"),
						},
					},
					IsDataAction: to.Ptr(false),
					Origin:       to.Ptr(armproviderhub.OperationOriginsSystem),
				}},
		},
	}, 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.OperationsPutContent = armproviderhub.OperationsPutContent{
	// 	Name: to.Ptr("operationTest"),
	// 	Type: to.Ptr("Microsoft.ProviderHub/providerRegistrations/operations"),
	// 	ID: to.Ptr("/subscriptions/ab7a8701-f7ef-471a-a2f4-d0ebbf494f77/providers/Microsoft.ProviderHub/providerRegistrations/Microsoft.Contoso/operations/default"),
	// 	SystemData: &armproviderhub.SystemData{
	// 		CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()),
	// 		CreatedBy: to.Ptr("string"),
	// 		CreatedByType: to.Ptr(armproviderhub.CreatedByTypeUser),
	// 		LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()),
	// 		LastModifiedBy: to.Ptr("string"),
	// 		LastModifiedByType: to.Ptr(armproviderhub.CreatedByTypeUser),
	// 	},
	// 	Properties: &armproviderhub.OperationsPutContentProperties{
	// 		Contents: []*armproviderhub.LocalizedOperationDefinition{
	// 			{
	// 				Name: to.Ptr("RP.69C09791/register/action"),
	// 				ActionType: to.Ptr(armproviderhub.OperationActionTypeInternal),
	// 				Display: &armproviderhub.LocalizedOperationDefinitionDisplay{
	// 					Default: &armproviderhub.LocalizedOperationDisplayDefinitionDefault{
	// 						Description: to.Ptr("Registers the subscription for the RP.69C09791 resource provider and enables the creation of RP.69C09791."),
	// 						Operation: to.Ptr("Registers the RP.69C09791 Resource Provider"),
	// 						Provider: to.Ptr("RP.69C09791"),
	// 						Resource: to.Ptr("Register"),
	// 					},
	// 				},
	// 				IsDataAction: to.Ptr(true),
	// 			},
	// 			{
	// 				Name: to.Ptr("RP.69C09791/unregister/action"),
	// 				Display: &armproviderhub.LocalizedOperationDefinitionDisplay{
	// 					Default: &armproviderhub.LocalizedOperationDisplayDefinitionDefault{
	// 						Description: to.Ptr("Unregisters the subscription for the RP.69C09791 resource provider and enables the creation of RP.69C09791."),
	// 						Operation: to.Ptr("Unregisters the RP.69C09791 Resource Provider"),
	// 						Provider: to.Ptr("RP.69C09791"),
	// 						Resource: to.Ptr("Unregister"),
	// 					},
	// 					En: &armproviderhub.LocalizedOperationDisplayDefinitionEn{
	// 						Description: to.Ptr("ece249f5-b5b9-492d-ac68-b4e1be1677bc"),
	// 						Operation: to.Ptr("d31623d6-8765-42fb-aca2-5a58303e52dd"),
	// 						Provider: to.Ptr("RP.69C09791"),
	// 						Resource: to.Ptr("2e1803d4-417f-492c-b305-148da38b211e"),
	// 					},
	// 				},
	// 				IsDataAction: to.Ptr(false),
	// 				Origin: to.Ptr(armproviderhub.OperationOriginsSystem),
	// 		}},
	// 	},
	// }
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7611bb6c9bad11244f4351eecfc50b2c46a86fde/specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2024-09-01/examples/Operations_Delete.json
func ExampleOperationsClient_Delete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armproviderhub.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewOperationsClient().Delete(ctx, "Microsoft.Contoso", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}
