/// <inheritdoc/>
        public async Task <BrowsePathResponseApiModel> NodeBrowsePathAsync(string endpointId,
                                                                           BrowsePathRequestApiModel content, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(endpointId))
            {
                throw new ArgumentNullException(nameof(endpointId));
            }
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (content.BrowsePaths == null || content.BrowsePaths.Count == 0 ||
                content.BrowsePaths.Any(p => p == null || p.Length == 0))
            {
                throw new ArgumentNullException(nameof(content.BrowsePaths));
            }
            var request = _httpClient.NewRequest($"{_serviceUri}/v2/browse/{endpointId}/path",
                                                 _resourceId);

            request.SetContent(content);
            var response = await _httpClient.PostAsync(request, ct).ConfigureAwait(false);

            response.Validate();
            return(response.GetContent <BrowsePathResponseApiModel>());
        }
        /// <inheritdoc/>
        public async Task <BrowsePathResponseApiModel> NodeBrowsePathAsync(EndpointApiModel endpoint,
                                                                           BrowsePathRequestApiModel 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.BrowsePaths == null || request.BrowsePaths.Count == 0 ||
                request.BrowsePaths.Any(p => p == null || p.Length == 0))
            {
                throw new ArgumentNullException(nameof(request.BrowsePaths));
            }
            var response = await _methodClient.CallMethodAsync(_deviceId, _moduleId,
                                                               "BrowsePath_V2", _serializer.SerializeToString(new {
                endpoint,
                request
            }), null, ct);

            return(_serializer.Deserialize <BrowsePathResponseApiModel>(response));
        }
Esempio n. 3
0
 /// <summary>
 /// Browse by path on endpoint
 /// </summary>
 /// <param name="api"></param>
 /// <param name="endpointUrl"></param>
 /// <param name="request"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <BrowsePathResponseApiModel> NodeBrowsePathAsync(
     this ITwinModuleApi api, string endpointUrl, BrowsePathRequestApiModel request,
     CancellationToken ct = default)
 {
     return(api.NodeBrowsePathAsync(new EndpointApiModel {
         Url = endpointUrl,
         SecurityMode = SecurityMode.None
     }, request, ct));
 }
        public async Task <BrowsePathResponseApiModel> BrowseUsingPathAsync(string endpointId,
                                                                            [FromBody][Required] BrowsePathRequestApiModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var browseresult = await _broser.NodeBrowsePathAsync(endpointId,
                                                                 request.ToServiceModel());

            return(new BrowsePathResponseApiModel(browseresult));
        }
Esempio n. 5
0
        /// <summary>
        /// Browse by path
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <BrowsePathResponseApiModel> BrowsePathAsync(
            BrowsePathRequestApiModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var result = await _browse.NodeBrowsePathAsync(
                _twin.Endpoint, request.ToServiceModel());

            return(new BrowsePathResponseApiModel(result));
        }
Esempio n. 6
0
 /// <summary>
 /// Convert back to service model
 /// </summary>
 /// <returns></returns>
 public static BrowsePathRequestModel ToServiceModel(
     this BrowsePathRequestApiModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new BrowsePathRequestModel {
         NodeId = model.NodeId,
         BrowsePaths = model.BrowsePaths,
         ReadVariableValues = model.ReadVariableValues,
         Header = model.Header.ToServiceModel()
     });
 }
 /// <summary>
 /// Browse using a browse path
 /// </summary>
 /// <remarks>
 /// Browse using a path from the specified node id. This call uses
 /// TranslateBrowsePathsToNodeIds service under the hood. 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 browse path request
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <BrowsePathResponseApiModel> BrowseUsingPathAsync(this IAzureOpcTwinClient operations, string endpointId, BrowsePathRequestApiModel body, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BrowseUsingPathWithHttpMessagesAsync(endpointId, body, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Browse using a browse path
 /// </summary>
 /// <remarks>
 /// Browse using a path from the specified node id. This call uses
 /// TranslateBrowsePathsToNodeIds service under the hood. 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 browse path request
 /// </param>
 public static BrowsePathResponseApiModel BrowseUsingPath(this IAzureOpcTwinClient operations, string endpointId, BrowsePathRequestApiModel body)
 {
     return(operations.BrowseUsingPathAsync(endpointId, body).GetAwaiter().GetResult());
 }
Esempio n. 9
0
 /// <inheritdoc/>
 public Task <BrowsePathResponseApiModel> NodeBrowsePathAsync(string endpointId,
                                                              BrowsePathRequestApiModel content, CancellationToken ct)
 {
     return(Task.FromException <BrowsePathResponseApiModel>(new NotImplementedException()));
 }