// 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 armrelationships_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/relationships/armrelationships"
	"log"
)

// Generated from example definition: 2023-09-01-preview/DependencyOfRelationships_CreateOrUpdate.json
func ExampleDependencyOfRelationshipsClient_BeginCreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armrelationships.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDependencyOfRelationshipsClient().BeginCreateOrUpdate(ctx, "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account", "relationshipOne", armrelationships.DependencyOfRelationship{
		Properties: &armrelationships.DependencyOfRelationshipProperties{
			TargetID:     to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg123/providers/Microsoft.Web/staticSites/test-site"),
			TargetTenant: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
		},
	}, 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 = armrelationships.DependencyOfRelationshipsClientCreateOrUpdateResponse{
	// 	DependencyOfRelationship: armrelationships.DependencyOfRelationship{
	// 		Properties: &armrelationships.DependencyOfRelationshipProperties{
	// 			SourceID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"),
	// 			TargetID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg123/providers/Microsoft.Web/staticSites/test-site"),
	// 			TargetTenant: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
	// 			OriginInformation: &armrelationships.RelationshipOriginInformation{
	// 				RelationshipOriginType: to.Ptr(armrelationships.RelationshipOrigins("SystemExplicitlyCreated")),
	// 				DiscoveryEngine: to.Ptr("PEM"),
	// 			},
	// 			Metadata: &armrelationships.RelationshipMetadata{
	// 				SourceType: to.Ptr("Microsoft.DocumentDb/databaseAccounts"),
	// 				TargetType: to.Ptr("Microsoft.Web/staticSites"),
	// 			},
	// 			ProvisioningState: to.Ptr(armrelationships.ProvisioningStateSucceeded),
	// 		},
	// 		ID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account/providers/Microsoft.Relationships/dependencyOf/relationshipOne"),
	// 		Name: to.Ptr("relationshipOne"),
	// 		Type: to.Ptr("Microsoft.Relationships/dependencyOf"),
	// 	},
	// }
}

// Generated from example definition: 2023-09-01-preview/DependencyOfRelationships_Delete.json
func ExampleDependencyOfRelationshipsClient_BeginDelete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armrelationships.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDependencyOfRelationshipsClient().BeginDelete(ctx, "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account", "relationshipOne", 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: 2023-09-01-preview/DependencyOfRelationships_Get.json
func ExampleDependencyOfRelationshipsClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armrelationships.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewDependencyOfRelationshipsClient().Get(ctx, "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account", "relationshipOne", 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 = armrelationships.DependencyOfRelationshipsClientGetResponse{
	// 	DependencyOfRelationship: armrelationships.DependencyOfRelationship{
	// 		Properties: &armrelationships.DependencyOfRelationshipProperties{
	// 			SourceID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"),
	// 			TargetID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg123/providers/Microsoft.Web/staticSites/test-site"),
	// 			TargetTenant: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
	// 			OriginInformation: &armrelationships.RelationshipOriginInformation{
	// 				RelationshipOriginType: to.Ptr(armrelationships.RelationshipOrigins("SystemExplicitlyCreated")),
	// 				DiscoveryEngine: to.Ptr("PEM"),
	// 			},
	// 			Metadata: &armrelationships.RelationshipMetadata{
	// 				SourceType: to.Ptr("Microsoft.DocumentDb/databaseAccounts"),
	// 				TargetType: to.Ptr("Microsoft.Web/staticSites"),
	// 			},
	// 			ProvisioningState: to.Ptr(armrelationships.ProvisioningStateSucceeded),
	// 		},
	// 		ID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account/providers/Microsoft.Relationships/dependencyOf/relationshipOne"),
	// 		Name: to.Ptr("relationshipOne"),
	// 		Type: to.Ptr("Microsoft.Relationships/dependencyOf"),
	// 	},
	// }
}
