예제 #1
0
def acquire(config, device_id):
    r = requests.post(config.baseURL + '/device/' + device_id + '/acquire',
                      headers=config.headers)
    if r.status_code == 200:
        return http.handle_response(r.json())

    print("\nError: ", r.json()['error'])
예제 #2
0
파일: admin.py 프로젝트: xiorcale/rubus-cli
def list_user(config):
    r = requests.get(config.baseURL + '/admin/user', headers=config.headers)

    if r.status_code == 200:
        return http.handle_response(r.json())

    print(r.json())

    print("\nError: ", r.json()['error'])
예제 #3
0
파일: admin.py 프로젝트: xiorcale/rubus-cli
def add_device(config):
    hostname = input('Enter the device\'s hostname: ')
    port = input('Enter the device\'s port: ')

    params = {'hostname': hostname, 'port': port}
    r = requests.post(config.baseURL + '/admin/device',
                      params=params,
                      headers=config.headers)

    if r.status_code == 201:
        return http.handle_response(r.json())

    print("\nError: ", r.json()['error'])
예제 #4
0
파일: admin.py 프로젝트: xiorcale/rubus-cli
def update_user_exp(config, user_id):
    exp = input('Enter a new expiration [YYYY-MM-DD]: ')
    params = {'expiration': exp}

    r = requests.post(config.baseURL + '/admin/user/' + user_id +
                      '/expiration',
                      params=params,
                      headers=config.headers)

    if r.status_code == 200:
        return http.handle_response(r.json())

    print("\nError: ", r.json()['error'])
예제 #5
0
파일: admin.py 프로젝트: xiorcale/rubus-cli
def create_user(config):
    user = {}
    user['username'] = input('Enter a username for the new user: '******'email'] = input('Enter an email for the new user: '******'password'] = getpass.getpass('Enter a password for the new user: '******'Do you want this user to be an administrator? [y/N] ')
    user[
        'role'] = 'administrator' if answer == 'y' or answer == 'Y' else 'user'
    answer = input(
        'Do you want to set an expiration date for the user? [Y/n] ')
    if answer not in ['n', 'N']:
        user['expiration'] = input('Enter an expiration date [YYYY-MM-DD]: ')

    r = requests.post(config.baseURL + '/admin/user',
                      headers=config.headers,
                      json=user)

    if r.status_code == 201:
        return http.handle_response(r.json())

    print("\nError: ", r.json()['error'])