public BuildDocumentModelRequest(string modelId, DocumentBuildMode buildMode)
        {
            if (modelId == null)
            {
                throw new ArgumentNullException(nameof(modelId));
            }

            ModelId   = modelId;
            BuildMode = buildMode;
            Tags      = new ChangeTrackingDictionary <string, string>();
        }
        internal static DocTypeInfo DeserializeDocTypeInfo(JsonElement element)
        {
            Optional <string>            description = default;
            Optional <DocumentBuildMode> buildMode   = default;
            IReadOnlyDictionary <string, DocumentFieldSchema> fieldSchema     = default;
            Optional <IReadOnlyDictionary <string, float> >   fieldConfidence = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("buildMode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    buildMode = new DocumentBuildMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("fieldSchema"))
                {
                    Dictionary <string, DocumentFieldSchema> dictionary = new Dictionary <string, DocumentFieldSchema>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, DocumentFieldSchema.DeserializeDocumentFieldSchema(property0.Value));
                    }
                    fieldSchema = dictionary;
                    continue;
                }
                if (property.NameEquals("fieldConfidence"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, float> dictionary = new Dictionary <string, float>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetSingle());
                    }
                    fieldConfidence = dictionary;
                    continue;
                }
            }
            return(new DocTypeInfo(description.Value, Optional.ToNullable(buildMode), fieldSchema, Optional.ToDictionary(fieldConfidence)));
        }
        /// <summary>
        /// Build a custom document analysis model from a collection of documents in an Azure Blob Storage container.
        /// </summary>
        /// <param name="trainingFilesUri">
        /// An externally accessible Azure Blob Storage container URI pointing to the container that has your training files.
        /// Note that a container URI without SAS is accepted only when the container is public or has a managed identity
        /// configured.
        /// For more information on setting up a training data set, see <see href="https://aka.ms/azsdk/formrecognizer/buildcustommodel">this article</see>.
        /// </param>
        /// <param name="buildMode">
        /// The technique to use to build the model. Use:
        /// <list type="bullet">
        ///   <item>
        ///     <term><see cref="DocumentBuildMode.Template"/></term>
        ///     <description>
        ///       When the custom documents all have the same layout. Fields are expected to be in the same place
        ///       across documents. Build time tends to be considerably shorter than <see cref="DocumentBuildMode.Neural"/>
        ///       mode.
        ///     </description>
        ///   </item>
        ///   <item>
        ///     <term><see cref="DocumentBuildMode.Neural"/></term>
        ///     <description>
        ///       Recommended mode when custom documents have different layouts. Fields are expected to be the same but
        ///       they can be placed in different positions across documents.
        ///     </description>
        ///   </item>
        /// </list>
        /// For more information see <see href="https://aka.ms/azsdk/formrecognizer/buildmode">here</see>.
        /// </param>
        /// <param name="modelId">A unique ID for your model. If not specified, a model ID will be created for you.</param>
        /// <param name="buildModelOptions">A set of options available for configuring the request. For example, set a model description or set a filter to apply
        /// to the documents in the source path.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        /// <returns>
        /// A <see cref="BuildModelOperation"/> to wait on this long-running operation. Its Value upon successful
        /// completion will contain meta-data about the created custom model.
        /// </returns>
        public virtual BuildModelOperation StartBuildModel(Uri trainingFilesUri, DocumentBuildMode buildMode, string modelId = default, BuildModelOptions buildModelOptions = default, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(trainingFilesUri, nameof(trainingFilesUri));

            buildModelOptions ??= new BuildModelOptions();

            using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(DocumentModelAdministrationClient)}.{nameof(StartBuildModel)}");
            scope.Start();

            try
            {
                var source = new AzureBlobContentSource(trainingFilesUri.AbsoluteUri);
                if (!string.IsNullOrEmpty(buildModelOptions.Prefix))
                {
                    source.Prefix = buildModelOptions.Prefix;
                }

                modelId ??= Guid.NewGuid().ToString();
                var request = new BuildDocumentModelRequest(modelId, buildMode)
                {
                    AzureBlobSource = source,
                    Description     = buildModelOptions.ModelDescription
                };

                foreach (var tag in buildModelOptions.Tags)
                {
                    request.Tags.Add(tag);
                }

                var response = ServiceClient.BuildDocumentModel(request, cancellationToken);
                return(new BuildModelOperation(response.Headers.OperationLocation, response.GetRawResponse(), ServiceClient, Diagnostics));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }