Skip to content

EventGrid data spec for Microsoft.Devices/Iothub#2424

Merged
dsgouda merged 5 commits into
Azure:masterfrom
cpjagan:eventgrid_iothub_spec
Feb 7, 2018
Merged

EventGrid data spec for Microsoft.Devices/Iothub#2424
dsgouda merged 5 commits into
Azure:masterfrom
cpjagan:eventgrid_iothub_spec

Conversation

@cpjagan
Copy link
Copy Markdown
Contributor

@cpjagan cpjagan commented Feb 5, 2018

Adding IotHub data schema for event grid specification

PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • Except for special cases involving multiple contributors, the PR is started from a fork of the main repository, not a branch.
  • If applicable, the PR references the bug/issue that it fixes.
  • Swagger files are correctly named (e.g. the api-version in the path should match the api-version in the spec).

Quality of Swagger

@AutorestCI
Copy link
Copy Markdown

AutorestCI commented Feb 5, 2018

Automation for azure-sdk-for-python

Swagger to SDK encountered an unknown error: (azure-sdk-for-python)

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/swaggertosdk/restapi/github.py", line 274, in create_context_pr
    base=sdk_base
  File "/usr/local/lib/python3.6/dist-packages/swaggertosdk/github_tools.py", line 137, in get_or_create_pull
    base=base
  File "/usr/local/lib/python3.6/dist-packages/github/Repository.py", line 994, in create_pull
    return self.__create_pull_1(*args, **kwds)
  File "/usr/local/lib/python3.6/dist-packages/github/Repository.py", line 1003, in __create_pull_1
    return self.__create_pull(title=title, body=body, base=base, head=head)
  File "/usr/local/lib/python3.6/dist-packages/github/Repository.py", line 1016, in __create_pull
    input=post_parameters
  File "/usr/local/lib/python3.6/dist-packages/github/Requester.py", line 172, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, cnx))
  File "/usr/local/lib/python3.6/dist-packages/github/Requester.py", line 180, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 422 {'message': 'Validation Failed', 'errors': [{'resource': 'PullRequest', 'code': 'custom', 'message': 'No commits between master and restapi_auto_eventgrid/data-plane'}], 'documentation_url': 'https://developer.github.com/v3/pulls/#create-a-pull-request'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/swaggertosdk/github_tools.py", line 29, in exception_to_github
    yield context
  File "/usr/local/lib/python3.6/dist-packages/swaggertosdk/restapi/github.py", line 197, in rest_handle_action
    return rest_pull_close(body, github_con, restapi_repo, sdk_pr_target_repo, context_tags, sdkbase, sdk_tag)
  File "/usr/local/lib/python3.6/dist-packages/swaggertosdk/restapi/github.py", line 379, in rest_pull_close
    create_context_pr(sdk_pr_target_repo, context_tags, sdk_base)
  File "/usr/local/lib/python3.6/dist-packages/swaggertosdk/restapi/github.py", line 283, in create_context_pr
    _LOGGER.info("Unable to manage Context PR %s:\n%s", context_pr.number, response)
UnboundLocalError: local variable 'context_pr' referenced before assignment

@AutorestCI
Copy link
Copy Markdown

Swagger to SDK encountered a Subprocess error: (Azure/azure-sdk-for-go)

Command: profileBuilder -s preview -name preview
Finished with return code 127
and output:

/bin/sh: 1: profileBuilder: not found

Copy link
Copy Markdown
Contributor

@kalyanaj kalyanaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Copy Markdown
Contributor

@dsgouda dsgouda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few redundancies that can be reduced by consolidating a few definitions and creating properties objects for inline properties.
Also, definitions defined here are not being referenced anywhere, so not sure on the intentions behind this PR

"description":
"Describes the schema of the Azure IoT Hub events published to Azure Event Grid. This corresponds to the Data property of an EventGridEvent."
},
"paths": {},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand correctly, you are simply defining models but not any paths from the service. What is the intention here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to document the schemas of the various events published to EventGrid. A consumer who is consuming events from EventGrid (e.g. in an Azure function or in any webhook) can use the generated classes to deserialize the event appropriately. This is the same pattern used for other existing event schemas as well (e.g. the storage events in the eventgrid data plane directory).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

