Skip to content

Commit

Permalink
[Service Bus] Adding the missing pieces for the ATOM API (Azure#9221)
Browse files Browse the repository at this point in the history
* Update Queue APIs aper the .NET proposal

* remove @internal @ignore tags wherever required and generate API report

* more exports

* more and more exports

* Add token credential constructor overlaod

* doesExist() for queue, topic and subscription

* generate API report

* api extractor and ts-config (TO BE REVERTED)

* feedback from the service team

* update index.ts

* update API report

* Update queue related imports in tests

* revert api-extractor and tsconfig changes to allow compiling tests

* fix build failures of ATOM API tests

* changes to rule options and interfaces

* fix test failures

* changes to Topic APIs

* fix build failures

* generate API report

* subscription APIs updated

* fix build failures

* generate API report

* fix API report warnings

* changes to rule APIs

* fix build failures

* generate API report

* getNamespaceProperties API

* namespace info improvement + API report

* fix warnings in the API report

* generatre API report

* resolve merge conflicts and organize imports

* fix the warnings from API report

* API report

* tests for getRuntimeInfo API for a single entity

* remove messageCount from *Description APIs

* remove unused helper

* test for Get namespace properties

* tests for entityExists

* tests for getEntitiesRuntimeInfo

* Add changelog

* Changelog

* fix subscription description tests

* subscription description - fix second test

* fix queue options tests

* queueOptions - updateQueue test fix

* subscriptionOptions - updateSubscription test fix

* remove token credential overload

* throwError for *Exists

* update doc comments for get APIs

* update docs as suggested by Ramya
  • Loading branch information
HarshaNalluru authored Jun 4, 2020
1 parent 2d7750b commit 1cfc819
Show file tree
Hide file tree
Showing 10 changed files with 1,115 additions and 85 deletions.
3 changes: 3 additions & 0 deletions sdk/servicebus/service-bus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- Improves the performance of the `ServiceBusMessageBatch.tryAdd` method.
[PR 8772](https://github.com/Azure/azure-sdk-for-js/pull/8772)
- Added management api features which allows CRUD operations on the entities of a namespace.
[PR 9116](https://github.com/Azure/azure-sdk-for-js/pull/9116)
[PR 9221](https://github.com/Azure/azure-sdk-for-js/pull/9221)

## 7.0.0-preview.2 (2020-05-05)

Expand Down
74 changes: 61 additions & 13 deletions sdk/servicebus/service-bus/review/service-bus.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,27 @@ export type EntityStatus = "Active" | "Creating" | "Deleting" | "ReceiveDisabled
export interface GetMessageIteratorOptions extends OperationOptions, WaitTimeOptions {
}

// @public
export type GetNamespaceResponse = NamespaceResponse;

// @public
export type GetQueueResponse = QueueResponse;

// @public
export interface GetQueueRuntimeInfoResponse extends QueueRuntimeInfo {
_response: HttpOperationResponse;
}

// @public
export interface GetQueuesResponse extends Array<QueueDescription> {
_response: HttpOperationResponse;
}

// @public
export interface GetQueuesRuntimeInfoResponse extends Array<QueueRuntimeInfo> {
_response: HttpOperationResponse;
}

// @public
export type GetRuleResponse = RuleResponse;

Expand All @@ -133,19 +146,39 @@ export interface GetRulesResponse extends Array<RuleDescription> {
// @public
export type GetSubscriptionResponse = SubscriptionResponse;

// @public
export interface GetSubscriptionRuntimeInfoResponse extends SubscriptionRuntimeInfo {
_response: HttpOperationResponse;
}

// @public
export interface GetSubscriptionsResponse extends Array<SubscriptionDescription> {
_response: HttpOperationResponse;
}

// @public
export interface GetSubscriptionsRuntimeInfoResponse extends Array<SubscriptionRuntimeInfo> {
_response: HttpOperationResponse;
}

// @public
export type GetTopicResponse = TopicResponse;

// @public
export interface GetTopicRuntimeInfoResponse extends TopicRuntimeInfo {
_response: HttpOperationResponse;
}

// @public
export interface GetTopicsResponse extends Array<TopicDescription> {
_response: HttpOperationResponse;
}

// @public
export interface GetTopicsRuntimeInfoResponse extends Array<TopicRuntimeInfo> {
_response: HttpOperationResponse;
}

// @public
export interface ListRequestOptions {
skip?: number;
Expand Down Expand Up @@ -176,6 +209,21 @@ export interface MessageHandlers<ReceivedMessageT> {

export { MessagingError }

// @public
export interface NamespaceProperties {
createdOn: string;
messagingSku: string;
messagingUnits: number | undefined;
name: string;
namespaceType: string;
updatedOn: string;
}

// @public
export interface NamespaceResponse extends NamespaceProperties {
_response: HttpOperationResponse;
}

// @public
export interface OperationOptions {
abortSignal?: AbortSignalLike;
Expand All @@ -196,8 +244,6 @@ export interface QueueDescription {
lockDuration?: string;
maxDeliveryCount?: number;
maxSizeInMegabytes?: number;
// (undocumented)
messageCount?: number;
name: string;
requiresDuplicateDetection?: boolean;
requiresSession?: boolean;
Expand All @@ -210,9 +256,7 @@ export interface QueueResponse extends QueueDescription {
_response: HttpOperationResponse;
}

// Warning: (ae-internal-missing-underscore) The name "QueueRuntimeInfo" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
// @public
export interface QueueRuntimeInfo {
accessedOn?: string;
createdOn?: string;
Expand Down Expand Up @@ -340,14 +384,24 @@ export class ServiceBusManagementClient extends ServiceClient {
deleteRule(topicName: string, subscriptionName: string, ruleName: string): Promise<DeleteRuleResponse>;
deleteSubscription(topicName: string, subscriptionName: string): Promise<DeleteSubscriptionResponse>;
deleteTopic(topicName: string): Promise<DeleteTopicResponse>;
getNamespaceProperties(): Promise<GetNamespaceResponse>;
getQueue(queueName: string): Promise<GetQueueResponse>;
getQueueRuntimeInfo(queueName: string): Promise<GetQueueRuntimeInfoResponse>;
getQueues(listRequestOptions?: ListRequestOptions): Promise<GetQueuesResponse>;
getQueuesRuntimeInfo(listRequestOptions?: ListRequestOptions): Promise<GetQueuesRuntimeInfoResponse>;
getRule(topicName: string, subscriptioName: string, ruleName: string): Promise<GetRuleResponse>;
getRules(topicName: string, subscriptionName: string, listRequestOptions?: ListRequestOptions): Promise<GetRulesResponse>;
getSubscription(topicName: string, subscriptionName: string): Promise<GetSubscriptionResponse>;
getSubscriptionRuntimeInfo(topicName: string, subscriptionName: string): Promise<GetSubscriptionRuntimeInfoResponse>;
getSubscriptions(topicName: string, listRequestOptions?: ListRequestOptions): Promise<GetSubscriptionsResponse>;
getSubscriptionsRuntimeInfo(topicName: string, listRequestOptions?: ListRequestOptions): Promise<GetSubscriptionsRuntimeInfoResponse>;
getTopic(topicName: string): Promise<GetTopicResponse>;
getTopicRuntimeInfo(topicName: string): Promise<GetTopicRuntimeInfoResponse>;
getTopics(listRequestOptions?: ListRequestOptions): Promise<GetTopicsResponse>;
getTopicsRuntimeInfo(listRequestOptions?: ListRequestOptions): Promise<GetTopicsRuntimeInfoResponse>;
queueExists(queueName: string): Promise<boolean>;
subscriptionExists(topicName: string, subscriptionName: string): Promise<boolean>;
topicExists(topicName: string): Promise<boolean>;
updateQueue(queue: QueueDescription): Promise<UpdateQueueResponse>;
updateRule(topicName: string, subscriptionName: string, rule: RuleDescription): Promise<UpdateRuleResponse>;
updateSubscription(subscription: SubscriptionDescription): Promise<UpdateSubscriptionResponse>;
Expand Down Expand Up @@ -443,8 +497,6 @@ export interface SubscriptionDescription {
forwardTo?: string;
lockDuration?: string;
maxDeliveryCount?: number;
// (undocumented)
messageCount?: number;
requiresSession?: boolean;
status?: EntityStatus;
subscriptionName: string;
Expand All @@ -457,9 +509,7 @@ export interface SubscriptionResponse extends SubscriptionDescription {
_response: HttpOperationResponse;
}

// Warning: (ae-internal-missing-underscore) The name "SubscriptionRuntimeInfo" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
// @public
export interface SubscriptionRuntimeInfo {
accessedOn?: string;
createdOn: string;
Expand Down Expand Up @@ -495,9 +545,7 @@ export interface TopicResponse extends TopicDescription {
_response: HttpOperationResponse;
}

// Warning: (ae-internal-missing-underscore) The name "TopicRuntimeInfo" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
// @public
export interface TopicRuntimeInfo {
accessedOn?: string;
createdOn?: string;
Expand Down
9 changes: 9 additions & 0 deletions sdk/servicebus/service-bus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { OperationOptions } from "./modelsToBeSharedWithEventHubs";
export { Receiver } from "./receivers/receiver";
export { SessionReceiver } from "./receivers/sessionReceiver";
export { Sender } from "./sender";
export { NamespaceProperties } from "./serializers/namespaceResourceSerializer";
export { QueueDescription, QueueRuntimeInfo } from "./serializers/queueResourceSerializer";
export {
RuleDescription,
Expand All @@ -52,15 +53,23 @@ export {
DeleteRuleResponse,
DeleteSubscriptionResponse,
DeleteTopicResponse,
GetNamespaceResponse,
GetQueueResponse,
GetQueueRuntimeInfoResponse,
GetQueuesResponse,
GetQueuesRuntimeInfoResponse,
GetRuleResponse,
GetRulesResponse,
GetSubscriptionResponse,
GetSubscriptionRuntimeInfoResponse,
GetSubscriptionsResponse,
GetSubscriptionsRuntimeInfoResponse,
GetTopicResponse,
GetTopicRuntimeInfoResponse,
GetTopicsResponse,
GetTopicsRuntimeInfoResponse,
ListRequestOptions,
NamespaceResponse,
QueueResponse,
RuleResponse,
ServiceBusManagementClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { HttpOperationResponse } from "@azure/core-http";
import {
AtomXmlSerializer,
deserializeAtomXmlResponse,
serializeToAtomXmlRequest
} from "../util/atomXmlHelper";
import { getInteger, getString } from "../util/utils";

/**
* Represents the metadata related to a service bus namespace.
*
* @export
* @interface NamespaceProperties
*/
export interface NamespaceProperties {
/**
* The time at which the namespace was created.
*/
createdOn: string;
/**
* The SKU/tier of the namespace.
* "Basic", "Standard" and "Premium"
*/
messagingSku: string;
/**
* The last time at which the namespace was modified.
*/
updatedOn: string;
/**
* Name of the namespace.
*/
name: string;
/**
* Type of entities present in the namespace.
*/
namespaceType: string;
/**
* Number of messaging units allocated for namespace.
* Valid only for Premium namespaces.
* messagingUnits would be set to `undefined` for Basic and Standard namespaces.
*/
messagingUnits: number | undefined;
}

/**
* @internal
* @ignore
* Builds the namespace object from the raw json object gotten after deserializing the
* response from the service
* @param rawNamespace
*/
export function buildNamespace(rawNamespace: any): NamespaceProperties {
const messagingSku = getString(rawNamespace["MessagingSKU"], "messagingSku");
return {
createdOn: getString(rawNamespace["CreatedTime"], "createdOn"),
messagingSku: messagingSku,
updatedOn: getString(rawNamespace["ModifiedTime"], "updatedOn"),
name: getString(rawNamespace["Name"], "name"),
namespaceType: getString(rawNamespace["NamespaceType"], "namespaceType"),
messagingUnits:
messagingSku === "Premium"
? getInteger(rawNamespace["MessagingUnits"], "messagingUnits")
: undefined
};
}

/**
* @internal
* @ignore
* Atom XML Serializer for Namespaces.
*/
export class NamespaceResourceSerializer implements AtomXmlSerializer {
serialize(): object {
return serializeToAtomXmlRequest("NamespaceProperties", {});
}

async deserialize(response: HttpOperationResponse): Promise<HttpOperationResponse> {
return deserializeAtomXmlResponse(["name"], response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export function buildQueue(rawQueue: any): QueueDescription {

authorizationRules: getAuthorizationRulesOrUndefined(rawQueue[Constants.AUTHORIZATION_RULES]),

status: rawQueue[Constants.STATUS],
messageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT])
status: rawQueue[Constants.STATUS]
};
}

Expand Down Expand Up @@ -245,8 +244,6 @@ export interface QueueDescription {
* `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`
*/
forwardDeadLetteredMessagesTo?: string;
// TODO: will be removed once the RuntimeInfo APIs are added
messageCount?: number;
}

/**
Expand Down Expand Up @@ -370,8 +367,6 @@ export interface InternalQueueOptions {
}

/**
* @internal
* @ignore
* Represents runtime info attributes of a queue entity
*/
export interface QueueRuntimeInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ export function buildSubscription(rawSubscription: any): SubscriptionDescription
forwardTo: getStringOrUndefined(rawSubscription[Constants.FORWARD_TO]),
userMetadata: rawSubscription[Constants.USER_METADATA],

status: getString(rawSubscription[Constants.STATUS], "status") as EntityStatus,
messageCount: getInteger(rawSubscription[Constants.MESSAGE_COUNT], "messageCount")
status: getString(rawSubscription[Constants.STATUS], "status") as EntityStatus
};
}

Expand Down Expand Up @@ -218,9 +217,6 @@ export interface SubscriptionDescription {
* such as "PT1M" for 1 minute, "PT5S" for 5 seconds.
*/
autoDeleteOnIdle?: string;

// TODO: will be removed once the RuntimeInfo APIs are added
messageCount?: number;
}

/**
Expand Down Expand Up @@ -321,8 +317,6 @@ export interface InternalSubscriptionOptions {
}

/**
* @internal
* @ignore
* Represents runtime info attributes of a subscription entity
*/
export interface SubscriptionRuntimeInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ export interface InternalTopicOptions {
}

/**
* @internal
* @ignore
* Represents runtime info attributes of a topic entity
*/
export interface TopicRuntimeInfo {
Expand Down
Loading

0 comments on commit 1cfc819

Please sign in to comment.