// 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 armcontainerregistry_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/containerregistry/armcontainerregistry/v3"
	"log"
)

// Generated from example definition: 2026-03-01-preview/CredentialSetCreate.json
func ExampleCredentialSetsClient_BeginCreate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcontainerregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewCredentialSetsClient().BeginCreate(ctx, "myResourceGroup", "myRegistry", "myCredentialSet", armcontainerregistry.CredentialSet{
		Properties: &armcontainerregistry.CredentialSetProperties{
			LoginServer: to.Ptr("docker.io"),
			AuthCredentials: []*armcontainerregistry.AuthCredential{
				{
					Name:                     to.Ptr(armcontainerregistry.CredentialNameCredential1),
					UsernameSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/username"),
					PasswordSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/password"),
				},
			},
		},
		Identity: &armcontainerregistry.IdentityProperties{
			Type: to.Ptr(armcontainerregistry.ResourceIdentityTypeSystemAssigned),
		},
	}, 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 = armcontainerregistry.CredentialSetsClientCreateResponse{
	// 	CredentialSet: armcontainerregistry.CredentialSet{
	// 		Type: to.Ptr("Microsoft.ContainerRegistry/registries/credentialSets"),
	// 		Identity: &armcontainerregistry.IdentityProperties{
	// 			PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 			TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 			Type: to.Ptr(armcontainerregistry.ResourceIdentityTypeSystemAssigned),
	// 		},
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/credentialSets/myCredentialSet"),
	// 		Name: to.Ptr("myCredentialSet"),
	// 		Properties: &armcontainerregistry.CredentialSetProperties{
	// 			LoginServer: to.Ptr("docker.io"),
	// 			AuthCredentials: []*armcontainerregistry.AuthCredential{
	// 				{
	// 					Name: to.Ptr(armcontainerregistry.CredentialNameCredential1),
	// 					UsernameSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/username"),
	// 					PasswordSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/password"),
	// 					CredentialHealth: &armcontainerregistry.CredentialHealth{
	// 						Status: to.Ptr(armcontainerregistry.CredentialHealthStatusHealthy),
	// 					},
	// 				},
	// 			},
	// 			CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-07T18:20:08.012276+00:00"); return t}()),
	// 			ProvisioningState: to.Ptr(armcontainerregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/CredentialSetDelete.json
func ExampleCredentialSetsClient_BeginDelete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcontainerregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewCredentialSetsClient().BeginDelete(ctx, "myResourceGroup", "myRegistry", "myCredentialSet", 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-03-01-preview/CredentialSetGet.json
func ExampleCredentialSetsClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcontainerregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewCredentialSetsClient().Get(ctx, "myResourceGroup", "myRegistry", "myCredentialSet", 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 = armcontainerregistry.CredentialSetsClientGetResponse{
	// 	CredentialSet: armcontainerregistry.CredentialSet{
	// 		Type: to.Ptr("Microsoft.ContainerRegistry/registries/credentialSets"),
	// 		Identity: &armcontainerregistry.IdentityProperties{
	// 			PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 			TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 			Type: to.Ptr(armcontainerregistry.ResourceIdentityTypeSystemAssigned),
	// 		},
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/credentialSets/myCredentialSet"),
	// 		Name: to.Ptr("myCredentialSet"),
	// 		Properties: &armcontainerregistry.CredentialSetProperties{
	// 			LoginServer: to.Ptr("docker.io"),
	// 			AuthCredentials: []*armcontainerregistry.AuthCredential{
	// 				{
	// 					Name: to.Ptr(armcontainerregistry.CredentialNameCredential1),
	// 					UsernameSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/username"),
	// 					PasswordSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/password"),
	// 					CredentialHealth: &armcontainerregistry.CredentialHealth{
	// 						Status: to.Ptr(armcontainerregistry.CredentialHealthStatusHealthy),
	// 					},
	// 				},
	// 			},
	// 			CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-07T18:20:08.012276+00:00"); return t}()),
	// 			ProvisioningState: to.Ptr(armcontainerregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/CredentialSetList.json
func ExampleCredentialSetsClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcontainerregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewCredentialSetsClient().NewListPager("myResourceGroup", "myRegistry", 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 = armcontainerregistry.CredentialSetsClientListResponse{
		// 	CredentialSetListResult: armcontainerregistry.CredentialSetListResult{
		// 		Value: []*armcontainerregistry.CredentialSet{
		// 			{
		// 				Type: to.Ptr("Microsoft.ContainerRegistry/registries/credentialSets"),
		// 				Identity: &armcontainerregistry.IdentityProperties{
		// 					PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
		// 					TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
		// 					Type: to.Ptr(armcontainerregistry.ResourceIdentityTypeSystemAssigned),
		// 				},
		// 				ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/credentialSets/myCredentialSet"),
		// 				Name: to.Ptr("myCredentialSet"),
		// 				Properties: &armcontainerregistry.CredentialSetProperties{
		// 					LoginServer: to.Ptr("docker.io"),
		// 					AuthCredentials: []*armcontainerregistry.AuthCredential{
		// 						{
		// 							Name: to.Ptr(armcontainerregistry.CredentialNameCredential1),
		// 							UsernameSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/username"),
		// 							PasswordSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/password"),
		// 							CredentialHealth: &armcontainerregistry.CredentialHealth{
		// 								Status: to.Ptr(armcontainerregistry.CredentialHealthStatusHealthy),
		// 							},
		// 						},
		// 					},
		// 					CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-07T18:20:08.012276+00:00"); return t}()),
		// 					ProvisioningState: to.Ptr(armcontainerregistry.ProvisioningStateSucceeded),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2026-03-01-preview/CredentialSetUpdate.json
func ExampleCredentialSetsClient_BeginUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcontainerregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewCredentialSetsClient().BeginUpdate(ctx, "myResourceGroup", "myRegistry", "myCredentialSet", armcontainerregistry.CredentialSetUpdateParameters{
		Properties: &armcontainerregistry.CredentialSetUpdateProperties{
			AuthCredentials: []*armcontainerregistry.AuthCredential{
				{
					Name:                     to.Ptr(armcontainerregistry.CredentialNameCredential1),
					UsernameSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/username2"),
					PasswordSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/password2"),
				},
			},
		},
	}, 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 = armcontainerregistry.CredentialSetsClientUpdateResponse{
	// 	CredentialSet: armcontainerregistry.CredentialSet{
	// 		Type: to.Ptr("Microsoft.ContainerRegistry/registries/credentialSets"),
	// 		Identity: &armcontainerregistry.IdentityProperties{
	// 			PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 			TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
	// 			Type: to.Ptr(armcontainerregistry.ResourceIdentityTypeSystemAssigned),
	// 		},
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/credentialSets/myCredentialSet"),
	// 		Name: to.Ptr("myCredentialSet"),
	// 		Properties: &armcontainerregistry.CredentialSetProperties{
	// 			LoginServer: to.Ptr("docker.io"),
	// 			AuthCredentials: []*armcontainerregistry.AuthCredential{
	// 				{
	// 					Name: to.Ptr(armcontainerregistry.CredentialNameCredential1),
	// 					UsernameSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/username2"),
	// 					PasswordSecretIdentifier: to.Ptr("https://myvault.vault.azure.net/secrets/password2"),
	// 					CredentialHealth: &armcontainerregistry.CredentialHealth{
	// 						Status: to.Ptr(armcontainerregistry.CredentialHealthStatusHealthy),
	// 					},
	// 				},
	// 			},
	// 			CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-07T18:20:08.012276+00:00"); return t}()),
	// 			ProvisioningState: to.Ptr(armcontainerregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}
