/// <inheritdoc/> public async Task <ReadResponseApiModel> NodeReadAsync(EndpointApiModel endpoint, ReadRequestApiModel request, CancellationToken ct) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (string.IsNullOrEmpty(endpoint.Url)) { throw new ArgumentNullException(nameof(endpoint.Url)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } if (request.Attributes == null || request.Attributes.Count == 0) { throw new ArgumentException(nameof(request.Attributes)); } var response = await _methodClient.CallMethodAsync(_deviceId, _moduleId, "NodeRead_V2", _serializer.SerializeToString(new { endpoint, request }), null, ct); return(_serializer.Deserialize <ReadResponseApiModel>(response)); }
public async Task <ReadResponseApiModel> ReadAttributesAsync( string endpointId, [FromBody][Required] ReadRequestApiModel request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var readresult = await _nodes.NodeReadAsync( endpointId, request.ToServiceModel()); return(new ReadResponseApiModel(readresult)); }
/// <summary> /// Read attributes /// </summary> /// <param name="endpoint"></param> /// <param name="request"></param> /// <returns></returns> public async Task <ReadResponseApiModel> NodeReadAsync( EndpointApiModel endpoint, ReadRequestApiModel request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var result = await _nodes.NodeReadAsync( endpoint.ToServiceModel(), request.ToServiceModel()); return(result.ToApiModel()); }
/// <summary> /// Convert back to service model /// </summary> /// <returns></returns> public static ReadRequestModel ToServiceModel( this ReadRequestApiModel model) { if (model == null) { return(null); } return(new ReadRequestModel { Attributes = model.Attributes? .Select(a => a.ToServiceModel()) .ToList(), Header = model.Header.ToServiceModel() }); }
/// <inheritdoc/> public async Task <ReadResponseApiModel> NodeReadAsync(string endpointId, ReadRequestApiModel content, CancellationToken ct) { if (string.IsNullOrEmpty(endpointId)) { throw new ArgumentNullException(nameof(endpointId)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } if (content.Attributes == null || content.Attributes.Count == 0) { throw new ArgumentException(nameof(content.Attributes)); } var request = _httpClient.NewRequest( $"{_serviceUri}/v2/read/{endpointId}/attributes", _resourceId); request.SetContent(content); var response = await _httpClient.PostAsync(request, ct).ConfigureAwait(false); response.Validate(); return(response.GetContent <ReadResponseApiModel>()); }
/// <summary> /// Read node attributes /// </summary> /// <remarks> /// Read attributes of a node. The endpoint must be activated and connected and /// the module client and server must trust each other. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='endpointId'> /// The identifier of the activated endpoint. /// </param> /// <param name='body'> /// The read request /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ReadResponseApiModel> ReadAttributesAsync(this IAzureOpcTwinClient operations, string endpointId, ReadRequestApiModel body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ReadAttributesWithHttpMessagesAsync(endpointId, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Read node attributes /// </summary> /// <remarks> /// Read attributes of a node. The endpoint must be activated and connected and /// the module client and server must trust each other. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='endpointId'> /// The identifier of the activated endpoint. /// </param> /// <param name='body'> /// The read request /// </param> public static ReadResponseApiModel ReadAttributes(this IAzureOpcTwinClient operations, string endpointId, ReadRequestApiModel body) { return(operations.ReadAttributesAsync(endpointId, body).GetAwaiter().GetResult()); }
/// <inheritdoc/> public Task <ReadResponseApiModel> NodeReadAsync(string endpointId, ReadRequestApiModel content, CancellationToken ct) { return(Task.FromException <ReadResponseApiModel>(new NotImplementedException())); }
/// <summary> /// Read node attributes on endpoint /// </summary> /// <param name="api"></param> /// <param name="endpointUrl"></param> /// <param name="request"></param> /// <param name="ct"></param> /// <returns></returns> public static Task <ReadResponseApiModel> NodeReadAsync( this ITwinModuleApi api, string endpointUrl, ReadRequestApiModel request, CancellationToken ct = default) { return(api.NodeReadAsync(NewEndpoint(endpointUrl), request, ct)); }
public ReadResponseApiModel ReadNode(string endpoint, ReadRequestApiModel content) { Task <ReadResponseApiModel> t = Task.Run(() => _twinServiceHandler.NodeReadAsync(endpoint, content)); return(t.Result); }
public async Task <ReadResponseApiModel> ReadNodeAsync(string endpoint, ReadRequestApiModel content) { var applications = await _twinServiceHandler.NodeReadAsync(endpoint, content).ConfigureAwait(false); return(applications); }