diff --git a/sdk/servicebus/service-bus/review/service-bus.api.md b/sdk/servicebus/service-bus/review/service-bus.api.md index c5ab07485a93..dea722fbe1b7 100644 --- a/sdk/servicebus/service-bus/review/service-bus.api.md +++ b/sdk/servicebus/service-bus/review/service-bus.api.md @@ -103,12 +103,12 @@ export { MessagingError } // @public export interface NamespaceProperties { - createdOn: string; + createdOn: Date; messagingSku: string; messagingUnits: number | undefined; name: string; namespaceType: string; - updatedOn: string; + updatedOn: Date; } // @public @@ -154,13 +154,13 @@ export interface QueueResponse extends QueueDescription, Response { // @public export interface QueueRuntimeInfo { - accessedOn?: string; - createdOn?: string; + accessedOn: Date; + createdOn: Date; messageCount?: number; messageCountDetails?: MessageCountDetails; name: string; sizeInBytes?: number; - updatedOn?: string; + updatedOn: Date; } // @public @@ -433,13 +433,13 @@ export interface SubscriptionResponse extends SubscriptionDescription, Response // @public export interface SubscriptionRuntimeInfo { - accessedOn?: string; - createdOn: string; + accessedOn: Date; + createdOn: Date; messageCount: number; messageCountDetails?: MessageCountDetails; subscriptionName: string; topicName: string; - updatedOn: string; + updatedOn: Date; } // @public @@ -480,12 +480,12 @@ export interface TopicResponse extends TopicDescription, Response { // @public export interface TopicRuntimeInfo { - accessedOn?: string; - createdOn?: string; + accessedOn: Date; + createdOn: Date; name: string; sizeInBytes?: number; subscriptionCount?: number; - updatedOn?: string; + updatedOn: Date; } // @public diff --git a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts index 484819af0f93..add75c4bc129 100644 --- a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts @@ -7,7 +7,7 @@ import { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from "../util/atomXmlHelper"; -import { getInteger, getString } from "../util/utils"; +import { getInteger, getString, getDate } from "../util/utils"; /** * Represents the metadata related to a service bus namespace. @@ -19,7 +19,7 @@ export interface NamespaceProperties { /** * The time at which the namespace was created. */ - createdOn: string; + createdOn: Date; /** * The SKU/tier of the namespace. * "Basic", "Standard" and "Premium" @@ -28,7 +28,7 @@ export interface NamespaceProperties { /** * The last time at which the namespace was modified. */ - updatedOn: string; + updatedOn: Date; /** * Name of the namespace. */ @@ -55,9 +55,9 @@ export interface NamespaceProperties { export function buildNamespace(rawNamespace: any): NamespaceProperties { const messagingSku = getString(rawNamespace["MessagingSKU"], "messagingSku"); return { - createdOn: getString(rawNamespace["CreatedTime"], "createdOn"), + createdOn: getDate(rawNamespace["CreatedTime"], "createdOn"), messagingSku: messagingSku, - updatedOn: getString(rawNamespace["ModifiedTime"], "updatedOn"), + updatedOn: getDate(rawNamespace["ModifiedTime"], "updatedOn"), name: getString(rawNamespace["Name"], "name"), namespaceType: getString(rawNamespace["NamespaceType"], "namespaceType"), messagingUnits: diff --git a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts index b797c459e6c3..31e24d7200f0 100644 --- a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts @@ -19,7 +19,8 @@ import { getRawAuthorizationRules, getString, getStringOrUndefined, - MessageCountDetails + MessageCountDetails, + getDate } from "../util/utils"; /** @@ -118,9 +119,9 @@ export function buildQueueRuntimeInfo(rawQueue: any): QueueRuntimeInfo { sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]), messageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]), messageCountDetails: getCountDetailsOrUndefined(rawQueue[Constants.COUNT_DETAILS]), - createdOn: rawQueue[Constants.CREATED_AT], - updatedOn: rawQueue[Constants.UPDATED_AT], - accessedOn: rawQueue[Constants.ACCESSED_AT] + createdOn: getDate(rawQueue[Constants.CREATED_AT], "createdOn"), + updatedOn: getDate(rawQueue[Constants.UPDATED_AT], "updatedOn"), + accessedOn: getDate(rawQueue[Constants.ACCESSED_AT], "accessedOn") }; } @@ -378,17 +379,17 @@ export interface QueueRuntimeInfo { /** * Created at timestamp */ - createdOn?: string; + createdOn: Date; /** * Updated at timestamp */ - updatedOn?: string; + updatedOn: Date; /** * Accessed at timestamp */ - accessedOn?: string; + accessedOn: Date; /** * The entity's message count. diff --git a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts index f45a47e00814..4c14bf7ef836 100644 --- a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts @@ -15,7 +15,8 @@ import { getInteger, getString, getStringOrUndefined, - MessageCountDetails + MessageCountDetails, + getDate } from "../util/utils"; /** @@ -108,9 +109,9 @@ export function buildSubscriptionRuntimeInfo(rawSubscription: any): Subscription topicName: getString(rawSubscription[Constants.TOPIC_NAME], "topicName"), messageCount: getInteger(rawSubscription[Constants.MESSAGE_COUNT], "messageCount"), messageCountDetails: getCountDetailsOrUndefined(rawSubscription[Constants.COUNT_DETAILS]), - createdOn: getString(rawSubscription[Constants.CREATED_AT], "createdOn"), - updatedOn: getString(rawSubscription[Constants.UPDATED_AT], "updatedOn"), - accessedOn: rawSubscription[Constants.ACCESSED_AT] + createdOn: getDate(rawSubscription[Constants.CREATED_AT], "createdOn"), + updatedOn: getDate(rawSubscription[Constants.UPDATED_AT], "updatedOn"), + accessedOn: getDate(rawSubscription[Constants.ACCESSED_AT], "accessedOn") }; } @@ -344,17 +345,17 @@ export interface SubscriptionRuntimeInfo { /** * Created at timestamp */ - createdOn: string; + createdOn: Date; /** * Updated at timestamp */ - updatedOn: string; + updatedOn: Date; /** * Accessed at timestamp */ - accessedOn?: string; + accessedOn: Date; } /** diff --git a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts index 7c0a77b7d43b..daaeb3513965 100644 --- a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts @@ -17,7 +17,8 @@ import { getIntegerOrUndefined, getRawAuthorizationRules, getString, - getStringOrUndefined + getStringOrUndefined, + getDate } from "../util/utils"; /** @@ -97,9 +98,9 @@ export function buildTopicRuntimeInfo(rawTopic: any): TopicRuntimeInfo { name: getString(rawTopic[Constants.TOPIC_NAME], "topicName"), sizeInBytes: getIntegerOrUndefined(rawTopic[Constants.SIZE_IN_BYTES]), subscriptionCount: getIntegerOrUndefined(rawTopic[Constants.SUBSCRIPTION_COUNT]), - createdOn: rawTopic[Constants.CREATED_AT], - updatedOn: rawTopic[Constants.UPDATED_AT], - accessedOn: rawTopic[Constants.ACCESSED_AT] + createdOn: getDate(rawTopic[Constants.CREATED_AT], "createdOn"), + updatedOn: getDate(rawTopic[Constants.UPDATED_AT], "updatedOn"), + accessedOn: getDate(rawTopic[Constants.ACCESSED_AT], "accessedOn") }; } @@ -292,17 +293,17 @@ export interface TopicRuntimeInfo { /** * Created at timestamp */ - createdOn?: string; + createdOn: Date; /** * Updated at timestamp */ - updatedOn?: string; + updatedOn: Date; /** * Accessed at timestamp */ - accessedOn?: string; + accessedOn: Date; } /** diff --git a/sdk/servicebus/service-bus/src/util/utils.ts b/sdk/servicebus/service-bus/src/util/utils.ts index 3f7391c16db4..d42079f07d00 100644 --- a/sdk/servicebus/service-bus/src/util/utils.ts +++ b/sdk/servicebus/service-bus/src/util/utils.ts @@ -242,6 +242,16 @@ export function getIntegerOrUndefined(value: any): number | undefined { return result == NaN ? undefined : result; } +/** + * @internal + * @ignore + * Helper utility to convert ISO-8601 time into Date type. + * @param value + */ +export function getDate(value: string, nameOfProperty: string): Date { + return new Date(getString(value, nameOfProperty)); +} + /** * @internal * @ignore