Skip to content

Commit 4b36169

Browse files
authored
Remove product init and add validation-type to test create (#5)
* Remove az iot product init (Azure#20) * Product (Azure#21) * Remove most cases of product_id * Updated Swagger * Add validation-type and make product-id only required for Certification validation type * Fix CLI linter * Fix tests
1 parent 8f83d90 commit 4b36169

39 files changed

+219
-415
lines changed

azext_iot/product/_help.py

-13
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,3 @@ def load_help():
3434
text: >
3535
az iot product requirement list
3636
"""
37-
helps[
38-
"iot product init"
39-
] = """
40-
type: command
41-
short-summary: Used to initialize local workspace for a new product certification
42-
examples:
43-
- name: Use default working folder ('PnPCert')
44-
text: >
45-
az iot product init --product-name {product_name}
46-
- name: Specify working folder
47-
text: >
48-
az iot product init --product-name {product_name} --working-folder {working_folder}
49-
"""

azext_iot/product/command_map.py

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020

2121
def load_product_commands(self, _):
22-
with self.command_group("iot product", command_type=product_ops) as g:
23-
g.command("init", "initialize_workspace")
24-
2522
with self.command_group(
2623
"iot product requirement", command_type=requirements_ops
2724
) as g:

azext_iot/product/command_product.py

-102
This file was deleted.

azext_iot/product/params.py

-12
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@
1414

1515
def load_product_params(self, _):
1616
with self.argument_context("iot product") as c:
17-
c.argument(
18-
"working_folder",
19-
options_list=["--working-folder", "--wf"],
20-
help="The folder to create in current path",
21-
arg_group="IoT Device Certification",
22-
)
23-
c.argument(
24-
"product_name",
25-
options_list=["--product-name"],
26-
help="Product name to display in catalog",
27-
arg_group="IoT Device Certification",
28-
)
2917
c.argument(
3018
"test_id",
3119
options_list=["--test-id", "-t"],

azext_iot/product/shared.py

+5
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ class DeviceTestTaskStatus(Enum):
3939
cancelled = "Cancelled"
4040

4141

42+
class ValidationType(Enum):
43+
test = "Test"
44+
certification = "Certification"
45+
46+
4247
BASE_URL = "https://certify.azureiotsolutions.com"

azext_iot/product/test/_help.py

+15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ def load_help():
3030
- name: Do not have service create provisioning configuration
3131
text: >
3232
az iot product test create --configuration-file {configuration_file} --skip-provisioning
33+
- name: Creating test with symmetric key attestation
34+
text: >
35+
az iot product test create --attestation-type SymmetricKey --device-type {device_type}
36+
- name: Creating test with TPM attestation
37+
text: >
38+
az iot product test create --attestation-type TPM --device-type {device_type} --endorsement-key {endorsement_key}
39+
- name: Creating test with x509 attestation
40+
text: >
41+
az iot product test create --attestation-type x509 --device-type {device_type} --certificate-path {certificate_path}
42+
- name: Creating test for Edge module
43+
text: >
44+
az iot product test create --attestation-type ConnectionString --device-type {device_type} --badge-type IotEdgeCompatible --connection-string {connection_string}
45+
- name: Creating test with symmetric key attestation and specified validation type
46+
text: >
47+
az iot product test create --attestation-type SymmetricKey --device-type {device_type} --validation-type Certification --product-id {product_id}
3348
"""
3449
helps[
3550
"iot product test search"

azext_iot/product/test/command_tests.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from azext_iot.product.providers.aics import AICSProvider
88
from azext_iot.sdk.product.models import DeviceTestSearchOptions
9-
from azext_iot.product.shared import BadgeType, AttestationType
9+
from azext_iot.product.shared import BadgeType, AttestationType, ValidationType
1010
from knack.log import get_logger
1111
from knack.util import CLIError
1212
import os
@@ -24,6 +24,7 @@ def create(
2424
connection_string=None,
2525
endorsement_key=None,
2626
badge_type=BadgeType.IotDevice.value,
27+
validation_type=ValidationType.test.value,
2728
models=None,
2829
skip_provisioning=False,
2930
base_url=None,
@@ -46,10 +47,14 @@ def create(
4647
raise CLIError(
4748
"Connection string is only available for Edge Compatible modules testing"
4849
)
50+
if validation_type != ValidationType.test.value and not product_id:
51+
raise CLIError(
52+
"Product Id is required for validation type {}".format(validation_type)
53+
)
4954
if not any(
5055
[
5156
configuration_file,
52-
all([device_type, product_id, attestation_type, badge_type]),
57+
all([device_type, attestation_type, badge_type]),
5358
]
5459
):
5560
raise CLIError(
@@ -67,6 +72,7 @@ def create(
6772
badge_type=badge_type,
6873
connection_string=connection_string,
6974
models=models,
75+
validation_type=validation_type
7076
)
7177
)
7278

@@ -210,9 +216,10 @@ def _build_test_configuration(
210216
connection_string,
211217
badge_type,
212218
models,
219+
validation_type
213220
):
214221
config = {
215-
"validationType": "Certification",
222+
"validationType": validation_type,
216223
"productId": product_id,
217224
"deviceType": device_type,
218225
"provisioningConfiguration": {"type": attestation_type},

azext_iot/product/test/params.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111
from azure.cli.core.commands.parameters import get_three_state_flag, get_enum_type
12-
from azext_iot.product.shared import AttestationType, DeviceType, TaskType
12+
from azext_iot.product.shared import AttestationType, DeviceType, TaskType, ValidationType
1313

1414

1515
def load_product_test_params(self, _):
@@ -73,8 +73,15 @@ def load_product_test_params(self, _):
7373
c.argument(
7474
"product_id",
7575
options_list=["--product-id", "-p"],
76-
help="The submitted product id",
76+
help="The submitted product id. Required when validation-type is 'Certification'.",
77+
arg_group="IoT Device Certification Device Definition",
78+
)
79+
c.argument(
80+
"validation_type",
81+
options_list=["--validation-type", "--vt"],
82+
help="The type of validations testing to be performed",
7783
arg_group="IoT Device Certification Device Definition",
84+
arg_type=get_enum_type(ValidationType)
7885
)
7986
with self.argument_context("iot product test search") as c:
8087
c.argument(

azext_iot/sdk/product/models/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .provisioning_configuration_py3 import ProvisioningConfiguration
2323
from .iot_device_certification_badge_configuration_py3 import IotDeviceCertificationBadgeConfiguration
2424
from .iot_edge_compatible_certification_badge_configuration_py3 import IotEdgeCompatibleCertificationBadgeConfiguration
25+
from .model_resolution_source_py3 import ModelResolutionSource
2526
from .pnp_certification_badge_configuration_py3 import PnpCertificationBadgeConfiguration
2627
from .device_test_py3 import DeviceTest
2728
from .device_test_search_options_py3 import DeviceTestSearchOptions
@@ -79,6 +80,7 @@
7980
from .provisioning_configuration import ProvisioningConfiguration
8081
from .iot_device_certification_badge_configuration import IotDeviceCertificationBadgeConfiguration
8182
from .iot_edge_compatible_certification_badge_configuration import IotEdgeCompatibleCertificationBadgeConfiguration
83+
from .model_resolution_source import ModelResolutionSource
8284
from .pnp_certification_badge_configuration import PnpCertificationBadgeConfiguration
8385
from .device_test import DeviceTest
8486
from .device_test_search_options import DeviceTestSearchOptions
@@ -137,6 +139,7 @@
137139
'ProvisioningConfiguration',
138140
'IotDeviceCertificationBadgeConfiguration',
139141
'IotEdgeCompatibleCertificationBadgeConfiguration',
142+
'ModelResolutionSource',
140143
'PnpCertificationBadgeConfiguration',
141144
'DeviceTest',
142145
'DeviceTestSearchOptions',

azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,14 @@
1515
class CannotRetrieveModelReposistorySasTokenError(Model):
1616
"""CannotRetrieveModelReposistorySasTokenError.
1717
18-
Variables are only populated by the server, and will be ignored when
19-
sending a request.
20-
2118
:param message:
2219
:type message: str
2320
:param code:
2421
:type code: int
25-
:ivar details:
26-
:vartype details: list[object]
22+
:param details:
23+
:type details: list[object]
2724
"""
2825

29-
_validation = {
30-
'details': {'readonly': True},
31-
}
32-
3326
_attribute_map = {
3427
'message': {'key': 'message', 'type': 'str'},
3528
'code': {'key': 'code', 'type': 'int'},
@@ -40,4 +33,4 @@ def __init__(self, **kwargs):
4033
super(CannotRetrieveModelReposistorySasTokenError, self).__init__(**kwargs)
4134
self.message = kwargs.get('message', None)
4235
self.code = kwargs.get('code', None)
43-
self.details = None
36+
self.details = kwargs.get('details', None)

azext_iot/sdk/product/models/cannot_retrieve_model_reposistory_sas_token_error_py3.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,22 @@
1515
class CannotRetrieveModelReposistorySasTokenError(Model):
1616
"""CannotRetrieveModelReposistorySasTokenError.
1717
18-
Variables are only populated by the server, and will be ignored when
19-
sending a request.
20-
2118
:param message:
2219
:type message: str
2320
:param code:
2421
:type code: int
25-
:ivar details:
26-
:vartype details: list[object]
22+
:param details:
23+
:type details: list[object]
2724
"""
2825

29-
_validation = {
30-
'details': {'readonly': True},
31-
}
32-
3326
_attribute_map = {
3427
'message': {'key': 'message', 'type': 'str'},
3528
'code': {'key': 'code', 'type': 'int'},
3629
'details': {'key': 'details', 'type': '[object]'},
3730
}
3831

39-
def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None:
32+
def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None:
4033
super(CannotRetrieveModelReposistorySasTokenError, self).__init__(**kwargs)
4134
self.message = message
4235
self.code = code
43-
self.details = None
36+
self.details = details

azext_iot/sdk/product/models/device_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DeviceTest(Model):
2323
:param validation_type:
2424
Microsoft.Azure.IoT.TestKit.Shared.Models.ValidationType of a
2525
Microsoft.Azure.IoT.TestKit.Models.DeviceTest. Possible values include:
26-
'Certification'
26+
'Certification', 'Test'
2727
:type validation_type: str or ~product.models.enum
2828
:param product_id: Product Id of the testing device in product service. In
2929
CLI scenario, this can be null.

azext_iot/sdk/product/models/device_test_not_exist_error.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,14 @@
1515
class DeviceTestNotExistError(Model):
1616
"""DeviceTestNotExistError.
1717
18-
Variables are only populated by the server, and will be ignored when
19-
sending a request.
20-
2118
:param message:
2219
:type message: str
2320
:param code:
2421
:type code: int
25-
:ivar details:
26-
:vartype details: list[object]
22+
:param details:
23+
:type details: list[object]
2724
"""
2825

29-
_validation = {
30-
'details': {'readonly': True},
31-
}
32-
3326
_attribute_map = {
3427
'message': {'key': 'message', 'type': 'str'},
3528
'code': {'key': 'code', 'type': 'int'},
@@ -40,4 +33,4 @@ def __init__(self, **kwargs):
4033
super(DeviceTestNotExistError, self).__init__(**kwargs)
4134
self.message = kwargs.get('message', None)
4235
self.code = kwargs.get('code', None)
43-
self.details = None
36+
self.details = kwargs.get('details', None)

0 commit comments

Comments
 (0)