Skip to content
Closed
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
25 changes: 19 additions & 6 deletions sdk/communication/communication-job-router-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-job-router.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"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
"azure-communication-services"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import { Client } from '@azure-rest/core-client';
import { ClientOptions } from '@azure-rest/core-client';
import { ErrorResponse } from '@azure-rest/core-client';
import { HttpResponse } from '@azure-rest/core-client';
import { KeyCredential } from '@azure/core-auth';
import { Paged } from '@azure/core-paging';
import { PagedAsyncIterableIterator } from '@azure/core-paging';
import { PathUncheckedResponse } from '@azure-rest/core-client';
import { RawHttpHeaders } from '@azure/core-rest-pipeline';
import { RawHttpHeadersInput } from '@azure/core-rest-pipeline';
import { RequestParameters } from '@azure-rest/core-client';
import { StreamableMethod } from '@azure-rest/core-client';
import { TokenCredential } from '@azure/core-auth';

// @public (undocumented)
export interface Accept {
Expand Down Expand Up @@ -279,10 +277,7 @@ export interface ConditionalWorkerSelectorAttachmentOutput extends WorkerSelecto
}

// @public
function createClient(connectionString: string, options: ClientOptions): AzureCommunicationRoutingServiceClient;

// @public
function createClient(endpoint: string, credentialOrOptions?: KeyCredential | TokenCredential, options?: ClientOptions): AzureCommunicationRoutingServiceClient;
function createClient(endpoint: string, options?: ClientOptions): AzureCommunicationRoutingServiceClient;
export default createClient;

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,39 @@
// Licensed under the MIT license.

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

/**
* Initialize a new instance of `AzureCommunicationRoutingServiceClient`
* @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
): AzureCommunicationRoutingServiceClient;

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

// Implementation
export default function createClient(
arg1: string,
arg2?: ClientOptions | (KeyCredential | TokenCredential),
arg3?: ClientOptions
options: ClientOptions = {}
): AzureCommunicationRoutingServiceClient {
let credentialOrOptions: KeyCredential | TokenCredential | undefined;
let options: ClientOptions | undefined;
const connectionStringOrUrl = arg1;

// Determine which constructor is being called based on the types of the arguments
if (isTokenCredential(arg2) || isKeyCredential(arg2)) {
credentialOrOptions = arg2 as KeyCredential | TokenCredential;
options = arg3 as ClientOptions;
} else {
options = arg2 as ClientOptions;
}
if (options === undefined) {
options = {};
}

// Rest of the function remains the same, using connectionStringOrUrl or endpoint as needed
const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);
const baseUrl = options?.baseUrl ?? `${url}`;
options.apiVersion = options?.apiVersion ?? "2023-11-01";

const userAgentInfo = "azsdk-js-communication-job-router-rest/1.0.1";
const baseUrl = options.baseUrl ?? `${endpoint}`;
options.apiVersion = options.apiVersion ?? "2023-11-01";
const userAgentInfo = `azsdk-js-communication-job-router-rest/1.0.0-beta.1`;
const userAgentPrefix =
options?.userAgentOptions && options?.userAgentOptions.userAgentPrefix
? `${options?.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
: `${userAgentInfo}`;
options = {
...options,
userAgentOptions: {
userAgentPrefix,
},
loggingOptions: {
logger: options?.loggingOptions?.logger ?? logger.info,
logger: options.loggingOptions?.logger ?? logger.info,
},
};

const client = getClient(baseUrl, options) as AzureCommunicationRoutingServiceClient;

const authPolicy = createCommunicationAuthPolicy(credential);
client.pipeline.addPolicy(authPolicy);
const client = getClient(
baseUrl,
options
) as AzureCommunicationRoutingServiceClient;

return client;
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ export interface UpsertClassificationPolicy {
/** Retrieves an existing classification policy by Id. */
get(
options?: GetClassificationPolicyParameters
): StreamableMethod<GetClassificationPolicy200Response | GetClassificationPolicyDefaultResponse>;
): StreamableMethod<
GetClassificationPolicy200Response | GetClassificationPolicyDefaultResponse
>;
/** Delete a classification policy by Id. */
delete(
options?: DeleteClassificationPolicyParameters
): StreamableMethod<
DeleteClassificationPolicy204Response | DeleteClassificationPolicyDefaultResponse
| DeleteClassificationPolicy204Response
| DeleteClassificationPolicyDefaultResponse
>;
}

Expand All @@ -138,7 +141,8 @@ export interface ListClassificationPolicies {
get(
options?: ListClassificationPoliciesParameters
): StreamableMethod<
ListClassificationPolicies200Response | ListClassificationPoliciesDefaultResponse
| ListClassificationPolicies200Response
| ListClassificationPoliciesDefaultResponse
>;
}

Expand All @@ -154,12 +158,15 @@ export interface UpsertDistributionPolicy {
/** Retrieves an existing distribution policy by Id. */
get(
options?: GetDistributionPolicyParameters
): StreamableMethod<GetDistributionPolicy200Response | GetDistributionPolicyDefaultResponse>;
): StreamableMethod<
GetDistributionPolicy200Response | GetDistributionPolicyDefaultResponse
>;
/** Delete a distribution policy by Id. */
delete(
options?: DeleteDistributionPolicyParameters
): StreamableMethod<
DeleteDistributionPolicy204Response | DeleteDistributionPolicyDefaultResponse
| DeleteDistributionPolicy204Response
| DeleteDistributionPolicyDefaultResponse
>;
}

