def api_request(self, method, path, headers={}, data=None): headers = dict((k.lower(), v) for k, v in six.iteritems(headers)) headers['accept'] = 'application/json' if data is not None: headers['content-type'] = 'application/json' data = json.dumps(data) response = self.request(method, path, headers, data) return response.json()
def api_request(self, method, path, headers={}, data=None): headers = dict((k.lower(), v) for k, v in headers.iteritems()) headers['accept'] = 'application/json' if data is not None: headers['content-type'] = 'application/json' data = json.dumps(data) response = self.request(method, path, headers, data) return json.loads(response)
def api_request(self, method, path, headers={}, data=None, params=None): headers = dict((k.lower(), v) for k, v in six.iteritems(headers)) headers['accept'] = 'application/json' if data is not None: headers['content-type'] = 'application/json' data = json.dumps(data) response = self.request(method, path, headers, data, params=params) return response.json()
def __get_log_entry_from_json(event): log_entry = {'timestamp': event["eventTime"]} try: log_entry['username'] = event["userIdentity"]["userName"] except: log_entry['username'] = "" try: log_entry['access_key'] = event["userIdentity"]["accessKeyId"] except: log_entry['access_key'] = "" log_entry['event_name'] = event["eventName"] log_entry['event_source'] = event["eventSource"] log_entry['source_ip'] = event["sourceIPAddress"] log_entry['user_agent'] = event["userAgent"] log_entry['region'] = event["awsRegion"] log_entry['request_parameters'] = json.dumps(event["requestParameters"]) log_entry['response'] = json.dumps(event["responseElements"]) return log_entry
def api_request(self, method, path, headers={}, data=None): headers = dict((k.lower(), v) for k, v in six.iteritems(headers)) headers['accept'] = 'application/json' if data is not None: headers['content-type'] = 'application/json' data = json.dumps(data) response = self.request(method, path, headers, data) if response.status_code == 404: raise ChefServerNotFoundError(response.json()['error']) if response.status_code == 405: raise ChefServerNotAllowedError('%s %s not allowed' % (method, path)) return response.json()
def _wrap(self, data): return '{"json_wrapper":%s}' % \ (json.dumps(data).replace(", ", ",").replace(": ", ":"),)
def encrypt(self): if self.encrypted_data is None: data = json.dumps({"json_wrapper": self.data}) self.encrypted_data = self.encryptor.encrypt(data) return self.encrypted_data