"type": "object",
"description":
"A portion of the properties that can be written only by the application back-end, and read by the device.",
"properties": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A. We discourage use of inline definitions for complex object properties.
B. Is this odata by any chance or does your model actually have properties with special characters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you are repeating this definition again in report, better pull it out into a different definition altogether and reference it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the model has properties with "$" to signify that they are system properties.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are not odata properties, we strongly recommend using x-ms-client-name (here)
You can name the property without special characters and specify its exact name with the special character as the x-ms-client-name value

},
"paths": {},
"definitions": {
"IotHubDeviceCreatedEventData": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you are sharing a bunch of properties with IotHubDeviceDeletedEventData, can you consolidate the common properties into a common definition here

"type": "object",
"description":
"Information about the device twin, which is the cloud represenation of application device metadata.",
"properties": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, please do not define inline properties like so, create a new definition

@cpjagan
Copy link
Copy Markdown
Contributor Author

cpjagan commented Feb 6, 2018

@dsgouda I have pushed changes based on your comments to split into smaller definitions.

@AutorestCI
Copy link
Copy Markdown

Swagger to SDK encountered a Subprocess error: (Azure/azure-sdk-for-go)

Command: profileBuilder -s preview -name preview
Finished with return code 127
and output:

/bin/sh: 1: profileBuilder: not found

"definitions": {
"IotHubDeviceCreatedEventData": {
"description": "Schema of the Data property of an EventGridEvent for an Microsoft.Devices.DeviceCreated event.",
"$ref" : "#/definitions/DeviceLifeCycleEventData"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right way to do this is:

"IotHubDeviceCreatedEventData": {
    "properties":{
          "x-ms-client-flatten": true,
          "$ref": "#/definitions/DeviceLifeCycleEventData",
          "description": "device life cycle properties."
   }
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to use the "x-ms-client-flatten": true, everywhere I reference is it?


"description": "Schema of the Data property of an EventGridEvent for an Microsoft.Devices.DeviceDeleted event.",
"$ref" : "#/definitions/DeviceLifeCycleEventData"
},
"DeviceLifeCycleEventData": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name here is DeviceLifeCycleEventProperties

Updated definition name for DeviceLifeCycleEvent
@cpjagan
Copy link
Copy Markdown
Contributor Author

cpjagan commented Feb 7, 2018

@dsgouda Pushed fixes based on your comment. Please review and let me know.

@AutorestCI
Copy link
Copy Markdown

Swagger to SDK encountered a Subprocess error: (Azure/azure-sdk-for-go)

Command: profileBuilder -s preview -name preview
Finished with return code 127
and output:

/bin/sh: 1: profileBuilder: not found

@AutorestCI
Copy link
Copy Markdown

Swagger to SDK encountered a Subprocess error: (Azure/azure-sdk-for-go)

Command: profileBuilder -s preview -name preview
Finished with return code 127
and output:

/bin/sh: 1: profileBuilder: not found

@azuresdkciprbot
Copy link
Copy Markdown

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/eventgrid/data-plane/readme.md
Before the PR: Warning(s): 0 Error(s): 0
After the PR: Warning(s): 0 Error(s): 0

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

Copy link
Copy Markdown
Contributor

@dsgouda dsgouda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor comments and still recommend usage of x-ms-client-name for property names with special characters, e.g."

 "lastUpdated": {
          "type": "string",
          "description": "The ISO8601 timestamp of the last time the properties were updated.",
          "x-ms-client-name":"$lastUpdated"
        }

"paths": {},
"definitions": {
"IotHubDeviceCreatedEventData": {
"description": "Schema of the Data property of an EventGridEvent for a Microsoft.Devices.DeviceCreated event.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: A better description would be
"Event data for IotHubDeviceCreated event"

}
}
},
"DeviceTwinProperties": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use a more meaningful name here, there already exists a definition for DeviceTwinInfo with some properties
something like TwinDeviceReportedProperties or DeviceReportedProperties based on the property name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this context reported properties has a different meaning. So using that would only confuse the reader who understands the iot hub twin concepts. DeviceTwinProperty is the right name.

Also, TwinInfo and TwinProperties were names I picked from another swagger doc that a partner team of us already uses. I would like to be consistent with those.

I will pass on this nit.

Copy link
Copy Markdown
Contributor

@dsgouda dsgouda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending CI builds

@AutorestCI
Copy link
Copy Markdown

Swagger to SDK encountered a Subprocess error: (Azure/azure-sdk-for-go)

Command: profileBuilder -s preview -name preview
Finished with return code 127
and output:

/bin/sh: 1: profileBuilder: not found

@azuresdkciprbot
Copy link
Copy Markdown

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/eventgrid/data-plane/readme.md
Before the PR: Warning(s): 0 Error(s): 0
After the PR: Warning(s): 0 Error(s): 0

AutoRest Linter Guidelines | AutoRest Linter Issues | Send feedback

Thanks for your co-operation.

@dsgouda dsgouda merged commit 68a0d93 into Azure:master Feb 7, 2018
@AutorestCI
Copy link
Copy Markdown

Swagger to SDK encountered a Subprocess error: (Azure/azure-sdk-for-go)

Command: profileBuilder -s preview -name preview
Finished with return code 127
and output:

/bin/sh: 1: profileBuilder: not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants