Skip to content

Commit de524fa

Browse files
authored
(FM-8079) Docs edit
1 parent 7887219 commit de524fa

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

docs/hands-on-lab/06-implementing-the-provider.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Implementing the Provider
1+
# Implementing the provider
22

3-
To expose resources from the HUE Hub to puppet, a type and provider define and implement the desired interactions. The *type*, like the transport schema, defines the shape of the data using Puppet Data Types. The implementation in the *provider* takes care of the communication and data transformation.
3+
To expose resources from the HUE Hub to Puppet, a type and provider define and implement the desired interactions. The *type*, like the transport schema, defines the shape of the data using Puppet data types. The implementation in the *provider* takes care of the communication and data transformation.
44

55
For this hands on lab, we'll now go through implementing a simple `hue_light` type and provider to manage the state of the light bulbs connected to the HUE Hub.
66

77
## Generating the Boilerplate
88

9-
In your module directory, run `pdk new provider hue_light`. This will create another set of files with a bare-bones type and provider, as well as unit tests.
9+
In your module directory, run `pdk new provider hue_light`. This creates another set of files with a bare-bones type and provider, as well as unit tests.
1010

1111
```
1212
david@davids:~/tmp/hue_workshop$ pdk new provider hue_light
@@ -17,17 +17,17 @@ pdk (INFO): Creating '/home/david/tmp/hue_workshop/spec/unit/puppet/type/hue_lig
1717
david@davids:~/tmp/hue_workshop$
1818
```
1919

20-
## Defining the Type
20+
## Defining the type
2121

2222
The type defines the attributes and allowed values, as well as a couple of other bits of information that concerns the processing of this provider.
2323

24-
For remote resources like this, adding the `'remote_resource'` feature is necessary to alert puppet of its specific needs. Add the string to the existing `features` array.
24+
For remote resources like this, adding the `'remote_resource'` feature is necessary to alert Puppet of its specific needs. Add the string to the existing `features` array.
2525

26-
Browsing through the Hub API (TODO: insert link), we can identify a few basic properties we want to manage:
26+
Browsing through the Hub API (TODO: insert link), we can identify a few basic properties we want to manage, for example:
2727

28-
* whether the lamp is on or off
29-
* the colour of the light (hue and saturation)
30-
* the brightness of the light
28+
* Whether the lamp is on or off
29+
* The colour of the light (hue and saturation)
30+
* The brightness of the light
3131

3232
To define the necessary attributes, insert the following snippet into the `attributes` hash, after the `name`:
3333

@@ -54,11 +54,11 @@ DESC
5454

5555
## Implementing the Provider
5656

57-
Every provider needs a `get` method, that returns a list of currently existing resources and their attributes from the remote target. For the HUE Hub, this is requires a call to the `lights` endpoint and some data transformation to the format puppet expects.
57+
Every provider needs a `get` method, that returns a list of currently existing resources and their attributes from the remote target. For the HUE Hub, this is requires a call to the `lights` endpoint and some data transformation to the format Puppet expects.
5858

5959
### Reading the state of the lights
6060

61-
Replace the example `get` function in `lib/puppet/provider/hue_light/hue_light.rb` with the following snippet:
61+
Replace the example `get` function in `lib/puppet/provider/hue_light/hue_light.rb` with the following code:
6262

6363
```
6464
# @summary
@@ -81,7 +81,7 @@ Replace the example `get` function in `lib/puppet/provider/hue_light/hue_light.r
8181
end
8282
```
8383

84-
This method will return all connected lights from the HUE Hub and allow puppet to process those. To try this out, you need to setup a test configuration and then `puppet device` can be used to drive your testing.
84+
This method returns all connected lights from the HUE Hub and allows Puppet to process them. To try this out, you need to setup a test configuration and use `puppet device` to drive your testing.
8585

8686
> TODO: explain steps to gain access to API keys for real device
8787
@@ -147,7 +147,7 @@ The final step here is to implement enforcing the desired state of the lights. T
147147

148148
For the HUE Hub API, we can remove the `create` and `delete` method. Since the attribute names and data definitions line up with the HUE Hub API, the `update` method is very short.
149149

150-
Replace the `create`, `update`, and `delete` methods with this snippet:
150+
Replace the `create`, `update`, and `delete` methods with the following code:
151151

152152
```
153153
def update(context, name, should)
@@ -190,9 +190,9 @@ david@davids:~/git/hue_workshop$
190190

191191
## Exercise
192192

193-
To round out the API support, add a `effect` attribute that defaults to `none`, but can be set to `colorloop`, and an `alert` attribute that defaults to `none` and can be set to `select`.
193+
To round out the API support, add an `effect` attribute that defaults to `none`, but can be set to `colorloop`, and an `alert` attribute that defaults to `none` and can be set to `select`.
194194

195-
Note that this exercise will require exploring new data types and Resource API options.
195+
Note that this exercise requires exploring new data types and Resource API options.
196196

197197
> TODO: add exercise hints
198198

0 commit comments

Comments
 (0)