internal static AnalyzeJobErrorsAndStatistics DeserializeAnalyzeJobErrorsAndStatistics(JsonElement element)
        {
            Optional <IReadOnlyList <TextAnalyticsErrorInternal> > errors = default;
            Optional <TextDocumentBatchStatistics> statistics             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TextAnalyticsErrorInternal> array = new List <TextAnalyticsErrorInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value);
                    continue;
                }
            }
            return(new AnalyzeJobErrorsAndStatistics(Optional.ToList(errors), statistics.Value));
        }
        internal static HealthcareTaskResult DeserializeHealthcareTaskResult(JsonElement element)
        {
            Optional <HealthcareResult> results = default;
            Optional <IReadOnlyList <TextAnalyticsErrorInternal> > errors = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("results"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    results = HealthcareResult.DeserializeHealthcareResult(property.Value);
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TextAnalyticsErrorInternal> array = new List <TextAnalyticsErrorInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(item));
                    }
                    errors = array;
                    continue;
                }
            }
            return(new HealthcareTaskResult(results.Value, Optional.ToList(errors)));
        }
        internal ErrorResponse(TextAnalyticsErrorInternal error)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            Error = error;
        }
        internal DocumentError(string id, TextAnalyticsErrorInternal error)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            Id    = id;
            Error = error;
        }
        internal static ErrorResponse DeserializeErrorResponse(JsonElement element)
        {
            TextAnalyticsErrorInternal error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    error = TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(property.Value);
                    continue;
                }
            }
            return(new ErrorResponse(error));
        }
        internal static DocumentError DeserializeDocumentError(JsonElement element)
        {
            string id = default;
            TextAnalyticsErrorInternal error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    error = TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(property.Value);
                    continue;
                }
            }
            return(new DocumentError(id, error));
        }
Example #7
0
        internal static AnalyzeJobState DeserializeAnalyzeJobState(JsonElement element)
        {
            AnalyzeTasks tasks = default;
            Optional <IReadOnlyList <TextAnalyticsErrorInternal> > errors = default;
            Optional <TextDocumentBatchStatistics> statistics             = default;
            Optional <string>         nextLink           = default;
            Optional <string>         displayName        = default;
            DateTimeOffset            createdDateTime    = default;
            Optional <DateTimeOffset> expirationDateTime = default;
            string         jobId = default;
            DateTimeOffset lastUpdateDateTime   = default;
            TextAnalyticsOperationStatus status = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tasks"))
                {
                    tasks = AnalyzeTasks.DeserializeAnalyzeTasks(property.Value);
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TextAnalyticsErrorInternal> array = new List <TextAnalyticsErrorInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentBatchStatistics.DeserializeTextDocumentBatchStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("@nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdDateTime"))
                {
                    createdDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("expirationDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expirationDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("jobId"))
                {
                    jobId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastUpdateDateTime"))
                {
                    lastUpdateDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = new TextAnalyticsOperationStatus(property.Value.GetString());
                    continue;
                }
            }
            return(new AnalyzeJobState(createdDateTime, Optional.ToNullable(expirationDateTime), jobId, lastUpdateDateTime, status, displayName.Value, tasks, Optional.ToList(errors), statistics.Value, nextLink.Value));
        }
        internal static HealthcareJobState DeserializeHealthcareJobState(JsonElement element)
        {
            Optional <HealthcareResult> results = default;
            Optional <IReadOnlyList <TextAnalyticsErrorInternal> > errors = default;
            Optional <string>         nextLink           = default;
            DateTimeOffset            createdDateTime    = default;
            Optional <string>         displayName        = default;
            Optional <DateTimeOffset> expirationDateTime = default;
            string         jobId = default;
            DateTimeOffset lastUpdateDateTime = default;
            JobStatus      status             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("results"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    results = HealthcareResult.DeserializeHealthcareResult(property.Value);
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TextAnalyticsErrorInternal> array = new List <TextAnalyticsErrorInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsErrorInternal.DeserializeTextAnalyticsErrorInternal(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("@nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdDateTime"))
                {
                    createdDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expirationDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expirationDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("jobId"))
                {
                    jobId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastUpdateDateTime"))
                {
                    lastUpdateDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = new JobStatus(property.Value.GetString());
                    continue;
                }
            }
            return(new HealthcareJobState(createdDateTime, displayName.Value, Optional.ToNullable(expirationDateTime), jobId, lastUpdateDateTime, status, results.Value, Optional.ToList(errors), nextLink.Value));
        }