def getKit(self, name, version, iteration=None): """ Get kit info. Returns: kit Throws: KitNotFound TortugaException """ dbVersion = '%s-%s' % (version, iteration) if not iteration: dbVersion = '%s' % (version) url = 'v1/kits/%s/%s' % (name, dbVersion) try: _, responseDict = self.sendSessionRequest(url) return Kit.getFromDict(responseDict.get('kit')) except TortugaException: raise except Exception as ex: raise TortugaException(exception=ex)
def getKit(self, name: str, version: Optional[str] = None, iteration: Optional[str] = None) -> Kit: """ Get kit info. Raises: KitNotFound """ url = 'kits/?name={}'.format(urllib.parse.quote_plus(name)) if version is not None: url += '&version={}'.format(urllib.parse.quote_plus(version)) if iteration is not None: url += '&iteration={}'.format(urllib.parse.quote_plus(iteration)) try: responseDict = self.get(url) # response is a list, so reference first item in list kits = responseDict.get('kits') if not kits: kit_spec_str = name if version: kit_spec_str += '-{}'.format(version) if iteration: kit_spec_str += '-{}'.format(iteration) raise KitNotFound( 'Kit matching specification [{}] not found'.format( kit_spec_str)) return Kit.getFromDict(kits[0]) except TortugaException: raise except Exception as ex: raise TortugaException(exception=ex)
def getKitById(self, id_: int) -> Kit: """ Get kit info by kitId. Raises: KitNotFound TortugaException """ url = 'kits/%s' % (id_) try: responseDict = self.get(url) return Kit.getFromDict(responseDict.get('kit')) except TortugaException: raise except Exception as ex: raise TortugaException(exception=ex)
def getKitById(self, id_): """ Get kit info by kitId. Returns: kit Throws: KitNotFound TortugaException """ url = 'v1/kits/%s' % (id_) try: _, responseDict = self.sendSessionRequest(url) return Kit.getFromDict(responseDict.get('kit')) except TortugaException: raise except Exception as ex: raise TortugaException(exception=ex)