Skip to content

Commit

Permalink
Remove product init and add validation-type to test create (#5)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
montgomp authored Aug 5, 2020
1 parent 8f83d90 commit 4b36169
Show file tree
Hide file tree
Showing 39 changed files with 219 additions and 415 deletions.
13 changes: 0 additions & 13 deletions azext_iot/product/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,3 @@ def load_help():
text: >
az iot product requirement list
"""
helps[
"iot product init"
] = """
type: command
short-summary: Used to initialize local workspace for a new product certification
examples:
- name: Use default working folder ('PnPCert')
text: >
az iot product init --product-name {product_name}
- name: Specify working folder
text: >
az iot product init --product-name {product_name} --working-folder {working_folder}
"""
3 changes: 0 additions & 3 deletions azext_iot/product/command_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@


def load_product_commands(self, _):
with self.command_group("iot product", command_type=product_ops) as g:
g.command("init", "initialize_workspace")

with self.command_group(
"iot product requirement", command_type=requirements_ops
) as g:
Expand Down
102 changes: 0 additions & 102 deletions azext_iot/product/command_product.py

This file was deleted.

12 changes: 0 additions & 12 deletions azext_iot/product/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@

def load_product_params(self, _):
with self.argument_context("iot product") as c:
c.argument(
"working_folder",
options_list=["--working-folder", "--wf"],
help="The folder to create in current path",
arg_group="IoT Device Certification",
)
c.argument(
"product_name",
options_list=["--product-name"],
help="Product name to display in catalog",
arg_group="IoT Device Certification",
)
c.argument(
"test_id",
options_list=["--test-id", "-t"],
Expand Down
5 changes: 5 additions & 0 deletions azext_iot/product/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ class DeviceTestTaskStatus(Enum):
cancelled = "Cancelled"


class ValidationType(Enum):
test = "Test"
certification = "Certification"


BASE_URL = "https://certify.azureiotsolutions.com"
15 changes: 15 additions & 0 deletions azext_iot/product/test/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ def load_help():
- name: Do not have service create provisioning configuration
text: >
az iot product test create --configuration-file {configuration_file} --skip-provisioning
- name: Creating test with symmetric key attestation
text: >
az iot product test create --attestation-type SymmetricKey --device-type {device_type}
- name: Creating test with TPM attestation
text: >
az iot product test create --attestation-type TPM --device-type {device_type} --endorsement-key {endorsement_key}
- name: Creating test with x509 attestation
text: >
az iot product test create --attestation-type x509 --device-type {device_type} --certificate-path {certificate_path}
- name: Creating test for Edge module
text: >
az iot product test create --attestation-type ConnectionString --device-type {device_type} --badge-type IotEdgeCompatible --connection-string {connection_string}
- name: Creating test with symmetric key attestation and specified validation type
text: >
az iot product test create --attestation-type SymmetricKey --device-type {device_type} --validation-type Certification --product-id {product_id}
"""
helps[
"iot product test search"
Expand Down
13 changes: 10 additions & 3 deletions azext_iot/product/test/command_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from azext_iot.product.providers.aics import AICSProvider
from azext_iot.sdk.product.models import DeviceTestSearchOptions
from azext_iot.product.shared import BadgeType, AttestationType
from azext_iot.product.shared import BadgeType, AttestationType, ValidationType
from knack.log import get_logger
from knack.util import CLIError
import os
Expand All @@ -24,6 +24,7 @@ def create(
connection_string=None,
endorsement_key=None,
badge_type=BadgeType.IotDevice.value,
validation_type=ValidationType.test.value,
models=None,
skip_provisioning=False,
base_url=None,
Expand All @@ -46,10 +47,14 @@ def create(
raise CLIError(
"Connection string is only available for Edge Compatible modules testing"
)
if validation_type != ValidationType.test.value and not product_id:
raise CLIError(
"Product Id is required for validation type {}".format(validation_type)
)
if not any(
[
configuration_file,
all([device_type, product_id, attestation_type, badge_type]),
all([device_type, attestation_type, badge_type]),
]
):
raise CLIError(
Expand All @@ -67,6 +72,7 @@ def create(
badge_type=badge_type,
connection_string=connection_string,
models=models,
validation_type=validation_type
)
)

Expand Down Expand Up @@ -210,9 +216,10 @@ def _build_test_configuration(
connection_string,
badge_type,
models,
validation_type
):
config = {
"validationType": "Certification",
"validationType": validation_type,
"productId": product_id,
"deviceType": device_type,
"provisioningConfiguration": {"type": attestation_type},
Expand Down
11 changes: 9 additions & 2 deletions azext_iot/product/test/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

from azure.cli.core.commands.parameters import get_three_state_flag, get_enum_type
from azext_iot.product.shared import AttestationType, DeviceType, TaskType
from azext_iot.product.shared import AttestationType, DeviceType, TaskType, ValidationType


def load_product_test_params(self, _):
Expand Down Expand Up @@ -73,8 +73,15 @@ def load_product_test_params(self, _):
c.argument(
"product_id",
options_list=["--product-id", "-p"],
help="The submitted product id",
help="The submitted product id. Required when validation-type is 'Certification'.",
arg_group="IoT Device Certification Device Definition",
)
c.argument(
"validation_type",
options_list=["--validation-type", "--vt"],
help="The type of validations testing to be performed",
arg_group="IoT Device Certification Device Definition",
arg_type=get_enum_type(ValidationType)
)
with self.argument_context("iot product test search") as c:
c.argument(
Expand Down
3 changes: 3 additions & 0 deletions azext_iot/sdk/product/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .provisioning_configuration_py3 import ProvisioningConfiguration
from .iot_device_certification_badge_configuration_py3 import IotDeviceCertificationBadgeConfiguration
from .iot_edge_compatible_certification_badge_configuration_py3 import IotEdgeCompatibleCertificationBadgeConfiguration
from .model_resolution_source_py3 import ModelResolutionSource
from .pnp_certification_badge_configuration_py3 import PnpCertificationBadgeConfiguration
from .device_test_py3 import DeviceTest
from .device_test_search_options_py3 import DeviceTestSearchOptions
Expand Down Expand Up @@ -79,6 +80,7 @@
from .provisioning_configuration import ProvisioningConfiguration
from .iot_device_certification_badge_configuration import IotDeviceCertificationBadgeConfiguration
from .iot_edge_compatible_certification_badge_configuration import IotEdgeCompatibleCertificationBadgeConfiguration
from .model_resolution_source import ModelResolutionSource
from .pnp_certification_badge_configuration import PnpCertificationBadgeConfiguration
from .device_test import DeviceTest
from .device_test_search_options import DeviceTestSearchOptions
Expand Down Expand Up @@ -137,6 +139,7 @@
'ProvisioningConfiguration',
'IotDeviceCertificationBadgeConfiguration',
'IotEdgeCompatibleCertificationBadgeConfiguration',
'ModelResolutionSource',
'PnpCertificationBadgeConfiguration',
'DeviceTest',
'DeviceTestSearchOptions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,14 @@
class CannotRetrieveModelReposistorySasTokenError(Model):
"""CannotRetrieveModelReposistorySasTokenError.
Variables are only populated by the server, and will be ignored when
sending a request.
:param message:
:type message: str
:param code:
:type code: int
:ivar details:
:vartype details: list[object]
:param details:
:type details: list[object]
"""

_validation = {
'details': {'readonly': True},
}

_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'code': {'key': 'code', 'type': 'int'},
Expand All @@ -40,4 +33,4 @@ def __init__(self, **kwargs):
super(CannotRetrieveModelReposistorySasTokenError, self).__init__(**kwargs)
self.message = kwargs.get('message', None)
self.code = kwargs.get('code', None)
self.details = None
self.details = kwargs.get('details', None)
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,22 @@
class CannotRetrieveModelReposistorySasTokenError(Model):
"""CannotRetrieveModelReposistorySasTokenError.
Variables are only populated by the server, and will be ignored when
sending a request.
:param message:
:type message: str
:param code:
:type code: int
:ivar details:
:vartype details: list[object]
:param details:
:type details: list[object]
"""

_validation = {
'details': {'readonly': True},
}

_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'code': {'key': 'code', 'type': 'int'},
'details': {'key': 'details', 'type': '[object]'},
}

def __init__(self, *, message: str=None, code: int=None, **kwargs) -> None:
def __init__(self, *, message: str=None, code: int=None, details=None, **kwargs) -> None:
super(CannotRetrieveModelReposistorySasTokenError, self).__init__(**kwargs)
self.message = message
self.code = code
self.details = None
self.details = details
2 changes: 1 addition & 1 deletion azext_iot/sdk/product/models/device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DeviceTest(Model):
:param validation_type:
Microsoft.Azure.IoT.TestKit.Shared.Models.ValidationType of a
Microsoft.Azure.IoT.TestKit.Models.DeviceTest. Possible values include:
'Certification'
'Certification', 'Test'
:type validation_type: str or ~product.models.enum
:param product_id: Product Id of the testing device in product service. In
CLI scenario, this can be null.
Expand Down
13 changes: 3 additions & 10 deletions azext_iot/sdk/product/models/device_test_not_exist_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,14 @@
class DeviceTestNotExistError(Model):
"""DeviceTestNotExistError.
Variables are only populated by the server, and will be ignored when
sending a request.
:param message:
:type message: str
:param code:
:type code: int
:ivar details:
:vartype details: list[object]
:param details:
:type details: list[object]
"""

_validation = {
'details': {'readonly': True},
}

_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'code': {'key': 'code', 'type': 'int'},
Expand All @@ -40,4 +33,4 @@ def __init__(self, **kwargs):
super(DeviceTestNotExistError, self).__init__(**kwargs)
self.message = kwargs.get('message', None)
self.code = kwargs.get('code', None)
self.details = None
self.details = kwargs.get('details', None)
Loading

0 comments on commit 4b36169

Please sign in to comment.