def list_silences(self, cloud_id): """List all silencers belong to a cloud. :param cloud_id: The id of cloud. """ url = utils.generate_url('/silences', cloud_id) return self.get(url, headers=self.headers).json()
def unregister_cloud(self, id): """Remove a cloud from Faythe :param id: The id of cloud. """ url = utils.generate_url('/clouds', id) return self.delete(url.format(id), headers=self.headers).json()
def delete_silence(self, cloud_id): """Delete a healer belong to a cloud. :param cloud_id: The id of cloud. """ url = utils.generate_url('/silences', cloud_id) return self.delete(url, headers=self.headers).json()
def delete_user(self, username): """Delete an existing user. :param username: The name of user. """ url = utils.generate_url('/users', username) return self.delete(url, headers=self.headers).json()
def delete_healers(self, cloud_id): """Delete a healer. :param cloud_id: The id of cloud. """ url = utils.generate_url('/healers', cloud_id) return self.delete(url.format(cloud_id), headers=self.headers).json()
def remove_policies(self, username, body): """Remove a set of policies. :param username: The name of user. :param body: A list of dictionary object. """ url = utils.generate_url('/policies', username) return self.delete(url, headers=self.headers, body=body).json()
def create_user(self, user): """Create new Faythe user. :param user: A dict of user information. for example: {'username': '******', 'password': '******'} """ url = utils.generate_url('/users') return self.post(url, headers=self.headers, data=user).json()
def create_silence(self, cloud_id, body): """Create a silencer to ignore healing action. :param cloud_id: The id of cloud. :param body: A dictionary object. """ url = utils.generate_url('/silences', cloud_id) return self.post(url, body=body, headers=self.headers).json()
def create_healer(self, cloud_id, body): """Create a new healer belongs to a cloud. :param cloud_id: The id of cloud. :param body: A dictionary object. """ url = utils.generate_url('/healers', cloud_id) return self.post(url, body=body, headers=self.headers).json()
def register_cloud(self, provider, body): """Register a new cloud to Faythe :param provider: The cloud provider type. 'OpenStack' is the only provider supported by now. :param body: A dictionary object. """ url = utils.generate_url('/clouds', provider) return self.post(url, body=body, headers=self.headers).json()
def update_cloud(self, id, body=None): """Update a cloud information :param id: The id of cloud. :param body: (optional) A dictionary object. If it is None, the cloud won't be updated. """ url = utils.generate_url('/clouds', id) return self.put(url, body=body, headers=self.headers).json()
def update_scaler(self, cloud_id, body=None): """Update a scaler information. :param cloud_id: The id of cloud. :param body: (optional) A dictionary object. If it is None, the scaler won't be updated. """ url = utils.generate_url('/scalers', cloud_id) return self.put(url, body=body, headers=self.headers).json()
def change_password(self, username, newpassword): """Change user's password. :param username: The name of user. :param newpassword: The new password. """ url = utils.generate_url('/users', username, 'change_password') return self.put(url, headers=self.headers, data={'newpassword': newpassword})
def list_scalers(self, cloud_id, **kwargs): """List all scalers belong to a cloud. :param cloud_id: The id of cloud. :param tags: (optional) A list of tags to filter the scaler list by. Scalers that match all tags in this list will be returned. :param tags_any: (optional) A list of tags to filter the scaler list by. Scalers that match any tags in this list will be returned. """ url = utils.generate_url('/scalers', cloud_id, **kwargs) return self.get(url, headers=self.headers).json()
def list_clouds(self, **kwargs): """List all clouds that are registerd to Faythe :param provider: (optional) Filter a cloud result by provider. The only supported provider is OpenStack so this one is useless right now. :param id: (optional) Filter cloud result by id. :param tags: (optional) A list of tags to filter the cloud list by. Clouds that match all tags in this list will be returned. :param tags_any: (optional) A list of tags to filter the cloud list by. Clouds that match any tags in this list will be returned. """ url = utils.generate_url('/clouds', **kwargs) return self.get(url, headers=self.headers).json()
def list_users(self): """List all Faythe users with policies.""" url = utils.generate_url('/users') return self.get(url, headers=self.headers).json()
def delete_scaler(self, cloud_id): """Delete a scaler.""" url = utils.generate_url('/scalers', cloud_id) return self.delete(url, headers=self.headers).json()