Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for path args appearing in JSON args as well #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wrouesnel
Copy link

Some Unifi requests (such as rest/firewallgroup) use the _id field as both a path parameter and part of the JSON arguments when being being updated by PUT requests.

This change adds the path_arg_in_request_body keyword parameter to UnifiAPICall which indicates the path_parameter should be replicated into the JSON request dict as well.

Example Usage

I've successfully used this modification to support updating firewall groups on software based unifi controller.

list_firewallgroups = UnifiAPICall(
    """List the detail of firewall groups

    Returns:
        List of dictionaries with firewall groups
    """,
    "rest/firewallgroup",
)

create_firewallgroup = UnifiAPICall(
    """Create a firewall group

    Returns:
        List of dictionaries with firewall groups
    """,
    "rest/firewallgroup",
    json_args=[
        "group_type",
        "name",
        "group_members",
    ],
    method="POST",
)

set_firewallgroup = UnifiAPICall(
    """Update an existing firewall group

    Returns:
        List of dictionaries with firewall groups
    """,
    "rest/firewallgroup",
    path_arg_name="_id",
    path_arg_optional=False,
    path_arg_in_request_body=True,
    json_args=[
        "site_id",
        "group_type",
        "name",
        "group_members",
    ],
    method="PUT",
)

Some Unifi requests (such as `rest/firewallgroup`) use the _id field
as both a path parameter and part of the JSON arguments when being
being updated by PUT requests.

This change adds the `path_arg_in_request_body` keyword parameter to
UnifiAPICall which indicates the path_parameter should be replicated
into the JSON request dict as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant