Skip to content

Commit f02368b

Browse files
authored
[DocumentIntelligence] Added overloads to the AnalyzeDocument method (Azure#47496)
1 parent 2a5e1af commit f02368b

File tree

5 files changed

+215
-0
lines changed

5 files changed

+215
-0
lines changed

sdk/documentintelligence/Azure.AI.DocumentIntelligence/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Features Added
66
- Added methods `GetAnalyzeBatchResult`, `GetAnalyzeBatchResults`, `DeleteAnalyzeBatchResult`, and `DeleteAnalyzeResult` to `DocumentIntelligenceClient`.
77
- Added class `AnalyzeBatchOperationDetails` to be used as the output of the `GetAnalyzeBatchResult` and `GetAnalyzeBatchResults` APIs.
8+
- Added overloads for the `AnalyzeDocument` API that take only required parameters.
89
- Added property `ModifiedOn` to `DocumentModelDetails` and to `DocumentClassifierDetails`.
910
- Added member `Skipped` to `DocumentIntelligenceOperationStatus` (former `OperationStatus`).
1011
- Exposed `JsonModelWriteCore` for model serialization procedure.

sdk/documentintelligence/Azure.AI.DocumentIntelligence/api/Azure.AI.DocumentIntelligence.net8.0.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,12 @@ public DocumentIntelligenceClient(System.Uri endpoint, Azure.Core.TokenCredentia
811811
public virtual System.Threading.Tasks.Task<Azure.Operation<System.BinaryData>> AnalyzeBatchDocumentsAsync(Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = null, string locale = null, string stringIndexType = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = null, System.Collections.Generic.IEnumerable<string> queryFields = null, string outputContentFormat = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = null, Azure.RequestContext context = null) { throw null; }
812812
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> AnalyzeDocument(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.AnalyzeDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
813813
public virtual Azure.Operation<System.BinaryData> AnalyzeDocument(Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = null, string locale = null, string stringIndexType = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = null, System.Collections.Generic.IEnumerable<string> queryFields = null, string outputContentFormat = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = null, Azure.RequestContext context = null) { throw null; }
814+
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> AnalyzeDocument(Azure.WaitUntil waitUntil, string modelId, System.BinaryData bytesSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
815+
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> AnalyzeDocument(Azure.WaitUntil waitUntil, string modelId, System.Uri uriSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
814816
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.AnalyzeDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
815817
public virtual System.Threading.Tasks.Task<Azure.Operation<System.BinaryData>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = null, string locale = null, string stringIndexType = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = null, System.Collections.Generic.IEnumerable<string> queryFields = null, string outputContentFormat = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = null, Azure.RequestContext context = null) { throw null; }
818+
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, string modelId, System.BinaryData bytesSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
819+
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, string modelId, System.Uri uriSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
816820
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> ClassifyDocument(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ClassifyDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
817821
public virtual Azure.Operation<System.BinaryData> ClassifyDocument(Azure.WaitUntil waitUntil, string classifierId, Azure.Core.RequestContent content, string stringIndexType = null, string split = null, string pages = null, Azure.RequestContext context = null) { throw null; }
818822
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> ClassifyDocumentAsync(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ClassifyDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }

sdk/documentintelligence/Azure.AI.DocumentIntelligence/api/Azure.AI.DocumentIntelligence.netstandard2.0.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,12 @@ public DocumentIntelligenceClient(System.Uri endpoint, Azure.Core.TokenCredentia
811811
public virtual System.Threading.Tasks.Task<Azure.Operation<System.BinaryData>> AnalyzeBatchDocumentsAsync(Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = null, string locale = null, string stringIndexType = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = null, System.Collections.Generic.IEnumerable<string> queryFields = null, string outputContentFormat = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = null, Azure.RequestContext context = null) { throw null; }
812812
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> AnalyzeDocument(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.AnalyzeDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
813813
public virtual Azure.Operation<System.BinaryData> AnalyzeDocument(Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = null, string locale = null, string stringIndexType = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = null, System.Collections.Generic.IEnumerable<string> queryFields = null, string outputContentFormat = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = null, Azure.RequestContext context = null) { throw null; }
814+
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> AnalyzeDocument(Azure.WaitUntil waitUntil, string modelId, System.BinaryData bytesSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
815+
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> AnalyzeDocument(Azure.WaitUntil waitUntil, string modelId, System.Uri uriSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
814816
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.AnalyzeDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
815817
public virtual System.Threading.Tasks.Task<Azure.Operation<System.BinaryData>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, string modelId, Azure.Core.RequestContent content, string pages = null, string locale = null, string stringIndexType = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.DocumentAnalysisFeature> features = null, System.Collections.Generic.IEnumerable<string> queryFields = null, string outputContentFormat = null, System.Collections.Generic.IEnumerable<Azure.AI.DocumentIntelligence.AnalyzeOutputOption> output = null, Azure.RequestContext context = null) { throw null; }
818+
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, string modelId, System.BinaryData bytesSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
819+
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> AnalyzeDocumentAsync(Azure.WaitUntil waitUntil, string modelId, System.Uri uriSource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
816820
public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> ClassifyDocument(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ClassifyDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
817821
public virtual Azure.Operation<System.BinaryData> ClassifyDocument(Azure.WaitUntil waitUntil, string classifierId, Azure.Core.RequestContent content, string stringIndexType = null, string split = null, string pages = null, Azure.RequestContext context = null) { throw null; }
818822
public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>> ClassifyDocumentAsync(Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ClassifyDocumentOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }

sdk/documentintelligence/Azure.AI.DocumentIntelligence/src/DocumentIntelligenceClient.cs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,94 @@ public virtual Operation<AnalyzeResult> ClassifyDocument(WaitUntil waitUntil, Cl
141141
return ProtocolOperationHelpers.Convert(response, FetchAnalyzeResultFromAnalyzeOperation, ClientDiagnostics, "DocumentIntelligenceClient.ClassifyDocument");
142142
}
143143

144+
// CUSTOM CODE NOTE: adding overloads for common scenarios of the AnalyzeDocument method.
145+
146+
/// <summary> Analyzes document with document model. </summary>
147+
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
148+
/// <param name="modelId"> Unique document model name. </param>
149+
/// <param name="uriSource"> Document URL to analyze. </param>
150+
/// <param name="cancellationToken"> The cancellation token to use. </param>
151+
/// <exception cref="ArgumentNullException"> <paramref name="modelId"/> or <paramref name="uriSource"/> is null. </exception>
152+
/// <exception cref="ArgumentException"> <paramref name="modelId"/> is an empty string, and was expected to be non-empty. </exception>
153+
public virtual async Task<Operation<AnalyzeResult>> AnalyzeDocumentAsync(WaitUntil waitUntil, string modelId, Uri uriSource, CancellationToken cancellationToken = default)
154+
{
155+
var options = new AnalyzeDocumentOptions(modelId, uriSource);
156+
157+
return await AnalyzeDocumentAsync(waitUntil, options, cancellationToken).ConfigureAwait(false);
158+
}
159+
160+
/// <summary> Analyzes document with document model. </summary>
161+
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
162+
/// <param name="modelId"> Unique document model name. </param>
163+
/// <param name="uriSource"> Document URL to analyze. </param>
164+
/// <param name="cancellationToken"> The cancellation token to use. </param>
165+
/// <exception cref="ArgumentNullException"> <paramref name="modelId"/> or <paramref name="uriSource"/> is null. </exception>
166+
/// <exception cref="ArgumentException"> <paramref name="modelId"/> is an empty string, and was expected to be non-empty. </exception>
167+
public virtual Operation<AnalyzeResult> AnalyzeDocument(WaitUntil waitUntil, string modelId, Uri uriSource, CancellationToken cancellationToken = default)
168+
{
169+
var options = new AnalyzeDocumentOptions(modelId, uriSource);
170+
171+
return AnalyzeDocument(waitUntil, options, cancellationToken);
172+
}
173+
174+
/// <summary> Analyzes document with document model. </summary>
175+
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
176+
/// <param name="modelId"> Unique document model name. </param>
177+
/// <param name="bytesSource">
178+
/// Bytes of the document to analyze.
179+
/// <para>
180+
/// To assign a byte[] to this property use <see cref="BinaryData.FromBytes(byte[])"/>.
181+
/// The byte[] will be serialized to a Base64 encoded string.
182+
/// </para>
183+
/// <para>
184+
/// Examples:
185+
/// <list type="bullet">
186+
/// <item>
187+
/// <term>BinaryData.FromBytes(new byte[] { 1, 2, 3 })</term>
188+
/// <description>Creates a payload of "AQID".</description>
189+
/// </item>
190+
/// </list>
191+
/// </para>
192+
/// </param>
193+
/// <param name="cancellationToken"> The cancellation token to use. </param>
194+
/// <exception cref="ArgumentNullException"> <paramref name="modelId"/> or <paramref name="bytesSource"/> is null. </exception>
195+
/// <exception cref="ArgumentException"> <paramref name="modelId"/> is an empty string, and was expected to be non-empty. </exception>
196+
public virtual async Task<Operation<AnalyzeResult>> AnalyzeDocumentAsync(WaitUntil waitUntil, string modelId, BinaryData bytesSource, CancellationToken cancellationToken = default)
197+
{
198+
var options = new AnalyzeDocumentOptions(modelId, bytesSource);
199+
200+
return await AnalyzeDocumentAsync(waitUntil, options, cancellationToken).ConfigureAwait(false);
201+
}
202+
203+
/// <summary> Analyzes document with document model. </summary>
204+
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
205+
/// <param name="modelId"> Unique document model name. </param>
206+
/// <param name="bytesSource">
207+
/// Bytes of the document to analyze.
208+
/// <para>
209+
/// To assign a byte[] to this property use <see cref="BinaryData.FromBytes(byte[])"/>.
210+
/// The byte[] will be serialized to a Base64 encoded string.
211+
/// </para>
212+
/// <para>
213+
/// Examples:
214+
/// <list type="bullet">
215+
/// <item>
216+
/// <term>BinaryData.FromBytes(new byte[] { 1, 2, 3 })</term>
217+
/// <description>Creates a payload of "AQID".</description>
218+
/// </item>
219+
/// </list>
220+
/// </para>
221+
/// </param>
222+
/// <param name="cancellationToken"> The cancellation token to use. </param>
223+
/// <exception cref="ArgumentNullException"> <paramref name="modelId"/> or <paramref name="bytesSource"/> is null. </exception>
224+
/// <exception cref="ArgumentException"> <paramref name="modelId"/> is an empty string, and was expected to be non-empty. </exception>
225+
public virtual Operation<AnalyzeResult> AnalyzeDocument(WaitUntil waitUntil, string modelId, BinaryData bytesSource, CancellationToken cancellationToken = default)
226+
{
227+
var options = new AnalyzeDocumentOptions(modelId, bytesSource);
228+
229+
return AnalyzeDocument(waitUntil, options, cancellationToken);
230+
}
231+
144232
// CUSTOM CODE NOTE: we're overwriting the behavior of the AnalyzeDocument,
145233
// AnalyzeBatchDocuments, and ClassifyDocument protocol methods to return an
146234
// instance of OperationWithId. This is a workaround since Operation.Id is not

0 commit comments

Comments
 (0)