-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial creation of Azure DigitalTwins SDK #9787
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not an expert in what this package is trying to accomplish, so apologies if I misunderstood parts of it. Most of my comments are regarding how this package doesn't quite conform to what we require of a data-plane track 2 client.
|
||
## Getting started | ||
|
||
The complete Microsoft Azure SDK can be downloaded from the [Microsoft Azure downloads][microsoft_sdk_download] page, and it ships with support for building deployment packages, integrating with tooling, rich command line tooling, and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a little weird to link off to downloading the SDK when we're in the GitHub for the SDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section points to the central download page but the next section provides the npm install instructions. I think both has value.
In reply to: 447215310 [](ancestors = 447215310)
<!-- LINKS --> | ||
|
||
[microsoft_sdk_download]: https://azure.microsoft.com/en-us/downloads/?sdk=net | ||
[azure_sdk_target_frameworks]: https://github.com/azure/azure-sdk-for-net#target-frameworks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[azure_sub]: https://azure.microsoft.com/free/ | ||
[source]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/digitaltwins | ||
[package]: https://www.npmjs.com/package/@azure/digitaltwins | ||
[adt_npm]: https://www.npmjs.com/package/@azure/digitaltwins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need two links for the same URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[npm]: https://www.npmjs.com/ | ||
[azure_portal]: https://portal.azure.com/ | ||
[azure_rest_api]: https://docs.microsoft.com/en-us/rest/api/azure/ | ||
[azure_core_library]: https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/core/Azure.Core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
digitalTwinId: string, | ||
options: DigitalTwinsListRelationshipsOptionalParams | ||
): AsyncIterableIterator<any> { | ||
const f = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxItemCount: number = -1 | ||
): PagedAsyncIterableIterator<EventRoute, EventRoutesListNextResponse> { | ||
var options: EventRoutesListOptionalParams & PageSettings = {}; | ||
if (maxItemCount != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint: should use strict equality checks
if (maxItemCount != -1) { | |
if (maxItemCount !== -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the linter isn't running, you may have to tweak .eslintrc.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
|
||
export { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically we have a /src/index.ts
that handles all top level package exports instead of the client doing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"pack": "npm pack 2>&1", | ||
"build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", | ||
"extract-api": "tsc -p . && api-extractor run --local", | ||
"generate-pl": "autorest --typescript --typescript.azure-arm=true [email protected]/[email protected] --add-credentials --model-enum-as-union --license-header=MICROSOFT_MIT_NO_VERSION --output-folder=./src/generated --input-file=swagger/digitaltwins.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need --typescript.azure-arm=true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we do. The paginated API generation is missing if we don't specify "arm" here. (Chris Radek figured it out)
In reply to: 447264176 [](ancestors = 447264176)
@@ -0,0 +1,1497 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the swagger being checked into this repo? I think it should live here instead: https://github.com/Azure/azure-rest-api-specs/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree and eventually it will be only in azure-rest-api-spec. But until we don't have a way to auto-generate from there, I followed the example of the digitaltwins .NET SDK and checked into this repo. (They have the swagger checked in to azure SDK folder) If you strongly against that I will remove it from here. It is not a big deal.
In reply to: 447264662 [](ancestors = 447264662)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about auto-generate
, but we simply reference the external swagger by URL in other client libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if there is no auto-generate in the case of new version of swagger it is better to keep the original swagger what is the code generated from, is'n it?
In reply to: 453892297 [](ancestors = 453892297)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make sense to me, except what about generating the other language SDKs? Having the spec live in some language neutral place has the advantage of allowing all languages to reference the same spec.
For cognitive search we used that to drive changes across languages (e.g. the service team updated the swagger in one place then we regenerated all clients.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments, all of them valuable. We will discuss what is the purpose of this service in a meeting. In reply to: 439452976 [](ancestors = 439452976) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking great, couple suggestions.
} | ||
|
||
// @public | ||
export interface DigitalTwinModelsAddOptionalParams extends coreHttp.RequestOptionsBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should extend OperationOptions
|
||
// @public | ||
export type DigitalTwinModelsAddResponse = Array<ModelData> & { | ||
_response: coreHttp.HttpResponse & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_response
is good.
|
||
// @public | ||
export interface DigitalTwinsAddHeaders { | ||
eTag: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js prefers etag
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a swagger change but it would effect all languages.
In reply to: 455321769 [](ancestors = 455321769)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if swagger has an "etag" type, but in the least it could be a fix to autorest code generator to use etag type if the parameter name is etag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a data point, currently in the data plane swagger, the etag header is spelled "ETag" (capital E and capital T). This looks consistent with the spelling in the RFC (RFC 7232) and places like Wikipedia.
}; | ||
|
||
// @public | ||
export interface DigitalTwinModelsListOptionalParams extends coreHttp.RequestOptionsBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally replace ROB with OperationOptions.
}; | ||
|
||
// @public | ||
export class DigitalTwinsClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we should discuss is whether it makes sense to have separate clients for models, twins, components, and relationships.
publishComponentTelemetry(digitalTwinId: string, componentPath: string, payload: string, messageId?: string): Promise<RestResponse>; | ||
publishTelemetry(digitalTwinId: string, payload: any, messageId?: string): Promise<RestResponse>; | ||
queryTwins(query?: string): PagedAsyncIterableIterator<any, QueryQueryTwinsResponse>; | ||
updateComponent(digitalTwinId: string, componentPath: string, componentPatch: any, ifMatch?: string): Promise<DigitalTwinsUpdateComponentResponse>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
componentPatch can likely be typed more precisely than any
. Even object
might be preferable if we can't be more specific.
|
||
// @public | ||
export interface DigitalTwinsSendComponentTelemetryOptionalParams extends coreHttp.RequestOptionsBase { | ||
dtTimestamp?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dtTimestamp
doesn't seem super descriptive to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed: this comes from the swagger and we have a work item to improve this name for ADT GA.
In reply to: 455324864 [](ancestors = 455324864)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, in the .NET client, we called this TimeStamp for now, and will update it along with the swagger change at GA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export type IfNoneMatch = '*'; | ||
|
||
// @public | ||
export type IfNoneMatch1 = '*'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate declaration here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const createdTwin = await serviceClient.upsertDigitalTwin( | ||
digitalTwinId, | ||
newTwin, | ||
(enableUpdate = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per review: we should avoid this pattern in our code. The usual recommendation is to use option bags so you can write {enableUpdate: true}
.
When that can't be used, it's accepted to use comments to name boolean params e.g. doFoo(/*forceUpdate*/ true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
### Install the package | ||
|
||
Install the Azure Digital Twins client library for Javascript with [NPM][npm_package]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capital S in JavaScript?
@zolvarga Do you mind updating the PR description with a link to Azure/azure-sdk#1499 for other reviewers stumbling on this? |
Closing as moved to final review |
No description provided.