Skip to content

Commit

Permalink
[Service Bus] Update relevant Docs for the update methods and and rem…
Browse files Browse the repository at this point in the history
…ove internal get calls (#9751)

* Add Docs and remove get calls from the update requests

* minor fix in docs

* Changelog

* fix update tests

* final fix

* fix updateSubscription tests

* remove .only

* update docs for update methods as Ramya suggested

* Update sdk/servicebus/service-bus/CHANGELOG.md

Co-authored-by: Ramya Rao <ramya.rao.a@outlook.com>

Co-authored-by: Ramya Rao <ramya.rao.a@outlook.com>
  • Loading branch information
HarshaNalluru and ramya-rao-a authored Jun 29, 2020
1 parent cbc8f17 commit 99f28bc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
4 changes: 4 additions & 0 deletions sdk/servicebus/service-bus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Bug - Messages scheduled in parallel with the `scheduleMessage` method have the same sequence number in response.
Fixed in [PR 9503](https://github.com/Azure/azure-sdk-for-js/pull/9503)
- Management api updates (Includes breaking changes)

- Following return types are changed to improve the API surface.
- [Create,Get,Update]QueueResponse as QueueResponse, DeleteQueueResponse as Response, GetQueueRuntimeInfoResponse as QueueRuntimeInfoResponse.
Similarly for topics, subscriptions and rules.
Expand All @@ -16,6 +17,9 @@
[PR 9434](https://github.com/Azure/azure-sdk-for-js/pull/9434)
- The property `top` in the options passed to any of the methods that get information for multiple entities like `getQueues` or `getQueuesRuntimeInfo` is renamed to `maxCount`.
[PR 9664](https://github.com/Azure/azure-sdk-for-js/pull/9664)
- The "update" methods (`updateQueue`, `updateTopic` and `updateSubscription`) now require all properties on the given queue/topic/subscription object to be set even though only a subset of them are actually updatable. Therefore, the suggested flow is to use the "get" methods to get the queue/topic/subscription object, update as needed and then pass it to the "update" methods. [PR 9751](https://github.com/Azure/azure-sdk-for-js/pull/9751).

See [update queue](https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue) and [update-topic](https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue) for list of updatable properties.

## 7.0.0-preview.3 (2020-06-08)

Expand Down
63 changes: 33 additions & 30 deletions sdk/servicebus/service-bus/src/serviceBusAtomManagementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,18 @@ export class ServiceBusManagementClient extends ServiceClient {
}

/**
* Updates properties on the Queue by the given name based on the given options
* @param queue Options to configure the Queue being updated.
* For example, you can configure a queue to support partitions or sessions.
* Updates the queue based on the queue description provided.
* All properties on the queue description must be set even though only a subset of them are actually updatable.
* Therefore, the suggested flow is to use `getQueue()` to get the queue description with all properties set,
* update as needed and then pass it to `updateQueue()`.
* See https://docs.microsoft.com/en-us/rest/api/servicebus/update-queue for more details.
*
* @param queue Object representing the queue with one or more of the below properties updated
* - defaultMessageTimeToLive
* - lockDuration
* - deadLetteringOnMessageExpiration
* - duplicateDetectionHistoryTimeWindow
* - maxDeliveryCount
*
* Following are errors that can be expected from this operation
* @throws `RestError` with code `UnauthorizedRequestError` when given request fails due to authorization problems,
Expand All @@ -477,13 +486,9 @@ export class ServiceBusManagementClient extends ServiceClient {
throw new TypeError(`"name" attribute of the parameter "queue" cannot be undefined.`);
}

const finalQueueOptions: QueueDescription = { name: queue.name };
const getQueueResult = await this.getQueue(queue.name);
Object.assign(finalQueueOptions, getQueueResult, queue);

const response: HttpOperationResponse = await this.putResource(
queue.name,
buildQueueOptions(finalQueueOptions),
buildQueueOptions(queue),
this.queueResourceSerializer,
true
);
Expand Down Expand Up @@ -684,9 +689,15 @@ export class ServiceBusManagementClient extends ServiceClient {
}

/**
* Updates properties on the Topic by the given name based on the given options
* @param topic Options to configure the Topic being updated.
* For example, you can configure a topic to support partitions or sessions.
* Updates the topic based on the topic description provided.
* All properties on the topic description must be set even though only a subset of them are actually updatable.
* Therefore, the suggested flow is to use `getTopic()` to get the topic description with all properties set,
* update as needed and then pass it to `updateTopic()`.
* See https://docs.microsoft.com/en-us/rest/api/servicebus/update-topic for more details.
*
* @param topic Object representing the topic with one or more of the below properties updated
* - defaultMessageTimeToLive
* - duplicateDetectionHistoryTimeWindow
*
* Following are errors that can be expected from this operation
* @throws `RestError` with code `UnauthorizedRequestError` when given request fails due to authorization problems,
Expand All @@ -713,13 +724,9 @@ export class ServiceBusManagementClient extends ServiceClient {
throw new TypeError(`"name" attribute of the parameter "topic" cannot be undefined.`);
}

const finalTopicOptions: TopicDescription = { name: topic.name };
const getTopicResult = await this.getTopic(topic.name);
Object.assign(finalTopicOptions, getTopicResult, topic);

const response: HttpOperationResponse = await this.putResource(
topic.name,
buildTopicOptions(finalTopicOptions),
buildTopicOptions(topic),
this.topicResourceSerializer,
true
);
Expand Down Expand Up @@ -964,9 +971,15 @@ export class ServiceBusManagementClient extends ServiceClient {
}

/**
* Updates properties on the Subscription by the given name based on the given options
* @param subscription Options to configure the Subscription being updated.
* For example, you can configure a Subscription to support partitions or sessions.
* Updates the subscription based on the subscription description provided.
* All properties on the subscription description must be set even though only a subset of them are actually updatable.
* Therefore, the suggested flow is to use `getSubscription()` to get the subscription description with all properties set,
* update as needed and then pass it to `updateSubscription()`.
*
* @param subscription Object representing the subscription with one or more of the below properties updated
* - lockDuration
* - deadLetteringOnMessageExpiration
* - maxDeliveryCount
*
* Following are errors that can be expected from this operation
* @throws `RestError` with code `UnauthorizedRequestError` when given request fails due to authorization problems,
Expand Down Expand Up @@ -1000,19 +1013,9 @@ export class ServiceBusManagementClient extends ServiceClient {
subscription.subscriptionName
);

const finalSubscriptionOptions: SubscriptionDescription = {
topicName: subscription.topicName,
subscriptionName: subscription.subscriptionName
};
const getSubscriptionResult = await this.getSubscription(
subscription.topicName,
subscription.subscriptionName
);
Object.assign(finalSubscriptionOptions, getSubscriptionResult, subscription);

const response: HttpOperationResponse = await this.putResource(
fullPath,
buildSubscriptionOptions(finalSubscriptionOptions),
buildSubscriptionOptions(subscription),
this.subscriptionResourceSerializer,
true
);
Expand Down
16 changes: 9 additions & 7 deletions sdk/servicebus/service-bus/test/atomManagement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1946,14 +1946,12 @@ describe("Atom management - Authentication", function(): void {
].forEach((testCase) => {
describe(`updateSubscription() using different variations to the input parameter "subscriptionOptions"`, function(): void {
beforeEach(async () => {
await recreateQueue(managementQueue1);
await recreateTopic(managementTopic1);
await recreateSubscription(managementTopic1, managementSubscription1);
});

afterEach(async () => {
await deleteEntity(EntityType.TOPIC, managementTopic1);
await deleteEntity(EntityType.QUEUE, managementQueue1);
});

it(`${testCase.testCaseTitle}`, async () => {
Expand Down Expand Up @@ -2446,14 +2444,16 @@ async function updateEntity(

switch (testEntityType) {
case EntityType.QUEUE:
const getQueueResponse = await serviceBusAtomManagementClient.getQueue(entityPath);
const queueResponse = await serviceBusAtomManagementClient.updateQueue({
name: entityPath,
...getQueueResponse,
...queueOptions
});
return queueResponse;
case EntityType.TOPIC:
const getTopicResponse = await serviceBusAtomManagementClient.getTopic(entityPath);
const topicResponse = await serviceBusAtomManagementClient.updateTopic({
name: entityPath,
...getTopicResponse,
...topicOptions
});
return topicResponse;
Expand All @@ -2463,9 +2463,12 @@ async function updateEntity(
"TestError: Topic path must be passed when invoking tests on subscriptions"
);
}
const getSubscriptionResponse = await serviceBusAtomManagementClient.getSubscription(
topicPath,
entityPath
);
const subscriptionResponse = await serviceBusAtomManagementClient.updateSubscription({
topicName: topicPath,
subscriptionName: entityPath,
...getSubscriptionResponse,
...subscriptionOptions
});
return subscriptionResponse;
Expand All @@ -2485,7 +2488,6 @@ async function updateEntity(
);
return ruleResponse;
}
throw new Error("TestError: Unrecognized EntityType");
}

async function deleteEntity(
Expand Down

0 comments on commit 99f28bc

Please sign in to comment.