diff --git a/main.py b/main.py index a701b56..5e04a16 100644 --- a/main.py +++ b/main.py @@ -17,12 +17,11 @@ class Access(object): """ def __init__(self, platform): if platform == 'vm': - self.input_container = 'vm_box' self.user_table = VmAccount if platform == 'dci': - self.input_container = 'input' self.user_table = AuthUser self.platform = platform + self.input_container = 'input' def get_admin(self): """ @@ -57,8 +56,8 @@ class Access(object): def get_key(self, admin): """ - Makes a post request to the endpoint - passing the admin data and + Makes a post request to the endpoint + passing the admin data and returns the generated access key Args: @@ -67,33 +66,13 @@ class Access(object): Returns: _dict_: _access key_ """ - host = self.input_container - url = 'http://{}:1500/auth/v4/user/{}/key'.format(host, admin['id']) + url = 'http://{}:1500/api/auth/v4/user/{}/key'.format( + self.input_container, admin['id'] + ) headers = {"Internal-Auth": "on", "Accept": "application/json"} req = requests.post(url, headers=headers, data={}) - result = req.json() - return result - - def make_access_link(self, key): - """ - Generates a clickable link which will be received in stdout - - Args: - key (_dict_): _access key data_ - - Returns: - _str_: link to access the platform - """ - key_type = 'key' # why for dcimgr key-4 ??? - - access_link = 'https://{}/auth/{}/{}'.format( - CLIENT_HOST, key_type, key['key'] - ) - if self.platform == 'dci': - access_link = 'https://{}/auth/{}/{}'.format( - CLIENT_HOST, key_type, key['key'] - ) - return access_link + key = req.json() + return key def main(): @@ -115,7 +94,7 @@ def main(): print("Key will be used:") print(key, "\n") - access_link = access.make_access_link(key) + access_link = 'https://{}/auth/key-v4/{}'.format(CLIENT_HOST, key['key']) print("Your access link: \n") print(access_link, "\n")