Skip to content

Commit 84016fb

Browse files
YingXuetjprescott
authored andcommitted
Ying/dps knack (Azure#5197)
* first commit of knack * added commands and helps * update parms for dps * add dps commands implementations * update command show to get * updated resource id and tests * update dps location for test * update history log * update history log * update a few verbs and pyproj file * update help string and run check style * update sdk * check style update * relax test check * update test to be more efficient * update yaml recording based on the new tests * update test yaml * update histroy and convert to live tests only
1 parent b155f0d commit 84016fb

File tree

10 files changed

+811
-5
lines changed

10 files changed

+811
-5
lines changed

azure-cli.pyproj

+3
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,11 @@
398398
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\sas_token_auth.py" />
399399
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_iot_certificate_commands.py" />
400400
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_iot_commands.py" />
401+
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_iot_dps_commands.py" />
401402
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_sas_token_auth.py" />
402403
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\_test_utils.py" />
404+
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_client_factory.py" />
405+
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_completers.py" />
403406
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_constants.py" />
404407
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_help.py" />
405408
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_params.py" />

azure-cli2017.pyproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,11 @@
351351
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\sas_token_auth.py" />
352352
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_iot_certificate_commands.py" />
353353
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_iot_commands.py" />
354+
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_iot_dps_commands.py" />
354355
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\tests\test_sas_token_auth.py" />
355356
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_constants.py" />
356-
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_factory.py" />
357+
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_client_factory.py" />
358+
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_completers.py" />
357359
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_help.py" />
358360
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_params.py" />
359361
<Compile Include="command_modules\azure-cli-iot\azure\cli\command_modules\iot\_utils.py" />

src/command_modules/azure-cli-iot/HISTORY.rst

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Release History
55

66
0.1.16
77
++++++
8+
* Added support for device provisioning service
89
* Added deprecation messages in commands and command help.
910
* Added IoT run once check to warn users about the availability of the IoT Extension.
1011

src/command_modules/azure-cli-iot/azure/cli/command_modules/iot/_client_factory.py

+6
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ def resource_service_factory(cli_ctx, **_):
1414
from azure.mgmt.resource import ResourceManagementClient
1515
from azure.cli.core.commands.client_factory import get_mgmt_service_client
1616
return get_mgmt_service_client(cli_ctx, ResourceManagementClient)
17+
18+
19+
def iot_service_provisioning_factory(cli_ctx, *_):
20+
from azure.cli.core.commands.client_factory import get_mgmt_service_client
21+
from azure.mgmt.iothubprovisioningservices.iot_dps_client import IotDpsClient
22+
return get_mgmt_service_client(cli_ctx, IotDpsClient)

src/command_modules/azure-cli-iot/azure/cli/command_modules/iot/_help.py

+247
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,253 @@
2525
type: group
2626
short-summary: (PREVIEW) Manage Azure IoT hubs.
2727
"""
28+
helps['iot dps'] = """
29+
type: group
30+
short-summary: Manage Azure IoT Hub Device Provisioning Service.
31+
"""
32+
33+
helps['iot dps create'] = """
34+
type: command
35+
short-summary: Create an Azure IoT Hub device provisioning service.
36+
long-summary: For an introduction to Azure IoT Hub Device Provisioning Service, see https://docs.microsoft.com/en-us/azure/iot-dps/about-iot-dps
37+
examples:
38+
- name: Create an Azure IoT Hub device provisioning service with the standard pricing tier S1, in the region of the resource group.
39+
text: >
40+
az iot dps create --name MyDps --resource-group MyResourceGroup
41+
- name: Create an Azure IoT Hub device provisioning service with the standard pricing tier S1, in the 'eastus' region.
42+
text: >
43+
az iot dps create --name MyDps --resource-group MyResourceGroup --location eastus
44+
"""
45+
46+
helps['iot dps list'] = """
47+
type: command
48+
short-summary: List Azure IoT Hub device provisioning services.
49+
examples:
50+
- name: List all Azure IoT Hub device provisioning services in a subscription.
51+
text: >
52+
az iot dps list
53+
- name: List all Azure IoT Hub device provisioning services in the resource group 'MyResourceGroup'
54+
text: >
55+
az iot dps list --resource-group MyResourceGroup
56+
"""
57+
58+
helps['iot dps show'] = """
59+
type: command
60+
short-summary: Get the details of an Azure IoT Hub device provisioning service.
61+
examples:
62+
- name: Show details of an Azure IoT Hub device provisioning service 'MyDps'
63+
text: >
64+
az iot dps show --name MyDps --resource-group MyResourceGroup
65+
"""
66+
67+
helps['iot dps delete'] = """
68+
type: command
69+
short-summary: Delete an Azure IoT Hub device provisioning service.
70+
examples:
71+
- name: Delete an Azure IoT Hub device provisioning service 'MyDps'
72+
text: >
73+
az iot dps delete --name MyDps --resource-group MyResourceGroup
74+
"""
75+
76+
helps['iot dps update'] = """
77+
type: command
78+
short-summary: Update an Azure IoT Hub device provisioning service.
79+
examples:
80+
- name: Update Allocation Policy to 'GeoLatency' of an Azure IoT Hub device provisioning service 'MyDps'
81+
text: >
82+
az iot dps delete --name MyDps --resource-group MyResourceGroup --set properties.allocationPolicy="GeoLatency"
83+
"""
84+
85+
helps['iot dps access-policy'] = """
86+
type: group
87+
short-summary: Manage Azure IoT Hub Device Provisioning Service access policies.
88+
"""
89+
90+
helps['iot dps access-policy create'] = """
91+
type: command
92+
short-summary: Create a new shared access policy in an Azure IoT Hub device provisioning service.
93+
examples:
94+
- name: Create a new shared access policy in an Azure IoT Hub device provisioning service with EnrollmentRead right
95+
text: >
96+
az iot dps access-policy create --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy --rights EnrollmentRead
97+
"""
98+
99+
helps['iot dps access-policy update'] = """
100+
type: command
101+
short-summary: Update a shared access policy in an Azure IoT Hub device provisioning service.
102+
examples:
103+
- name: Update access policy 'MyPolicy' in an Azure IoT Hub device provisioning service with EnrollmentWrite right
104+
text: >
105+
az iot dps access-policy update --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy --rights EnrollmentWrite
106+
"""
107+
108+
helps['iot dps access-policy list'] = """
109+
type: command
110+
short-summary: List all shared access policies in an Azure IoT Hub device provisioning service.
111+
examples:
112+
- name: List all shared access policies in MyDps
113+
text: >
114+
az iot dps access-policy list --dps-name MyDps --resource-group MyResourceGroup
115+
"""
116+
117+
helps['iot dps access-policy show'] = """
118+
type: command
119+
short-summary: Show details of a shared access policies in an Azure IoT Hub device provisioning service.
120+
examples:
121+
- name: Show details of shared access policy 'MyPolicy' in an Azure IoT Hub device provisioning service
122+
text: >
123+
az iot dps access-policy show --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy
124+
"""
125+
126+
helps['iot dps access-policy delete'] = """
127+
type: command
128+
short-summary: Delete a shared access policies in an Azure IoT Hub device provisioning service.
129+
examples:
130+
- name: Delete shared access policy 'MyPolicy' in an Azure IoT Hub device provisioning service
131+
text: >
132+
az iot dps access-policy delete --dps-name MyDps --resource-group MyResourceGroup --name MyPolicy
133+
"""
134+
135+
helps['iot dps linked-hub'] = """
136+
type: group
137+
short-summary: Manage Azure IoT Hub Device Provisioning Service linked IoT hubs.
138+
"""
139+
140+
helps['iot dps linked-hub create'] = """
141+
type: command
142+
short-summary: Create a linked IoT hub in an Azure IoT Hub device provisioning service.
143+
examples:
144+
- name: Create a linked IoT hub in an Azure IoT Hub device provisioning service
145+
text: >
146+
az iot dps linked-hub create --dps-name MyDps --resource-group MyResourceGroup --connection-string
147+
HostName=test.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=XNBhoasdfhqRlgGnasdfhivtshcwh4bJwe7c0RIGuWsirW0=
148+
--location westus
149+
- name: Create a linked IoT hub in an Azure IoT Hub device provisioning service which applies allocation weight and weight being 10
150+
text: >
151+
az iot dps linked-hub create --dps-name MyDps --resource-group MyResourceGroup --connection-string
152+
HostName=test.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=XNBhoasdfhqRlgGnasdfhivtshcwh4bJwe7c0RIGuWsirW0=
153+
--location westus --allocation-weight 10 --apply-allocation-policy True
154+
"""
155+
156+
helps['iot dps linked-hub update'] = """
157+
type: command
158+
short-summary: Update a linked IoT hub in an Azure IoT Hub device provisioning service.
159+
examples:
160+
- name: Update linked IoT hub 'MyLinkedHub.azure-devices.net' in an Azure IoT Hub device provisioning service
161+
text: >
162+
az iot dps linked-hub update --dps-name MyDps --resource-group MyResourceGroup --name MyLinkedHub.azure-devices.net
163+
--allocation-weight 10 --apply-allocation-policy True
164+
"""
165+
166+
helps['iot dps linked-hub list'] = """
167+
type: command
168+
short-summary: List all linked IoT hubs in an Azure IoT Hub device provisioning service.
169+
examples:
170+
- name: List all linked IoT hubs in MyDps
171+
text: >
172+
az iot dps linked-hub list --dps-name MyDps --resource-group MyResourceGroup
173+
"""
174+
175+
helps['iot dps linked-hub show'] = """
176+
type: command
177+
short-summary: Show details of a linked IoT hub in an Azure IoT Hub device provisioning service.
178+
examples:
179+
- name: Show details of linked IoT hub 'MyLinkedHub' in an Azure IoT Hub device provisioning service
180+
text: >
181+
az iot dps linked-hub show --dps-name MyDps --resource-group MyResourceGroup --name MyLinkedHub
182+
"""
183+
184+
helps['iot dps linked-hub delete'] = """
185+
type: command
186+
short-summary: Update a linked IoT hub in an Azure IoT Hub device provisioning service.
187+
examples:
188+
- name: Delete linked IoT hub 'MyLinkedHub' in an Azure IoT Hub device provisioning service
189+
text: >
190+
az iot dps linked-hub delete --dps-name MyDps --resource-group MyResourceGroup --name MyLinkedHub
191+
"""
192+
193+
helps['iot dps certificate'] = """
194+
type: group
195+
short-summary: Manage Azure IoT Hub Device Provisioning Service certificates.
196+
"""
197+
198+
helps['iot dps certificate create'] = """
199+
type: command
200+
short-summary: Create/upload an Azure IoT Hub Device Provisioning Service certificate.
201+
examples:
202+
- name: Upload a CA certificate PEM file to an Azure IoT Hub device provisioning service.
203+
text: >
204+
az iot dps certificate create --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate --path /certificates/Certificate.pem
205+
- name: Upload a CA certificate CER file to an Azure IoT Hub device provisioning service.
206+
text: >
207+
az iot dps certificate create --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate --path /certificates/Certificate.cer
208+
"""
209+
210+
helps['iot dps certificate update'] = """
211+
type: command
212+
short-summary: Update an Azure IoT Hub Device Provisioning Service certificate.
213+
long-summary: Upload a new certificate to replace the existing certificate with the same name.
214+
examples:
215+
- name: Update a CA certificate in an Azure IoT Hub device provisioning service by uploading a new PEM file.
216+
text: >
217+
az iot dps certificate update --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate
218+
--path /certificates/NewCertificate.pem --etag AAAAAAAAAAA=
219+
- name: Update a CA certificate in an Azure IoT Hub device provisioning service by uploading a new CER file.
220+
text: >
221+
az iot dps certificate update --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate
222+
--path /certificates/NewCertificate.cer --etag AAAAAAAAAAA=
223+
"""
224+
225+
helps['iot dps certificate delete'] = """
226+
type: command
227+
short-summary: Delete an Azure IoT Hub Device Provisioning Service certificate.
228+
examples:
229+
- name: Delete MyCertificate in an Azure IoT Hub device provisioning service
230+
text: >
231+
az iot dps certificate delete --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate --etag AAAAAAAAAAA=
232+
"""
233+
234+
helps['iot dps certificate show'] = """
235+
type: command
236+
short-summary: Show information about a particular Azure IoT Hub Device Provisioning Service certificate.
237+
examples:
238+
- name: Show details about MyCertificate in an Azure IoT Hub device provisioning service
239+
text: >
240+
az iot dps certificate show --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate
241+
"""
242+
243+
helps['iot dps certificate list'] = """
244+
type: command
245+
short-summary: List all certificates contained within an Azure IoT Hub device provisioning service
246+
examples:
247+
- name: List all certificates in MyDps
248+
text: >
249+
az iot dps certificate list --dps-name MyDps --resource-group MyResourceGroup
250+
"""
251+
252+
helps['iot dps certificate generate-verification-code'] = """
253+
type: command
254+
short-summary: Generate a verification code for an Azure IoT Hub Device Provisioning Service certificate.
255+
long-summary: This verification code is used to complete the proof of possession step for a certificate. Use this
256+
verification code as the CN of a new certificate signed with the root certificates private key.
257+
examples:
258+
- name: Generate a verification code for MyCertificate
259+
text: >
260+
az iot dps certificate generate-verification-code --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate
261+
--etag AAAAAAAAAAA=
262+
"""
263+
264+
helps['iot dps certificate verify'] = """
265+
type: command
266+
short-summary: Verify an Azure IoT Hub Device Provisioning Service certificate.
267+
long-summary: Verify a certificate by uploading a verification certificate containing the verification code obtained
268+
by calling generate-verification-code. This is the last step in the proof of possession process.
269+
examples:
270+
- name: Verify ownership of the MyCertificate private key.
271+
text: >
272+
az iot dps certificate verify --dps-name MyDps --resource-group MyResourceGroup --name MyCertificate
273+
--path /certificates/Verification.pem --etag AAAAAAAAAAA=
274+
"""
28275

29276
helps['iot hub certificate'] = """
30277
type: group

0 commit comments

Comments
 (0)