/// <summary> /// Generate authorization for copying a custom model into the target Form Recognizer resource. /// </summary> /// <param name="modelId">A unique ID for your copied model. If not specified, a model ID will be created for you.</param> /// <param name="modelDescription">An optional description to add to the model.</param> /// <param name="tags">A list of user-defined key-value tag attributes associated with the model.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to <see cref="CopyAuthorization"/> containing /// the authorization information necessary to copy a custom model into a target Form Recognizer resource.</returns> public virtual async Task <Response <CopyAuthorization> > GetCopyAuthorizationAsync(string modelId = default, string modelDescription = default, IDictionary <string, string> tags = default, CancellationToken cancellationToken = default) { modelId ??= Guid.NewGuid().ToString(); var request = new AuthorizeCopyRequest(modelId) { Description = modelDescription }; if (tags != null) { foreach (var tag in tags) { request.Tags.Add(tag); } } using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(DocumentModelAdministrationClient)}.{nameof(GetCopyAuthorization)}"); scope.Start(); try { var response = await ServiceClient.AuthorizeCopyDocumentModelAsync(request, cancellationToken).ConfigureAwait(false); return(Response.FromValue(response.Value, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Generate authorization for copying a custom model into the target Form Recognizer resource. /// </summary> /// <param name="modelId">A unique ID for your copied model. If not specified, a model ID will be created for you.</param> /// <param name="modelDescription">An optional description to add to the model.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to <see cref="CopyAuthorization"/> containing /// the authorization information necessary to copy a custom model into a target Form Recognizer resource.</returns> public virtual Response <CopyAuthorization> GetCopyAuthorization(string modelId = default, string modelDescription = default, CancellationToken cancellationToken = default) { modelId ??= Guid.NewGuid().ToString(); var request = new AuthorizeCopyRequest(modelId) { Description = modelDescription }; using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(DocumentModelAdministrationClient)}.{nameof(GetCopyAuthorization)}"); scope.Start(); try { var response = ServiceClient.DocumentAnalysisAuthorizeCopyDocumentModel(request, cancellationToken); return(Response.FromValue(response.Value, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }