// 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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v6"
	"log"
)

// Generated from example definition: 2026-04-01-preview/BackupsLongTermRetentionCheckPrerequisites.json
func ExampleBackupsLongTermRetentionClient_CheckPrerequisites() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewBackupsLongTermRetentionClient().CheckPrerequisites(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.LtrPreBackupRequest{
		BackupSettings: &armpostgresqlflexibleservers.BackupSettings{
			BackupName: to.Ptr("exampleltrbackup"),
		},
	}, 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 = armpostgresqlflexibleservers.BackupsLongTermRetentionClientCheckPrerequisitesResponse{
	// 	LtrPreBackupResponse: armpostgresqlflexibleservers.LtrPreBackupResponse{
	// 		Properties: &armpostgresqlflexibleservers.BackupsLongTermRetentionResponseProperties{
	// 			NumberOfContainers: to.Ptr[int32](1),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-04-01-preview/BackupsLongTermRetentionGet.json
func ExampleBackupsLongTermRetentionClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewBackupsLongTermRetentionClient().Get(ctx, "exampleresourcegroup", "exampleserver", "exampleltrbackup", 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 = armpostgresqlflexibleservers.BackupsLongTermRetentionClientGetResponse{
	// 	BackupsLongTermRetentionOperation: armpostgresqlflexibleservers.BackupsLongTermRetentionOperation{
	// 		Name: to.Ptr("exampleltrbackup"),
	// 		Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers/ltrbackupOperations"),
	// 		ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver"),
	// 		Properties: &armpostgresqlflexibleservers.LtrBackupOperationResponseProperties{
	// 			BackupMetadata: to.Ptr("backupMetadata"),
	// 			BackupName: to.Ptr("exampleltrbackup"),
	// 			DataTransferredInBytes: to.Ptr[int64](9),
	// 			DatasourceSizeInBytes: to.Ptr[int64](21),
	// 			EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t}()),
	// 			PercentComplete: to.Ptr[float64](4),
	// 			StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
	// 			Status: to.Ptr(armpostgresqlflexibleservers.ExecutionStatusRunning),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-04-01-preview/BackupsLongTermRetentionListByServer.json
func ExampleBackupsLongTermRetentionClient_NewListByServerPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewBackupsLongTermRetentionClient().NewListByServerPager("exampleresourcegroup", "exampleserver", 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 = armpostgresqlflexibleservers.BackupsLongTermRetentionClientListByServerResponse{
		// 	LtrServerBackupOperationList: armpostgresqlflexibleservers.LtrServerBackupOperationList{
		// 		Value: []*armpostgresqlflexibleservers.BackupsLongTermRetentionOperation{
		// 			{
		// 				Name: to.Ptr("exampleltrbackup"),
		// 				Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers/ltrbackupOperations"),
		// 				ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/exampleresourcegroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/exampleserver"),
		// 				Properties: &armpostgresqlflexibleservers.LtrBackupOperationResponseProperties{
		// 					BackupMetadata: to.Ptr("backupMetadata"),
		// 					BackupName: to.Ptr("exampleltrbackup"),
		// 					DataTransferredInBytes: to.Ptr[int64](9),
		// 					DatasourceSizeInBytes: to.Ptr[int64](21),
		// 					EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t}()),
		// 					PercentComplete: to.Ptr[float64](4),
		// 					StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
		// 					Status: to.Ptr(armpostgresqlflexibleservers.ExecutionStatusRunning),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2026-04-01-preview/BackupsLongTermRetentionStart.json
func ExampleBackupsLongTermRetentionClient_BeginStart() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armpostgresqlflexibleservers.NewClientFactory("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewBackupsLongTermRetentionClient().BeginStart(ctx, "exampleresourcegroup", "exampleserver", armpostgresqlflexibleservers.BackupsLongTermRetentionRequest{
		BackupSettings: &armpostgresqlflexibleservers.BackupSettings{
			BackupName: to.Ptr("exampleltrbackup"),
		},
		TargetDetails: &armpostgresqlflexibleservers.BackupStoreDetails{
			SasURIList: []*string{
				to.Ptr("sasuri"),
			},
		},
	}, 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 = armpostgresqlflexibleservers.BackupsLongTermRetentionClientStartResponse{
	// 	BackupsLongTermRetentionResponse: armpostgresqlflexibleservers.BackupsLongTermRetentionResponse{
	// 		Properties: &armpostgresqlflexibleservers.LtrBackupOperationResponseProperties{
	// 			BackupMetadata: to.Ptr("backupmetadata"),
	// 			DataTransferredInBytes: to.Ptr[int64](23),
	// 			DatasourceSizeInBytes: to.Ptr[int64](23),
	// 			EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:35:22.123Z"); return t}()),
	// 			PercentComplete: to.Ptr[float64](100),
	// 			StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-06-01T18:30:22.123Z"); return t}()),
	// 			Status: to.Ptr(armpostgresqlflexibleservers.ExecutionStatusRunning),
	// 		},
	// 	},
	// }
}