Expand All @@ -168,7 +175,8 @@ export interface ListDistributionPolicies {
get(
options?: ListDistributionPoliciesParameters
): StreamableMethod<
ListDistributionPolicies200Response | ListDistributionPoliciesDefaultResponse
| ListDistributionPolicies200Response
| ListDistributionPoliciesDefaultResponse
>;
}

Expand All @@ -184,25 +192,33 @@ export interface UpsertExceptionPolicy {
/** Retrieves an existing exception policy by Id. */
get(
options?: GetExceptionPolicyParameters
): StreamableMethod<GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse>;
): StreamableMethod<
GetExceptionPolicy200Response | GetExceptionPolicyDefaultResponse
>;
/** Deletes a exception policy by Id. */
delete(
options?: DeleteExceptionPolicyParameters
): StreamableMethod<DeleteExceptionPolicy204Response | DeleteExceptionPolicyDefaultResponse>;
): StreamableMethod<
DeleteExceptionPolicy204Response | DeleteExceptionPolicyDefaultResponse
>;
}

export interface ListExceptionPolicies {
/** Retrieves existing exception policies. */
get(
options?: ListExceptionPoliciesParameters
): StreamableMethod<ListExceptionPolicies200Response | ListExceptionPoliciesDefaultResponse>;
): StreamableMethod<
ListExceptionPolicies200Response | ListExceptionPoliciesDefaultResponse
>;
}

export interface UpsertQueue {
/** Creates or updates a queue. */
patch(
options: UpsertQueueParameters
): StreamableMethod<UpsertQueue200Response | UpsertQueue201Response | UpsertQueueDefaultResponse>;
): StreamableMethod<
UpsertQueue200Response | UpsertQueue201Response | UpsertQueueDefaultResponse
>;
/** Retrieves an existing queue by Id. */
get(
options?: GetQueueParameters
Expand All @@ -224,9 +240,13 @@ export interface UpsertJob {
/** Creates or updates a router job. */
patch(
options: UpsertJobParameters
): StreamableMethod<UpsertJob200Response | UpsertJob201Response | UpsertJobDefaultResponse>;
): StreamableMethod<
UpsertJob200Response | UpsertJob201Response | UpsertJobDefaultResponse
>;
/** Retrieves an existing job by Id. */
get(options?: GetJobParameters): StreamableMethod<GetJob200Response | GetJobDefaultResponse>;
get(
options?: GetJobParameters
): StreamableMethod<GetJob200Response | GetJobDefaultResponse>;
/** Deletes a job and all of its traces. */
delete(
options?: DeleteJobParameters
Expand All @@ -242,7 +262,9 @@ export interface Reclassify {

export interface Cancel {
/** Submits request to cancel an existing job by Id while supplying free-form cancellation reason. */
post(options?: CancelParameters): StreamableMethod<Cancel200Response | CancelDefaultResponse>;
post(
options?: CancelParameters
): StreamableMethod<Cancel200Response | CancelDefaultResponse>;
}

export interface Complete {
Expand All @@ -254,7 +276,9 @@ export interface Complete {

export interface Close {
/** Closes a completed job. */
post(options?: CloseParameters): StreamableMethod<Close200Response | CloseDefaultResponse>;
post(
options?: CloseParameters
): StreamableMethod<Close200Response | CloseDefaultResponse>;
}

export interface ListJobs {
Expand All @@ -268,7 +292,9 @@ export interface GetInQueuePosition {
/** Gets a job's position details. */
get(
options?: GetInQueuePositionParameters
): StreamableMethod<GetInQueuePosition200Response | GetInQueuePositionDefaultResponse>;
): StreamableMethod<
GetInQueuePosition200Response | GetInQueuePositionDefaultResponse
>;
}

export interface Unassign {
Expand All @@ -280,27 +306,35 @@ export interface Unassign {

export interface Accept {
/** Accepts an offer to work on a job and returns a 409/Conflict if another agent accepted the job already. */
post(options?: AcceptParameters): StreamableMethod<Accept200Response | AcceptDefaultResponse>;
post(
options?: AcceptParameters
): StreamableMethod<Accept200Response | AcceptDefaultResponse>;
}

export interface Decline {
/** Declines an offer to work on a job. */
post(options?: DeclineParameters): StreamableMethod<Decline200Response | DeclineDefaultResponse>;
post(
options?: DeclineParameters
): StreamableMethod<Decline200Response | DeclineDefaultResponse>;
}

export interface GetQueueStatistics {
/** Retrieves a queue's statistics. */
get(
options?: GetQueueStatisticsParameters
): StreamableMethod<GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse>;
): StreamableMethod<
GetQueueStatistics200Response | GetQueueStatisticsDefaultResponse
>;
}

export interface UpsertWorker {
/** Creates or updates a worker. */
patch(
options: UpsertWorkerParameters
): StreamableMethod<
UpsertWorker200Response | UpsertWorker201Response | UpsertWorkerDefaultResponse
| UpsertWorker200Response
| UpsertWorker201Response
| UpsertWorkerDefaultResponse
>;
/** Retrieves an existing worker by Id. */
get(
Expand Down Expand Up @@ -386,7 +420,10 @@ export interface Routes {
offerId: string
): Decline;
/** Resource for '/routing/queues/\{queueId\}/statistics' has methods for the following verbs: get */
(path: "/routing/queues/{queueId}/statistics", queueId: string): GetQueueStatistics;
(
path: "/routing/queues/{queueId}/statistics",
queueId: string
): GetQueueStatistics;
/** Resource for '/routing/workers/\{workerId\}' has methods for the following verbs: patch, get, delete */
(path: "/routing/workers/{workerId}", workerId: string): UpsertWorker;
/** Resource for '/routing/workers' has methods for the following verbs: get */
Expand Down
Loading