// 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 armapimanagement_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/apimanagement/armapimanagement/v4"
	"log"
)

// Generated from example definition: 2025-09-01-preview/ApiManagementCreateWorkspaceApiDiagnostic.json
func ExampleWorkspaceAPIDiagnosticClient_CreateOrUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armapimanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewWorkspaceAPIDiagnosticClient().CreateOrUpdate(ctx, "rg1", "apimService1", "wks1", "57d1f7558aa04f15146d9d8a", "applicationinsights", armapimanagement.DiagnosticContract{
		Properties: &armapimanagement.DiagnosticContractProperties{
			AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors),
			Backend: &armapimanagement.PipelineDiagnosticSettings{
				Response: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
				Request: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
			},
			Frontend: &armapimanagement.PipelineDiagnosticSettings{
				Response: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
				Request: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
			},
			LoggerID: to.Ptr("/workspaces/wks1/loggers/applicationinsights"),
			Sampling: &armapimanagement.SamplingSettings{
				Percentage:   to.Ptr[float64](50),
				SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed),
			},
		},
	}, 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 = armapimanagement.WorkspaceAPIDiagnosticClientCreateOrUpdateResponse{
	// 	DiagnosticContract: armapimanagement.DiagnosticContract{
	// 		Name: to.Ptr("applicationinsights"),
	// 		Type: to.Ptr("Microsoft.ApiManagement/service/workspaces/apis/diagnostics"),
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/57d1f7558aa04f15146d9d8a/diagnostics/applicationinsights"),
	// 		Properties: &armapimanagement.DiagnosticContractProperties{
	// 			AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors),
	// 			Backend: &armapimanagement.PipelineDiagnosticSettings{
	// 				Response: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](512),
	// 					},
	// 					Headers: []*string{
	// 						to.Ptr("Content-type"),
	// 					},
	// 				},
	// 				Request: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](512),
	// 					},
	// 					Headers: []*string{
	// 						to.Ptr("Content-type"),
	// 					},
	// 				},
	// 			},
	// 			Frontend: &armapimanagement.PipelineDiagnosticSettings{
	// 				Response: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](512),
	// 					},
	// 					Headers: []*string{
	// 						to.Ptr("Content-type"),
	// 					},
	// 				},
	// 				Request: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](512),
	// 					},
	// 					Headers: []*string{
	// 						to.Ptr("Content-type"),
	// 					},
	// 				},
	// 			},
	// 			LoggerID: to.Ptr("/workspaces/wks1/loggers/applicationinsights"),
	// 			Sampling: &armapimanagement.SamplingSettings{
	// 				Percentage: to.Ptr[float64](50),
	// 				SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed),
	// 			},
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-09-01-preview/ApiManagementDeleteWorkspaceApiDiagnostic.json
func ExampleWorkspaceAPIDiagnosticClient_Delete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armapimanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewWorkspaceAPIDiagnosticClient().Delete(ctx, "rg1", "apimService1", "wks1", "57d1f7558aa04f15146d9d8a", "applicationinsights", "*", 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 = armapimanagement.WorkspaceAPIDiagnosticClientDeleteResponse{
	// }
}

// Generated from example definition: 2025-09-01-preview/ApiManagementGetWorkspaceApiDiagnostic.json
func ExampleWorkspaceAPIDiagnosticClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armapimanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewWorkspaceAPIDiagnosticClient().Get(ctx, "rg1", "apimService1", "wks1", "57d1f7558aa04f15146d9d8a", "applicationinsights", 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 = armapimanagement.WorkspaceAPIDiagnosticClientGetResponse{
	// 	DiagnosticContract: armapimanagement.DiagnosticContract{
	// 		Name: to.Ptr("applicationinsights"),
	// 		Type: to.Ptr("Microsoft.ApiManagement/service/workspaces/apis/diagnostics"),
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/diagnostics/applicationinsights"),
	// 		Properties: &armapimanagement.DiagnosticContractProperties{
	// 			AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors),
	// 			Backend: &armapimanagement.PipelineDiagnosticSettings{
	// 				Response: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 				Request: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 			},
	// 			Frontend: &armapimanagement.PipelineDiagnosticSettings{
	// 				Response: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 				Request: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 			},
	// 			HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy),
	// 			LogClientIP: to.Ptr(true),
	// 			LoggerID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/loggers/aisamplingtest"),
	// 			Sampling: &armapimanagement.SamplingSettings{
	// 				Percentage: to.Ptr[float64](100),
	// 				SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed),
	// 			},
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2025-09-01-preview/ApiManagementHeadWorkspaceApiDiagnostic.json
func ExampleWorkspaceAPIDiagnosticClient_GetEntityTag() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armapimanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewWorkspaceAPIDiagnosticClient().GetEntityTag(ctx, "rg1", "apimService1", "wks1", "57d1f7558aa04f15146d9d8a", "applicationinsights", 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 = armapimanagement.WorkspaceAPIDiagnosticClientGetEntityTagResponse{
	// }
}

// Generated from example definition: 2025-09-01-preview/ApiManagementListWorkspaceApiDiagnostics.json
func ExampleWorkspaceAPIDiagnosticClient_NewListByWorkspacePager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armapimanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewWorkspaceAPIDiagnosticClient().NewListByWorkspacePager("rg1", "apimService1", "wks1", "echo-api", 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 = armapimanagement.WorkspaceAPIDiagnosticClientListByWorkspaceResponse{
		// 	DiagnosticCollection: armapimanagement.DiagnosticCollection{
		// 		Count: to.Ptr[int64](1),
		// 		Value: []*armapimanagement.DiagnosticContract{
		// 			{
		// 				Name: to.Ptr("applicationinsights"),
		// 				Type: to.Ptr("Microsoft.ApiManagement/service/workspaces/apis/diagnostics"),
		// 				ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/diagnostics/applicationinsights"),
		// 				Properties: &armapimanagement.DiagnosticContractProperties{
		// 					AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors),
		// 					Backend: &armapimanagement.PipelineDiagnosticSettings{
		// 						Response: &armapimanagement.HTTPMessageDiagnostic{
		// 							Body: &armapimanagement.BodyDiagnosticSettings{
		// 								Bytes: to.Ptr[int32](100),
		// 							},
		// 							Headers: []*string{
		// 							},
		// 						},
		// 						Request: &armapimanagement.HTTPMessageDiagnostic{
		// 							Body: &armapimanagement.BodyDiagnosticSettings{
		// 								Bytes: to.Ptr[int32](100),
		// 							},
		// 							Headers: []*string{
		// 							},
		// 						},
		// 					},
		// 					Frontend: &armapimanagement.PipelineDiagnosticSettings{
		// 						Response: &armapimanagement.HTTPMessageDiagnostic{
		// 							Body: &armapimanagement.BodyDiagnosticSettings{
		// 								Bytes: to.Ptr[int32](100),
		// 							},
		// 							Headers: []*string{
		// 							},
		// 						},
		// 						Request: &armapimanagement.HTTPMessageDiagnostic{
		// 							Body: &armapimanagement.BodyDiagnosticSettings{
		// 								Bytes: to.Ptr[int32](100),
		// 							},
		// 							Headers: []*string{
		// 							},
		// 						},
		// 					},
		// 					HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy),
		// 					LogClientIP: to.Ptr(true),
		// 					LoggerID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/loggers/aisamplingtest"),
		// 					Sampling: &armapimanagement.SamplingSettings{
		// 						Percentage: to.Ptr[float64](100),
		// 						SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed),
		// 					},
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2025-09-01-preview/ApiManagementUpdateWorkspaceApiDiagnostic.json
func ExampleWorkspaceAPIDiagnosticClient_Update() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armapimanagement.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewWorkspaceAPIDiagnosticClient().Update(ctx, "rg1", "apimService1", "wks1", "echo-api", "applicationinsights", "*", armapimanagement.DiagnosticUpdateContract{
		Properties: &armapimanagement.DiagnosticContractUpdateProperties{
			AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors),
			Backend: &armapimanagement.PipelineDiagnosticSettings{
				Response: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
				Request: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
			},
			Frontend: &armapimanagement.PipelineDiagnosticSettings{
				Response: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
				Request: &armapimanagement.HTTPMessageDiagnostic{
					Body: &armapimanagement.BodyDiagnosticSettings{
						Bytes: to.Ptr[int32](512),
					},
					Headers: []*string{
						to.Ptr("Content-type"),
					},
				},
			},
			LoggerID: to.Ptr("/workspaces/wks1/loggers/applicationinsights"),
			Sampling: &armapimanagement.SamplingSettings{
				Percentage:   to.Ptr[float64](50),
				SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed),
			},
		},
	}, 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 = armapimanagement.WorkspaceAPIDiagnosticClientUpdateResponse{
	// 	DiagnosticContract: armapimanagement.DiagnosticContract{
	// 		Name: to.Ptr("applicationinsights"),
	// 		Type: to.Ptr("Microsoft.ApiManagement/service/workspaces/apis/diagnostics"),
	// 		ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/diagnostics/applicationinsights"),
	// 		Properties: &armapimanagement.DiagnosticContractProperties{
	// 			AlwaysLog: to.Ptr(armapimanagement.AlwaysLogAllErrors),
	// 			Backend: &armapimanagement.PipelineDiagnosticSettings{
	// 				Response: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 				Request: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 			},
	// 			Frontend: &armapimanagement.PipelineDiagnosticSettings{
	// 				Response: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 				Request: &armapimanagement.HTTPMessageDiagnostic{
	// 					Body: &armapimanagement.BodyDiagnosticSettings{
	// 						Bytes: to.Ptr[int32](100),
	// 					},
	// 					Headers: []*string{
	// 					},
	// 				},
	// 			},
	// 			HTTPCorrelationProtocol: to.Ptr(armapimanagement.HTTPCorrelationProtocolLegacy),
	// 			LogClientIP: to.Ptr(true),
	// 			LoggerID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/loggers/aisamplingtest"),
	// 			Sampling: &armapimanagement.SamplingSettings{
	// 				Percentage: to.Ptr[float64](100),
	// 				SamplingType: to.Ptr(armapimanagement.SamplingTypeFixed),
	// 			},
	// 		},
	// 	},
	// }
}
