// 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 armdeviceregistry_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/deviceregistry/armdeviceregistry/v2"
	"log"
)

// Generated from example definition: 2026-03-01-preview/CreateOrReplace_NamespaceDevice.json
func ExampleNamespaceDevicesClient_BeginCreateOrReplace_createOrReplaceNamespaceDevices() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginCreateOrReplace(ctx, "myResourceGroup", "adr-namespace-gbk0925-n01", "dev-namespace-gbk0925-n01", armdeviceregistry.NamespaceDevice{
		Location: to.Ptr("West Europe"),
		Properties: &armdeviceregistry.NamespaceDeviceProperties{
			Endpoints: &armdeviceregistry.MessagingEndpoints{
				Outbound: &armdeviceregistry.OutboundEndpoints{
					Assigned: map[string]*armdeviceregistry.DeviceMessagingEndpoint{
						"iothubEndpoint": {
							EndpointType: to.Ptr("Microsoft.Devices/IotHubs"),
							Address:      to.Ptr("https://iothub-for-dps.azure-devices.net"),
						},
					},
				},
			},
			Enabled: to.Ptr(true),
			Attributes: map[string]any{
				"deviceType":     "sensor",
				"deviceOwner":    "IT",
				"deviceCategory": 16,
			},
		},
	}, 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 = armdeviceregistry.NamespaceDevicesClientCreateOrReplaceResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/microsoft.deviceregistry/namespaces/my-namespace-1/devices/adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Name: to.Ptr("adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Type: to.Ptr("microsoft.deviceregistry/namespaces/devices"),
	// 		Location: to.Ptr("North Europe"),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			Endpoints: &armdeviceregistry.MessagingEndpoints{
	// 				Outbound: &armdeviceregistry.OutboundEndpoints{
	// 					Assigned: map[string]*armdeviceregistry.DeviceMessagingEndpoint{
	// 						"iothubEndpoint": &armdeviceregistry.DeviceMessagingEndpoint{
	// 							EndpointType: to.Ptr("Microsoft.Devices/IotHubs"),
	// 							Address: to.Ptr("https://iothub-for-dps.azure-devices.net"),
	// 						},
	// 					},
	// 				},
	// 			},
	// 			Enabled: to.Ptr(true),
	// 			Attributes: map[string]any{
	// 				"deviceType": "sensor",
	// 				"deviceOwner": "IT",
	// 				"deviceCategory": 16,
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/CreateOrReplace_NamespaceDevice_Edge_Anonymous.json
func ExampleNamespaceDevicesClient_BeginCreateOrReplace_createEdgeEnabledDeviceWithAnonymousHostAuthentication() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginCreateOrReplace(ctx, "myResourceGroup", "adr-namespace-gbk0925-n01", "namespace-device-on-edge", armdeviceregistry.NamespaceDevice{
		ExtendedLocation: &armdeviceregistry.ExtendedLocation{
			Type: to.Ptr("CustomLocation"),
			Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"),
		},
		Location: to.Ptr("West Europe"),
		Properties: &armdeviceregistry.NamespaceDeviceProperties{
			Endpoints: &armdeviceregistry.MessagingEndpoints{
				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
					"theOnlyOPCUABroker": {
						Address:      to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
						EndpointType: to.Ptr("microsoft.opcua:v1"),
						Version:      to.Ptr("2"),
						Authentication: &armdeviceregistry.HostAuthentication{
							Method: to.Ptr(armdeviceregistry.AuthenticationMethodAnonymous),
						},
					},
				},
			},
			ExternalDeviceID: to.Ptr("unique-edge-device-identifier"),
			Enabled:          to.Ptr(true),
			Attributes: map[string]any{
				"deviceType":     "dough-maker",
				"deviceOwner":    "OT",
				"deviceCategory": 16,
			},
		},
	}, 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 = armdeviceregistry.NamespaceDevicesClientCreateOrReplaceResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/microsoft.deviceregistry/namespaces/my-namespace-1/devices/adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Name: to.Ptr("namespace-device-on-edge"),
	// 		Type: to.Ptr("microsoft.deviceregistry/namespaces/devices"),
	// 		Location: to.Ptr("West Europe"),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity,rotation"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			UUID: to.Ptr("3575e690-31d7-4168-a6c9-9ff1b9eed282"),
	// 			Endpoints: &armdeviceregistry.MessagingEndpoints{
	// 				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
	// 					"myonlyOPCUABroker": &armdeviceregistry.InboundEndpoints{
	// 						Address: to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
	// 						EndpointType: to.Ptr("microsoft.opcua:v1"),
	// 						Version: to.Ptr("2"),
	// 						Authentication: &armdeviceregistry.HostAuthentication{
	// 							Method: to.Ptr(armdeviceregistry.AuthenticationMethodAnonymous),
	// 						},
	// 					},
	// 				},
	// 			},
	// 			ExternalDeviceID: to.Ptr("unique-edge-device-identifier"),
	// 			Enabled: to.Ptr(true),
	// 			Attributes: map[string]any{
	// 				"deviceType": "dough-maker",
	// 				"deviceOwner": "OT",
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/CreateOrReplace_NamespaceDevice_Edge_UsernamePass.json
func ExampleNamespaceDevicesClient_BeginCreateOrReplace_createEdgeEnabledDeviceWithUsernamesPasswordInboundAuthentication() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginCreateOrReplace(ctx, "myResourceGroup", "adr-namespace-gbk0925-n01", "namespace-device-on-edge", armdeviceregistry.NamespaceDevice{
		ExtendedLocation: &armdeviceregistry.ExtendedLocation{
			Type: to.Ptr("CustomLocation"),
			Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"),
		},
		Location: to.Ptr("West Europe"),
		Properties: &armdeviceregistry.NamespaceDeviceProperties{
			Endpoints: &armdeviceregistry.MessagingEndpoints{
				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
					"theOnlyOPCUABroker": {
						Address:      to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
						EndpointType: to.Ptr("microsoft.opcua:v1"),
						Version:      to.Ptr("2"),
						Authentication: &armdeviceregistry.HostAuthentication{
							Method: to.Ptr(armdeviceregistry.AuthenticationMethodUsernamePassword),
							UsernamePasswordCredentials: &armdeviceregistry.UsernamePasswordCredentials{
								UsernameSecretName: to.Ptr("user-ref"),
								PasswordSecretName: to.Ptr("pwd-ref"),
							},
						},
					},
				},
			},
			ExternalDeviceID: to.Ptr("unique-edge-device-identifier"),
			Enabled:          to.Ptr(true),
			Attributes: map[string]any{
				"deviceType":     "sensor",
				"deviceOwner":    "IT",
				"deviceCategory": 16,
			},
		},
	}, 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 = armdeviceregistry.NamespaceDevicesClientCreateOrReplaceResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/microsoft.deviceregistry/namespaces/my-namespace-1/devices/adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Name: to.Ptr("namespace-device-on-edge"),
	// 		Type: to.Ptr("microsoft.deviceregistry/namespaces/devices"),
	// 		Location: to.Ptr("West Europe"),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity,rotation"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			UUID: to.Ptr("3575e690-31d7-4168-a6c9-9ff1b9eed282"),
	// 			Endpoints: &armdeviceregistry.MessagingEndpoints{
	// 				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
	// 					"theOnlyOPCUABroker": &armdeviceregistry.InboundEndpoints{
	// 						Address: to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
	// 						EndpointType: to.Ptr("microsoft.opcua:v1"),
	// 						Version: to.Ptr("2"),
	// 						Authentication: &armdeviceregistry.HostAuthentication{
	// 							Method: to.Ptr(armdeviceregistry.AuthenticationMethodUsernamePassword),
	// 							UsernamePasswordCredentials: &armdeviceregistry.UsernamePasswordCredentials{
	// 								UsernameSecretName: to.Ptr("user-ref"),
	// 								PasswordSecretName: to.Ptr("pwd-ref"),
	// 							},
	// 						},
	// 					},
	// 				},
	// 			},
	// 			ExternalDeviceID: to.Ptr("unique-edge-device-identifier"),
	// 			Enabled: to.Ptr(true),
	// 			Attributes: map[string]any{
	// 				"deviceType": "dough-maker",
	// 				"deviceOwner": "IT",
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/CreateOrReplace_NamespaceDevice_Edge_x509.json
func ExampleNamespaceDevicesClient_BeginCreateOrReplace_createEdgeEnabledDeviceWithX509InboundAuthentication() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginCreateOrReplace(ctx, "myResourceGroup", "adr-namespace-gbk0925-n01", "namespace-device-on-edge", armdeviceregistry.NamespaceDevice{
		ExtendedLocation: &armdeviceregistry.ExtendedLocation{
			Type: to.Ptr("CustomLocation"),
			Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"),
		},
		Location: to.Ptr("West Europe"),
		Properties: &armdeviceregistry.NamespaceDeviceProperties{
			Endpoints: &armdeviceregistry.MessagingEndpoints{
				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
					"theV1OPCUAEndpoint": {
						Address:      to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
						EndpointType: to.Ptr("microsoft.opcua"),
						Version:      to.Ptr("2"),
						Authentication: &armdeviceregistry.HostAuthentication{
							Method: to.Ptr(armdeviceregistry.AuthenticationMethodCertificate),
							X509Credentials: &armdeviceregistry.X509CertificateCredentials{
								CertificateSecretName: to.Ptr("cert-secret"),
							},
						},
					},
					"theV2OPCUAEndpoint": {
						Address:      to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
						EndpointType: to.Ptr("microsoft.opcua"),
						Version:      to.Ptr("2"),
						Authentication: &armdeviceregistry.HostAuthentication{
							Method: to.Ptr(armdeviceregistry.AuthenticationMethodCertificate),
							X509Credentials: &armdeviceregistry.X509CertificateCredentials{
								CertificateSecretName: to.Ptr("cert-secret"),
							},
						},
						TrustSettings: &armdeviceregistry.TrustSettings{
							TrustList: to.Ptr("trust-secret-reference"),
						},
					},
				},
			},
			ExternalDeviceID: to.Ptr("unique-edge-device-identifier"),
			Enabled:          to.Ptr(true),
			Attributes: map[string]any{
				"deviceType":     "OPCUAServers",
				"deviceOwner":    "OT",
				"deviceCategory": 16,
			},
		},
	}, 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 = armdeviceregistry.NamespaceDevicesClientCreateOrReplaceResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/microsoft.deviceregistry/namespaces/my-namespace-1/devices/adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Name: to.Ptr("namespace-device-on-edge"),
	// 		Type: to.Ptr("microsoft.deviceregistry/namespaces/devices"),
	// 		Location: to.Ptr("West Europe"),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity,rotation"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			UUID: to.Ptr("3575e690-31d7-4168-a6c9-9ff1b9eed282"),
	// 			Endpoints: &armdeviceregistry.MessagingEndpoints{
	// 				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
	// 					"theV1OPCUAEndpoint": &armdeviceregistry.InboundEndpoints{
	// 						Address: to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
	// 						EndpointType: to.Ptr("microsoft.opcua"),
	// 						Version: to.Ptr("2"),
	// 						Authentication: &armdeviceregistry.HostAuthentication{
	// 							Method: to.Ptr(armdeviceregistry.AuthenticationMethodCertificate),
	// 							X509Credentials: &armdeviceregistry.X509CertificateCredentials{
	// 								CertificateSecretName: to.Ptr("cert-secret"),
	// 							},
	// 						},
	// 					},
	// 					"theV2OPCUAEndpoint": &armdeviceregistry.InboundEndpoints{
	// 						Address: to.Ptr("opc.tcp://192.168.86.23:51211/UA/SampleServer"),
	// 						EndpointType: to.Ptr("microsoft.opcua"),
	// 						Version: to.Ptr("2"),
	// 						Authentication: &armdeviceregistry.HostAuthentication{
	// 							Method: to.Ptr(armdeviceregistry.AuthenticationMethodCertificate),
	// 							X509Credentials: &armdeviceregistry.X509CertificateCredentials{
	// 								CertificateSecretName: to.Ptr("cert-secret"),
	// 							},
	// 						},
	// 						TrustSettings: &armdeviceregistry.TrustSettings{
	// 							TrustList: to.Ptr("trust-secret-reference"),
	// 						},
	// 					},
	// 				},
	// 			},
	// 			ExternalDeviceID: to.Ptr("unique-edge-device-identifier"),
	// 			Enabled: to.Ptr(true),
	// 			Attributes: map[string]any{
	// 				"deviceType": "OPCUAServers",
	// 				"deviceOwner": "OT",
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/Delete_NamespaceDevice.json
func ExampleNamespaceDevicesClient_BeginDelete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginDelete(ctx, "myResourceGroup", "adr-namespace-gbk0925-n01", "adr-device-gbk0925-n01", 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: 2026-03-01-preview/Get_NamespaceDevice.json
func ExampleNamespaceDevicesClient_Get_getNamespaceDevice() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewNamespaceDevicesClient().Get(ctx, "myResourceGroup", "my-namespace-1", "my-device-name", 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 = armdeviceregistry.NamespaceDevicesClientGetResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/Microsoft.DeviceRegistry/namespaces/my-namespace-1/devices/adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
	// 		Name: to.Ptr("adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
	// 		Type: to.Ptr("Microsoft.DeviceRegistry/namespaces/devices"),
	// 		Location: to.Ptr("North Europe"),
	// 		Etag: to.Ptr("\"c80325f9-0000-0800-0000-66fcb0290000\""),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			ExternalDeviceID: to.Ptr("adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
	// 			Enabled: to.Ptr(true),
	// 			Attributes: map[string]any{
	// 				"deviceType": "sensor",
	// 				"deviceOwner": "IT",
	// 				"deviceCategory": 16,
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/Get_NamespaceDeviceWithEndpointErrorStatus.json
func ExampleNamespaceDevicesClient_Get_getNamespaceDeviceWithEndpointErrorStatus() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := clientFactory.NewNamespaceDevicesClient().Get(ctx, "myResourceGroup", "my-namespace-1", "my-device-name", 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 = armdeviceregistry.NamespaceDevicesClientGetResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/Microsoft.DeviceRegistry/namespaces/my-namespace-1/devices/adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
	// 		Name: to.Ptr("adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
	// 		Type: to.Ptr("Microsoft.DeviceRegistry/namespaces/devices"),
	// 		Location: to.Ptr("North Europe"),
	// 		ExtendedLocation: &armdeviceregistry.ExtendedLocation{
	// 			Type: to.Ptr("CustomLocation"),
	// 			Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"),
	// 		},
	// 		Etag: to.Ptr("\"c80325f9-0000-0800-0000-66fcb0290000\""),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			Endpoints: &armdeviceregistry.MessagingEndpoints{
	// 				Inbound: map[string]*armdeviceregistry.InboundEndpoints{
	// 					"myOPCUABroker": &armdeviceregistry.InboundEndpoints{
	// 						Address: to.Ptr("opc.tcp://foo"),
	// 						EndpointType: to.Ptr("microsoft.opcua"),
	// 						Version: to.Ptr("2"),
	// 						Authentication: &armdeviceregistry.HostAuthentication{
	// 							Method: to.Ptr(armdeviceregistry.AuthenticationMethodCertificate),
	// 							X509Credentials: &armdeviceregistry.X509CertificateCredentials{
	// 								CertificateSecretName: to.Ptr("certificateSecretName"),
	// 							},
	// 						},
	// 					},
	// 				},
	// 			},
	// 			Version: to.Ptr[int64](1),
	// 			Status: &armdeviceregistry.DeviceStatus{
	// 				Config: &armdeviceregistry.StatusConfig{
	// 					Version: to.Ptr[int64](2),
	// 					LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
	// 				},
	// 				Endpoints: &armdeviceregistry.DeviceStatusEndpoints{
	// 					Inbound: map[string]*armdeviceregistry.DeviceStatusEndpoint{
	// 						"myOPCUABroker": &armdeviceregistry.DeviceStatusEndpoint{
	// 							Error: &armdeviceregistry.StatusError{
	// 								Code: to.Ptr("InvalidCertificate"),
	// 								Message: to.Ptr("The client certificate is invalid."),
	// 								Details: []*armdeviceregistry.ErrorDetails{
	// 									{
	// 										Code: to.Ptr("InvalidCertificate"),
	// 										Message: to.Ptr("The certificate is invalid."),
	// 									},
	// 								},
	// 							},
	// 						},
	// 					},
	// 				},
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}

// Generated from example definition: 2026-03-01-preview/List_NamespaceDevices_ByResourceGroup.json
func ExampleNamespaceDevicesClient_NewListByResourceGroupPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewNamespaceDevicesClient().NewListByResourceGroupPager("myResourceGroup", "adr-namespace-gbk0925-n01", 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 = armdeviceregistry.NamespaceDevicesClientListByResourceGroupResponse{
		// 	NamespaceDeviceListResult: armdeviceregistry.NamespaceDeviceListResult{
		// 		Value: []*armdeviceregistry.NamespaceDevice{
		// 			{
		// 				ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/Microsoft.DeviceRegistry/namespaces/my-namespace-1/devices/adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
		// 				Name: to.Ptr("adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
		// 				Type: to.Ptr("Microsoft.DeviceRegistry/namespaces/devices"),
		// 				Location: to.Ptr("North Europe"),
		// 				Etag: to.Ptr("\"c80325f9-0000-0800-0000-66fcb0290000\""),
		// 				Tags: map[string]*string{
		// 					"sensor": to.Ptr("temperature,humidity"),
		// 				},
		// 				SystemData: &armdeviceregistry.SystemData{
		// 					CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
		// 					CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
		// 					CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
		// 					LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
		// 					LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
		// 					LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T02:30:01.6394987Z"); return t}()),
		// 				},
		// 				Properties: &armdeviceregistry.NamespaceDeviceProperties{
		// 					ExternalDeviceID: to.Ptr("adr-smart-device3-f191f536-f652-4eb4-b9a0-1a9d43300cab"),
		// 					Enabled: to.Ptr(true),
		// 					Attributes: map[string]any{
		// 						"deviceType": "sensor",
		// 						"deviceOwner": "IT",
		// 						"deviceCategory": 16,
		// 					},
		// 					ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
		// 				},
		// 			},
		// 			{
		// 				ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/Microsoft.DeviceRegistry/namespaces/my-namespace-1/devices/adr-smart-device3-67b8b41c-25e9-479a-884e-5502a5e9afbd"),
		// 				Name: to.Ptr("adr-smart-device3-67b8b41c-25e9-479a-884e-5502a5e9afbd"),
		// 				Type: to.Ptr("Microsoft.DeviceRegistry/namespaces/devices"),
		// 				Location: to.Ptr("North Europe"),
		// 				Etag: to.Ptr("\"e103c7dc-0000-0800-0000-66fda99c0000\""),
		// 				Tags: map[string]*string{
		// 					"sensor": to.Ptr("temperature,humidity"),
		// 				},
		// 				SystemData: &armdeviceregistry.SystemData{
		// 					CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
		// 					CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
		// 					CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:14:20.0968397Z"); return t}()),
		// 					LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
		// 					LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
		// 					LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:14:20.0968397Z"); return t}()),
		// 				},
		// 				Properties: &armdeviceregistry.NamespaceDeviceProperties{
		// 					Endpoints: &armdeviceregistry.MessagingEndpoints{
		// 						Outbound: &armdeviceregistry.OutboundEndpoints{
		// 							Assigned: map[string]*armdeviceregistry.DeviceMessagingEndpoint{
		// 								"iothubEndpoint": &armdeviceregistry.DeviceMessagingEndpoint{
		// 									EndpointType: to.Ptr("Microsoft.Devices/IotHubs"),
		// 									Address: to.Ptr("https://iothub-for-dps.azure-devices.net"),
		// 								},
		// 							},
		// 						},
		// 					},
		// 					ExternalDeviceID: to.Ptr("adr-smart-device3-67b8b41c-25e9-479a-884e-5502a5e9afbd"),
		// 					Enabled: to.Ptr(true),
		// 					Attributes: map[string]any{
		// 						"deviceType": "sensor",
		// 						"deviceOwner": "IT",
		// 						"deviceCategory": 16,
		// 					},
		// 					ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2026-03-01-preview/NamespaceDevices_Revoke.json
func ExampleNamespaceDevicesClient_BeginRevoke_namespaceDevicesRevoke() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginRevoke(ctx, "rgdeviceregistry", "mynamespace", "device1", armdeviceregistry.DeviceCredentialsRevokeRequest{
		Disable: to.Ptr(true),
	}, 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 = armdeviceregistry.NamespaceDevicesClientRevokeResponse{
	// }
}

// Generated from example definition: 2026-03-01-preview/NamespaceDevices_RevokeFailure.json
func ExampleNamespaceDevicesClient_BeginRevoke_namespaceDevicesRevokeFailure() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginRevoke(ctx, "rgdeviceregistry", "mynamespace", "device1", armdeviceregistry.DeviceCredentialsRevokeRequest{
		Disable: to.Ptr(true),
	}, 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 = armdeviceregistry.NamespaceDevicesClientRevokeResponse{
	// }
}

// Generated from example definition: 2026-03-01-preview/Update_NamespaceDevice.json
func ExampleNamespaceDevicesClient_BeginUpdate() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armdeviceregistry.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewNamespaceDevicesClient().BeginUpdate(ctx, "myResourceGroup", "adr-namespace-gbk0925-n01", "dev-namespace-gbk0925-n01", armdeviceregistry.NamespaceDeviceUpdate{
		Properties: &armdeviceregistry.NamespaceDeviceUpdateProperties{
			Endpoints: &armdeviceregistry.MessagingEndpoints{
				Outbound: &armdeviceregistry.OutboundEndpoints{
					Assigned: map[string]*armdeviceregistry.DeviceMessagingEndpoint{
						"iothubEndpoint": {
							EndpointType: to.Ptr("Microsoft.Devices/IotHubs"),
							Address:      to.Ptr("https://iothub-for-dps.azure-devices.net"),
						},
					},
				},
			},
			Enabled: to.Ptr(true),
			Attributes: map[string]any{
				"deviceType":     "sensor",
				"deviceOwner":    "IT",
				"deviceCategory": 16,
			},
		},
	}, 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 = armdeviceregistry.NamespaceDevicesClientUpdateResponse{
	// 	NamespaceDevice: armdeviceregistry.NamespaceDevice{
	// 		ID: to.Ptr("/subscriptions/00000000-1366-430f-0000-cc873bcf2d27/resourceGroups/gbktestRG/providers/Microsoft.DeviceRegistry/namespaces/my-namespace-1/devices/adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Name: to.Ptr("adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 		Type: to.Ptr("Microsoft.DeviceRegistry/namespaces/devices"),
	// 		Location: to.Ptr("North Europe"),
	// 		Tags: map[string]*string{
	// 			"sensor": to.Ptr("temperature,humidity"),
	// 		},
	// 		SystemData: &armdeviceregistry.SystemData{
	// 			CreatedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 			LastModifiedBy: to.Ptr("00003442-0000-0000-0000-494059220000"),
	// 			LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication),
	// 			LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-02T20:15:21.8874648Z"); return t}()),
	// 		},
	// 		Properties: &armdeviceregistry.NamespaceDeviceProperties{
	// 			Endpoints: &armdeviceregistry.MessagingEndpoints{
	// 				Outbound: &armdeviceregistry.OutboundEndpoints{
	// 					Assigned: map[string]*armdeviceregistry.DeviceMessagingEndpoint{
	// 						"iothubEndpoint": &armdeviceregistry.DeviceMessagingEndpoint{
	// 							EndpointType: to.Ptr("Microsoft.Devices/IotHubs"),
	// 							Address: to.Ptr("https://iothub-for-dps.azure-devices.net"),
	// 						},
	// 					},
	// 				},
	// 			},
	// 			ExternalDeviceID: to.Ptr("adr-smart-device3-7a848b15-af47-40a7-8c06-a3f43314d44f"),
	// 			Enabled: to.Ptr(true),
	// 			Attributes: map[string]any{
	// 				"deviceType": "sensor",
	// 				"deviceOwner": "IT",
	// 				"deviceCategory": 16,
	// 			},
	// 			ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded),
	// 		},
	// 	},
	// }
}
