Class AdrServiceClient
- Namespace
- Azure.Iot.Operations.Services.AssetAndDeviceRegistry
- Assembly
- Azure.Iot.Operations.Services.dll
public class AdrServiceClient : IAdrServiceClient, IAsyncDisposable
- Inheritance
-
AdrServiceClient
- Implements
- Inherited Members
Constructors
AdrServiceClient(ApplicationContext, IMqttPubSubClient, IRetryPolicy?)
Construct an ADR service client.
public AdrServiceClient(ApplicationContext applicationContext, IMqttPubSubClient mqttClient, IRetryPolicy? retryPolicy = null)
Parameters
applicationContext
ApplicationContextThe shared context for this application.
mqttClient
IMqttPubSubClientThe MQTT client to communicate with the ADR service with.
retryPolicy
IRetryPolicyThe retry policy to apply to all operations. By default, ExponentialBackoffRetryPolicy will be used if none is provided. NoRetryPolicy can be provided if no retry is desired.
Methods
CreateOrUpdateDiscoveredAssetAsync(string, string, CreateOrUpdateDiscoveredAssetRequest, TimeSpan?, CancellationToken)
Creates or updates a discovered asset.
public Task<CreateOrUpdateDiscoveredAssetResponsePayload> CreateOrUpdateDiscoveredAssetAsync(string deviceName, string inboundEndpointName, CreateOrUpdateDiscoveredAssetRequest request, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
request
CreateOrUpdateDiscoveredAssetRequestThe request containing discovered asset creation parameters.
commandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<CreateOrUpdateDiscoveredAssetResponsePayload>
A task that represents the asynchronous operation, containing the response for the created discovered asset.
CreateOrUpdateDiscoveredDeviceAsync(CreateOrUpdateDiscoveredDeviceRequestSchema, string, TimeSpan?, CancellationToken)
Creates or updates a discovered device.
public Task<CreateOrUpdateDiscoveredDeviceResponsePayload> CreateOrUpdateDiscoveredDeviceAsync(CreateOrUpdateDiscoveredDeviceRequestSchema request, string inboundEndpointType, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
request
CreateOrUpdateDiscoveredDeviceRequestSchemaThe request containing discovered device endpoint profile creation parameters.
inboundEndpointType
stringcommandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<CreateOrUpdateDiscoveredDeviceResponsePayload>
A task that represents the asynchronous operation, containing the response for the created discovered device endpoint profile.
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
GetAssetAsync(string, string, string, TimeSpan?, CancellationToken)
Retrieves details of a specific asset.
public Task<Asset> GetAssetAsync(string deviceName, string inboundEndpointName, string assetName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
assetName
stringcommandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
GetAssetStatusAsync(string, string, string, TimeSpan?, CancellationToken)
Retrieves the status of a specific asset.
public Task<AssetStatus> GetAssetStatusAsync(string deviceName, string inboundEndpointName, string assetName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
assetName
stringThe name of the asset.
commandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<AssetStatus>
A task that represents the asynchronous operation, containing the asset status.
GetDeviceAsync(string, string, TimeSpan?, CancellationToken)
Retrieves details of a specific device.
public Task<Device> GetDeviceAsync(string deviceName, string inboundEndpointName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
commandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
GetDeviceStatusAsync(string, string, TimeSpan?, CancellationToken)
Retrieves the status of a specific device.
public Task<DeviceStatus> GetDeviceStatusAsync(string deviceName, string inboundEndpointName, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
commandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<DeviceStatus>
A task that represents the asynchronous operation, containing the device status.
RunWithRetryAsync<TResult>(Func<Task<TResult>>, CancellationToken)
public Task<TResult> RunWithRetryAsync<TResult>(Func<Task<TResult>> taskFunc, CancellationToken cancellationToken)
Parameters
taskFunc
Func<Task<TResult>>cancellationToken
CancellationToken
Returns
- Task<TResult>
Type Parameters
TResult
SetNotificationPreferenceForAssetUpdatesAsync(string, string, string, NotificationPreference, TimeSpan?, CancellationToken)
Observe or unobserve updates for a specific asset.
public Task<SetNotificationPreferenceForAssetUpdatesResponsePayload> SetNotificationPreferenceForAssetUpdatesAsync(string deviceName, string inboundEndpointName, string assetName, NotificationPreference notificationPreference, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
assetName
stringThe name of the asset.
notificationPreference
NotificationPreferencecommandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<SetNotificationPreferenceForAssetUpdatesResponsePayload>
A task that represents the asynchronous operation, containing the notification response.
SetNotificationPreferenceForDeviceUpdatesAsync(string, string, NotificationPreference, TimeSpan?, CancellationToken)
Observe or unobserve updates for a specific device endpoint.
public Task<SetNotificationPreferenceForDeviceUpdatesResponsePayload> SetNotificationPreferenceForDeviceUpdatesAsync(string deviceName, string inboundEndpointName, NotificationPreference notificationPreference, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
notificationPreference
NotificationPreferencecommandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<SetNotificationPreferenceForDeviceUpdatesResponsePayload>
A task that represents the asynchronous operation, containing the notification response.
UpdateAssetStatusAsync(string, string, UpdateAssetStatusRequest, TimeSpan?, CancellationToken)
Updates the status of a specific asset.
public Task<AssetStatus> UpdateAssetStatusAsync(string deviceName, string inboundEndpointName, UpdateAssetStatusRequest request, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
request
UpdateAssetStatusRequestThe request containing asset status update parameters.
commandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<AssetStatus>
A task that represents the asynchronous operation, containing the updated asset details.
UpdateDeviceStatusAsync(string, string, DeviceStatus, TimeSpan?, CancellationToken)
Updates the status of a specific device.
public Task<DeviceStatus> UpdateDeviceStatusAsync(string deviceName, string inboundEndpointName, DeviceStatus status, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
deviceName
stringThe name of the device.
inboundEndpointName
stringThe name of the inbound endpoint.
status
DeviceStatusThe new status of the device.
commandTimeout
TimeSpan?Optional timeout for the command.
cancellationToken
CancellationTokenOptional cancellation token.
Returns
- Task<DeviceStatus>
A task that represents the asynchronous operation, containing the updated device details.
Events
OnReceiveAssetUpdateEventTelemetry
Event triggered when an asset update telemetry event is received. NOTE: This event starts triggering after the call to SetNotificationPreferenceForAssetUpdatesAsync(string, string, string, NotificationPreference, TimeSpan?, CancellationToken).
public event Func<string, Asset, Task>? OnReceiveAssetUpdateEventTelemetry
Event Type
OnReceiveDeviceUpdateEventTelemetry
Event triggered when a device update telemetry event is received. NOTE: This event starts triggering after the call to SetNotificationPreferenceForDeviceUpdatesAsync(string, string, NotificationPreference, TimeSpan?, CancellationToken).
public event Func<string, string, Device, Task>? OnReceiveDeviceUpdateEventTelemetry