Exemple #1
0
def update(ctx, attributes, endpoint_a, id, name, site_id, endpoint_z,
           attr_action):
    """
    Update a Circuit.

    You must either have a Site ID configured in your .pysnotrc file or specify
    one using the -s/--site-id option.

    The -a/--attributes option may be provided multiple times, once for each
    key-value pair.

    When modifying attributes you have three actions to choose from:

    * Add (--add-attributes). This is the default behavior that will add
    attributes if they don't exist, or update them if they do.

    * Delete (--delete-attributes). This will cause attributes to be
    deleted. If combined with --multi the attribute will be deleted if
    either no value is provided, or if the attribute no longer contains a
    valid value.

    * Replace (--replace-attributes). This will cause attributes to
    replaced. If combined with --multi and multiple attributes of the same
    name are provided, only the last value provided will be used.
    """

    # If we get a name as an identifier, slugify it
    if ctx.params.get('id') and not ctx.params['id'].isdigit():
        ctx.params['id'] = slugify(ctx.params['id'])

    if not any([attributes, endpoint_a, name, endpoint_z]):
        msg = 'You must supply at least one of the optional arguments.'
        raise click.UsageError(msg)

    ctx.obj.update(ctx.params)
def remove(ctx, id, site_id):
    """
    Remove a Circuit.

    You must either have a Site ID configured in your .pysnotrc file or specify
    one using the -s/--site-id option.

    When removing Circuits, all objects are displayed by default. You
    optionally may look up a single Circuit by ID or Name using the -i/--id
    option.
    """

    # If we get a name as an identifier, slugify it
    if ctx.params.get('id') and not ctx.params['id'].isdigit():
        ctx.params['id'] = slugify(ctx.params['id'])

    ctx.obj.remove(**ctx.params)
def list(ctx, attributes, endpoint_a, endpoint_z, grep, id, limit, name,
         natural_key, offset, query, site_id):
    """
    List existing Circuits for a Site.

    You must either have a Site ID configured in your .pysnotrc file or specify
    one using the -s/--site-id option.

    When listing Circuits, all objects are displayed by default. You optionally
    may look up a single Circuit by ID or Name using the -i/--id option.

    You may limit the number of results using the -l/--limit option.
    """

    # If we get a name as an identifier, slugify it
    if ctx.params.get('id') and not ctx.params['id'].isdigit():
        ctx.params['id'] = slugify(ctx.params['id'])

    # Don't list interfaces if a subcommand is invoked
    if ctx.invoked_subcommand is None:
        ctx.obj.list(ctx.params, display_fields=DISPLAY_FIELDS)