Esempio n. 1
0
 def __get_entities(self, etype):
     """Helper to get entities for a given type."""
     r = fapi.get_entities(self.namespace, self.name,
                           etype, self.api_url)
     fapi._check_response_code(r, 200)
     return [Entity(e['entityType'], e['name'], e['attributes'])
             for e in r.json()]
Esempio n. 2
0
 def entities(self):
     """List all entities in workspace."""
     r = fapi.get_entities_with_type(self.namespace,
                                     self.name, self.api_url)
     fapi._check_response_code(r, 200)
     edicts = r.json()
     return [Entity(e['entityType'], e['name'], e['attributes'])
             for e in edicts]
Esempio n. 3
0
    def import_entities(self, entities):
        """Upload entity objects.

        Args:
            entities: iterable of firecloud.Entity objects.
        """
        edata = Entity.create_payload(entities)
        r = fapi.upload_entities(self.namespace, self.name,
                                 edata, self.api_url)
        fapi._check_response_code(r, 201)
Esempio n. 4
0
    def get_entity(self, etype, entity_id):
        """Return entity in this workspace.

        Args:
            etype (str): Entity type
            entity_id (str): Entity name/unique id
        """
        r = fapi.get_entity(self.namespace, self.name, etype,
                               entity_id, self.api_url)
        fapi._check_response_code(r, 200)
        dresp = r.json()
        return Entity(etype, entity_id, dresp['attributes'])