public static GetJobResponse Unmarshall(UnmarshallerContext context) { GetJobResponse getJobResponse = new GetJobResponse(); getJobResponse.HttpResponse = context.HttpResponse; getJobResponse.RequestId = context.StringValue("GetJob.RequestId"); GetJobResponse.GetJob_Job job = new GetJobResponse.GetJob_Job(); job.JobName = context.StringValue("GetJob.Job.JobName"); job.ProjectName = context.StringValue("GetJob.Job.ProjectName"); job.JobType = context.StringValue("GetJob.Job.JobType"); job.ApiType = context.StringValue("GetJob.Job.ApiType"); job.Code = context.StringValue("GetJob.Job.Code"); job.PlanJson = context.StringValue("GetJob.Job.PlanJson"); job.Properties = context.StringValue("GetJob.Job.Properties"); job.Packages = context.StringValue("GetJob.Job.Packages"); job.IsCommitted = context.BooleanValue("GetJob.Job.IsCommitted"); job.Creator = context.StringValue("GetJob.Job.Creator"); job.CreateTime = context.LongValue("GetJob.Job.CreateTime"); job.Modifier = context.StringValue("GetJob.Job.Modifier"); job.ModifyTime = context.LongValue("GetJob.Job.ModifyTime"); job.Description = context.StringValue("GetJob.Job.Description"); job.EngineVersion = context.StringValue("GetJob.Job.EngineVersion"); job.ClusterId = context.StringValue("GetJob.Job.ClusterId"); job.QueueName = context.StringValue("GetJob.Job.QueueName"); job.FolderId = context.LongValue("GetJob.Job.FolderId"); job.JobId = context.StringValue("GetJob.Job.JobId"); getJobResponse.Job = job; return(getJobResponse); }
/// <summary> /// Builds a GetJobResponse object /// </summary> public static GetJobResponse CreateGetJobResponse(string jobName) { GetJobResponse response = new GetJobResponse(); SetProperty(response, "StatusCode", HttpStatusCode.OK); Job job = new Job(); SetProperty(job, "Name", jobName); SetProperty(response, "Job", job); return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetJobResponse response = new GetJobResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Job", targetDepth)) { var unmarshaller = JobUnmarshaller.Instance; response.Job = unmarshaller.Unmarshall(context); continue; } } return(response); }
public void GettingExistingJobShouldReturnsItsData() { string id = Jobs.SampleHeader.Identifier.ToHex(); GetJobResponse data = new GetJobResponse { id = id, version = Jobs.SampleHeader.Version, name = Jobs.SampleData.Name, description = Jobs.SampleData.Description, executable = Jobs.SampleData.Executable, arguments = Jobs.SampleData.Arguments, blob = Jobs.SampleData.Blob.ToHex() }; BrowserResponse response = browser.Get($"/api/jobs/{id}", with => { }); response.Body.DeserializeJson <GetJobResponse>().ShouldBeEquivalentTo(data); }
public void GetBatchJobTest() { // Setup cmdlet to get a Job by name BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; cmdlet.WorkItemName = "workItem"; cmdlet.Name = "job-0000000001"; cmdlet.Filter = null; // Build a Job instead of querying the service on a GetJob call YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) => { if (request is GetJobRequest) { GetJobResponse response = BatchTestHelpers.CreateGetJobResponse(cmdlet.Name); Task <object> task = Task <object> .Factory.StartNew(() => { return(response); }); return(task); } return(null); }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Setup the cmdlet to write pipeline output to a list that can be examined later List <PSCloudJob> pipeline = new List <PSCloudJob>(); commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSCloudJob>())).Callback <object>(j => pipeline.Add((PSCloudJob)j)); cmdlet.ExecuteCmdlet(); // Verify that the cmdlet wrote the Job returned from the OM to the pipeline Assert.Equal(1, pipeline.Count); Assert.Equal(cmdlet.Name, pipeline[0].Name); }
public static GetJobResponse Unmarshall(UnmarshallerContext context) { GetJobResponse getJobResponse = new GetJobResponse(); getJobResponse.HttpResponse = context.HttpResponse; getJobResponse.RequestId = context.StringValue("GetJob.RequestId"); getJobResponse.Success = context.BooleanValue("GetJob.Success"); getJobResponse.Code = context.StringValue("GetJob.Code"); getJobResponse.Message = context.StringValue("GetJob.Message"); getJobResponse.HttpStatusCode = context.IntegerValue("GetJob.HttpStatusCode"); GetJobResponse.GetJob_Job job = new GetJobResponse.GetJob_Job(); job.JobId = context.StringValue("GetJob.Job.JobId"); job.GroupId = context.StringValue("GetJob.Job.GroupId"); job.ScenarioId = context.StringValue("GetJob.Job.ScenarioId"); job.StrategyId = context.StringValue("GetJob.Job.StrategyId"); job.Priority = context.IntegerValue("GetJob.Job.Priority"); job.SystemPriority = context.IntegerValue("GetJob.Job.SystemPriority"); job.Status = context.StringValue("GetJob.Job.Status"); job.ReferenceId = context.StringValue("GetJob.Job.ReferenceId"); job.FailureReason = context.StringValue("GetJob.Job.FailureReason"); List <string> job_callingNumbers = new List <string>(); for (int i = 0; i < context.Length("GetJob.Job.CallingNumbers.Length"); i++) { job_callingNumbers.Add(context.StringValue("GetJob.Job.CallingNumbers[" + i + "]")); } job.CallingNumbers = job_callingNumbers; List <GetJobResponse.GetJob_Job.GetJob_Contact> job_contacts = new List <GetJobResponse.GetJob_Job.GetJob_Contact>(); for (int i = 0; i < context.Length("GetJob.Job.Contacts.Length"); i++) { GetJobResponse.GetJob_Job.GetJob_Contact contact = new GetJobResponse.GetJob_Job.GetJob_Contact(); contact.ContactId = context.StringValue("GetJob.Job.Contacts[" + i + "].ContactId"); contact.ContactName = context.StringValue("GetJob.Job.Contacts[" + i + "].ContactName"); contact.Honorific = context.StringValue("GetJob.Job.Contacts[" + i + "].Honorific"); contact.Role = context.StringValue("GetJob.Job.Contacts[" + i + "].Role"); contact.PhoneNumber = context.StringValue("GetJob.Job.Contacts[" + i + "].PhoneNumber"); contact.State = context.StringValue("GetJob.Job.Contacts[" + i + "].State"); contact.ReferenceId = context.StringValue("GetJob.Job.Contacts[" + i + "].ReferenceId"); job_contacts.Add(contact); } job.Contacts = job_contacts; List <GetJobResponse.GetJob_Job.GetJob_KeyValuePair> job_extras = new List <GetJobResponse.GetJob_Job.GetJob_KeyValuePair>(); for (int i = 0; i < context.Length("GetJob.Job.Extras.Length"); i++) { GetJobResponse.GetJob_Job.GetJob_KeyValuePair keyValuePair = new GetJobResponse.GetJob_Job.GetJob_KeyValuePair(); keyValuePair.Key = context.StringValue("GetJob.Job.Extras[" + i + "].Key"); keyValuePair._Value = context.StringValue("GetJob.Job.Extras[" + i + "].Value"); job_extras.Add(keyValuePair); } job.Extras = job_extras; List <GetJobResponse.GetJob_Job.GetJob_Task> job_tasks = new List <GetJobResponse.GetJob_Job.GetJob_Task>(); for (int i = 0; i < context.Length("GetJob.Job.Tasks.Length"); i++) { GetJobResponse.GetJob_Job.GetJob_Task task = new GetJobResponse.GetJob_Job.GetJob_Task(); task.TaskId = context.StringValue("GetJob.Job.Tasks[" + i + "].TaskId"); task.JobId = context.StringValue("GetJob.Job.Tasks[" + i + "].JobId"); task.ScenarioId = context.StringValue("GetJob.Job.Tasks[" + i + "].ScenarioId"); task.ChatbotId = context.StringValue("GetJob.Job.Tasks[" + i + "].ChatbotId"); task.PlanedTime = context.LongValue("GetJob.Job.Tasks[" + i + "].PlanedTime"); task.ActualTime = context.LongValue("GetJob.Job.Tasks[" + i + "].ActualTime"); task.CallingNumber = context.StringValue("GetJob.Job.Tasks[" + i + "].CallingNumber"); task.CalledNumber = context.StringValue("GetJob.Job.Tasks[" + i + "].CalledNumber"); task.CallId = context.StringValue("GetJob.Job.Tasks[" + i + "].CallId"); task.Status = context.StringValue("GetJob.Job.Tasks[" + i + "].Status"); task.Brief = context.StringValue("GetJob.Job.Tasks[" + i + "].Brief"); task.Duration = context.IntegerValue("GetJob.Job.Tasks[" + i + "].Duration"); GetJobResponse.GetJob_Job.GetJob_Task.GetJob_Contact2 contact2 = new GetJobResponse.GetJob_Job.GetJob_Task.GetJob_Contact2(); contact2.ContactId = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.ContactId"); contact2.ContactName = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.ContactName"); contact2.Honorific = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.Honorific"); contact2.Role = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.Role"); contact2.PhoneNumber = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.PhoneNumber"); contact2.State = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.State"); contact2.ReferenceId = context.StringValue("GetJob.Job.Tasks[" + i + "].Contact.ReferenceId"); task.Contact2 = contact2; List <GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail> task_conversation = new List <GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail>(); for (int j = 0; j < context.Length("GetJob.Job.Tasks[" + i + "].Conversation.Length"); j++) { GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail conversationDetail = new GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail(); conversationDetail.Timestamp = context.LongValue("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Timestamp"); conversationDetail.Speaker = context.StringValue("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Speaker"); conversationDetail.Script = context.StringValue("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Script"); List <GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail.GetJob_SummaryItem> conversationDetail_summary1 = new List <GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail.GetJob_SummaryItem>(); for (int k = 0; k < context.Length("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Summary.Length"); k++) { GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail.GetJob_SummaryItem summaryItem = new GetJobResponse.GetJob_Job.GetJob_Task.GetJob_ConversationDetail.GetJob_SummaryItem(); summaryItem.Category = context.StringValue("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Summary[" + k + "].Category"); summaryItem.SummaryName = context.StringValue("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Summary[" + k + "].SummaryName"); summaryItem.Content = context.StringValue("GetJob.Job.Tasks[" + i + "].Conversation[" + j + "].Summary[" + k + "].Content"); conversationDetail_summary1.Add(summaryItem); } conversationDetail.Summary1 = conversationDetail_summary1; task_conversation.Add(conversationDetail); } task.Conversation = task_conversation; job_tasks.Add(task); } job.Tasks = job_tasks; List <GetJobResponse.GetJob_Job.GetJob_SummaryItem3> job_summary = new List <GetJobResponse.GetJob_Job.GetJob_SummaryItem3>(); for (int i = 0; i < context.Length("GetJob.Job.Summary.Length"); i++) { GetJobResponse.GetJob_Job.GetJob_SummaryItem3 summaryItem3 = new GetJobResponse.GetJob_Job.GetJob_SummaryItem3(); summaryItem3.Category = context.StringValue("GetJob.Job.Summary[" + i + "].Category"); summaryItem3.SummaryName = context.StringValue("GetJob.Job.Summary[" + i + "].SummaryName"); summaryItem3.Content = context.StringValue("GetJob.Job.Summary[" + i + "].Content"); job_summary.Add(summaryItem3); } job.Summary = job_summary; getJobResponse.Job = job; return(getJobResponse); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetJobResponse response = new GetJobResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("CreatedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Details", targetDepth)) { var unmarshaller = ResponseDetailsUnmarshaller.Instance; response.Details = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Errors", targetDepth)) { var unmarshaller = new ListUnmarshaller <JobError, JobErrorUnmarshaller>(JobErrorUnmarshaller.Instance); response.Errors = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("State", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.State = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Type", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Type = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("UpdatedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.UpdatedAt = unmarshaller.Unmarshall(context); continue; } } return(response); }
public void GettingExistingJobShouldReturnsItsData() { string id = Jobs.SampleHeader.Identifier.ToHex(); GetJobResponse data = new GetJobResponse { id = id, version = Jobs.SampleHeader.Version, name = Jobs.SampleData.Name, description = Jobs.SampleData.Description, executable = Jobs.SampleData.Executable, arguments = Jobs.SampleData.Arguments, blob = Jobs.SampleData.Blob.ToHex() }; BrowserResponse response = browser.Get($"/api/jobs/{id}", with => { }); response.Body.DeserializeJson<GetJobResponse>().ShouldBeEquivalentTo(data); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetJobResponse response = new GetJobResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("algorithmSpecification", targetDepth)) { var unmarshaller = AlgorithmSpecificationUnmarshaller.Instance; response.AlgorithmSpecification = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("billableDuration", targetDepth)) { var unmarshaller = IntUnmarshaller.Instance; response.BillableDuration = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("checkpointConfig", targetDepth)) { var unmarshaller = JobCheckpointConfigUnmarshaller.Instance; response.CheckpointConfig = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("createdAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("deviceConfig", targetDepth)) { var unmarshaller = DeviceConfigUnmarshaller.Instance; response.DeviceConfig = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("endedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.EndedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("events", targetDepth)) { var unmarshaller = new ListUnmarshaller <JobEventDetails, JobEventDetailsUnmarshaller>(JobEventDetailsUnmarshaller.Instance); response.Events = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("failureReason", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.FailureReason = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("hyperParameters", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance); response.HyperParameters = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("inputDataConfig", targetDepth)) { var unmarshaller = new ListUnmarshaller <InputFileConfig, InputFileConfigUnmarshaller>(InputFileConfigUnmarshaller.Instance); response.InputDataConfig = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("instanceConfig", targetDepth)) { var unmarshaller = InstanceConfigUnmarshaller.Instance; response.InstanceConfig = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("jobArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.JobArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("jobName", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.JobName = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("outputDataConfig", targetDepth)) { var unmarshaller = JobOutputDataConfigUnmarshaller.Instance; response.OutputDataConfig = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("roleArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.RoleArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("startedAt", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.StartedAt = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("status", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Status = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("stoppingCondition", targetDepth)) { var unmarshaller = JobStoppingConditionUnmarshaller.Instance; response.StoppingCondition = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("tags", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance); response.Tags = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Builds a GetJobResponse object /// </summary> public static GetJobResponse CreateGetJobResponse(string jobName) { GetJobResponse response = new GetJobResponse(); SetProperty(response, "StatusCode", HttpStatusCode.OK); Job job = new Job(); SetProperty(job, "Name", jobName); SetProperty(response, "Job", job); return response; }