Skip to content

Commit

Permalink
Rename RouterClient to JobRouterClient (#26192)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR


### Issues associated with this PR


### Describe the problem that is addressed by this PR


### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [x] Added impacted package name to the issue description
- [x] Added a changelog (if necessary)
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
  • Loading branch information
adamtuck-msft authored Jun 27, 2023
1 parent f3a04d1 commit 6215f27
Show file tree
Hide file tree
Showing 53 changed files with 689 additions and 645 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ import {
ExceptionPolicy,
JobQueue,
QueueLengthExceptionTrigger,
RouterAdministrationClient } from "@azure/communication-job-router";
JobRouterAdministrationClient,
} from "@azure/communication-job-router";

// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// Create an classification policy
async function createClassificationPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const distributionPolicyId = "distribution-policy-123";
const distributionPolicyRequest: DistributionPolicy = {
Expand All @@ -31,17 +32,20 @@ async function createClassificationPolicy(): Promise<void> {
kind: "longest-idle",
minConcurrentOffers: 1,
maxConcurrentOffers: 1,
bypassSelectors: false
bypassSelectors: false,
},
offerTtlSeconds: 15
offerTtlSeconds: 15,
};
await routerAdministrationClient.createDistributionPolicy(distributionPolicyId, distributionPolicyRequest);
await routerAdministrationClient.createDistributionPolicy(
distributionPolicyId,
distributionPolicyRequest
);

// define exception trigger for queue over flow
const queueLengthExceptionTrigger: QueueLengthExceptionTrigger = {
kind: "queue-length",
threshold: 100
}
threshold: 100,
};

const exceptionPolicyId = "exception-policy-123";
const exceptionPolicyRequest: ExceptionPolicy = {
Expand All @@ -54,13 +58,13 @@ async function createClassificationPolicy(): Promise<void> {
kind: "reclassify",
classificationPolicyId: "Main",
labelsToUpsert: {
escalated: true
}
}
escalated: true,
},
},
},
trigger: queueLengthExceptionTrigger
}
}
trigger: queueLengthExceptionTrigger,
},
},
};
await routerAdministrationClient.createExceptionPolicy(exceptionPolicyId, exceptionPolicyRequest);

Expand All @@ -70,7 +74,7 @@ async function createClassificationPolicy(): Promise<void> {
distributionPolicyId: "distribution-policy-123",
name: "Main",
labels: {},
exceptionPolicyId: "exception-policy-123"
exceptionPolicyId: "exception-policy-123",
};
await routerAdministrationClient.createQueue(queueId, queueRequest);

Expand All @@ -86,24 +90,25 @@ async function createClassificationPolicy(): Promise<void> {
{
key: "foo",
labelOperator: "equal",
value: { "default": 10 }
}
]
}
value: { default: 10 },
},
],
},
],
prioritizationRule: {
kind: "static-rule",
value: { "default": 2 }
}
value: { default: 2 },
},
};


const request = classificationPolicyRequest;

const result = await routerAdministrationClient.createClassificationPolicy(classificationPolicyId, request);
const result = await routerAdministrationClient.createClassificationPolicy(
classificationPolicyId,
request
);

console.log("classification policy: " + result);

};
}

void createClassificationPolicy();
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@
/**
* @summary Classification policy crud
*/
import { RouterAdministrationClient } from "@azure/communication-job-router";
import { JobRouterAdministrationClient } from "@azure/communication-job-router";

// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// Delete classification policy
async function deleteClassificationPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);

const policyId = "classification-policy-123"
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const policyId = "classification-policy-123";

const result = await routerAdministrationClient.deleteClassificationPolicy(policyId);

console.log("classification policy: " + result);

};
}

deleteClassificationPolicy().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@
/**
* @summary Classification policy crud
*/
import { RouterAdministrationClient } from "@azure/communication-job-router";
import { JobRouterAdministrationClient } from "@azure/communication-job-router";

// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// Get a classification policy

async function getClassificationPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);

const policyId = "classification-policy-123"
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const policyId = "classification-policy-123";

const result = await routerAdministrationClient.getClassificationPolicy(policyId);

console.log("classification policy: " + result);

};
}

