//go:build go1.18
// +build go1.18

// 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) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// DO NOT EDIT.

package armdatashare_test

import (
	"context"
	"log"

	"time"

	"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/datashare/armdatashare"
)

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/datashare/resource-manager/Microsoft.DataShare/stable/2020-09-01/examples/SynchronizationSettings_Get.json
func ExampleSynchronizationSettingsClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdatashare.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSynchronizationSettingsClient().Get(ctx, "SampleResourceGroup", "Account1", "Share1", "SynchronizationSetting1", 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 = armdatashare.SynchronizationSettingsClientGetResponse{
	// 	                            SynchronizationSettingClassification: &armdatashare.ScheduledSynchronizationSetting{
	// 		Name: to.Ptr("SynchronizationSetting1"),
	// 		Type: to.Ptr("Microsoft.DataShare/accounts/shares/synchronizationSettings"),
	// 		ID: to.Ptr("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.DataShare/accounts/Account1/shares/Share1/synchronizationSettings/SynchronizationSetting1"),
	// 		Kind: to.Ptr(armdatashare.SynchronizationSettingKindScheduleBased),
	// 		Properties: &armdatashare.ScheduledSynchronizationSettingProperties{
	// 			ProvisioningState: to.Ptr(armdatashare.ProvisioningStateSucceeded),
	// 			RecurrenceInterval: to.Ptr(armdatashare.RecurrenceIntervalDay),
	// 			SynchronizationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-14T04:47:52.961Z"); return t}()),
	// 			UserName: to.Ptr("John Smith"),
	// 		},
	// 	},
	// 	                        }
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/datashare/resource-manager/Microsoft.DataShare/stable/2020-09-01/examples/SynchronizationSettings_Create.json
func ExampleSynchronizationSettingsClient_Create() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdatashare.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewSynchronizationSettingsClient().Create(ctx, "SampleResourceGroup", "Account1", "Share1", "Dataset1", &armdatashare.ScheduledSynchronizationSetting{
		Kind: to.Ptr(armdatashare.SynchronizationSettingKindScheduleBased),
		Properties: &armdatashare.ScheduledSynchronizationSettingProperties{
			RecurrenceInterval:  to.Ptr(armdatashare.RecurrenceIntervalDay),
			SynchronizationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-14T04:47:52.961Z"); 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 = armdatashare.SynchronizationSettingsClientCreateResponse{
	// 	                            SynchronizationSettingClassification: &armdatashare.ScheduledSynchronizationSetting{
	// 		Name: to.Ptr("SynchronizationSetting1"),
	// 		Type: to.Ptr("Microsoft.DataShare/accounts/shares/synchronizationSettings"),
	// 		ID: to.Ptr("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.DataShare/accounts/Account1/shares/Share1/synchronizationSettings/SynchronizationSetting1"),
	// 		Kind: to.Ptr(armdatashare.SynchronizationSettingKindScheduleBased),
	// 		Properties: &armdatashare.ScheduledSynchronizationSettingProperties{
	// 			ProvisioningState: to.Ptr(armdatashare.ProvisioningStateSucceeded),
	// 			RecurrenceInterval: to.Ptr(armdatashare.RecurrenceIntervalDay),
	// 			SynchronizationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-14T04:47:52.961Z"); return t}()),
	// 			UserName: to.Ptr("John Smith"),
	// 		},
	// 	},
	// 	                        }
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/datashare/resource-manager/Microsoft.DataShare/stable/2020-09-01/examples/SynchronizationSettings_Delete.json
func ExampleSynchronizationSettingsClient_BeginDelete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdatashare.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewSynchronizationSettingsClient().BeginDelete(ctx, "SampleResourceGroup", "Account1", "Share1", "SynchronizationSetting1", 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 pull 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.OperationResponse = armdatashare.OperationResponse{
	// 	Status: to.Ptr(armdatashare.StatusSucceeded),
	// }
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/datashare/resource-manager/Microsoft.DataShare/stable/2020-09-01/examples/SynchronizationSettings_ListByShare.json
func ExampleSynchronizationSettingsClient_NewListBySharePager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdatashare.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewSynchronizationSettingsClient().NewListBySharePager("SampleResourceGroup", "Account1", "Share1", &armdatashare.SynchronizationSettingsClientListByShareOptions{SkipToken: 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.SynchronizationSettingList = armdatashare.SynchronizationSettingList{
		// 	Value: []armdatashare.SynchronizationSettingClassification{
		// 		&armdatashare.ScheduledSynchronizationSetting{
		// 			Name: to.Ptr("SynchronizationSetting1"),
		// 			Type: to.Ptr("Microsoft.DataShare/accounts/shares/synchronizationSettings"),
		// 			ID: to.Ptr("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.DataShare/accounts/Account1/shares/Share1/synchronizationSettings/SynchronizationSetting1"),
		// 			Kind: to.Ptr(armdatashare.SynchronizationSettingKindScheduleBased),
		// 			Properties: &armdatashare.ScheduledSynchronizationSettingProperties{
		// 				RecurrenceInterval: to.Ptr(armdatashare.RecurrenceIntervalDay),
		// 				SynchronizationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-14T04:47:52.961Z"); return t}()),
		// 				UserName: to.Ptr("John Smith"),
		// 			},
		// 	}},
		// }
	}
}
