Registers a device model and instance.

    Device model fields can only contain letters, numbers, and the following
    symbols: period (.), hyphen (-), underscore (_), space ( ) and plus (+).
    The first character of a field must be a letter or number.

    Device instance fields must start with a letter or number. The device ID
    can only contain letters, numbers, and the following symbols: period (.),
    hyphen (-), underscore (_), and plus (+). The device nickname can only
    contain numbers, letters, and the space ( ) symbol.

def register(ctx, model, type, trait, manufacturer, product_name, description,
             device, nickname, client_type):
    """Registers a device model and instance.

    Device model fields can only contain letters, numbers, and the following
    symbols: period (.), hyphen (-), underscore (_), space ( ) and plus (+).
    The first character of a field must be a letter or number.

    Device instance fields must start with a letter or number. The device ID
    can only contain letters, numbers, and the following symbols: period (.),
    hyphen (-), underscore (_), and plus (+). The device nickname can only
    contain numbers, letters, and the space ( ) symbol.
    """
    # cache SESSION and PROJECT_ID
    # so that we don't re-create them between commands
    ctx.obj['SESSION'] = google.auth.transport.requests.AuthorizedSession(
        ctx.obj['CREDENTIALS']
    )
    ctx.invoke(register_model,
               model=model, type=type, trait=trait,
               manufacturer=manufacturer,
               product_name=product_name,
               description=description)
    ctx.invoke(register_device, device=device, model=model,
               nickname=nickname, client_type=client_type)