// 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 armresourcegraph_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/resourcegraph/armresourcegraph"
	"log"
)

// Generated from example definition: 2024-04-01/GraphQueryAdd.json
func ExampleGraphQueryClient_CreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcegraph.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewGraphQueryClient("024e2271-06fa-46b6-9079-f1ed3c7b070e").CreateOrUpdate(ctx, "my-resource-group", "MyDockerVMs", armresourcegraph.GraphQueryResource{
		Properties: &armresourcegraph.GraphQueryProperties{
			Description: to.Ptr("Docker VMs in PROD"),
			Query:       to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
		},
		Tags: map[string]*string{},
	}, 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 = armresourcegraph.GraphQueryClientCreateOrUpdateResponse{
	// 	GraphQueryResource: armresourcegraph.GraphQueryResource{
	// 		Name: to.Ptr("MyDockerVMs"),
	// 		Type: to.Ptr("Microsoft.ResourceGraph/queries"),
	// 		Etag: to.Ptr("5d64408e-4ca3-41f7-b725-6914f3012afa"),
	// 		ID: to.Ptr("/subscriptions/024e2271-06fa-46b6-9079-f1ed3c7b070e/resourceGroups/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs"),
	// 		Properties: &armresourcegraph.GraphQueryProperties{
	// 			Description: to.Ptr("Docker VMs in PROD"),
	// 			Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
	// 			ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
	// 			TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-12T13:51:13-07:00"); return t}()),
	// 		},
	// 		Tags: map[string]*string{
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2024-04-01/GraphQueryDelete.json
func ExampleGraphQueryClient_Delete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcegraph.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewGraphQueryClient("024e2271-06fa-46b6-9079-f1ed3c7b070e").Delete(ctx, "my-resource-group", "MyDockerVM", 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 = armresourcegraph.GraphQueryClientDeleteResponse{
	// }
}

// Generated from example definition: 2024-04-01/GraphQueryGet.json
func ExampleGraphQueryClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcegraph.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewGraphQueryClient("024e2271-06fa-46b6-9079-f1ed3c7b070e").Get(ctx, "my-resource-group", "MyDockerVMs", 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 = armresourcegraph.GraphQueryClientGetResponse{
	// 	GraphQueryResource: armresourcegraph.GraphQueryResource{
	// 		Name: to.Ptr("MyDockerVMs"),
	// 		Type: to.Ptr("Microsoft.ResourceGraph/queries"),
	// 		Etag: to.Ptr("5d64408e-4ca3-41f7-b725-6914f3012afa"),
	// 		ID: to.Ptr("/subscriptions/024e2271-06fa-46b6-9079-f1ed3c7b070e/resourceGroups/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs"),
	// 		Properties: &armresourcegraph.GraphQueryProperties{
	// 			Description: to.Ptr("Docker VMs in PROD"),
	// 			Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
	// 			ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
	// 			TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-12T13:51:13-07:00"); return t}()),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2024-04-01/GraphQueryList1.json
func ExampleGraphQueryClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcegraph.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewGraphQueryClient("024e2271-06fa-46b6-9079-f1ed3c7b070e").NewListPager("my-resource-group", 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 = armresourcegraph.GraphQueryClientListResponse{
		// 	GraphQueryListResult: armresourcegraph.GraphQueryListResult{
		// 		NextLink: to.Ptr("https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.ResourceGraph/queries?api-version=2019-09-01-preview&$top=10&$skiptoken=skiptoken"),
		// 		Value: []*armresourcegraph.GraphQueryResource{
		// 			{
		// 				Name: to.Ptr("MyDockerVMs"),
		// 				Type: to.Ptr("Microsoft.ResourceGraph/queries"),
		// 				Etag: to.Ptr("5d64408e-4ca3-41f7-b725-6914f3012afa"),
		// 				ID: to.Ptr("/subscriptions/87f4f8b0-83c1-4aa9-b318-5237aeb15264/resourceGroups/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs"),
		// 				Properties: &armresourcegraph.GraphQueryProperties{
		// 					Description: to.Ptr("Docker VMs in PROD"),
		// 					Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
		// 					ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
		// 					TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-12T13:51:13-07:00"); return t}()),
		// 				},
		// 				Tags: map[string]*string{
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("MyTestVMs"),
		// 				Type: to.Ptr("Microsoft.ResourceGraph/queries"),
		// 				Etag: to.Ptr("b0809832-ca62-4133-8f13-0c46580f9db1"),
		// 				ID: to.Ptr("/subscriptions/6abb2f31-3e6a-4134-9968-219a596012a0/resourceGroups/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyTestVMs"),
		// 				Properties: &armresourcegraph.GraphQueryProperties{
		// 					Description: to.Ptr("Test VMs in PROD"),
		// 					Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'test'"),
		// 					ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
		// 					TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-13T13:51:13-07:00"); return t}()),
		// 				},
		// 				Tags: map[string]*string{
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2024-04-01/GraphQueryList.json
func ExampleGraphQueryClient_NewListBySubscriptionPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcegraph.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewGraphQueryClient("024e2271-06fa-46b6-9079-f1ed3c7b070e").NewListBySubscriptionPager(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 = armresourcegraph.GraphQueryClientListBySubscriptionResponse{
		// 	GraphQueryListResult: armresourcegraph.GraphQueryListResult{
		// 		NextLink: to.Ptr("https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.ResourceGraph/queries?api-version=2019-09-01-preview&$top=10&$skiptoken=skiptoken"),
		// 		Value: []*armresourcegraph.GraphQueryResource{
		// 			{
		// 				Name: to.Ptr("MyDockerVMs"),
		// 				Type: to.Ptr("Microsoft.ResourceGraph/queries"),
		// 				Etag: to.Ptr("5d64408e-4ca3-41f7-b725-6914f3012afa"),
		// 				ID: to.Ptr("/subscriptions/87f4f8b0-83c1-4aa9-b318-5237aeb15264/resourceGroups/rid1/providers/Microsoft.ResourceGraph/queries/MyDockerVMs"),
		// 				Properties: &armresourcegraph.GraphQueryProperties{
		// 					Description: to.Ptr("Docker VMs in PROD"),
		// 					Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
		// 					ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
		// 					TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-12T13:51:13-07:00"); return t}()),
		// 				},
		// 				Tags: map[string]*string{
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("MyTestVMs"),
		// 				Type: to.Ptr("Microsoft.ResourceGraph/queries"),
		// 				Etag: to.Ptr("b0809832-ca62-4133-8f13-0c46580f9db1"),
		// 				ID: to.Ptr("/subscriptions/6abb2f31-3e6a-4134-9968-219a596012a0/resourceGroups/rid2/providers/Microsoft.ResourceGraph/queries/MyTestVMs"),
		// 				Properties: &armresourcegraph.GraphQueryProperties{
		// 					Description: to.Ptr("Test VMs in PROD"),
		// 					Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'test'"),
		// 					ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
		// 					TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-13T13:51:13-07:00"); return t}()),
		// 				},
		// 				Tags: map[string]*string{
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2024-04-01/GraphQueryUpdate.json
func ExampleGraphQueryClient_Update() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armresourcegraph.NewClientFactory(cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewGraphQueryClient("024e2271-06fa-46b6-9079-f1ed3c7b070e").Update(ctx, "my-resource-group", "MyDockerVMs", armresourcegraph.GraphQueryUpdateParameters{
		Etag: to.Ptr("b0809832-ca62-4133-8f13-0c46580f9db1"),
		Properties: &armresourcegraph.GraphQueryPropertiesUpdateParameters{
			Description: to.Ptr("Modified description"),
			Query:       to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
		},
	}, 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 = armresourcegraph.GraphQueryClientUpdateResponse{
	// 	GraphQueryResource: armresourcegraph.GraphQueryResource{
	// 		Name: to.Ptr("MyDockerVMs"),
	// 		Type: to.Ptr("Microsoft.ResourceGraph/queries"),
	// 		Etag: to.Ptr("73811091-6188-4523-97b7-b5e7134e7fd9"),
	// 		ID: to.Ptr("/subscriptions/024e2271-06fa-46b6-9079-f1ed3c7b070e/resourceGroups/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs"),
	// 		Properties: &armresourcegraph.GraphQueryProperties{
	// 			Description: to.Ptr("Modified description"),
	// 			Query: to.Ptr("where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'"),
	// 			ResultKind: to.Ptr(armresourcegraph.ResultKindBasic),
	// 			TimeModified: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-14T13:51:13-07:00"); return t}()),
	// 		},
	// 	},
	// }
}
