Skip to content
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

docs(azure-iot-device): setOptions documentation #865

Merged
merged 5 commits into from
Jul 28, 2020

Conversation

YoDaMa
Copy link
Contributor

@YoDaMa YoDaMa commented Jul 27, 2020

Part of this is adding clarity where the Device Client supports Proxy. It is also consolidating our documentation for setOptions into a file, a new "README" for the Device Client that is linked from the main readme. Maybe the better place should be the Wiki... Unclear. That can be discussed @elhorton.


The Azure IoT Device Client Library provides an efficient and well tested API for connecting and using devices with the Azure IoT Hub.

## client.setOptions(options, [callback])
Copy link
Contributor

Choose a reason for hiding this comment

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

(fyi, I'm going to be asking naive questions like a customer with no knowledge of the SDK)-- in what circumstance would I add a callback to the setOptions call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

callback is if you're using client.setOptions in the traditional node callback way, where once it completes the callback is used to move on to the next operation. In the Node Promises syntax you would not need a callback, and just call await on the setOptions: await client.setOptions(options);

Copy link
Contributor

Choose a reason for hiding this comment

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

ok got it, as long as customers understand the use here--- as a javascript developer seems pretty straightforward

- `modelId`: !!Digital Twin Use Only!! String used in MQTT username setting the Digital Twin modelId.
- `tokenRenewal`: Optional object with token renewal values. Only use with authentication that uses pre shared keys.
- `mqtt`: Options specific to the MQTT transport
- `webSocketAgent`: [Agent]{@link https://nodejs.org/api/https.html#https_class_https_agent} object to use with MQTT-WS connections. Can be used for tunneling proxies.
Copy link
Contributor

Choose a reason for hiding this comment

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

in the case of protocol specific options, do I need to specify the protocol? Or will a call to client.SetOptions(webSocketAgent=xxx) automatically work for whichever protocol I'm using (assuming amqp or mqtt in this case based on the parameter name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is incorrect. what's a good way to guide users that they need to put it in an object?

i.e.: client.setOptions({mqtt: {websocketAgent: agent}}

(also, I know the API looks kinda dumb, since all three can accept an agent, but,,, that's just how it is and we can't break it now).

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it's fine, doesn't have to be perfect as long as it's usable-- in this case, probably best to just show an example. As in, before starting the protocol specific examples with mqtt, a line saying:

Protocol specific options: to use options for a specific protocol, you must pass it as an object that specifies both the protocol used and the option you are setting. For example, client.setOptions({mqtt: {websocketAgent: agent}}).


Used directly after creating the Device Client to set options on the client. These should not be dynamically altered during runtime of the device client.

### Available Options
Copy link
Contributor

Choose a reason for hiding this comment

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

Will these options also show up somewhere in API reference docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...no...

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, should they? seems to me like it would be helpful but if that's breaking API reference doc precedent that's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait sorry, these options do show up in the API somewhere, but not in this form. I pulled most of the definitions for the options from the docstrings.

- `drain`: Boolean indicating whether only one message should be received all messages should be drained.
- `amqp`: Options specific to the AMQP transport
- `webSocketAgent`: [Agent]{@link https://nodejs.org/api/https.html#https_class_https_agent} object to use with AMQP-WS connections. Can be used for tunneling proxies.
- `cert`: X509 Certificate.
Copy link
Collaborator

@jebrando jebrando Jul 27, 2020

Choose a reason for hiding this comment

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

Could you please expand this cert one to be

X.509 certificate used for authenticating the device to the IoTHub.

doc/device_client.md Outdated Show resolved Hide resolved
doc/device_client.md Outdated Show resolved Hide resolved
@YoDaMa YoDaMa merged commit 9032271 into Azure:master Jul 28, 2020
@YoDaMa YoDaMa deleted the proxy_support branch July 28, 2020 20:54
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.

None yet

3 participants