// 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 armauthorization_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/authorization/armauthorization/v3"
	"log"
	"time"
)

// Generated from example definition: 2024-09-01-preview/CancelRoleAssignmentScheduleRequestByName.json
func ExampleRoleAssignmentScheduleRequestsClient_Cancel() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRoleAssignmentScheduleRequestsClient().Cancel(ctx, "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", "fea7a502-9a96-4806-a26f-eee560e52045", 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 = armauthorization.RoleAssignmentScheduleRequestsClientCancelResponse{
	// }
}

// Generated from example definition: 2024-09-01-preview/PutRoleAssignmentScheduleRequest.json
func ExampleRoleAssignmentScheduleRequestsClient_Create() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	_, err = clientFactory.NewRoleAssignmentScheduleRequestsClient().Create(ctx, "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", "fea7a502-9a96-4806-a26f-eee560e52045", armauthorization.RoleAssignmentScheduleRequest{
		Properties: &armauthorization.RoleAssignmentScheduleRequestProperties{
			Condition:                       to.Ptr("@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'"),
			ConditionVersion:                to.Ptr("1.0"),
			LinkedRoleEligibilityScheduleID: to.Ptr("b1477448-2cc6-4ceb-93b4-54a202a89413"),
			PrincipalID:                     to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
			RequestType:                     to.Ptr(armauthorization.RequestTypeSelfActivate),
			RoleDefinitionID:                to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
			ScheduleInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfo{
				Expiration: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration{
					Type:     to.Ptr(armauthorization.TypeAfterDuration),
					Duration: to.Ptr("PT8H"),
				},
				StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t }()),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
}

// Generated from example definition: 2024-09-01-preview/GetRoleAssignmentScheduleRequestByName.json
func ExampleRoleAssignmentScheduleRequestsClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRoleAssignmentScheduleRequestsClient().Get(ctx, "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", "fea7a502-9a96-4806-a26f-eee560e52045", 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 = armauthorization.RoleAssignmentScheduleRequestsClientGetResponse{
	// 	RoleAssignmentScheduleRequest: armauthorization.RoleAssignmentScheduleRequest{
	// 		Name: to.Ptr("fea7a502-9a96-4806-a26f-eee560e52045"),
	// 		Type: to.Ptr("Microsoft.Authorization/RoleAssignmentScheduleRequests"),
	// 		ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/RoleAssignmentScheduleRequests/fea7a502-9a96-4806-a26f-eee560e52045"),
	// 		Properties: &armauthorization.RoleAssignmentScheduleRequestProperties{
	// 			Condition: to.Ptr("@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'"),
	// 			ConditionVersion: to.Ptr("1.0"),
	// 			CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t}()),
	// 			ExpandedProperties: &armauthorization.ExpandedProperties{
	// 				Principal: &armauthorization.ExpandedPropertiesPrincipal{
	// 					Type: to.Ptr("User"),
	// 					DisplayName: to.Ptr("User Account"),
	// 					Email: to.Ptr("user@my-tenant.com"),
	// 					ID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
	// 				},
	// 				RoleDefinition: &armauthorization.ExpandedPropertiesRoleDefinition{
	// 					Type: to.Ptr("BuiltInRole"),
	// 					DisplayName: to.Ptr("Contributor"),
	// 					ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
	// 				},
	// 				Scope: &armauthorization.ExpandedPropertiesScope{
	// 					Type: to.Ptr("subscription"),
	// 					DisplayName: to.Ptr("Pay-As-You-Go"),
	// 					ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"),
	// 				},
	// 			},
	// 			PrincipalID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
	// 			PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
	// 			RequestType: to.Ptr(armauthorization.RequestTypeSelfActivate),
	// 			RequestorID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
	// 			RoleDefinitionID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
	// 			ScheduleInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfo{
	// 				Expiration: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration{
	// 					Type: to.Ptr(armauthorization.TypeAfterDuration),
	// 					Duration: to.Ptr("PT8H"),
	// 				},
	// 				StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t}()),
	// 			},
	// 			Scope: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"),
	// 			Status: to.Ptr(armauthorization.StatusProvisioned),
	// 			TargetRoleAssignmentScheduleID: to.Ptr("b1477448-2cc6-4ceb-93b4-54a202a89413"),
	// 			TicketInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesTicketInfo{
	// 			},
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2024-09-01-preview/GetRoleAssignmentScheduleRequestByScope.json
func ExampleRoleAssignmentScheduleRequestsClient_NewListForScopePager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewRoleAssignmentScheduleRequestsClient().NewListForScopePager("providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", &armauthorization.RoleAssignmentScheduleRequestsClientListForScopeOptions{
		Filter: to.Ptr("assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')")})
	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 = armauthorization.RoleAssignmentScheduleRequestsClientListForScopeResponse{
		// 	RoleAssignmentScheduleRequestListResult: armauthorization.RoleAssignmentScheduleRequestListResult{
		// 		Value: []*armauthorization.RoleAssignmentScheduleRequest{
		// 			{
		// 				Name: to.Ptr("fea7a502-9a96-4806-a26f-eee560e52045"),
		// 				Type: to.Ptr("Microsoft.Authorization/RoleAssignmentScheduleRequests"),
		// 				ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/RoleAssignmentScheduleRequests/fea7a502-9a96-4806-a26f-eee560e52045"),
		// 				Properties: &armauthorization.RoleAssignmentScheduleRequestProperties{
		// 					Condition: to.Ptr("@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'"),
		// 					ConditionVersion: to.Ptr("1.0"),
		// 					CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t}()),
		// 					ExpandedProperties: &armauthorization.ExpandedProperties{
		// 						Principal: &armauthorization.ExpandedPropertiesPrincipal{
		// 							Type: to.Ptr("User"),
		// 							DisplayName: to.Ptr("User Account"),
		// 							Email: to.Ptr("user@my-tenant.com"),
		// 							ID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
		// 						},
		// 						RoleDefinition: &armauthorization.ExpandedPropertiesRoleDefinition{
		// 							Type: to.Ptr("BuiltInRole"),
		// 							DisplayName: to.Ptr("Contributor"),
		// 							ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
		// 						},
		// 						Scope: &armauthorization.ExpandedPropertiesScope{
		// 							Type: to.Ptr("subscription"),
		// 							DisplayName: to.Ptr("Pay-As-You-Go"),
		// 							ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"),
		// 						},
		// 					},
		// 					PrincipalID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
		// 					PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
		// 					RequestType: to.Ptr(armauthorization.RequestTypeSelfActivate),
		// 					RequestorID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
		// 					RoleDefinitionID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
		// 					ScheduleInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfo{
		// 						Expiration: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration{
		// 							Type: to.Ptr(armauthorization.TypeAfterDuration),
		// 							Duration: to.Ptr("PT8H"),
		// 						},
		// 						StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t}()),
		// 					},
		// 					Scope: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"),
		// 					Status: to.Ptr(armauthorization.StatusProvisioned),
		// 					TargetRoleAssignmentScheduleID: to.Ptr("b1477448-2cc6-4ceb-93b4-54a202a89413"),
		// 					TicketInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesTicketInfo{
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2024-09-01-preview/ValidateRoleAssignmentScheduleRequestByName.json
func ExampleRoleAssignmentScheduleRequestsClient_Validate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRoleAssignmentScheduleRequestsClient().Validate(ctx, "subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f", "fea7a502-9a96-4806-a26f-eee560e52045", armauthorization.RoleAssignmentScheduleRequest{
		Properties: &armauthorization.RoleAssignmentScheduleRequestProperties{
			Condition:                       to.Ptr("@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'"),
			ConditionVersion:                to.Ptr("1.0"),
			LinkedRoleEligibilityScheduleID: to.Ptr("b1477448-2cc6-4ceb-93b4-54a202a89413"),
			PrincipalID:                     to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
			RequestType:                     to.Ptr(armauthorization.RequestTypeSelfActivate),
			RoleDefinitionID:                to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
			ScheduleInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfo{
				Expiration: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration{
					Type:     to.Ptr(armauthorization.TypeAfterDuration),
					Duration: to.Ptr("PT8H"),
				},
				StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t }()),
			},
		},
	}, 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 = armauthorization.RoleAssignmentScheduleRequestsClientValidateResponse{
	// 	RoleAssignmentScheduleRequest: armauthorization.RoleAssignmentScheduleRequest{
	// 		Name: to.Ptr("fea7a502-9a96-4806-a26f-eee560e52045"),
	// 		Type: to.Ptr("Microsoft.Authorization/RoleAssignmentScheduleRequests"),
	// 		ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/RoleAssignmentScheduleRequests/fea7a502-9a96-4806-a26f-eee560e52045"),
	// 		Properties: &armauthorization.RoleAssignmentScheduleRequestProperties{
	// 			Condition: to.Ptr("@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'"),
	// 			ConditionVersion: to.Ptr("1.0"),
	// 			CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t}()),
	// 			ExpandedProperties: &armauthorization.ExpandedProperties{
	// 				Principal: &armauthorization.ExpandedPropertiesPrincipal{
	// 					Type: to.Ptr("User"),
	// 					DisplayName: to.Ptr("User Account"),
	// 					Email: to.Ptr("user@my-tenant.com"),
	// 					ID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
	// 				},
	// 				RoleDefinition: &armauthorization.ExpandedPropertiesRoleDefinition{
	// 					Type: to.Ptr("BuiltInRole"),
	// 					DisplayName: to.Ptr("Contributor"),
	// 					ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
	// 				},
	// 				Scope: &armauthorization.ExpandedPropertiesScope{
	// 					Type: to.Ptr("subscription"),
	// 					DisplayName: to.Ptr("Pay-As-You-Go"),
	// 					ID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"),
	// 				},
	// 			},
	// 			PrincipalID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
	// 			PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
	// 			RequestType: to.Ptr(armauthorization.RequestTypeSelfActivate),
	// 			RequestorID: to.Ptr("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"),
	// 			RoleDefinitionID: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"),
	// 			ScheduleInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfo{
	// 				Expiration: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration{
	// 					Type: to.Ptr(armauthorization.TypeAfterDuration),
	// 					Duration: to.Ptr("PT8H"),
	// 				},
	// 				StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-09T21:35:27.91Z"); return t}()),
	// 			},
	// 			Scope: to.Ptr("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"),
	// 			Status: to.Ptr(armauthorization.StatusProvisioned),
	// 			TargetRoleAssignmentScheduleID: to.Ptr("c9e264ff-3133-4776-a81a-ebc7c33c8ec6"),
	// 			TicketInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesTicketInfo{
	// 			},
	// 		},
	// 	},
	// }
}
