Esempio n. 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListSnapshotsResponse response = new ListSnapshotsResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Snapshots", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <SnapshotSummary, SnapshotSummaryUnmarshaller>(SnapshotSummaryUnmarshaller.Instance);
                    response.Snapshots = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Esempio n. 2
0
        public static ListSnapshotsResponse Unmarshall(UnmarshallerContext context)
        {
            ListSnapshotsResponse listSnapshotsResponse = new ListSnapshotsResponse();

            listSnapshotsResponse.HttpResponse = context.HttpResponse;
            listSnapshotsResponse.RequestId    = context.StringValue("ListSnapshots.RequestId");

            ListSnapshotsResponse.ListSnapshots_MediaSnapshot mediaSnapshot = new ListSnapshotsResponse.ListSnapshots_MediaSnapshot();
            mediaSnapshot.Total        = context.LongValue("ListSnapshots.MediaSnapshot.Total");
            mediaSnapshot.Regular      = context.StringValue("ListSnapshots.MediaSnapshot.Regular");
            mediaSnapshot.CreationTime = context.StringValue("ListSnapshots.MediaSnapshot.CreationTime");
            mediaSnapshot.JobId        = context.StringValue("ListSnapshots.MediaSnapshot.JobId");

            List <ListSnapshotsResponse.ListSnapshots_MediaSnapshot.ListSnapshots_Snapshot> mediaSnapshot_snapshots = new List <ListSnapshotsResponse.ListSnapshots_MediaSnapshot.ListSnapshots_Snapshot>();

            for (int i = 0; i < context.Length("ListSnapshots.MediaSnapshot.Snapshots.Length"); i++)
            {
                ListSnapshotsResponse.ListSnapshots_MediaSnapshot.ListSnapshots_Snapshot snapshot = new ListSnapshotsResponse.ListSnapshots_MediaSnapshot.ListSnapshots_Snapshot();
                snapshot.Index = context.LongValue("ListSnapshots.MediaSnapshot.Snapshots[" + i + "].Index");
                snapshot.Url   = context.StringValue("ListSnapshots.MediaSnapshot.Snapshots[" + i + "].Url");

                mediaSnapshot_snapshots.Add(snapshot);
            }
            mediaSnapshot.Snapshots             = mediaSnapshot_snapshots;
            listSnapshotsResponse.MediaSnapshot = mediaSnapshot;

            return(listSnapshotsResponse);
        }
        private static void ListSnapshots(EvsClient client)
        {
            ListSnapshotsRequest req = new ListSnapshotsRequest()
            {
                ServiceType = "EVS",
                Limit       = 2,
                Offset      = 0,
                Name        = "test"
            };

            try
            {
                ListSnapshotsResponse resp = client.ListSnapshots(req);
                Console.WriteLine(resp.Count);
                Console.WriteLine(resp.HttpStatusCode);
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
Esempio n. 4
0
 public override string ExecuteCommand()
 {
     try
     {
         var contentResult = base.ExecuteCommand();
         var result        = JsonConvert.DeserializeObject <ListSnapshotsResponseDto>(contentResult);
         ListSnapshotsResponse = result.ListSnapshotsResponse;
     }
     catch (Exception e)
     {
         LogHelper.WriteAllLog(e.Message, LogHelper.LogType.Error);
         throw;
     }
     return(string.Empty);
 }
 /// <summary>Snippet for ListSnapshots</summary>
 public void ListSnapshotsRequestObject()
 {
     // Snippet: ListSnapshots(ListSnapshotsRequest, CallSettings)
     // Create client
     SnapshotsV1Beta3Client snapshotsV1Beta3Client = SnapshotsV1Beta3Client.Create();
     // Initialize request argument(s)
     ListSnapshotsRequest request = new ListSnapshotsRequest
     {
         ProjectId = "",
         Location  = "",
         JobId     = "",
     };
     // Make the request
     ListSnapshotsResponse response = snapshotsV1Beta3Client.ListSnapshots(request);
     // End snippet
 }
Esempio n. 6
0
        public ICommandResponse ParseResponse(WebResponse webResponse)
        {
            var response       = new ListSnapshotsResponse();
            var responseStream = webResponse.GetResponseStream();

            if ((responseStream != null) && (responseStream.CanRead))
            {
                var responseDocument = XDocument.Load(responseStream);
                response.Snapshots =
                    responseDocument.Root.Elements()
                    .Where(e => e.Name.LocalName.Equals("snapshot", StringComparison.InvariantCultureIgnoreCase))
                    .Select(Snapshot.From);
            }

            return(response);
        }
        /// <summary>Snippet for ListSnapshotsAsync</summary>
        public async Task ListSnapshotsRequestObjectAsync()
        {
            // Snippet: ListSnapshotsAsync(ListSnapshotsRequest, CallSettings)
            // Additional: ListSnapshotsAsync(ListSnapshotsRequest, CancellationToken)
            // Create client
            SnapshotsV1Beta3Client snapshotsV1Beta3Client = await SnapshotsV1Beta3Client.CreateAsync();

            // Initialize request argument(s)
            ListSnapshotsRequest request = new ListSnapshotsRequest
            {
                ProjectId = "",
                Location  = "",
                JobId     = "",
            };
            // Make the request
            ListSnapshotsResponse response = await snapshotsV1Beta3Client.ListSnapshotsAsync(request);

            // End snippet
        }
Esempio n. 8
0
        public void ListSnapshotsRequestObject()
        {
            moq::Mock <SnapshotsV1Beta3.SnapshotsV1Beta3Client> mockGrpcClient = new moq::Mock <SnapshotsV1Beta3.SnapshotsV1Beta3Client>(moq::MockBehavior.Strict);
            ListSnapshotsRequest request = new ListSnapshotsRequest
            {
                ProjectId = "project_id43ad98b0",
                Location  = "locatione09d18d5",
                JobId     = "job_id38ea97d6",
            };
            ListSnapshotsResponse expectedResponse = new ListSnapshotsResponse
            {
                Snapshots = { new Snapshot(), },
            };

            mockGrpcClient.Setup(x => x.ListSnapshots(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SnapshotsV1Beta3Client client   = new SnapshotsV1Beta3ClientImpl(mockGrpcClient.Object, null);
            ListSnapshotsResponse  response = client.ListSnapshots(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 9
0
 /// <summary>
 /// 查询截图信息 需要更高的权限
 /// </summary>
 public static void SearchSnapshotJob()
 {
     try
     {
         // 发起请求,并得到 response
         ListSnapshotsResponse response = ListSnapshots(client);
         if (response.MediaSnapshot.Snapshots.Count > 0)
         {
             foreach (var item in response.MediaSnapshot.Snapshots)
             {
                 Console.WriteLine("图片的Url地址: " + item.Url);
             }
         }
     }
     catch (ServerException e)
     {
         if (e.RequestId != null)
         {
             Console.WriteLine("RequestId = " + e.RequestId);
         }
         Console.WriteLine("ErrorCode = " + e.ErrorCode);
         Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
     }
     catch (ClientException e)
     {
         if (e.RequestId != null)
         {
             Console.WriteLine("RequestId = " + e.RequestId);
         }
         Console.WriteLine("ErrorCode = " + e.ErrorCode);
         Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
     }
     catch (Exception e)
     {
         Console.WriteLine("ErrorMessage = " + e.ToString());
     }
 }
Esempio n. 10
0
        public async stt::Task ListSnapshotsRequestObjectAsync()
        {
            moq::Mock <SnapshotsV1Beta3.SnapshotsV1Beta3Client> mockGrpcClient = new moq::Mock <SnapshotsV1Beta3.SnapshotsV1Beta3Client>(moq::MockBehavior.Strict);
            ListSnapshotsRequest request = new ListSnapshotsRequest
            {
                ProjectId = "project_id43ad98b0",
                Location  = "locatione09d18d5",
                JobId     = "job_id38ea97d6",
            };
            ListSnapshotsResponse expectedResponse = new ListSnapshotsResponse
            {
                Snapshots = { new Snapshot(), },
            };

            mockGrpcClient.Setup(x => x.ListSnapshotsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ListSnapshotsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            SnapshotsV1Beta3Client client = new SnapshotsV1Beta3ClientImpl(mockGrpcClient.Object, null);
            ListSnapshotsResponse  responseCallSettings = await client.ListSnapshotsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ListSnapshotsResponse responseCancellationToken = await client.ListSnapshotsAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }