Best Python code snippet using tempest_python
qos_client.py
Source:qos_client.py
...20 Client class to send CRUD QoS API requests21 """22 def is_resource_deleted(self, qos_id):23 try:24 self.show_qos(qos_id)25 except lib_exc.NotFound:26 return True27 return False28 @property29 def resource_type(self):30 """Returns the primary type of resource this client works with."""31 return 'qos'32 def create_qos(self, **kwargs):33 """Create a QoS Specification.34 For a full list of available parameters, please refer to the official35 API reference:36 https://docs.openstack.org/api-ref/block-storage/v3/index.html#create-a-qos-specification37 """38 post_body = json.dumps({'qos_specs': kwargs})39 resp, body = self.post('qos-specs', post_body)40 body = json.loads(body)41 self.validate_response(schema.show_qos, resp, body)42 return rest_client.ResponseBody(resp, body)43 def delete_qos(self, qos_id, force=False):44 """Delete the specified QoS specification."""45 resp, body = self.delete(46 "qos-specs/%s?force=%s" % (qos_id, force))47 self.validate_response(schema.delete_qos, resp, body)48 return rest_client.ResponseBody(resp, body)49 def list_qos(self):50 """List all the QoS specifications created."""51 url = 'qos-specs'52 resp, body = self.get(url)53 body = json.loads(body)54 self.validate_response(schema.list_qos, resp, body)55 return rest_client.ResponseBody(resp, body)56 def show_qos(self, qos_id):57 """Get the specified QoS specification."""58 url = "qos-specs/%s" % qos_id59 resp, body = self.get(url)60 body = json.loads(body)61 self.validate_response(schema.show_qos, resp, body)62 return rest_client.ResponseBody(resp, body)63 def set_qos_key(self, qos_id, **kwargs):64 """Set the specified keys/values of QoS specification.65 For a full list of available parameters, please refer to the official66 API reference:67 https://docs.openstack.org/api-ref/block-storage/v3/index.html#set-keys-in-a-qos-specification68 """69 put_body = json.dumps({"qos_specs": kwargs})70 resp, body = self.put('qos-specs/%s' % qos_id, put_body)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!