Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the latest typespec commit ID and re-generating the SDK #30940

Merged
merged 7 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions sdk/translation/ai-translation-document-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
"dependencies": {
"@azure/core-rest-pipeline": "^1.8.0",
"@azure/logger": "^1.0.0",
"@azure/core-paging": "^1.2.0",
"@azure/core-paging": "^1.5.0",
"@azure-rest/core-client": "^2.0.0",
"@azure/core-auth": "^1.6.0",
"tslib": "^2.6.2",
"@azure/core-lro": "3.0.0-beta.1",
"@azure/abort-controller": "^2.0.0"
"@azure/core-lro": "^3.0.0",
"@azure/abort-controller": "^2.1.2"
},
"devDependencies": {
"@azure/storage-blob": "^12.23.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { AbortSignalLike } from '@azure/abort-controller';
import { CancelOnProgress } from '@azure/core-lro';
import { Client } from '@azure-rest/core-client';
import { ClientOptions } from '@azure-rest/core-client';
import { createFile } from '@azure/core-rest-pipeline';
import { createFileFromStream } from '@azure/core-rest-pipeline';
import { CreateFileFromStreamOptions } from '@azure/core-rest-pipeline';
import { CreateFileOptions } from '@azure/core-rest-pipeline';
import { CreateHttpPollerOptions } from '@azure/core-lro';
import { ErrorResponse } from '@azure-rest/core-client';
import { HttpResponse } from '@azure-rest/core-client';
Expand Down Expand Up @@ -59,17 +55,9 @@ export interface CancelTranslationDefaultResponse extends HttpResponse {
export type CancelTranslationParameters = RequestParameters;

// @public
function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient;
function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, { apiVersion, ...options }?: DocumentTranslationClientOptions): DocumentTranslationClient;
hamshavathimunibyraiah marked this conversation as resolved.
Show resolved Hide resolved
export default createClient;

export { createFile }

export { createFileFromStream }

export { CreateFileFromStreamOptions }

export { CreateFileOptions }

// @public
export interface DocumentFilter {
prefix?: string;
Expand Down Expand Up @@ -103,6 +91,7 @@ export interface DocumentTranslate {

// @public (undocumented)
export interface DocumentTranslate200Headers {
"content-type": "application/octet-stream";
"x-ms-client-request-id"?: string;
}

Expand All @@ -117,8 +106,7 @@ export interface DocumentTranslate200Response extends HttpResponse {

// @public (undocumented)
export interface DocumentTranslateBodyParam {
// (undocumented)
body?: DocumentTranslateContent;
body: DocumentTranslateContent;
}

// @public
Expand Down Expand Up @@ -201,6 +189,11 @@ export type DocumentTranslationClient = Client & {
path: Routes;
};

// @public
export interface DocumentTranslationClientOptions extends ClientOptions {
apiVersion?: string;
hamshavathimunibyraiah marked this conversation as resolved.
Show resolved Hide resolved
}

// @public
export interface FileFormatOutput {
contentTypes: string[];
Expand All @@ -212,7 +205,7 @@ export interface FileFormatOutput {
}

// @public
export type FileFormatType = "document" | "glossary" | string;
export type FileFormatType = string;
hamshavathimunibyraiah marked this conversation as resolved.
Show resolved Hide resolved

// @public
export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
Expand Down Expand Up @@ -494,6 +487,7 @@ export interface SimplePollerLike<TState extends OperationState<TResult>, TResul
getOperationState(): TState;
getResult(): TResult | undefined;
isDone(): boolean;
// @deprecated
isStopped(): boolean;
onProgress(callback: (state: TState) => void): CancelOnProgress;
poll(options?: {
Expand Down Expand Up @@ -521,7 +515,7 @@ export interface SourceInput {
// @public (undocumented)
export interface StartTranslation {
get(options?: GetTranslationsStatusParameters): StreamableMethod<GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse>;
post(options?: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
post(options: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
}

// @public (undocumented)
Expand All @@ -539,8 +533,7 @@ export interface StartTranslation202Response extends HttpResponse {

// @public (undocumented)
export interface StartTranslationBodyParam {
// (undocumented)
body?: StartTranslationDetails;
body: StartTranslationDetails;
}

// @public (undocumented)
Expand Down Expand Up @@ -573,7 +566,7 @@ export interface StartTranslationLogicalResponse extends HttpResponse {
export type StartTranslationParameters = StartTranslationBodyParam & RequestParameters;

// @public
export type StatusOutput = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Cancelled" | "Cancelling" | "ValidationFailed" | string;
export type StatusOutput = string;
hamshavathimunibyraiah marked this conversation as resolved.
Show resolved Hide resolved

// @public
export interface StatusSummaryOutput {
Expand All @@ -587,10 +580,10 @@ export interface StatusSummaryOutput {
}

// @public
export type StorageInputType = "Folder" | "File" | string;
export type StorageInputType = string;

// @public
export type StorageSource = "AzureBlob" | string;
export type StorageSource = string;

// @public
export interface SupportedFileFormatsOutput {
Expand All @@ -607,7 +600,7 @@ export interface TargetInput {
}

// @public
export type TranslationErrorCodeOutput = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh" | string;
export type TranslationErrorCodeOutput = string;

// @public
export interface TranslationErrorOutput {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import {
DocumentTranslateParameters,
StartTranslationParameters,
Expand Down Expand Up @@ -61,7 +64,7 @@ export interface StartTranslation {
* must be unique.
*/
post(
options?: StartTranslationParameters,
options: StartTranslationParameters,
): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
/**
* Returns a list of batch requests submitted and the status for each
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { getClient, ClientOptions } from "@azure-rest/core-client";
import { logger } from "./logger";
import { TokenCredential, KeyCredential } from "@azure/core-auth";
import { DocumentTranslationClient } from "./clientDefinitions";

/** The optional parameters for the client */
export interface DocumentTranslationClientOptions extends ClientOptions {
/** The api version option of the client */
apiVersion?: string;
}

/**
* Initialize a new instance of `DocumentTranslationClient`
* @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.
Expand All @@ -15,11 +24,10 @@ import { DocumentTranslationClient } from "./clientDefinitions";
export default function createClient(
endpointParam: string,
credentials: TokenCredential | KeyCredential,
options: ClientOptions = {},
{ apiVersion = "2024-05-01", ...options }: DocumentTranslationClientOptions = {},
): DocumentTranslationClient {
const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;
options.apiVersion = options.apiVersion ?? "2024-05-01";
const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.2`;
const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
Expand All @@ -37,8 +45,24 @@ export default function createClient(
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
},
};

const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;

client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
client.pipeline.addPolicy({
name: "ClientApiVersionPolicy",
sendRequest: (req, next) => {
// Use the apiVersion defined in request url directly
// Append one if there is no apiVersion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version") && apiVersion) {
req.url = `${req.url}${
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
}api-version=${apiVersion}`;
}

return next(req);
},
});

return client;
}
9 changes: 3 additions & 6 deletions sdk/translation/ai-translation-document-rest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import DocumentTranslationClient from "./documentTranslationClient";

export * from "./documentTranslationClient";
Expand All @@ -12,11 +15,5 @@ export * from "./models";
export * from "./outputModels";
export * from "./paginateHelper";
export * from "./pollingHelper";
export {
createFile,
createFileFromStream,
type CreateFileOptions,
type CreateFileFromStreamOptions,
} from "@azure/core-rest-pipeline";

export default DocumentTranslationClient;
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation.
hamshavathimunibyraiah marked this conversation as resolved.
Show resolved Hide resolved
// Licensed under the MIT license.

import {
DocumentTranslate200Response,
DocumentTranslateDefaultResponse,
Expand Down
3 changes: 3 additions & 0 deletions sdk/translation/ai-translation-document-rest/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { createClientLogger } from "@azure/logger";
export const logger = createClientLogger("ai-translation-document");
33 changes: 26 additions & 7 deletions sdk/translation/ai-translation-document-rest/src/models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export interface DocumentTranslateContentDocumentPartDescriptor {
name: "document";
body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;
Expand All @@ -27,7 +30,11 @@ export interface BatchRequest {
source: SourceInput;
/** Location of the destination for the output */
targets: Array<TargetInput>;
/** Storage type of the input documents source string */
/**
* Storage type of the input documents source string
*
* Possible values: "Folder", "File"
*/
storageType?: StorageInputType;
}

Expand All @@ -42,7 +49,11 @@ export interface SourceInput {
* If none is specified, we will perform auto detect on the document
*/
language?: string;
/** Storage Source */
/**
* Storage Source
*
* Possible values: "AzureBlob"
*/
storageSource?: StorageSource;
}

Expand Down Expand Up @@ -73,7 +84,11 @@ export interface TargetInput {
language: string;
/** List of Glossary */
glossaries?: Array<Glossary>;
/** Storage Source */
/**
* Storage Source
*
* Possible values: "AzureBlob"
*/
storageSource?: StorageSource;
}

Expand All @@ -92,7 +107,11 @@ export interface Glossary {
format: string;
/** Optional Version. If not specified, default is used. */
version?: string;
/** Storage Source */
/**
* Storage Source
*
* Possible values: "AzureBlob"
*/
storageSource?: StorageSource;
}

Expand All @@ -104,8 +123,8 @@ export type DocumentTranslateContent =
| DocumentTranslateContentGlossaryPartDescriptor
>;
/** Alias for StorageSource */
export type StorageSource = "AzureBlob" | string;
export type StorageSource = string;
/** Alias for StorageInputType */
export type StorageInputType = "Folder" | "File" | string;
export type StorageInputType = string;
/** Alias for FileFormatType */
export type FileFormatType = "document" | "glossary" | string;
export type FileFormatType = string;
Loading