Skip to content

Commit

Permalink
CodeGen from PR 29440 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 02b541d35fc6862db3f7955cd6178b61635ba4f4 into 30c95a2a424a347f27ac78b6bdefd37f71314b7e
  • Loading branch information
SDKAuto committed Jun 14, 2024
1 parent 090184d commit 9f86b7c
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 263 deletions.
25 changes: 19 additions & 6 deletions sdk/communication/communication-messages-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/communication-messages.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"
}
}
}
}
}
5 changes: 2 additions & 3 deletions sdk/communication/communication-messages-rest/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ module.exports = function (config) {

envPreprocessor: [
"TEST_MODE",
"ENDPOINT",
"AZURE_CLIENT_SECRET",
"AZURE_CLIENT_ID",
"AZURE_TENANT_ID",
"CHANNEL_ID",
"RECIPIENT_PHONE_NUMBER",
"COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING",
"SUBSCRIPTION_ID",
"RECORDINGS_RELATIVE_PATH",
],

Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/communication-messages-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@
"azure-communication-services"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import { StreamableMethod } from '@azure-rest/core-client';
import { TokenCredential } from '@azure/core-auth';

// @public
export interface ClientRequestIdHeaderOutput {
}
export type CommunicationMessageKind = string | "text" | "image" | "template";

// @public
function createClient(connectionString: string, options?: ClientOptions): MessagesServiceClient;
export type CommunicationMessagesChannelOutput = string | "whatsApp";

// @public
function createClient(endpoint: string, credential: KeyCredential | TokenCredential, options?: ClientOptions): MessagesServiceClient;
function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): MessagesServiceClient;
export default createClient;

// @public
Expand Down Expand Up @@ -184,10 +183,13 @@ export interface MessageTemplate {
// @public
export type MessageTemplateBindings = MessageTemplateBindingsParent | WhatsAppMessageTemplateBindings;

// @public
export type MessageTemplateBindingsKind = string | "whatsApp";

// @public
export interface MessageTemplateBindingsParent {
// (undocumented)
kind: string;
kind: MessageTemplateBindingsKind;
}

// @public
Expand All @@ -212,10 +214,10 @@ export type MessageTemplateItemOutput = MessageTemplateItemOutputParent | WhatsA
// @public
export interface MessageTemplateItemOutputParent {
// (undocumented)
kind: string;
kind: CommunicationMessagesChannelOutput;
language: string;
readonly name: string;
status: string;
status: MessageTemplateStatusOutput;
}

// @public
Expand All @@ -234,6 +236,9 @@ export interface MessageTemplateQuickAction extends MessageTemplateValueParent {
text?: string;
}

// @public
export type MessageTemplateStatusOutput = string | "approved" | "rejected" | "pending" | "paused";

// @public
export interface MessageTemplateText extends MessageTemplateValueParent {
kind: "text";
Expand All @@ -243,10 +248,13 @@ export interface MessageTemplateText extends MessageTemplateValueParent {
// @public
export type MessageTemplateValue = MessageTemplateValueParent | MessageTemplateText | MessageTemplateImage | MessageTemplateDocument | MessageTemplateVideo | MessageTemplateLocation | MessageTemplateQuickAction;

// @public
export type MessageTemplateValueKind = string | "text" | "image" | "document" | "video" | "location" | "quickAction";

// @public
export interface MessageTemplateValueParent {
// (undocumented)
kind: string;
kind: MessageTemplateValueKind;
name: string;
}

Expand All @@ -265,7 +273,7 @@ export type NotificationContent = NotificationContentParent | TextNotificationCo
export interface NotificationContentParent {
channelRegistrationId: string;
// (undocumented)
kind: string;
kind: CommunicationMessageKind;
to: string[];
}

Expand All @@ -287,14 +295,6 @@ export interface PagingOptions<TResponse> {
customGetPage?: GetPage<PaginateReturn<TResponse>[]>;
}

// @public
export interface RepeatabilityRequestHeadersOutput {
}

// @public
export interface RepeatabilityResponseHeadersOutput {
}

// @public
export type RepeatabilityResultOutput = "accepted" | "rejected";

Expand Down Expand Up @@ -380,6 +380,9 @@ export interface TextNotificationContent extends NotificationContentParent {
kind: "text";
}

// @public
export type WhatsAppMessageButtonSubType = string | "quickReply" | "url";

// @public
export interface WhatsAppMessageTemplateBindings extends MessageTemplateBindingsParent {
body?: Array<WhatsAppMessageTemplateBindingsComponent>;
Expand All @@ -392,7 +395,7 @@ export interface WhatsAppMessageTemplateBindings extends MessageTemplateBindings
// @public
export interface WhatsAppMessageTemplateBindingsButton {
refValue: string;
subType: string;
subType: WhatsAppMessageButtonSubType;
}

// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
GetMediaParameters,
SendParameters,
ListTemplatesParameters,
} from "./parameters";
} from "./parameters.js";
import {
GetMedia200Response,
GetMediaDefaultResponse,
Send202Response,
SendDefaultResponse,
ListTemplates200Response,
ListTemplatesDefaultResponse,
} from "./responses";
} from "./responses.js";
import { Client, StreamableMethod } from "@azure-rest/core-client";

export interface GetMedia {
Expand Down

This file was deleted.

This file was deleted.

20 changes: 11 additions & 9 deletions sdk/communication/communication-messages-rest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import MessagesServiceClient from "./messagesServiceClient";
export * from "./generated/src/messagesServiceClient";
export * from "./generated/src/parameters";
export * from "./generated/src/responses";
export * from "./generated/src/clientDefinitions";
export * from "./generated/src/isUnexpected";
export * from "./generated/src/models";
export * from "./generated/src/outputModels";
export * from "./generated/src/paginateHelper";
import MessagesServiceClient from "./messagesServiceClient.js";

export * from "./messagesServiceClient.js";
export * from "./parameters.js";
export * from "./responses.js";
export * from "./clientDefinitions.js";
export * from "./isUnexpected.js";
export * from "./models.js";
export * from "./outputModels.js";
export * from "./paginateHelper.js";

export default MessagesServiceClient;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SendDefaultResponse,
ListTemplates200Response,
ListTemplatesDefaultResponse,
} from "./responses";
} from "./responses.js";

