Skip to content

Commit

Permalink
Creating an options bag for optional parameters (#31517)
Browse files Browse the repository at this point in the history
* Trying to override the parameters fro getTranslationsStatus

* A fix

* Adding documentation

* Testing

* Added models for the list of parameters and also added protocol methods for GetTranslationsStatus and GetDocumentsStatus

* Format fix and updating swagger

* Removed unused using

* Addressing review comments

* Addressing review comments
  • Loading branch information
hamshavathimunibyraiah authored Nov 14, 2024
1 parent 00d50cb commit 63d530d
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 288 deletions.
12 changes: 12 additions & 0 deletions specification/translation/Azure.AI.DocumentTranslation/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ interface SingleDocumentTranslationClient {

@@clientName(DocumentTranslation.StorageSource, "translationStorageSource");

@@clientName(DocumentTranslation.GetTranslationsStatusOptions.ids,
"translationIds"
);

@@clientName(DocumentTranslation.GetDocumentsStatusOptions.id, "translationId");

@@clientName(DocumentTranslation.GetDocumentsStatusOptions.ids, "documentIds");

@@clientName(DocumentTranslation.DocumentTranslateBody.body,
"documentTranslateContent",
"csharp, java"
Expand All @@ -74,6 +82,10 @@ interface SingleDocumentTranslationClient {

@@convenientAPI(DocumentTranslationClient.getSupportedFormats, false, "java");

@@convenientAPI(DocumentTranslationClient.getTranslationsStatus, false, "java");

@@convenientAPI(DocumentTranslationClient.getDocumentsStatus, false, "java");

@@access(DocumentTranslationClient.getSupportedFormats,
Access.internal,
"python"
Expand Down
154 changes: 154 additions & 0 deletions specification/translation/Azure.AI.DocumentTranslation/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,157 @@ model StartTranslationBody {
@body
body: StartTranslationDetails;
}

@doc("Get Translations Status options")
model GetTranslationsStatusOptions {
@doc("""
top indicates the total number of records the user wants to be returned across
all pages.
Clients MAY use top and skip query parameters to
specify a number of results to return and an offset into the collection.
When
both top and skip are given by a client, the server SHOULD first apply skip
and then top on the collection.
Note: If the server can't honor
top and/or skip, the server MUST return an error to the client informing
about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("top")
top?: int32;

@doc("""
skip indicates the number of records to skip from the list of records held by
the server based on the sorting method specified. By default, we sort by
descending start time.
Clients MAY use top and skip query
parameters to specify a number of results to return and an offset into the
collection.
When both top and skip are given by a client, the server SHOULD
first apply skip and then top on the collection.
Note: If the
server can't honor top and/or skip, the server MUST return an error to the
client informing about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("skip")
skip?: int32;

@doc("""
maxpagesize is the maximum items returned in a page. If more items are
requested via top (or top is not specified and there are more items to be
returned), @nextLink will contain the link to the next page.
Clients MAY request server-driven paging with a specific page size by
specifying a maxpagesize preference. The server SHOULD honor this preference
if the specified page size is smaller than the server's default page size.
""")
@maxValue(100)
@minValue(1)
@query("maxpagesize")
maxpagesize?: int32 = 50;

@doc("Ids to use in filtering")
@query("ids")
ids?: uuid[];

@doc("Statuses to use in filtering")
@query("statuses")
statuses?: string[];

@doc("the start datetime to get items after")
@query("createdDateTimeUtcStart")
createdDateTimeUtcStart?: utcDateTime;

@doc("the end datetime to get items before")
@query("createdDateTimeUtcEnd")
createdDateTimeUtcEnd?: utcDateTime;

@doc("the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc')")
@query("orderby")
orderby?: string[];
}

@doc("Get Documents Status options")
model GetDocumentsStatusOptions {
@doc("Format - uuid. The operation id")
@path
id: uuid;

@doc("""
top indicates the total number of records the user wants to be returned across
all pages.
Clients MAY use top and skip query parameters to
specify a number of results to return and an offset into the collection.
When
both top and skip are given by a client, the server SHOULD first apply skip
and then top on the collection.
Note: If the server can't honor
top and/or skip, the server MUST return an error to the client informing
about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("top")
top?: int32;

@doc("""
skip indicates the number of records to skip from the list of records held by
the server based on the sorting method specified. By default, we sort by
descending start time.
Clients MAY use top and skip query
parameters to specify a number of results to return and an offset into the
collection.
When both top and skip are given by a client, the server SHOULD
first apply skip and then top on the collection.
Note: If the
server can't honor top and/or skip, the server MUST return an error to the
client informing about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("skip")
skip?: int32;

@doc("""
maxpagesize is the maximum items returned in a page. If more items are
requested via top (or top is not specified and there are more items to be
returned), @nextLink will contain the link to the next page.
Clients MAY request server-driven paging with a specific page size by
specifying a maxpagesize preference. The server SHOULD honor this preference
if the specified page size is smaller than the server's default page size.
""")
@maxValue(100)
@minValue(1)
@query("maxpagesize")
maxpagesize?: int32 = 50;

@doc("Ids to use in filtering")
@query("ids")
ids?: uuid[];

@doc("Statuses to use in filtering")
@query("statuses")
statuses?: string[];

@doc("the start datetime to get items after")
@query("createdDateTimeUtcStart")
createdDateTimeUtcStart?: utcDateTime;

@doc("the end datetime to get items before")
@query("createdDateTimeUtcEnd")
createdDateTimeUtcEnd?: utcDateTime;

@doc("the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc')")
@query("orderby")
orderby?: string[];
}
155 changes: 2 additions & 153 deletions specification/translation/Azure.AI.DocumentTranslation/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -130,80 +130,7 @@ interface DocumentTranslationOperations {
@route("/document/batches")
@get
getTranslationsStatus is Azure.Core.Foundations.Operation<
{
@doc("""
top indicates the total number of records the user wants to be returned across
all pages.
Clients MAY use top and skip query parameters to
specify a number of results to return and an offset into the collection.
When
both top and skip are given by a client, the server SHOULD first apply skip
and then top on the collection.
Note: If the server can't honor
top and/or skip, the server MUST return an error to the client informing
about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("top")
top?: int32;

@doc("""
skip indicates the number of records to skip from the list of records held by
the server based on the sorting method specified. By default, we sort by
descending start time.
Clients MAY use top and skip query
parameters to specify a number of results to return and an offset into the
collection.
When both top and skip are given by a client, the server SHOULD
first apply skip and then top on the collection.
Note: If the
server can't honor top and/or skip, the server MUST return an error to the
client informing about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("skip")
skip?: int32;

@doc("""
maxpagesize is the maximum items returned in a page. If more items are
requested via top (or top is not specified and there are more items to be
returned), @nextLink will contain the link to the next page.
Clients MAY request server-driven paging with a specific page size by
specifying a maxpagesize preference. The server SHOULD honor this preference
if the specified page size is smaller than the server's default page size.
""")
@maxValue(100)
@minValue(1)
@query("maxpagesize")
maxpagesize?: int32 = 50;

@doc("Ids to use in filtering")
@clientName("translationIds")
@query("ids")
ids?: uuid[];

@doc("Statuses to use in filtering")
@query("statuses")
statuses?: string[];

@doc("the start datetime to get items after")
@query("createdDateTimeUtcStart")
createdDateTimeUtcStart?: utcDateTime;

@doc("the end datetime to get items before")
@query("createdDateTimeUtcEnd")
createdDateTimeUtcEnd?: utcDateTime;

@doc("the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc')")
@query("orderby")
orderby?: string[];
},
GetTranslationsStatusOptions,
TranslationsStatus
>;

Expand Down Expand Up @@ -328,85 +255,7 @@ interface DocumentTranslationOperations {
@route("/document/batches/{id}/documents")
@get
getDocumentsStatus is Azure.Core.Foundations.Operation<
{
@doc("Format - uuid. The operation id")
@clientName("translationId")
@path
id: uuid;

@doc("""
top indicates the total number of records the user wants to be returned across
all pages.
Clients MAY use top and skip query parameters to
specify a number of results to return and an offset into the collection.
When
both top and skip are given by a client, the server SHOULD first apply skip
and then top on the collection.
Note: If the server can't honor
top and/or skip, the server MUST return an error to the client informing
about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("top")
top?: int32;

@doc("""
skip indicates the number of records to skip from the list of records held by
the server based on the sorting method specified. By default, we sort by
descending start time.
Clients MAY use top and skip query
parameters to specify a number of results to return and an offset into the
collection.
When both top and skip are given by a client, the server SHOULD
first apply skip and then top on the collection.
Note: If the
server can't honor top and/or skip, the server MUST return an error to the
client informing about it instead of just ignoring the query options.
""")
@maxValue(2147483647)
@query("skip")
skip?: int32;

@doc("""
maxpagesize is the maximum items returned in a page. If more items are
requested via top (or top is not specified and there are more items to be
returned), @nextLink will contain the link to the next page.
Clients MAY request server-driven paging with a specific page size by
specifying a maxpagesize preference. The server SHOULD honor this preference
if the specified page size is smaller than the server's default page size.
""")
@maxValue(100)
@minValue(1)
@query("maxpagesize")
maxpagesize?: int32 = 50;

@doc("Ids to use in filtering")
@clientName("documentIds")
@query("ids")
ids?: uuid[];

@doc("Statuses to use in filtering")
@query("statuses")
statuses?: string[];

@doc("the start datetime to get items after")
@query("createdDateTimeUtcStart")
createdDateTimeUtcStart?: utcDateTime;

@doc("the end datetime to get items before")
@query("createdDateTimeUtcEnd")
createdDateTimeUtcEnd?: utcDateTime;

@doc("the sorting query for the collection (ex: 'CreatedDateTimeUtc asc','CreatedDateTimeUtc desc')")
@query("orderby")
orderby?: string[];
},
GetDocumentsStatusOptions,
DocumentsStatus
>;

Expand Down
Loading

0 comments on commit 63d530d

Please sign in to comment.