[Service Bus] [core-http] Implement ATOM based management API#4880
[Service Bus] [core-http] Implement ATOM based management API#4880ramya0820 wants to merge 2 commits intoAzure:masterfrom
Conversation
|
@amarzavery @ramya-rao-a @nemakam @bterlson @daviwil |
|
Build successful but blocked on some other unrelated changes |
ramya-rao-a
left a comment
There was a problem hiding this comment.
@ramya0820 I have left a few high level comments, please take a look at them.
Once #4863 is merged, please rebase/merge from master, after which @bterlson will help in reviewing the changes specific to the http request/response code paths.
Also, please update the PR description with
- pointers to the old code base from which this feature has been picked from. Especially the libraries which you have taken as a reference. Preferably, in a format which gives a 1:1 mapping between libraries and the files in this PR
- any docs around the ATOM based management apis
|
|
||
| const HeaderConstants = Constants.HeaderConstants; | ||
|
|
||
| export class ServiceBusSASServiceClientCredentials implements ServiceClientCredentials { |
There was a problem hiding this comment.
Since this credential is specific to a particular Azure service, it should live in the library for that service and not core-http.
Please move this to the Service Bus library.
| * - serialize HTTP requests with input in JSON to ATOM based XML requests, and | ||
| * - deserialize the ATOM based XML responses as they pass through the HTTP pipeline. | ||
| */ | ||
| export class ServiceBusAtomSerializationPolicy extends BaseRequestPolicy { |
There was a problem hiding this comment.
Does this policy make any assumptions on how Azure Service Bus expects requests and returns responses? If yes, then this should move to the Service Bus library. If this policy is service agnostic, then it can stay in core-http
| } | ||
|
|
||
| // @public | ||
| export class ServiceBusAtomManagementClient extends ServiceClient { |
There was a problem hiding this comment.
Customers will not be aware of the existence of a separate client in order to carry out the crud operations. They are aware of the existing ServiceBusClient and would expect all the crud operations to exist on it.
Below is what I would recommend:
- Do not expose
ServiceBusAtomManagementClientto customer, instead have it as property onServiceBusClient.
When user creates aServiceBusClient, you instantiateServiceBusAtomManagementClientinternally - Replicate all the crud operations on
ServiceBusClient. These will call the corresponding counterparts in theServiceBusAtomManagementClient
| * @param credentials Credentials needed for the client to connect to Azure. | ||
| * @param options The parameter options | ||
| */ | ||
| constructor(connectionString: any, options?: ServiceClientOptions) { |
There was a problem hiding this comment.
Does the ATOM based management apis only work with Shared Access Keys?
Do they not work with AAD?
sdk/core/core-http/package.json
Outdated
| "uuid": "^3.3.2", | ||
| "xml2js": "^0.4.19" | ||
| "xml2js": "^0.4.19", | ||
| "underscore": "1.4.x", |
There was a problem hiding this comment.
| "underscore": "1.4.x", | |
| "underscore": "^1.4.x", |
There was a problem hiding this comment.
Unless there is an exception, all dependencies should use caret ^ to float to latest within major.
@bterlson, do you think this is a runtime dependency worth taking? I know we wanted to minimize the number of runtime deps.
There was a problem hiding this comment.
I do not. Please remove underscore dependency.
sdk/core/core-http/package.json
Outdated
| "xml2js": "^0.4.19" | ||
| "xml2js": "^0.4.19", | ||
| "underscore": "1.4.x", | ||
| "xmlbuilder": "0.4.3" |
There was a problem hiding this comment.
| "xmlbuilder": "0.4.3" | |
| "xmlbuilder": "^0.4.3" |
There was a problem hiding this comment.
Unless there is an exception, all dependencies should use caret ^ to float to latest within major.
@bterlson, do you think this is a runtime dependency worth taking? I know we wanted to minimize the number of runtime deps.
There was a problem hiding this comment.
xmlbuilder I'm less sure about. Looking at the usage it seems fairly simple and could maybe be replaced with string templates instead. @ramya0820 let me know any thoughts on this?
There was a problem hiding this comment.
I thought having a utility in place to work with serializing to / building XML docs seemed useful / preferable generally speaking.
Hence brought over the js2xml utility from azure-sb that uses both xmlbuilder and underscore. Would prefer if we could come up with an alternative library, like using https://www.npmjs.com/package/fast-xml-parser maybe?
I'll take another pass at the code to see if I can remove the dependencies and simplify / uniformize the XML handling bits in core-http (specifically the serialization bits).
I just worry that building these handlers from scratch, apart from incurring some more efforts and time, may
- miss out any specific usage / corner cases that were being handled by the underlying libraries (
xmlbuilder,underscore, etc.)(and probably why these were chosen in implementation inazure-sb?) - not be that easily extendable, scalable should any other XML related use-cases come in
There was a problem hiding this comment.
For now, I'll take another look into minimizing / removing these 2 dependencies.
| import { stringIsEmpty, stringStartsWith } from "./util/utils"; | ||
| import { Constants } from "./util/constants"; | ||
| import { AtomHandler } from "./util/atomHandler"; | ||
| import { each, isUndefined, isArray, isObject, isDate } from "./util/utils"; |
There was a problem hiding this comment.
This import can be combined with the line 17.
| @@ -0,0 +1,14 @@ | |||
| import { ResourceSerializer } from "./resourceSerializer"; | |||
There was a problem hiding this comment.
Copyright text is missing in this file.
| if ( | ||
| sharedAccessKeyName === null || | ||
| sharedAccessKeyName === undefined || | ||
| typeof sharedAccessKeyName.valueOf() !== "string" |
There was a problem hiding this comment.
I think we don't need to add separate checks for null and undefined. We can combine these 2 checks.
Something like:
if(!(typeof sharedAccessKeyName ==="string" && sharedAccessKeyName )){
throw new Error("sharedAccessKeyName is missing.");
}| if ( | ||
| sharedAccessKey === null || | ||
| sharedAccessKey === undefined || | ||
| typeof sharedAccessKey.valueOf() !== "string" |
There was a problem hiding this comment.
I think we don't need to add separate checks for null and undefined. We can combine these 2 checks.
Something like:
if(!(typeof sharedAccessKey==="string" && sharedAccessKey)){
throw new Error("sharedAccessKey is missing.");
}|
Thanks for the comments so far! @mikeharder @ramya-rao-a @ShivangiReja @bterlson
This PR will be closed in favor of other 2 PRs where the requested changes will be made at. |
This PR includes end to end implementation of the ATOM management API and set of tests for CRUD operations on Queues.
Can be considered as a draft, as working on straightening out few more things - mostly code organization, simplifications.
cc @ramya-rao-a @AlexGhiondea