const responseMap: Record<string, string[]> = {
"GET /messages/streams/{id}": ["200"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,51 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import {
TokenCredential,
isTokenCredential,
KeyCredential,
isKeyCredential,
} from "@azure/core-auth";
import { ClientOptions } from "@azure-rest/core-client";
import { parseClientArguments, createCommunicationAuthPolicy } from "@azure/communication-common";
import { MessagesServiceClient } from "./generated/src/clientDefinitions";
import GeneratedAzureCommunicationMessageServiceClient from "./generated/src/messagesServiceClient";
import { getClient, ClientOptions } from "@azure-rest/core-client";
import { logger } from "./logger.js";
import { TokenCredential, KeyCredential } from "@azure/core-auth";
import { MessagesServiceClient } from "./clientDefinitions.js";

/**
* Initialize a new instance of `MessagesServiceClient`
* @param connectionString - The connectionString or url of your Communication Services resource.
* @param options - the parameter for all optional parameters
*/
export default function createClient(
connectionString: string,
options?: ClientOptions,
): MessagesServiceClient;

/**
* Initialize a new instance of `MessagesServiceClient`
* @param endpoint - The endpoint of your Communication Services resource.
* @param credential - The key or token credential.
* @param options - the parameter for all optional parameters
*/
export default function createClient(
endpoint: string,
credential: KeyCredential | TokenCredential,
options?: ClientOptions,
): MessagesServiceClient;

/**
* Initialize a new instance of `MessagesServiceClient`
* @param endpoint - The communication resource, for example https://my-resource.communication.azure.com
* @param endpointParam - The communication resource, for example https://my-resource.communication.azure.com
* @param credentials - uniquely identify client credential
* @param options - the parameter for all optional parameters
*/
export default function createClient(
endpointOrConnectionString: string,
credentialOrOptions?: ClientOptions | (TokenCredential | KeyCredential),
options?: ClientOptions,
endpointParam: string,
credentials: TokenCredential | KeyCredential,
options: ClientOptions = {},
): MessagesServiceClient {
if (!(isTokenCredential(credentialOrOptions) || isKeyCredential(credentialOrOptions))) {
options = credentialOrOptions as ClientOptions;
}

if (options === undefined) {
options = {};
}

const { url, credential } = parseClientArguments(endpointOrConnectionString, credentialOrOptions);
const baseUrl = options.baseUrl ?? `${url}`;

const client = GeneratedAzureCommunicationMessageServiceClient(baseUrl, credential, options);
const authPolicy = createCommunicationAuthPolicy(credential);
client.pipeline.addPolicy(authPolicy);
const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}`;
options.apiVersion = options.apiVersion ?? "2024-02-01";
const userAgentInfo = `azsdk-js-communication-messages-rest/1.0.0-beta.2`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
: `${userAgentInfo}`;
options = {
...options,
userAgentOptions: {
userAgentPrefix,
},
loggingOptions: {
logger: options.loggingOptions?.logger ?? logger.info,
},
credentials: {
scopes: options.credentials?.scopes ?? [
"https://communication.azure.com/.default",
],
apiKeyHeaderName:
options.credentials?.apiKeyHeaderName ?? "Authorization",
},
};

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

return client;
}
Loading

0 comments on commit 9f86b7c

Please sign in to comment.