internal static SweepJob DeserializeSweepJob(JsonElement element) { Optional <JobStatus> status = default; ParameterSamplingConfiguration parameterSamplingConfiguration = default; Optional <TerminationConfiguration> terminationConfiguration = default; EvaluationConfiguration evaluationConfiguration = default; Optional <TrialComponent> trialComponent = default; Optional <string> experimentName = default; ComputeBinding computeBinding = default; Optional <JobOutput> output = default; JobType jobType = default; Optional <JobBaseInteractionEndpoints> interactionEndpoints = default; Optional <string> description = default; Optional <IDictionary <string, string> > tags = default; Optional <IDictionary <string, string> > properties = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("status")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } status = new JobStatus(property.Value.GetString()); continue; } if (property.NameEquals("parameterSamplingConfiguration")) { parameterSamplingConfiguration = ParameterSamplingConfiguration.DeserializeParameterSamplingConfiguration(property.Value); continue; } if (property.NameEquals("terminationConfiguration")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } terminationConfiguration = TerminationConfiguration.DeserializeTerminationConfiguration(property.Value); continue; } if (property.NameEquals("evaluationConfiguration")) { evaluationConfiguration = EvaluationConfiguration.DeserializeEvaluationConfiguration(property.Value); continue; } if (property.NameEquals("trialComponent")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } trialComponent = TrialComponent.DeserializeTrialComponent(property.Value); continue; } if (property.NameEquals("experimentName")) { experimentName = property.Value.GetString(); continue; } if (property.NameEquals("computeBinding")) { computeBinding = ComputeBinding.DeserializeComputeBinding(property.Value); continue; } if (property.NameEquals("output")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } output = JobOutput.DeserializeJobOutput(property.Value); continue; } if (property.NameEquals("jobType")) { jobType = new JobType(property.Value.GetString()); continue; } if (property.NameEquals("interactionEndpoints")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value); continue; } if (property.NameEquals("description")) { description = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } properties = dictionary; continue; } } return(new SweepJob(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), experimentName.Value, computeBinding, output.Value, Optional.ToNullable(status), parameterSamplingConfiguration, terminationConfiguration.Value, evaluationConfiguration, trialComponent.Value)); }
internal static JobBase DeserializeJobBase(JsonElement element) { if (element.TryGetProperty("jobType", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "Command": return(CommandJob.DeserializeCommandJob(element)); case "ComputeJobBase": return(ComputeJobBase.DeserializeComputeJobBase(element)); case "Labeling": return(LabelingJob.DeserializeLabelingJob(element)); case "Sweep": return(SweepJob.DeserializeSweepJob(element)); } } JobType jobType = default; Optional <JobBaseInteractionEndpoints> interactionEndpoints = default; Optional <string> description = default; Optional <IDictionary <string, string> > tags = default; Optional <IDictionary <string, string> > properties = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("jobType")) { jobType = new JobType(property.Value.GetString()); continue; } if (property.NameEquals("interactionEndpoints")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value); continue; } if (property.NameEquals("description")) { description = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } properties = dictionary; continue; } } return(new JobBase(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties))); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(Status)) { writer.WritePropertyName("status"); writer.WriteStringValue(Status.Value.ToString()); } writer.WritePropertyName("parameterSamplingConfiguration"); writer.WriteObjectValue(ParameterSamplingConfiguration); if (Optional.IsDefined(TerminationConfiguration)) { writer.WritePropertyName("terminationConfiguration"); writer.WriteObjectValue(TerminationConfiguration); } writer.WritePropertyName("evaluationConfiguration"); writer.WriteObjectValue(EvaluationConfiguration); if (Optional.IsDefined(TrialComponent)) { writer.WritePropertyName("trialComponent"); writer.WriteObjectValue(TrialComponent); } if (Optional.IsDefined(ExperimentName)) { writer.WritePropertyName("experimentName"); writer.WriteStringValue(ExperimentName); } writer.WritePropertyName("computeBinding"); writer.WriteObjectValue(ComputeBinding); if (Optional.IsDefined(Output)) { writer.WritePropertyName("output"); writer.WriteObjectValue(Output); } writer.WritePropertyName("jobType"); writer.WriteStringValue(JobType.ToString()); if (Optional.IsDefined(Description)) { writer.WritePropertyName("description"); writer.WriteStringValue(Description); } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"); writer.WriteStartObject(); foreach (var item in Tags) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } if (Optional.IsCollectionDefined(Properties)) { writer.WritePropertyName("properties"); writer.WriteStartObject(); foreach (var item in Properties) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } writer.WriteEndObject(); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsCollectionDefined(LabelCategories)) { writer.WritePropertyName("labelCategories"); writer.WriteStartObject(); foreach (var item in LabelCategories) { writer.WritePropertyName(item.Key); writer.WriteObjectValue(item.Value); } writer.WriteEndObject(); } if (Optional.IsDefined(JobInstructions)) { writer.WritePropertyName("jobInstructions"); writer.WriteObjectValue(JobInstructions); } if (Optional.IsDefined(DatasetConfiguration)) { writer.WritePropertyName("datasetConfiguration"); writer.WriteObjectValue(DatasetConfiguration); } if (Optional.IsDefined(MlAssistConfiguration)) { writer.WritePropertyName("mlAssistConfiguration"); writer.WriteObjectValue(MlAssistConfiguration); } if (Optional.IsDefined(LabelingJobMediaProperties)) { writer.WritePropertyName("labelingJobMediaProperties"); writer.WriteObjectValue(LabelingJobMediaProperties); } if (Optional.IsDefined(ProjectId)) { writer.WritePropertyName("projectId"); writer.WriteStringValue(ProjectId.Value); } if (Optional.IsDefined(Status)) { writer.WritePropertyName("status"); writer.WriteStringValue(Status.Value.ToString()); } if (Optional.IsDefined(ProgressMetrics)) { writer.WritePropertyName("progressMetrics"); writer.WriteObjectValue(ProgressMetrics); } if (Optional.IsCollectionDefined(StatusMessages)) { writer.WritePropertyName("statusMessages"); writer.WriteStartArray(); foreach (var item in StatusMessages) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (Optional.IsDefined(CreatedTimeUtc)) { writer.WritePropertyName("createdTimeUtc"); writer.WriteStringValue(CreatedTimeUtc.Value, "O"); } writer.WritePropertyName("jobType"); writer.WriteStringValue(JobType.ToString()); if (Optional.IsDefined(Description)) { writer.WritePropertyName("description"); writer.WriteStringValue(Description); } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"); writer.WriteStartObject(); foreach (var item in Tags) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } if (Optional.IsCollectionDefined(Properties)) { writer.WritePropertyName("properties"); writer.WriteStartObject(); foreach (var item in Properties) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } writer.WriteEndObject(); }
internal static LabelingJob DeserializeLabelingJob(JsonElement element) { Optional <IDictionary <string, LabelCategory> > labelCategories = default; Optional <LabelingJobInstructions> jobInstructions = default; Optional <LabelingDatasetConfiguration> datasetConfiguration = default; Optional <MLAssistConfiguration> mlAssistConfiguration = default; Optional <LabelingJobMediaProperties> labelingJobMediaProperties = default; Optional <Guid> projectId = default; Optional <JobStatus> status = default; Optional <ProgressMetrics> progressMetrics = default; Optional <IList <StatusMessage> > statusMessages = default; Optional <DateTimeOffset> createdTimeUtc = default; JobType jobType = default; Optional <JobBaseInteractionEndpoints> interactionEndpoints = default; Optional <string> description = default; Optional <IDictionary <string, string> > tags = default; Optional <IDictionary <string, string> > properties = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("labelCategories")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, LabelCategory> dictionary = new Dictionary <string, LabelCategory>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, LabelCategory.DeserializeLabelCategory(property0.Value)); } labelCategories = dictionary; continue; } if (property.NameEquals("jobInstructions")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } jobInstructions = LabelingJobInstructions.DeserializeLabelingJobInstructions(property.Value); continue; } if (property.NameEquals("datasetConfiguration")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } datasetConfiguration = LabelingDatasetConfiguration.DeserializeLabelingDatasetConfiguration(property.Value); continue; } if (property.NameEquals("mlAssistConfiguration")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } mlAssistConfiguration = MLAssistConfiguration.DeserializeMLAssistConfiguration(property.Value); continue; } if (property.NameEquals("labelingJobMediaProperties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } labelingJobMediaProperties = LabelingJobMediaProperties.DeserializeLabelingJobMediaProperties(property.Value); continue; } if (property.NameEquals("projectId")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } projectId = property.Value.GetGuid(); continue; } if (property.NameEquals("status")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } status = new JobStatus(property.Value.GetString()); continue; } if (property.NameEquals("progressMetrics")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } progressMetrics = ProgressMetrics.DeserializeProgressMetrics(property.Value); continue; } if (property.NameEquals("statusMessages")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <StatusMessage> array = new List <StatusMessage>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(StatusMessage.DeserializeStatusMessage(item)); } statusMessages = array; continue; } if (property.NameEquals("createdTimeUtc")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } createdTimeUtc = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("jobType")) { jobType = new JobType(property.Value.GetString()); continue; } if (property.NameEquals("interactionEndpoints")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value); continue; } if (property.NameEquals("description")) { description = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } properties = dictionary; continue; } } return(new LabelingJob(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), Optional.ToDictionary(labelCategories), jobInstructions.Value, datasetConfiguration.Value, mlAssistConfiguration.Value, labelingJobMediaProperties.Value, Optional.ToNullable(projectId), Optional.ToNullable(status), progressMetrics.Value, Optional.ToList(statusMessages), Optional.ToNullable(createdTimeUtc))); }
internal static CommandJob DeserializeCommandJob(JsonElement element) { Optional <JobStatus> status = default; Optional <long> maxRunDurationSeconds = default; CodeConfiguration codeConfiguration = default; Optional <string> environmentId = default; Optional <IDictionary <string, DataBinding> > dataBindings = default; Optional <DistributionConfiguration> distributionConfiguration = default; Optional <string> experimentName = default; ComputeBinding computeBinding = default; Optional <JobOutput> output = default; JobType jobType = default; Optional <JobBaseInteractionEndpoints> interactionEndpoints = default; Optional <string> description = default; Optional <IDictionary <string, string> > tags = default; Optional <IDictionary <string, string> > properties = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("status")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } status = new JobStatus(property.Value.GetString()); continue; } if (property.NameEquals("maxRunDurationSeconds")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } maxRunDurationSeconds = property.Value.GetInt64(); continue; } if (property.NameEquals("codeConfiguration")) { codeConfiguration = CodeConfiguration.DeserializeCodeConfiguration(property.Value); continue; } if (property.NameEquals("environmentId")) { environmentId = property.Value.GetString(); continue; } if (property.NameEquals("dataBindings")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, DataBinding> dictionary = new Dictionary <string, DataBinding>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, DataBinding.DeserializeDataBinding(property0.Value)); } dataBindings = dictionary; continue; } if (property.NameEquals("distributionConfiguration")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } distributionConfiguration = DistributionConfiguration.DeserializeDistributionConfiguration(property.Value); continue; } if (property.NameEquals("experimentName")) { experimentName = property.Value.GetString(); continue; } if (property.NameEquals("computeBinding")) { computeBinding = ComputeBinding.DeserializeComputeBinding(property.Value); continue; } if (property.NameEquals("output")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } output = JobOutput.DeserializeJobOutput(property.Value); continue; } if (property.NameEquals("jobType")) { jobType = new JobType(property.Value.GetString()); continue; } if (property.NameEquals("interactionEndpoints")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value); continue; } if (property.NameEquals("description")) { description = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } properties = dictionary; continue; } } return(new CommandJob(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), experimentName.Value, computeBinding, output.Value, Optional.ToNullable(status), Optional.ToNullable(maxRunDurationSeconds), codeConfiguration, environmentId.Value, Optional.ToDictionary(dataBindings), distributionConfiguration.Value)); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(Status)) { writer.WritePropertyName("status"); writer.WriteStringValue(Status.Value.ToString()); } if (Optional.IsDefined(MaxRunDurationSeconds)) { writer.WritePropertyName("maxRunDurationSeconds"); writer.WriteNumberValue(MaxRunDurationSeconds.Value); } writer.WritePropertyName("codeConfiguration"); writer.WriteObjectValue(CodeConfiguration); if (Optional.IsDefined(EnvironmentId)) { writer.WritePropertyName("environmentId"); writer.WriteStringValue(EnvironmentId); } if (Optional.IsCollectionDefined(DataBindings)) { writer.WritePropertyName("dataBindings"); writer.WriteStartObject(); foreach (var item in DataBindings) { writer.WritePropertyName(item.Key); writer.WriteObjectValue(item.Value); } writer.WriteEndObject(); } if (Optional.IsDefined(DistributionConfiguration)) { writer.WritePropertyName("distributionConfiguration"); writer.WriteObjectValue(DistributionConfiguration); } if (Optional.IsDefined(ExperimentName)) { writer.WritePropertyName("experimentName"); writer.WriteStringValue(ExperimentName); } writer.WritePropertyName("computeBinding"); writer.WriteObjectValue(ComputeBinding); if (Optional.IsDefined(Output)) { writer.WritePropertyName("output"); writer.WriteObjectValue(Output); } writer.WritePropertyName("jobType"); writer.WriteStringValue(JobType.ToString()); if (Optional.IsDefined(Description)) { writer.WritePropertyName("description"); writer.WriteStringValue(Description); } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"); writer.WriteStartObject(); foreach (var item in Tags) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } if (Optional.IsCollectionDefined(Properties)) { writer.WritePropertyName("properties"); writer.WriteStartObject(); foreach (var item in Properties) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } writer.WriteEndObject(); }