// 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 armdataprotection_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/dataprotection/armdataprotection/v4"
	"log"
	"time"
)

// Generated from example definition: 2025-07-01/PolicyCRUD/CreateOrUpdateBackupPolicy.json
func ExampleBackupPoliciesClient_CreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdataprotection.NewClientFactory("04cf684a-d41f-4550-9f70-7708a3a2283b", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewBackupPoliciesClient().CreateOrUpdate(ctx, "000pikumar", "PrivatePreviewVault", "OSSDBPolicy", armdataprotection.BaseBackupPolicyResource{
		Properties: &armdataprotection.BackupPolicy{
			DatasourceTypes: []*string{
				to.Ptr("OssDB"),
			},
			ObjectType: to.Ptr("BackupPolicy"),
			PolicyRules: []armdataprotection.BasePolicyRuleClassification{
				&armdataprotection.AzureBackupRule{
					Name: to.Ptr("BackupWeekly"),
					BackupParameters: &armdataprotection.AzureBackupParams{
						BackupType: to.Ptr("Full"),
						ObjectType: to.Ptr("AzureBackupParams"),
					},
					DataStore: &armdataprotection.DataStoreInfoBase{
						DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
						ObjectType:    to.Ptr("DataStoreInfoBase"),
					},
					ObjectType: to.Ptr("AzureBackupRule"),
					Trigger: &armdataprotection.ScheduleBasedTriggerContext{
						ObjectType: to.Ptr("ScheduleBasedTriggerContext"),
						Schedule: &armdataprotection.BackupSchedule{
							RepeatingTimeIntervals: []*string{
								to.Ptr("R/2019-11-20T08:00:00-08:00/P1W"),
							},
						},
						TaggingCriteria: []*armdataprotection.TaggingCriteria{
							{
								IsDefault: to.Ptr(true),
								TagInfo: &armdataprotection.RetentionTag{
									TagName: to.Ptr("Default"),
								},
								TaggingPriority: to.Ptr[int64](99),
							},
							{
								Criteria: []armdataprotection.BackupCriteriaClassification{
									&armdataprotection.ScheduleBasedBackupCriteria{
										DaysOfTheWeek: []*armdataprotection.DayOfWeek{
											to.Ptr(armdataprotection.DayOfWeekSunday),
										},
										ObjectType: to.Ptr("ScheduleBasedBackupCriteria"),
										ScheduleTimes: []*time.Time{
											to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t }()),
										},
									},
								},
								IsDefault: to.Ptr(false),
								TagInfo: &armdataprotection.RetentionTag{
									TagName: to.Ptr("Weekly"),
								},
								TaggingPriority: to.Ptr[int64](20),
							},
						},
					},
				},
				&armdataprotection.AzureRetentionRule{
					Name:      to.Ptr("Default"),
					IsDefault: to.Ptr(true),
					Lifecycles: []*armdataprotection.SourceLifeCycle{
						{
							DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
								Duration:   to.Ptr("P1W"),
								ObjectType: to.Ptr("AbsoluteDeleteOption"),
							},
							SourceDataStore: &armdataprotection.DataStoreInfoBase{
								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
								ObjectType:    to.Ptr("DataStoreInfoBase"),
							},
						},
					},
					ObjectType: to.Ptr("AzureRetentionRule"),
				},
				&armdataprotection.AzureRetentionRule{
					Name:      to.Ptr("Weekly"),
					IsDefault: to.Ptr(false),
					Lifecycles: []*armdataprotection.SourceLifeCycle{
						{
							DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
								Duration:   to.Ptr("P12W"),
								ObjectType: to.Ptr("AbsoluteDeleteOption"),
							},
							SourceDataStore: &armdataprotection.DataStoreInfoBase{
								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
								ObjectType:    to.Ptr("DataStoreInfoBase"),
							},
						},
					},
					ObjectType: to.Ptr("AzureRetentionRule"),
				},
			},
		},
	}, 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 = armdataprotection.BackupPoliciesClientCreateOrUpdateResponse{
	// 	BaseBackupPolicyResource: &armdataprotection.BaseBackupPolicyResource{
	// 		Name: to.Ptr("OSSDBPolicy"),
	// 		Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies"),
	// 		ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PrivatePreviewVault/backupPolicies/OSSDBPolicy"),
	// 		Properties: &armdataprotection.BackupPolicy{
	// 			DatasourceTypes: []*string{
	// 				to.Ptr("OssDB"),
	// 			},
	// 			ObjectType: to.Ptr("BackupPolicy"),
	// 			PolicyRules: []armdataprotection.BasePolicyRuleClassification{
	// 				&armdataprotection.AzureBackupRule{
	// 					Name: to.Ptr("BackupWeekly"),
	// 					BackupParameters: &armdataprotection.AzureBackupParams{
	// 						BackupType: to.Ptr("Full"),
	// 						ObjectType: to.Ptr("AzureBackupParams"),
	// 					},
	// 					DataStore: &armdataprotection.DataStoreInfoBase{
	// 						DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
	// 						ObjectType: to.Ptr("DataStoreInfoBase"),
	// 					},
	// 					ObjectType: to.Ptr("AzureBackupRule"),
	// 					Trigger: &armdataprotection.ScheduleBasedTriggerContext{
	// 						ObjectType: to.Ptr("ScheduleBasedTriggerContext"),
	// 						Schedule: &armdataprotection.BackupSchedule{
	// 							RepeatingTimeIntervals: []*string{
	// 								to.Ptr("R/2019-11-20T08:00:00-08:00/P1W"),
	// 							},
	// 						},
	// 						TaggingCriteria: []*armdataprotection.TaggingCriteria{
	// 							{
	// 								IsDefault: to.Ptr(true),
	// 								TagInfo: &armdataprotection.RetentionTag{
	// 									ID: to.Ptr("Default_"),
	// 									TagName: to.Ptr("Default"),
	// 								},
	// 								TaggingPriority: to.Ptr[int64](99),
	// 							},
	// 							{
	// 								Criteria: []armdataprotection.BackupCriteriaClassification{
	// 									&armdataprotection.ScheduleBasedBackupCriteria{
	// 										DaysOfTheWeek: []*armdataprotection.DayOfWeek{
	// 											to.Ptr(armdataprotection.DayOfWeekSunday),
	// 										},
	// 										ObjectType: to.Ptr("ScheduleBasedBackupCriteria"),
	// 										ScheduleTimes: []*time.Time{
	// 											to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()),
	// 										},
	// 									},
	// 								},
	// 								IsDefault: to.Ptr(false),
	// 								TagInfo: &armdataprotection.RetentionTag{
	// 									ID: to.Ptr("Weekly_"),
	// 									TagName: to.Ptr("Weekly"),
	// 								},
	// 								TaggingPriority: to.Ptr[int64](20),
	// 							},
	// 						},
	// 					},
	// 				},
	// 				&armdataprotection.AzureRetentionRule{
	// 					Name: to.Ptr("Default"),
	// 					IsDefault: to.Ptr(true),
	// 					Lifecycles: []*armdataprotection.SourceLifeCycle{
	// 						{
	// 							DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
	// 								Duration: to.Ptr("P1W"),
	// 								ObjectType: to.Ptr("AbsoluteDeleteOption"),
	// 							},
	// 							SourceDataStore: &armdataprotection.DataStoreInfoBase{
	// 								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
	// 								ObjectType: to.Ptr("DataStoreInfoBase"),
	// 							},
	// 						},
	// 					},
	// 					ObjectType: to.Ptr("AzureRetentionRule"),
	// 				},
	// 				&armdataprotection.AzureRetentionRule{
	// 					Name: to.Ptr("Weekly"),
	// 					IsDefault: to.Ptr(false),
	// 					Lifecycles: []*armdataprotection.SourceLifeCycle{
	// 						{
	// 							DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
	// 								Duration: to.Ptr("P12W"),
	// 								ObjectType: to.Ptr("AbsoluteDeleteOption"),
	// 							},
	// 							SourceDataStore: &armdataprotection.DataStoreInfoBase{
	// 								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
	// 								ObjectType: to.Ptr("DataStoreInfoBase"),
	// 							},
	// 						},
	// 					},
	// 					ObjectType: to.Ptr("AzureRetentionRule"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-07-01/PolicyCRUD/DeleteBackupPolicy.json
func ExampleBackupPoliciesClient_Delete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdataprotection.NewClientFactory("04cf684a-d41f-4550-9f70-7708a3a2283b", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewBackupPoliciesClient().Delete(ctx, "000pikumar", "PrivatePreviewVault", "OSSDBPolicy", 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 = armdataprotection.BackupPoliciesClientDeleteResponse{
	// }
}

// Generated from example definition: 2025-07-01/PolicyCRUD/GetBackupPolicy.json
func ExampleBackupPoliciesClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdataprotection.NewClientFactory("04cf684a-d41f-4550-9f70-7708a3a2283b", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewBackupPoliciesClient().Get(ctx, "000pikumar", "PrivatePreviewVault", "OSSDBPolicy", 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 = armdataprotection.BackupPoliciesClientGetResponse{
	// 	BaseBackupPolicyResource: &armdataprotection.BaseBackupPolicyResource{
	// 		Name: to.Ptr("OSSDBPolicy"),
	// 		Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies"),
	// 		ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PrivatePreviewVault/backupPolicies/OSSDBPolicy"),
	// 		Properties: &armdataprotection.BackupPolicy{
	// 			DatasourceTypes: []*string{
	// 				to.Ptr("OssDB"),
	// 			},
	// 			ObjectType: to.Ptr("BackupPolicy"),
	// 			PolicyRules: []armdataprotection.BasePolicyRuleClassification{
	// 				&armdataprotection.AzureBackupRule{
	// 					Name: to.Ptr("BackupWeekly"),
	// 					BackupParameters: &armdataprotection.AzureBackupParams{
	// 						BackupType: to.Ptr("Full"),
	// 						ObjectType: to.Ptr("AzureBackupParams"),
	// 					},
	// 					DataStore: &armdataprotection.DataStoreInfoBase{
	// 						DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
	// 						ObjectType: to.Ptr("DataStoreInfoBase"),
	// 					},
	// 					ObjectType: to.Ptr("AzureBackupRule"),
	// 					Trigger: &armdataprotection.ScheduleBasedTriggerContext{
	// 						ObjectType: to.Ptr("ScheduleBasedTriggerContext"),
	// 						Schedule: &armdataprotection.BackupSchedule{
	// 							RepeatingTimeIntervals: []*string{
	// 								to.Ptr("R/2019-11-20T08:00:00-08:00/P1W"),
	// 							},
	// 						},
	// 						TaggingCriteria: []*armdataprotection.TaggingCriteria{
	// 							{
	// 								IsDefault: to.Ptr(true),
	// 								TagInfo: &armdataprotection.RetentionTag{
	// 									ID: to.Ptr("Default_"),
	// 									TagName: to.Ptr("Default"),
	// 								},
	// 								TaggingPriority: to.Ptr[int64](99),
	// 							},
	// 							{
	// 								Criteria: []armdataprotection.BackupCriteriaClassification{
	// 									&armdataprotection.ScheduleBasedBackupCriteria{
	// 										DaysOfTheWeek: []*armdataprotection.DayOfWeek{
	// 											to.Ptr(armdataprotection.DayOfWeekSunday),
	// 										},
	// 										ObjectType: to.Ptr("ScheduleBasedBackupCriteria"),
	// 										ScheduleTimes: []*time.Time{
	// 											to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()),
	// 										},
	// 									},
	// 								},
	// 								IsDefault: to.Ptr(false),
	// 								TagInfo: &armdataprotection.RetentionTag{
	// 									ID: to.Ptr("Weekly_"),
	// 									TagName: to.Ptr("Weekly"),
	// 								},
	// 								TaggingPriority: to.Ptr[int64](20),
	// 							},
	// 						},
	// 					},
	// 				},
	// 				&armdataprotection.AzureRetentionRule{
	// 					Name: to.Ptr("Default"),
	// 					IsDefault: to.Ptr(true),
	// 					Lifecycles: []*armdataprotection.SourceLifeCycle{
	// 						{
	// 							DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
	// 								Duration: to.Ptr("P1W"),
	// 								ObjectType: to.Ptr("AbsoluteDeleteOption"),
	// 							},
	// 							SourceDataStore: &armdataprotection.DataStoreInfoBase{
	// 								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
	// 								ObjectType: to.Ptr("DataStoreInfoBase"),
	// 							},
	// 						},
	// 					},
	// 					ObjectType: to.Ptr("AzureRetentionRule"),
	// 				},
	// 				&armdataprotection.AzureRetentionRule{
	// 					Name: to.Ptr("Weekly"),
	// 					IsDefault: to.Ptr(false),
	// 					Lifecycles: []*armdataprotection.SourceLifeCycle{
	// 						{
	// 							DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
	// 								Duration: to.Ptr("P12W"),
	// 								ObjectType: to.Ptr("AbsoluteDeleteOption"),
	// 							},
	// 							SourceDataStore: &armdataprotection.DataStoreInfoBase{
	// 								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
	// 								ObjectType: to.Ptr("DataStoreInfoBase"),
	// 							},
	// 						},
	// 					},
	// 					ObjectType: to.Ptr("AzureRetentionRule"),
	// 				},
	// 			},
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-07-01/PolicyCRUD/ListBackupPolicy.json
func ExampleBackupPoliciesClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdataprotection.NewClientFactory("04cf684a-d41f-4550-9f70-7708a3a2283b", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewBackupPoliciesClient().NewListPager("000pikumar", "PrivatePreviewVault", 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 = armdataprotection.BackupPoliciesClientListResponse{
		// 	BaseBackupPolicyResourceList: armdataprotection.BaseBackupPolicyResourceList{
		// 		Value: []*armdataprotection.BaseBackupPolicyResource{
		// 			{
		// 				Name: to.Ptr("OSSDBPolicy"),
		// 				Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies"),
		// 				ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PrivatePreviewVault/backupPolicies/OSSDBPolicy"),
		// 				Properties: &armdataprotection.BackupPolicy{
		// 					DatasourceTypes: []*string{
		// 						to.Ptr("OssDB"),
		// 					},
		// 					ObjectType: to.Ptr("BackupPolicy"),
		// 					PolicyRules: []armdataprotection.BasePolicyRuleClassification{
		// 						&armdataprotection.AzureBackupRule{
		// 							Name: to.Ptr("BackupWeekly"),
		// 							BackupParameters: &armdataprotection.AzureBackupParams{
		// 								BackupType: to.Ptr("Full"),
		// 								ObjectType: to.Ptr("AzureBackupParams"),
		// 							},
		// 							DataStore: &armdataprotection.DataStoreInfoBase{
		// 								DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
		// 								ObjectType: to.Ptr("DataStoreInfoBase"),
		// 							},
		// 							ObjectType: to.Ptr("AzureBackupRule"),
		// 							Trigger: &armdataprotection.ScheduleBasedTriggerContext{
		// 								ObjectType: to.Ptr("ScheduleBasedTriggerContext"),
		// 								Schedule: &armdataprotection.BackupSchedule{
		// 									RepeatingTimeIntervals: []*string{
		// 										to.Ptr("R/2019-11-20T08:00:00-08:00/P1W"),
		// 									},
		// 								},
		// 								TaggingCriteria: []*armdataprotection.TaggingCriteria{
		// 									{
		// 										IsDefault: to.Ptr(true),
		// 										TagInfo: &armdataprotection.RetentionTag{
		// 											ID: to.Ptr("Default_"),
		// 											TagName: to.Ptr("Default"),
		// 										},
		// 										TaggingPriority: to.Ptr[int64](99),
		// 									},
		// 									{
		// 										Criteria: []armdataprotection.BackupCriteriaClassification{
		// 											&armdataprotection.ScheduleBasedBackupCriteria{
		// 												DaysOfTheWeek: []*armdataprotection.DayOfWeek{
		// 													to.Ptr(armdataprotection.DayOfWeekSunday),
		// 												},
		// 												ObjectType: to.Ptr("ScheduleBasedBackupCriteria"),
		// 												ScheduleTimes: []*time.Time{
		// 													to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()),
		// 												},
		// 											},
		// 										},
		// 										IsDefault: to.Ptr(false),
		// 										TagInfo: &armdataprotection.RetentionTag{
		// 											ID: to.Ptr("Weekly_"),
		// 											TagName: to.Ptr("Weekly"),
		// 										},
		// 										TaggingPriority: to.Ptr[int64](20),
		// 									},
		// 								},
		// 							},
		// 						},
		// 						&armdataprotection.AzureRetentionRule{
		// 							Name: to.Ptr("Default"),
		// 							IsDefault: to.Ptr(true),
		// 							Lifecycles: []*armdataprotection.SourceLifeCycle{
		// 								{
		// 									DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
		// 										Duration: to.Ptr("P1W"),
		// 										ObjectType: to.Ptr("AbsoluteDeleteOption"),
		// 									},
		// 									SourceDataStore: &armdataprotection.DataStoreInfoBase{
		// 										DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
		// 										ObjectType: to.Ptr("DataStoreInfoBase"),
		// 									},
		// 								},
		// 							},
		// 							ObjectType: to.Ptr("AzureRetentionRule"),
		// 						},
		// 						&armdataprotection.AzureRetentionRule{
		// 							Name: to.Ptr("Weekly"),
		// 							IsDefault: to.Ptr(false),
		// 							Lifecycles: []*armdataprotection.SourceLifeCycle{
		// 								{
		// 									DeleteAfter: &armdataprotection.AbsoluteDeleteOption{
		// 										Duration: to.Ptr("P12W"),
		// 										ObjectType: to.Ptr("AbsoluteDeleteOption"),
		// 									},
		// 									SourceDataStore: &armdataprotection.DataStoreInfoBase{
		// 										DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore),
		// 										ObjectType: to.Ptr("DataStoreInfoBase"),
		// 									},
		// 								},
		// 							},
		// 							ObjectType: to.Ptr("AzureRetentionRule"),
		// 						},
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}
