Skip to content

Commit

Permalink
CodeGen from PR 25570 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge ec6e6866e442d9e6ab33fd3cef7ddc23afcb29b4 into d6665aaea57eb608c4142d729d747d75c77e3c14
  • Loading branch information
SDKAuto committed Dec 8, 2023
1 parent 17de1a2 commit 37d9e12
Show file tree
Hide file tree
Showing 13 changed files with 410 additions and 47 deletions.
25 changes: 19 additions & 6 deletions sdk/contentsafety/ai-content-safety-rest/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "./types/src/index.d.ts",
"docModel": { "enabled": true },
"apiReport": { "enabled": true, "reportFolder": "./review" },
"docModel": {
"enabled": true
},
"apiReport": {
"enabled": true,
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/ai-content-safety.d.ts"
},
"messages": {
"tsdocMessageReporting": { "default": { "logLevel": "none" } },
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
},
"extractorMessageReporting": {
"ae-missing-release-tag": { "logLevel": "none" },
"ae-unresolved-link": { "logLevel": "none" }
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "none"
}
}
}
}
}
2 changes: 1 addition & 1 deletion sdk/contentsafety/ai-content-safety-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@
"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure-rest/ai-content-safety?view=azure-node-preview"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ export interface AnalyzeTextDefaultResponse extends HttpResponse {
status: string;
}

// @public
export interface AnalyzeTextJailbreakOptions {
text: string;
}

// @public
export interface AnalyzeTextJailbreakOptionsOutput {
text: string;
}

// @public
export interface AnalyzeTextJailbreakResultOutput {
jailbreakAnalysis: JailbreakAnalysisResultOutput;
}

