// 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 armiotoperations_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/iotoperations/armiotoperations"
	"log"
)

// Generated from example definition: 2026-07-01/RegistryEndpoint_CreateOrUpdate_MaximumSet_Gen.json
func ExampleRegistryEndpointClient_BeginCreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armiotoperations.NewClientFactory("F8C729F9-DF9C-4743-848F-96EE433D8E53", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewRegistryEndpointClient().BeginCreateOrUpdate(ctx, "rgiotoperations", "resource-123", "resource-123", armiotoperations.RegistryEndpointResource{
		Properties: &armiotoperations.RegistryEndpointProperties{
			Host: to.Ptr("contoso.azurecr.io"),
			Authentication: &armiotoperations.RegistryEndpointAnonymousAuthentication{
				Method:            to.Ptr(armiotoperations.RegistryEndpointAuthenticationMethodAnonymous),
				AnonymousSettings: &armiotoperations.RegistryEndpointAnonymousSettings{},
			},
			CodeSigningCas: []armiotoperations.RegistryEndpointTrustedSigningKeyClassification{
				&armiotoperations.RegistryEndpointTrustedSigningKeySecret{
					Type:      to.Ptr(armiotoperations.RegistryEndpointTrustedSigningKeyTypeSecret),
					SecretRef: to.Ptr("my-secret"),
				},
				&armiotoperations.RegistryEndpointTrustedSigningKeyConfigMap{
					Type:         to.Ptr(armiotoperations.RegistryEndpointTrustedSigningKeyTypeConfigMap),
					ConfigMapRef: to.Ptr("my-configmap"),
				},
			},
		},
		ExtendedLocation: &armiotoperations.ExtendedLocation{
			Name: to.Ptr("/subscriptions/F8C729F9-DF9C-4743-848F-96EE433D8E53/resourceGroups/rgiotoperations/providers/Microsoft.ExtendedLocation/customLocations/resource-123"),
			Type: to.Ptr(armiotoperations.ExtendedLocationTypeCustomLocation),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to poll the result: %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 = armiotoperations.RegistryEndpointClientCreateOrUpdateResponse{
	// 	RegistryEndpointResource: armiotoperations.RegistryEndpointResource{
	// 		Properties: &armiotoperations.RegistryEndpointProperties{
	// 			Host: to.Ptr("contoso.azurecr.io"),
	// 			Authentication: &armiotoperations.RegistryEndpointAnonymousAuthentication{
	// 				Method: to.Ptr(armiotoperations.RegistryEndpointAuthenticationMethodAnonymous),
	// 				AnonymousSettings: &armiotoperations.RegistryEndpointAnonymousSettings{
	// 				},
	// 			},
	// 			CodeSigningCas: []armiotoperations.RegistryEndpointTrustedSigningKeyClassification{
	// 				&armiotoperations.RegistryEndpointTrustedSigningKeySecret{
	// 					Type: to.Ptr(armiotoperations.RegistryEndpointTrustedSigningKeyTypeSecret),
	// 					SecretRef: to.Ptr("my-secret"),
	// 				},
	// 				&armiotoperations.RegistryEndpointTrustedSigningKeyConfigMap{
	// 					Type: to.Ptr(armiotoperations.RegistryEndpointTrustedSigningKeyTypeConfigMap),
	// 					ConfigMapRef: to.Ptr("my-configmap"),
	// 				},
	// 			},
	// 			ProvisioningState: to.Ptr(armiotoperations.ProvisioningStateSucceeded),
	// 		},
	// 		ExtendedLocation: &armiotoperations.ExtendedLocation{
	// 			Name: to.Ptr("/subscriptions/F8C729F9-DF9C-4743-848F-96EE433D8E53/resourceGroups/rgiotoperations/providers/Microsoft.ExtendedLocation/customLocations/resource-123"),
	// 			Type: to.Ptr(armiotoperations.ExtendedLocationTypeCustomLocation),
	// 		},
	// 		ID: to.Ptr("/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/registryEndpoints/resource-name123"),
	// 		Name: to.Ptr("resource-name123"),
	// 		Type: to.Ptr("Microsoft.IoTOperations/registryEndpoints"),
	// 		SystemData: &armiotoperations.SystemData{
	// 			CreatedBy: to.Ptr("contosouser"),
	// 			CreatedByType: to.Ptr(armiotoperations.CreatedByTypeUser),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-09T18:13:29.389Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("contosouser"),
	// 			LastModifiedByType: to.Ptr(armiotoperations.CreatedByTypeUser),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-09T18:13:29.389Z"); return t}()),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-07-01/RegistryEndpoint_Delete_MaximumSet_Gen.json
func ExampleRegistryEndpointClient_BeginDelete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armiotoperations.NewClientFactory("F8C729F9-DF9C-4743-848F-96EE433D8E53", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewRegistryEndpointClient().BeginDelete(ctx, "rgiotoperations", "resource-123", "resource-123", nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	_, err = poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to poll the result: %v", err)
	}
}

// Generated from example definition: 2026-07-01/RegistryEndpoint_Get_MaximumSet_Gen.json
func ExampleRegistryEndpointClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armiotoperations.NewClientFactory("F8C729F9-DF9C-4743-848F-96EE433D8E53", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewRegistryEndpointClient().Get(ctx, "rgiotoperations", "resource-123", "resource-123", 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 = armiotoperations.RegistryEndpointClientGetResponse{
	// 	RegistryEndpointResource: armiotoperations.RegistryEndpointResource{
	// 		Properties: &armiotoperations.RegistryEndpointProperties{
	// 			Host: to.Ptr("contoso.azurecr.io"),
	// 			Authentication: &armiotoperations.RegistryEndpointAnonymousAuthentication{
	// 				Method: to.Ptr(armiotoperations.RegistryEndpointAuthenticationMethodAnonymous),
	// 				AnonymousSettings: &armiotoperations.RegistryEndpointAnonymousSettings{
	// 				},
	// 			},
	// 			ProvisioningState: to.Ptr(armiotoperations.ProvisioningStateSucceeded),
	// 		},
	// 		ExtendedLocation: &armiotoperations.ExtendedLocation{
	// 			Name: to.Ptr("/subscriptions/F8C729F9-DF9C-4743-848F-96EE433D8E53/resourceGroups/rgiotoperations/providers/Microsoft.ExtendedLocation/customLocations/resource-123"),
	// 			Type: to.Ptr(armiotoperations.ExtendedLocationTypeCustomLocation),
	// 		},
	// 		ID: to.Ptr("/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/registryEndpoints/resource-name123"),
	// 		Name: to.Ptr("resource-name123"),
	// 		Type: to.Ptr("Microsoft.IoTOperations/registryEndpoints"),
	// 		SystemData: &armiotoperations.SystemData{
	// 			CreatedBy: to.Ptr("contosouser"),
	// 			CreatedByType: to.Ptr(armiotoperations.CreatedByTypeUser),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-09T18:13:29.389Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("contosouser"),
	// 			LastModifiedByType: to.Ptr(armiotoperations.CreatedByTypeUser),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-09T18:13:29.389Z"); return t}()),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-07-01/RegistryEndpoint_ListByInstanceResource_MaximumSet_Gen.json
func ExampleRegistryEndpointClient_NewListByInstanceResourcePager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armiotoperations.NewClientFactory("F8C729F9-DF9C-4743-848F-96EE433D8E53", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewRegistryEndpointClient().NewListByInstanceResourcePager("rgiotoperations", "resource-123", 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 = armiotoperations.RegistryEndpointClientListByInstanceResourceResponse{
		// 	RegistryEndpointResourceListResult: armiotoperations.RegistryEndpointResourceListResult{
		// 		Value: []*armiotoperations.RegistryEndpointResource{
		// 			{
		// 				Properties: &armiotoperations.RegistryEndpointProperties{
		// 					Host: to.Ptr("contoso.azurecr.io"),
		// 					Authentication: &armiotoperations.RegistryEndpointAnonymousAuthentication{
		// 						Method: to.Ptr(armiotoperations.RegistryEndpointAuthenticationMethodAnonymous),
		// 						AnonymousSettings: &armiotoperations.RegistryEndpointAnonymousSettings{
		// 						},
		// 					},
		// 					ProvisioningState: to.Ptr(armiotoperations.ProvisioningStateSucceeded),
		// 				},
		// 				ExtendedLocation: &armiotoperations.ExtendedLocation{
		// 					Name: to.Ptr("/subscriptions/F8C729F9-DF9C-4743-848F-96EE433D8E53/resourceGroups/rgiotoperations/providers/Microsoft.ExtendedLocation/customLocations/resource-123"),
		// 					Type: to.Ptr(armiotoperations.ExtendedLocationTypeCustomLocation),
		// 				},
		// 				ID: to.Ptr("/subscriptions/0000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup123/providers/Microsoft.IoTOperations/instances/resource-name123/registryEndpoints/resource-name123"),
		// 				Name: to.Ptr("resource-name123"),
		// 				Type: to.Ptr("Microsoft.IoTOperations/registryEndpoints"),
		// 				SystemData: &armiotoperations.SystemData{
		// 					CreatedBy: to.Ptr("contosouser"),
		// 					CreatedByType: to.Ptr(armiotoperations.CreatedByTypeUser),
		// 					CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-09T18:13:29.389Z"); return t}()),
		// 					LastModifiedBy: to.Ptr("contosouser"),
		// 					LastModifiedByType: to.Ptr(armiotoperations.CreatedByTypeUser),
		// 					LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-08-09T18:13:29.389Z"); return t}()),
		// 				},
		// 			},
		// 		},
		// 		NextLink: to.Ptr("https://microsoft.com/a"),
		// 	},
		// }
	}
}
