コード例 #1
0
def delete_domain(domain_id):
    """Deletes a domain using the given domain ID.

    If the domain with this ID has been already deleted,
    response code 404 is returned.
    """
    response = api("config/domain_management/domains/" + str(domain_id), "DELETE")
    pp_response(response)
コード例 #2
0
def get_default_domain():
    """Retrieves the default domain from the list of all domains.

    The default domain always exists.
    Any other domain is retrieved the same way.
    """
    response = api('config/domain_management/domains/0', 'GET')
    pp_response(response)
コード例 #3
0
def delete_domain(domain_id):
    """Deletes a domain using the given domain ID.

    If the domain with this ID has been already deleted,
    response code 404 is returned.
    """
    response = api('config/domain_management/domains/' + str(domain_id),
                   'DELETE')
    pp_response(response)
コード例 #4
0
def get_non_existing_domain():
    """Tries to retrieve a domain that does not exist... and fails with code 404.
    """
    response = api('config/domain_management/domains/-1', 'GET')
    if response.code == 404:
        pp_response(response)
    else:
        print('ERROR: Response code 404 was expected', file=sys.stderr)
        sys.exit(1)
コード例 #5
0
def update_domain(domain):
    """Returns an updated domain.

    It is only the description of the domain which is changed from empty to
    'New Description'.
    """
    domain['description'] = 'New Description'
    response = api('config/domain_management/domains/' + str(domain['id']),
                   'POST', data=to_json(domain), json=True)
    if response.code == 200:
        updated_domain = from_json(response)
        if updated_domain['description'] == 'New Description':
            print('INFO: Domain successfully updated', file=sys.stderr)
            return domain

    print('ERROR: Domain update failed', file=sys.stderr)
    pp_response(response)
コード例 #6
0
def update_domain(domain):
    """Returns an updated domain.

    It is only the description of the domain which is changed from empty to
    'New Description'.
    """
    domain['description'] = 'New Description'
    response = api('config/domain_management/domains/' + str(domain['id']),
                   'POST',
                   data=to_json(domain),
                   json=True)
    if response.code == 200:
        updated_domain = from_json(response)
        if updated_domain['description'] == 'New Description':
            print('INFO: Domain successfully updated', file=sys.stderr)
            return domain

    print('ERROR: Domain update failed', file=sys.stderr)
    pp_response(response)