Update attribute(s) of a specific endpoint.

    id
        The unique ID of the enpoint entry.

    endpoint: incidents
        Endpoint name.

    page_id
        Page ID. Can also be specified in the config file.

    api_key
        API key. Can also be specified in the config file.

    api_version: 1
        API version. Can also be specified in the config file.

    api_url
        Custom API URL in case the user has a StatusPage service running in a custom environment.

    CLI Example:

    .. code-block:: bash

        salt 'minion' statuspage.update id=dz959yz2nd4l status=resolved

    Example output:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                ----------
                created_at:
                    2017-01-03T15:25:30.718Z
                description:
                    None
                group_id:
                    993vgplshj12
                id:
                    dz959yz2nd4l
                name:
                    Management Portal
                page_id:
                    xzwjjdw87vpf
                position:
                    11
                status:
                    resolved
                updated_at:
                    2017-01-05T15:34:27.676Z
            result:
                True

def update(endpoint='incidents',
           id=None,
           api_url=None,
           page_id=None,
           api_key=None,
           api_version=None,
           **kwargs):
    '''
    Update attribute(s) of a specific endpoint.

    id
        The unique ID of the enpoint entry.

    endpoint: incidents
        Endpoint name.

    page_id
        Page ID. Can also be specified in the config file.

    api_key
        API key. Can also be specified in the config file.

    api_version: 1
        API version. Can also be specified in the config file.

    api_url
        Custom API URL in case the user has a StatusPage service running in a custom environment.

    CLI Example:

    .. code-block:: bash

        salt 'minion' statuspage.update id=dz959yz2nd4l status=resolved

    Example output:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                ----------
                created_at:
                    2017-01-03T15:25:30.718Z
                description:
                    None
                group_id:
                    993vgplshj12
                id:
                    dz959yz2nd4l
                name:
                    Management Portal
                page_id:
                    xzwjjdw87vpf
                position:
                    11
                status:
                    resolved
                updated_at:
                    2017-01-05T15:34:27.676Z
            result:
                True
    '''
    endpoint_sg = endpoint[:-1]  # singular
    if not id:
        log.error('Invalid %s ID', endpoint_sg)
        return {
            'result': False,
            'comment': 'Please specify a valid {endpoint} ID'.format(endpoint=endpoint_sg)
        }
    params = _get_api_params(api_url=api_url,
                             page_id=page_id,
                             api_key=api_key,
                             api_version=api_version)
    if not _validate_api_params(params):
        log.error('Invalid API params.')
        log.error(params)
        return {
            'result': False,
            'comment': 'Invalid API params. See log for details'
        }
    headers = _get_headers(params)
    update_url = '{base_url}/v{version}/pages/{page_id}/{endpoint}/{id}.json'.format(
        base_url=params['api_url'],
        version=params['api_version'],
        page_id=params['api_page_id'],
        endpoint=endpoint,
        id=id
    )
    change_request = {}
    for karg, warg in six.iteritems(kwargs):
        if warg is None or karg.startswith('__') or karg in UPDATE_FORBIDDEN_FILEDS:
            continue
        change_request_key = '{endpoint_sg}[{karg}]'.format(
            endpoint_sg=endpoint_sg,
            karg=karg
        )
        change_request[change_request_key] = warg
    return _http_request(update_url,
                         method='PATCH',
                         headers=headers,
                         data=change_request)