Skip to content

Commit

Permalink
chg: dev: Refactor getting of value for key in response. !refactor
Browse files Browse the repository at this point in the history
Closes #126
  • Loading branch information
ashmastaflash committed Sep 6, 2018
1 parent 7cdd62b commit 0eb2ab2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
4 changes: 1 addition & 3 deletions cloudpassage/cve_exception.py
Expand Up @@ -53,9 +53,7 @@ def describe(self, exception_id):

endpoint = "/v1/cve_exceptions/%s" % exception_id
request = HttpHelper(self.session)
response = request.get(endpoint)
cve_exception = response["cve_exception"]
return cve_exception
return request.get(endpoint)["cve_exception"]

def create(self, package_name, package_version, scope="all", scope_id=''):
"""This method allows user to create CVE exceptions.
Expand Down
4 changes: 1 addition & 3 deletions cloudpassage/scan.py
Expand Up @@ -186,9 +186,7 @@ def scan_details(self, scan_id):

endpoint = "/v1/scans/%s" % scan_id
request = HttpHelper(self.session)
response = request.get(endpoint)
report = response["scan"]
return report
return request.get(endpoint)["scan"]

def scan_status_supported(self, scan_status):
"""Determine if scan status is supported for query"""
Expand Down
12 changes: 3 additions & 9 deletions cloudpassage/server.py
Expand Up @@ -114,9 +114,7 @@ def describe(self, server_id):

endpoint = "/v1/servers/%s" % server_id
request = HttpHelper(self.session)
response = request.get(endpoint)
server_details = response["server"]
return server_details
return request.get(endpoint)["server"]

def retire(self, server_id):
"""This method retires a server
Expand Down Expand Up @@ -218,9 +216,7 @@ def command_details(self, server_id, command_id):

endpoint = "/v1/servers/%s/commands/%s" % (server_id, command_id)
request = HttpHelper(self.session)
response = request.get(endpoint)
command_status = response["command"]
return command_status
return request.get(endpoint)["command"]

def list_local_accounts(self, server_id):
"""This method retrieves all local user accounts on the server\
Expand Down Expand Up @@ -252,9 +248,7 @@ def describe_local_account(self, server_id, username):
"""
endpoint = "/v1/servers/%s/accounts/%s" % (server_id, username)
request = HttpHelper(self.session)
response = request.get(endpoint)
account_detail = response["account"]
return account_detail
return request.get(endpoint)["account"]

def list_connections(self, server_id, **kwargs):
"""This method retrieves all recently detected connections on the server\
Expand Down
8 changes: 2 additions & 6 deletions cloudpassage/server_group.py
Expand Up @@ -52,9 +52,7 @@ def list_members(self, group_id):

endpoint = "/v1/groups/%s/servers" % group_id
request = HttpHelper(self.session)
response = request.get(endpoint)
servers = response["servers"]
return servers
return request.get(endpoint)["servers"]

def create(self, group_name, **kwargs):
"""Creates a ServerGroup.
Expand Down Expand Up @@ -104,9 +102,7 @@ def describe(self, group_id):

endpoint = "/v1/groups/%s" % group_id
request = HttpHelper(self.session)
response = request.get(endpoint)
group = response["group"]
return group
return request.get(endpoint)["group"]

def update(self, group_id, **kwargs):
"""Updates a ServerGroup.
Expand Down

0 comments on commit 0eb2ab2

Please sign in to comment.