void getClassificationPolicy();

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
/**
* @summary Classification policy crud
*/
import { ClassificationPolicyItem, RouterAdministrationClient } from "@azure/communication-job-router";
import {
ClassificationPolicyItem,
JobRouterAdministrationClient,
} from "@azure/communication-job-router";

// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
Expand All @@ -13,17 +16,19 @@ dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// List classification policies
async function listClassificationPolicies(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

let pagesCount = 1;
const maxPageSize = 3;
const receivedPagedItems: ClassificationPolicyItem[] = [];

for await (const page of routerAdministrationClient.listClassificationPolicies({ maxPageSize: maxPageSize }).byPage()) {
for await (const page of routerAdministrationClient
.listClassificationPolicies({ maxPageSize: maxPageSize })
.byPage()) {
++pagesCount;

console.log("page: " + pagesCount);
Expand All @@ -36,8 +41,6 @@ async function listClassificationPolicies(): Promise<void> {
let pageSize = receivedPagedItems.length;
assert.isAtMost(pageSize, maxPageSize);
}

};
}

listClassificationPolicies().catch(console.error);

Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
/**
* @summary Classification policy crud
*/
import { ClassificationPolicyResponse, RouterAdministrationClient } from "@azure/communication-job-router";
import {
ClassificationPolicyResponse,
JobRouterAdministrationClient,
} from "@azure/communication-job-router";

// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";



// Update a classification policy
async function updateClassificationPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const classificationPolicyRequest: ClassificationPolicyResponse = {
id: "classification-policy-123",
Expand All @@ -30,24 +32,22 @@ async function updateClassificationPolicy(): Promise<void> {
{
key: "foo",
labelOperator: "lessThan",
value: { "default": 5 }
}
]
}
value: { default: 5 },
},
],
},
],
prioritizationRule: {
kind: "static-rule",
value: { "default": 20 }
}
value: { default: 20 },
},
};


const request = classificationPolicyRequest;

const result = await routerAdministrationClient.updateClassificationPolicy(request.id, request);

console.log("classification policy: " + result);

};
}

void updateClassificationPolicy();
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
*/
// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
import { DistributionPolicy, RouterAdministrationClient } from "@azure/communication-job-router";
import { DistributionPolicy, JobRouterAdministrationClient } from "@azure/communication-job-router";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// Create an distribution policy
async function createDistributionPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const id = "distribution-policy-123";
const distributionPolicyRequest: DistributionPolicy = {
Expand All @@ -23,18 +23,16 @@ async function createDistributionPolicy(): Promise<void> {
kind: "longest-idle",
minConcurrentOffers: 1,
maxConcurrentOffers: 5,
bypassSelectors: false
bypassSelectors: false,
},
offerTtlSeconds: 120
offerTtlSeconds: 120,
};


const request = distributionPolicyRequest;

const result = await routerAdministrationClient.createDistributionPolicy(id, request);

console.log("distribution policy: " + result);

};
}

createDistributionPolicy().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@
*/
// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
import { RouterAdministrationClient } from "@azure/communication-job-router";
import { JobRouterAdministrationClient } from "@azure/communication-job-router";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// Delete distribution policy
async function deleteDistributionPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);

const policyId = "distribution-policy-123"
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const policyId = "distribution-policy-123";

const result = await routerAdministrationClient.deleteDistributionPolicy(policyId);

console.log("distribution policy: " + result);

};
}

deleteDistributionPolicy().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@
*/
// Load the .env file (you will need to set these environment variables)
import * as dotenv from "dotenv";
import { RouterAdministrationClient } from "@azure/communication-job-router";
import { JobRouterAdministrationClient } from "@azure/communication-job-router";
dotenv.config();

const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";


// Get a distribution policy

async function getDistributionPolicy(): Promise<void> {
// Create the Router Client
const routerAdministrationClient: RouterAdministrationClient = new RouterAdministrationClient(connectionString);

const policyId = "distribution-policy-123"
const routerAdministrationClient: JobRouterAdministrationClient =
new JobRouterAdministrationClient(connectionString);

const policyId = "distribution-policy-123";

const result = await routerAdministrationClient.getDistributionPolicy(policyId);

console.log("distribution policy: " + result);

};
}

getDistributionPolicy().catch(console.error);

Loading

0 comments on commit 6215f27

Please sign in to comment.