// @public
export interface AnalyzeTextOptions {
blocklistNames?: string[];
Expand All @@ -172,6 +187,21 @@ export interface AnalyzeTextOptionsOutput {
// @public (undocumented)
export type AnalyzeTextParameters = AnalyzeTextBodyParam & RequestParameters;

// @public
export interface AnalyzeTextProtectedMaterialOptions {
text: string;
}

// @public
export interface AnalyzeTextProtectedMaterialOptionsOutput {
text: string;
}

// @public
export interface AnalyzeTextProtectedMaterialResultOutput {
protectedMaterialAnalysis: ProtectedMaterialAnalysisResultOutput;
}

// @public
export interface AnalyzeTextResultOutput {
blocklistsMatch?: Array<TextBlocklistMatchOutput>;
Expand Down Expand Up @@ -255,6 +285,78 @@ export interface DeleteTextBlocklistDefaultResponse extends HttpResponse {
// @public (undocumented)
export type DeleteTextBlocklistParameters = RequestParameters;

// @public (undocumented)
export interface DetectTextJailbreak {
post(options: DetectTextJailbreakParameters): StreamableMethod<DetectTextJailbreak200Response | DetectTextJailbreakDefaultResponse>;
}

// @public
export interface DetectTextJailbreak200Response extends HttpResponse {
// (undocumented)
body: AnalyzeTextJailbreakResultOutput;
// (undocumented)
status: "200";
}

// @public (undocumented)
export interface DetectTextJailbreakBodyParam {
body: AnalyzeTextJailbreakOptions;
}

// @public (undocumented)
export interface DetectTextJailbreakDefaultHeaders {
"x-ms-error-code"?: string;
}

// @public (undocumented)
export interface DetectTextJailbreakDefaultResponse extends HttpResponse {
// (undocumented)
body: ErrorResponse;
// (undocumented)
headers: RawHttpHeaders & DetectTextJailbreakDefaultHeaders;
// (undocumented)
status: string;
}

// @public (undocumented)
export type DetectTextJailbreakParameters = DetectTextJailbreakBodyParam & RequestParameters;

// @public (undocumented)
export interface DetectTextProtectedMaterial {
post(options: DetectTextProtectedMaterialParameters): StreamableMethod<DetectTextProtectedMaterial200Response | DetectTextProtectedMaterialDefaultResponse>;
}

// @public
export interface DetectTextProtectedMaterial200Response extends HttpResponse {
// (undocumented)
body: AnalyzeTextProtectedMaterialResultOutput;
// (undocumented)
status: "200";
}

// @public (undocumented)
export interface DetectTextProtectedMaterialBodyParam {
body: AnalyzeTextProtectedMaterialOptions;
}

// @public (undocumented)
export interface DetectTextProtectedMaterialDefaultHeaders {
"x-ms-error-code"?: string;
}

// @public (undocumented)
export interface DetectTextProtectedMaterialDefaultResponse extends HttpResponse {
// (undocumented)
body: ErrorResponse;
// (undocumented)
headers: RawHttpHeaders & DetectTextProtectedMaterialDefaultHeaders;
// (undocumented)
status: string;
}

// @public (undocumented)
export type DetectTextProtectedMaterialParameters = DetectTextProtectedMaterialBodyParam & RequestParameters;

// @public
export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;

Expand Down Expand Up @@ -350,6 +452,12 @@ export interface ImageDataOutput {
// @public (undocumented)
export function isUnexpected(response: AnalyzeText200Response | AnalyzeTextDefaultResponse): response is AnalyzeTextDefaultResponse;

// @public (undocumented)
export function isUnexpected(response: DetectTextJailbreak200Response | DetectTextJailbreakDefaultResponse): response is DetectTextJailbreakDefaultResponse;

// @public (undocumented)
export function isUnexpected(response: DetectTextProtectedMaterial200Response | DetectTextProtectedMaterialDefaultResponse): response is DetectTextProtectedMaterialDefaultResponse;

// @public (undocumented)
export function isUnexpected(response: AnalyzeImage200Response | AnalyzeImageDefaultResponse): response is AnalyzeImageDefaultResponse;

Expand Down Expand Up @@ -377,6 +485,11 @@ export function isUnexpected(response: GetTextBlocklistItem200Response | GetText
// @public (undocumented)
export function isUnexpected(response: ListTextBlocklistItems200Response | ListTextBlocklistItemsDefaultResponse): response is ListTextBlocklistItemsDefaultResponse;

// @public
export interface JailbreakAnalysisResultOutput {
detected: boolean;
}

// @public (undocumented)
export interface ListTextBlocklistItems {
get(options?: ListTextBlocklistItemsParameters): StreamableMethod<ListTextBlocklistItems200Response | ListTextBlocklistItemsDefaultResponse>;
Expand Down Expand Up @@ -473,6 +586,11 @@ export interface PagingOptions<TResponse> {
customGetPage?: GetPage<PaginateReturn<TResponse>[]>;
}

// @public
export interface ProtectedMaterialAnalysisResultOutput {
detected: boolean;
}

// @public (undocumented)
export interface RemoveBlocklistItems {
post(options: RemoveBlocklistItemsParameters): StreamableMethod<RemoveBlocklistItems204Response | RemoveBlocklistItemsDefaultResponse>;
Expand Down Expand Up @@ -515,6 +633,8 @@ export interface RemoveTextBlocklistItemsOptions {
// @public (undocumented)
export interface Routes {
(path: "/text:analyze"): AnalyzeText;
(path: "/text:detectJailbreak"): DetectTextJailbreak;
(path: "/text:detectProtectedMaterial"): DetectTextProtectedMaterial;
(path: "/image:analyze"): AnalyzeImage;
(path: "/text/blocklists/{blocklistName}", blocklistName: string): GetTextBlocklist;
(path: "/text/blocklists"): ListTextBlocklists;
Expand Down
61 changes: 53 additions & 8 deletions sdk/contentsafety/ai-content-safety-rest/src/clientDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import {
AnalyzeTextParameters,
DetectTextJailbreakParameters,
DetectTextProtectedMaterialParameters,
AnalyzeImageParameters,
GetTextBlocklistParameters,
CreateOrUpdateTextBlocklistParameters,
Expand All @@ -16,6 +18,10 @@ import {
import {
AnalyzeText200Response,
AnalyzeTextDefaultResponse,
DetectTextJailbreak200Response,
DetectTextJailbreakDefaultResponse,
DetectTextProtectedMaterial200Response,
DetectTextProtectedMaterialDefaultResponse,
AnalyzeImage200Response,
AnalyzeImageDefaultResponse,
GetTextBlocklist200Response,
Expand Down Expand Up @@ -45,6 +51,25 @@ export interface AnalyzeText {
): StreamableMethod<AnalyzeText200Response | AnalyzeTextDefaultResponse>;
}

export interface DetectTextJailbreak {
/** A synchronous API for the analysis of text jailbreak. */
post(
options: DetectTextJailbreakParameters
): StreamableMethod<
DetectTextJailbreak200Response | DetectTextJailbreakDefaultResponse
>;
}

export interface DetectTextProtectedMaterial {
/** A synchronous API for the analysis of protected material. */
post(
options: DetectTextProtectedMaterialParameters
): StreamableMethod<
| DetectTextProtectedMaterial200Response
| DetectTextProtectedMaterialDefaultResponse
>;
}

export interface AnalyzeImage {
/** A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence. */
post(
Expand All @@ -56,7 +81,9 @@ export interface GetTextBlocklist {
/** Returns text blocklist details. */
get(
options?: GetTextBlocklistParameters
): StreamableMethod<GetTextBlocklist200Response | GetTextBlocklistDefaultResponse>;
): StreamableMethod<
GetTextBlocklist200Response | GetTextBlocklistDefaultResponse
>;
/** Updates a text blocklist. If the blocklistName does not exist, a new blocklist will be created. */
patch(
options: CreateOrUpdateTextBlocklistParameters
Expand All @@ -68,53 +95,71 @@ export interface GetTextBlocklist {
/** Deletes a text blocklist. */
delete(
options?: DeleteTextBlocklistParameters
): StreamableMethod<DeleteTextBlocklist204Response | DeleteTextBlocklistDefaultResponse>;
): StreamableMethod<
DeleteTextBlocklist204Response | DeleteTextBlocklistDefaultResponse
>;
}

export interface ListTextBlocklists {
/** Get all text blocklists details. */
get(
options?: ListTextBlocklistsParameters
): StreamableMethod<ListTextBlocklists200Response | ListTextBlocklistsDefaultResponse>;
): StreamableMethod<
ListTextBlocklists200Response | ListTextBlocklistsDefaultResponse
>;
}

export interface AddOrUpdateBlocklistItems {
/** Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one request. */
post(
options: AddOrUpdateBlocklistItemsParameters
): StreamableMethod<
AddOrUpdateBlocklistItems200Response | AddOrUpdateBlocklistItemsDefaultResponse
| AddOrUpdateBlocklistItems200Response
| AddOrUpdateBlocklistItemsDefaultResponse
>;
}

export interface RemoveBlocklistItems {
/** Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request. */
post(
options: RemoveBlocklistItemsParameters
): StreamableMethod<RemoveBlocklistItems204Response | RemoveBlocklistItemsDefaultResponse>;
): StreamableMethod<
RemoveBlocklistItems204Response | RemoveBlocklistItemsDefaultResponse
>;
}

export interface GetTextBlocklistItem {
/** Get blocklistItem by blocklistName and blocklistItemId from a text blocklist. */
get(
options?: GetTextBlocklistItemParameters
): StreamableMethod<GetTextBlocklistItem200Response | GetTextBlocklistItemDefaultResponse>;
): StreamableMethod<
GetTextBlocklistItem200Response | GetTextBlocklistItemDefaultResponse
>;
}

export interface ListTextBlocklistItems {
/** Get all blocklistItems in a text blocklist. */
get(
options?: ListTextBlocklistItemsParameters
): StreamableMethod<ListTextBlocklistItems200Response | ListTextBlocklistItemsDefaultResponse>;
): StreamableMethod<
ListTextBlocklistItems200Response | ListTextBlocklistItemsDefaultResponse
>;
}

export interface Routes {
/** Resource for '/text:analyze' has methods for the following verbs: post */
(path: "/text:analyze"): AnalyzeText;
/** Resource for '/text:detectJailbreak' has methods for the following verbs: post */
(path: "/text:detectJailbreak"): DetectTextJailbreak;
/** Resource for '/text:detectProtectedMaterial' has methods for the following verbs: post */
(path: "/text:detectProtectedMaterial"): DetectTextProtectedMaterial;
/** Resource for '/image:analyze' has methods for the following verbs: post */
(path: "/image:analyze"): AnalyzeImage;
/** Resource for '/text/blocklists/\{blocklistName\}' has methods for the following verbs: get, patch, delete */
(path: "/text/blocklists/{blocklistName}", blocklistName: string): GetTextBlocklist;
(
path: "/text/blocklists/{blocklistName}",
blocklistName: string
): GetTextBlocklist;
/** Resource for '/text/blocklists' has methods for the following verbs: get */
(path: "/text/blocklists"): ListTextBlocklists;
/** Resource for '/text/blocklists/\{blocklistName\}:addOrUpdateBlocklistItems' has methods for the following verbs: post */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function createClient(
options: ClientOptions = {}
): ContentSafetyClient {
const baseUrl = options.baseUrl ?? `${endpoint}/contentsafety`;
options.apiVersion = options.apiVersion ?? "2023-10-01";
options.apiVersion = options.apiVersion ?? "2023-10-15-preview";
const userAgentInfo = `azsdk-js-ai-content-safety-rest/1.0.0`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
Expand All @@ -34,12 +34,19 @@ export default function createClient(
logger: options.loggingOptions?.logger ?? logger.info,
},
credentials: {
scopes: options.credentials?.scopes ?? ["https://cognitiveservices.azure.com/.default"],
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
scopes: options.credentials?.scopes ?? [
"https://cognitiveservices.azure.com/.default",
],
apiKeyHeaderName:
options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
},
};

const client = getClient(baseUrl, credentials, options) as ContentSafetyClient;
const client = getClient(
baseUrl,
credentials,
options
) as ContentSafetyClient;

return client;
}
Loading

0 comments on commit 37d9e12

Please sign in to comment.