Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
187edee
Update FormRecognizer v2.0-preview spec with new operations 'CopyCust…
krishnand Jan 8, 2020
affb869
Add claimResourceRegion. Remove move option from Copy data contract b…
krishnand Jan 13, 2020
0cd19cb
Address PR comments
krishnand Jan 14, 2020
608865c
Remove authorizationClaim from CopyRequest contract. Updated referenc…
krishnand Jan 16, 2020
131a4e9
Fixed typo in CopyRequest required attribute
krishnand Jan 16, 2020
17e7cef
Add AuthorizationClaim contract and include it with CopyRequest
krishnand Feb 4, 2020
3bf751f
AuthorizationClaim - typo in required attrib
krishnand Feb 4, 2020
7c44a2a
Rename AuthorizationClaim to Authorization
krishnand Feb 6, 2020
df47f58
Rename modelResourceId to modelId in the 'Authorization' contract. Fi…
krishnand Feb 10, 2020
df79efd
Adding source query string parameter to the POST copy request
krishnand Feb 19, 2020
0ea6232
Set 'application/json' consumes option for POST copy
krishnand Feb 19, 2020
4e1f391
Introduce models/copyAuthorization route. Added sample for the new ro…
krishnand Feb 20, 2020
02e46e3
Change expirationDateTime to expirationDateTimeTicks in the CopyAutho…
krishnand Feb 24, 2020
725dd73
Remove enum reference for targetResourceRegion. Update to a loose pat…
krishnand Mar 5, 2020
e8b2604
Address ModelValidation and Sample validation errors
krishnand Mar 5, 2020
a1eb575
Fix copy samples JSON validation issues
krishnand Mar 5, 2020
af0cf01
Run prettier on FormRecognizer.json swagger and example files
krishnand Mar 12, 2020
c191d80
Add sample for COpy operation result with errors. Fix description for…
krishnand Mar 20, 2020
020ab6a
Prettier fix for CopyOperationResultWithErrors.json
krishnand Mar 20, 2020
2a56797
Add LRO annotation to copy API
krishnand Mar 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,149 @@
}
}
},
"/custom/models/{modelId}/copy": {
"post": {
"summary": "Copy Custom Model",
"description": "Copy custom model stored in this resource (the source) to user specified target Form Recognizer resource.",
"operationId": "CopyCustomModel",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "modelId",
"in": "path",
"description": "Model identifier.",
"required": true,
"type": "string",
"format": "uuid"
},
{
"name": "copyRequest",
"in": "body",
"description": "Copy request parameters.",
"required": true,
"schema": {
"$ref": "#/definitions/CopyRequest"
}
}
],
"responses": {
"202": {
"description": "Copy request is queued successfully.",
"headers": {
"Operation-Location": {
"type": "string",
"description": "URL containing the resultId used to track the progress and obtain the result of the copy operation."
}
}
},
"default": {
"description": "Response entity accompanying non-successful responses containing additional details about the error.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"x-ms-examples": {
"Copy custom model": {
"$ref": "./examples/CopyModel.json"
}
},
"x-ms-long-running-operation": true
}
},
"/custom/models/{modelId}/copyResults/{resultId}": {
"get": {
"summary": "Get Custom Model Copy Result",
"description": "Obtain current status and the result of a custom model copy operation.",
"operationId": "GetCustomModelCopyResult",
"consumes": [],
"produces": [
"application/json"
],
"parameters": [
{
"name": "modelId",
"in": "path",
"description": "Model identifier.",
"required": true,
"type": "string",
"format": "uuid"
},
{
"name": "resultId",
"in": "path",
"description": "Copy operation result identifier.",
"required": true,
"type": "string",
"format": "uuid"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/CopyOperationResult"
}
},
"default": {
"description": "Response entity accompanying non-successful responses containing additional details about the error.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"x-ms-examples": {
"Get copy custom model result": {
"$ref": "./examples/CopyOperationResult.json"
},
"Get copy custom model result with failures": {
"$ref": "./examples/CopyOperationResultWithErrors.json"
}
}
}
},
"/custom/models/copyAuthorization": {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the modelId generated by the service, or is it missing from this path?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes modelId will be generated by Service and returned in response (and Location header)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that authorization allows users to copy all models in the resource? Would there be a use-case where users might want to allow copying some models but not others?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sayachao, please correct me if/when I'm wrong/not explaining things correctly, but this API "reserves" a slot that someone can copy another model into. You use the information in the response to initiate a copy. The API could be extended to take an optional source model id (if we wanted to restrict which model could be copied into this "slot").

The current version of the API allows for any user whom I give the generated token/target location (there should only be one) to copy one model they have "own"/have access to into the target location. And you cannot overwrite the target - once you have copied a model, the token is done.

Copy link
Copy Markdown
Contributor

@annelo-msft annelo-msft Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schaabs, does this look like a reasonable pattern from an auth perspective? Will we need to add new auth patterns to Azure.Core to support it, or is it fine to handle it as a pattern specific to this service?

"post": {
"summary": "Generate Copy Authorization",
"description": "Generate authorization to copy a model into the target Form Recognizer resource.",
"operationId": "GenerateModelCopyAuthorization",
"consumes": [],
"produces": [
"application/json"
],
"parameters": [],
"responses": {
"201": {
"description": "Copy request is authorized successfully.",
"headers": {
"Location": {
"type": "string",
"description": "Location and ID of the model being copied. The status of model copy is specified in the status property at the model location."
}
},
"schema": {
"$ref": "#/definitions/CopyAuthorizationResult"
}
},
"default": {
"description": "Response entity accompanying non-successful responses containing additional details about the error.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"x-ms-examples": {
"Copy custom model": {
"$ref": "./examples/CopyModelAuthorization.json"
}
}
}
},
"/prebuilt/receipt/analyze": {
"post": {
"summary": "Analyze Receipt",
Expand Down Expand Up @@ -506,6 +649,111 @@
},
"x-nullable": false
},
"CopyAuthorizationResult": {
"description": "Request parameter that contains authorization claims for copy operation.",
"required": [
"modelId",
"accessToken",
"expirationDateTimeTicks"
],
"type": "object",
"properties": {
"modelId": {
"description": "Model identifier.",
"type": "string"
},
"accessToken": {
"description": "Token claim used to authorize the request.",
"type": "string"
},
"expirationDateTimeTicks": {
"description": "The time when the access token expires. The date is represented as the number of seconds from 1970-01-01T0:0:0Z UTC until the expiration time.",
"type": "integer",
"format": "int64"
}
}
},
"CopyRequest": {
"description": "Request parameter to copy an existing custom model from the source resource to a target resource referenced by the resource ID.",
"required": [
"targetResourceId",
"targetResourceRegion",
"copyAuthorization"
],
"type": "object",
"properties": {
"targetResourceId": {
"description": "Azure Resource Id of the target Form Recognizer resource where the model is copied to.",
"maxLength": 1024,
"type": "string",
"pattern": "^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.CognitiveServices/accounts/[^/]*$",
"x-ms-azure-resource": true
},
"targetResourceRegion": {
"description": "Location of the target Azure resource. A valid Azure region name supported by Cognitive Services.",
"type": "string",
"pattern": "^[a-z0-9]+$",
"minLength": 1,
"maxLength": 24
},
"copyAuthorization": {
"description": "Entity that encodes claims to authorize the copy request.",
"$ref": "#/definitions/CopyAuthorizationResult"
}
}
},
"CopyOperationResult": {
"description": "Status and result of the queued copy operation.",
"type": "object",
"required": [
"status",
"createdDateTime",
"lastUpdatedDateTime"
],
"properties": {
"status": {
"description": "Operation status.",
"$ref": "#/definitions/OperationStatus"
},
"createdDateTime": {
"format": "date-time",
"description": "Date and time (UTC) when the copy operation was submitted.",
"type": "string",
"x-nullable": false
},
"lastUpdatedDateTime": {
"format": "date-time",
"description": "Date and time (UTC) when the status was last updated.",
"type": "string",
"x-nullable": false
},
"copyResult": {
"description": "Results of the copy operation.",
"$ref": "#/definitions/CopyResult"
}
}
},
"CopyResult": {
"description": "Custom model copy result.",
"type": "object",
"required": [
"modelId"
],
"properties": {
"modelId": {
"description": "Identifier of the target model.",
"type": "string",
"format": "uuid"
},
"errors": {
"description": "Errors returned during the copy operation.",
"type": "array",
"items": {
"$ref": "#/definitions/ErrorInformation"
}
}
}
},
"AnalyzeOperationResult": {
"description": "Status and result of the queued analyze operation.",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parameters": {
"endpoint": "{endpoint}",
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "{API key}",
"modelId": "{modelId}",
"body": {},
"copyRequest": {
"targetResourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{resourceName}",
"targetResourceRegion": "westus2",
"copyAuthorization": {
"modelId": "{modelId}",
"accessToken": "{accessToken}",
"expirationDateTimeTicks": 637190189980000000
}
}
},
"responses": {
"202": {
"headers": {
"Operation-Location": "{endpoint}/formrecognizer/v2.0-preview/custom/models/{modelId}/copyResults/{resultId}"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"parameters": {
"endpoint": "{endpoint}",
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "{API key}",
"body": {}
},
"responses": {
"201": {
"headers": {
"Location": "{endpoint}/formrecognizer/v2.0-preview/custom/models/{modelId}"
},
"body": {
"modelId": "{modelId}",
"accessToken": "{accessToken}",
"expirationDateTimeTicks": 637190189980000000
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parameters": {
"endpoint": "{endpoint}",
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "{API key}",
"modelId": "{modelId}",
"resultId": "{resultId}",
"body": {}
},
"responses": {
"200": {
"body": {
"status": "succeeded",
"createdDateTime": "2020-01-01T00:00:00Z",
"lastUpdatedDateTime": "2020-01-01T00:01:00Z",
"copyResult": {
"modelId": "{modelId}",
"errors": []
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"parameters": {
"endpoint": "{endpoint}",
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "{API key}",
"modelId": "{modelId}",
"resultId": "{resultId}",
"body": {}
},
"responses": {
"200": {
"body": {
"status": "failed",
"createdDateTime": "2020-01-01T00:00:00Z",
"lastUpdatedDateTime": "2020-01-01T00:01:00Z",
"copyResult": {
"modelId": "{modelId}",
"errors": [
{
"code": "ResourceResolverError",
"message": "{ErrorMessage}"
}
]
}
}
}
}
}