QuestionAnsweringAuthoringClient.UpdateSources Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Updates the sources of a project.
public virtual Azure.Operation<Azure.Pageable<BinaryData>> UpdateSources(Azure.WaitUntil waitUntil, string projectName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member UpdateSources : Azure.WaitUntil * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<Azure.Pageable<BinaryData>>
override this.UpdateSources : Azure.WaitUntil * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<Azure.Pageable<BinaryData>>
Public Overridable Function UpdateSources (waitUntil As WaitUntil, projectName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Operation(Of Pageable(Of BinaryData))
Parameters
- waitUntil
- WaitUntil
Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
- projectName
- String
The name of the project to use.
- content
- RequestContent
The content to send as the body of the request. Details of the request body schema are in the Remarks section below.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The Operation<T> from the service that will contain a Pageable<T> containing a list of BinaryData objects once the asynchronous operation on the service has completed. Details of the body schema for the operation's final value are in the Remarks section below.
Exceptions
projectName
or content
is null.
projectName
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call UpdateSources with required parameters and request content and parse the result.
var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new QuestionAnsweringAuthoringClient(endpoint, credential);
var data = new[] {
new {
op = "add",
value = new {
displayName = "<displayName>",
source = "<source>",
sourceUri = "<sourceUri>",
sourceKind = "file",
contentStructureKind = "unstructured",
},
}
};
var operation = client.UpdateSources(WaitUntil.Completed, "<projectName>", RequestContent.Create(data));
var response = operation.WaitForCompletion();
foreach (var data in response.Value)
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("source").ToString());
Console.WriteLine(result.GetProperty("sourceUri").ToString());
Console.WriteLine(result.GetProperty("sourceKind").ToString());
Console.WriteLine(result.GetProperty("contentStructureKind").ToString());
}
Remarks
Below is the JSON schema for the request payload and one item in the pageable response. Additional information can be found in the service REST API documentation: https://learn.microsoft.com/rest/api/cognitiveservices/questionanswering/question-answering-projects/update-sources
Request Body:
Schema for UpdateSourceRecord
:
{
op: "add" | "delete" | "replace", # Required. Update operation type for assets.
value: {
displayName: string, # Optional. Friendly name of the Source.
source: string, # Optional. Unique source identifier. Name of the file if it's a 'file' source; otherwise, the complete URL if it's a 'url' source.
sourceUri: string, # Required. URI location for the file or url.
sourceKind: "file" | "url", # Required. Supported source types.
contentStructureKind: "unstructured", # Optional. Content structure type for sources.
}, # Required. Update source record.
}
Response Body:
Schema for QnaSourcesMetadata
:
{
displayName: string, # Optional. Friendly name of the Source.
source: string, # Optional. Unique source identifier. Name of the file if it's a 'file' source; otherwise, the complete URL if it's a 'url' source.
sourceUri: string, # Required. URI location for the file or url.
sourceKind: "file" | "url", # Required. Supported source types.
contentStructureKind: "unstructured", # Optional. Content structure type for sources.
}