public async Task SendPipelineRequests() { try { // create a pipeline topology and live pipeline var pipelineTopology = BuildPipelineTopology(); var livePipeline = BuildLivePipeline(pipelineTopology.Name); //set topology without using helper function #region Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod var setPipelineTopRequest = new PipelineTopologySetRequest(pipelineTopology); var directMethod = new CloudToDeviceMethod(setPipelineTopRequest.MethodName); directMethod.SetPayloadJson(setPipelineTopRequest.GetPayloadAsJson()); var setPipelineTopResponse = await serviceClient.InvokeDeviceMethodAsync(deviceId, moduleId, directMethod); #endregion Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod // get a topology using helper function var getPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyGetRequest(pipelineTopology.Name)); var getPipelineTopResponse = PipelineTopology.Deserialize(getPipelineTopRequest.GetPayloadAsJson()); // list all topologies var listPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyListRequest()); var listPipelineTopResponse = PipelineTopologyCollection.Deserialize(listPipelineTopRequest.GetPayloadAsJson()); //set live pipeline var setLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineSetRequest(livePipeline)); //activate live pipeline var activateLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineActivateRequest(livePipeline.Name)); //get live pipeline var getLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineGetRequest(livePipeline.Name)); var getLivePipelineResponse = LivePipeline.Deserialize(getLivePipelineRequest.GetPayloadAsJson()); // list all live pipeline var listLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineListRequest()); var listLivePipelineResponse = LivePipelineCollection.Deserialize(listLivePipelineRequest.GetPayloadAsJson()); //getlive pipeline var deactiveLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeactivateRequest(livePipeline.Name)); var deleteLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeleteRequest(livePipeline.Name)); //delete live pipeline var deletePipelineTopology = await InvokeDirectMethodHelper(new PipelineTopologyDeleteRequest(pipelineTopology.Name)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Assert.Fail(); } }
public async Task SendRequests() { try { //create a pipeline topology and live pipeline var pipelineTopology = BuildPipelineTopology(); var livePipeline = BuildLivePipeline(pipelineTopology.Name); //set topology without using helper function #region Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod var setPipelineTopRequest = new PipelineTopologySetRequest(pipelineTopology); var directMethod = new CloudToDeviceMethod(setPipelineTopRequest.MethodName); directMethod.SetPayloadJson(setPipelineTopRequest.GetPayloadAsJson()); var setPipelineTopResponse = await _serviceClient.InvokeDeviceMethodAsync(_deviceId, _moduleId, directMethod); #endregion Snippet:Azure_VideoAnalyzerSamples_InvokeDirectMethod // get a topology using helper function var getPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyGetRequest(pipelineTopology.Name)); var getPipelineTopResponse = PipelineTopology.Deserialize(getPipelineTopRequest.GetPayloadAsJson()); // list all topologies var listPipelineTopRequest = await InvokeDirectMethodHelper(new PipelineTopologyListRequest()); var listPipelineTopResponse = PipelineTopologyCollection.Deserialize(listPipelineTopRequest.GetPayloadAsJson()); //set live pipeline var setLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineSetRequest(livePipeline)); //activate live pipeline var activateLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineActivateRequest(livePipeline.Name)); //get live pipeline var getLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineGetRequest(livePipeline.Name)); var getLivePipelineResponse = LivePipeline.Deserialize(getLivePipelineRequest.GetPayloadAsJson()); // list all live pipeline var listLivePipelineRequest = await InvokeDirectMethodHelper(new LivePipelineListRequest()); var listLivePipelineResponse = LivePipelineCollection.Deserialize(listLivePipelineRequest.GetPayloadAsJson()); //getlive pipeline var deactiveLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeactivateRequest(livePipeline.Name)); var deleteLivePipeline = await InvokeDirectMethodHelper(new LivePipelineDeleteRequest(livePipeline.Name)); //delete live pipeline var deletePipelineTopology = await InvokeDirectMethodHelper(new PipelineTopologyDeleteRequest(pipelineTopology.Name)); //get an onvif device var onvifDeviceGetRequest = await InvokeDirectMethodHelper(new OnvifDeviceGetRequest(new UnsecuredEndpoint("rtsp://camerasimulator:8554"))); var onvifDeviceGetResponse = OnvifDevice.Deserialize(onvifDeviceGetRequest.GetPayloadAsJson()); //get all onvif devices on the network var onvifDiscoverRequest = await InvokeDirectMethodHelper(new OnvifDeviceDiscoverRequest()); var onvifDiscoverResponse = DiscoveredOnvifDeviceCollection.Deserialize(onvifDiscoverRequest.GetPayloadAsJson()); // create a remote device adapter and send a set request for it var iotDeviceName = "iotDeviceSample"; var remoteDeviceName = "remoteDeviceSample"; var iotDevice = await GetOrAddIoTDeviceAsync(iotDeviceName); var remoteDeviceAdapter = CreateRemoteDeviceAdapter(remoteDeviceName, iotDeviceName, iotDevice.Authentication.SymmetricKey.PrimaryKey); var remoteDeviceAdapterSetRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterSetRequest(remoteDeviceAdapter)); var remoteDeviceAdapterSetResponse = RemoteDeviceAdapter.Deserialize(remoteDeviceAdapterSetRequest.GetPayloadAsJson()); //get a remote device adapter var remoteDeviceAdapterGetRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterGetRequest(remoteDeviceName)); var remoteDeviceAdapterGetResponse = RemoteDeviceAdapter.Deserialize(remoteDeviceAdapterGetRequest.GetPayloadAsJson()); //list all remote device adapters var remoteDeviceAdapterListRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterListRequest()); var remoteDeviceAdapterListResponse = RemoteDeviceAdapterCollection.Deserialize(remoteDeviceAdapterListRequest.GetPayloadAsJson()); //delete a remote device adapater var remoteDeviceAdapterDeleteRequest = await InvokeDirectMethodHelper(new RemoteDeviceAdapterDeleteRequest(remoteDeviceName)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Assert.Fail(); } }
/// <summary> /// Creates or updates a pipeline topology. /// </summary> /// <remarks> /// Creates a new pipeline topology or updates an existing one, with the given /// name. A pipeline topology describes the processing steps to be applied when /// processing content for a particular outcome. The topology should be defined /// according to the scenario to be achieved and can be reused across many /// pipeline instances which share the same processing characteristics. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='accountName'> /// The Azure Video Analyzer account name. /// </param> /// <param name='pipelineTopologyName'> /// Pipeline topology unique identifier. /// </param> /// <param name='parameters'> /// The request parameters /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PipelineTopology> CreateOrUpdateAsync(this IPipelineTopologiesOperations operations, string resourceGroupName, string accountName, string pipelineTopologyName, PipelineTopology parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, accountName, pipelineTopologyName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates a pipeline topology. /// </summary> /// <remarks> /// Creates a new pipeline topology or updates an existing one, with the given /// name. A pipeline topology describes the processing steps to be applied when /// processing content for a particular outcome. The topology should be defined /// according to the scenario to be achieved and can be reused across many /// pipeline instances which share the same processing characteristics. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='accountName'> /// The Azure Video Analyzer account name. /// </param> /// <param name='pipelineTopologyName'> /// Pipeline topology unique identifier. /// </param> /// <param name='parameters'> /// The request parameters /// </param> public static PipelineTopology CreateOrUpdate(this IPipelineTopologiesOperations operations, string resourceGroupName, string accountName, string pipelineTopologyName, PipelineTopology parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, accountName, pipelineTopologyName, parameters).GetAwaiter().GetResult()); }