def get_resources(self,
                      odata_type,
                      any_child_version=None,
                      constraints=None):
        """
        :type odata_type: str
        :type any_child_version: bool
        :type constraints: list[constraint]
        :return: list[str, ApiResource]
        """
        if constraints is None:
            constraints = []

        if any_child_version:
            temp_df = DataFrame()
            for odata_type in self._get_proper_odata_type_versions(odata_type):
                if odata_type in self._dataframes.keys():
                    temp_df = concat([self._dataframes[odata_type], temp_df],
                                     axis=0,
                                     ignore_index=True)
        else:
            if odata_type not in self._dataframes:
                return []
            temp_df = self._dataframes[odata_type]

        for requirement in constraints:
            if not len(temp_df.index):
                break
            temp_df = requirement.apply(temp_df)

        return [(url, ApiResourceProxy(self[url], self))
                for url in [row.url for _, row in temp_df.iterrows()]]
 def root_resources(self):
     """
     :rtype: list[ApiResource]
     """
     resources = [ApiResourceProxy(r, self) for r in self.physical_location_aware_resources() if
                  not r.location.parent_id]
     return resources
 def iter_all(self, odata_type):
     """
     :type odata_type: str
     returns generator of resources of given @odata.type
     """
     t = self.get_resources(odata_type, any_child_version=True)
     resources = (ApiResourceProxy(r, self) for _, r in t)
     return resources
 def physical_location_aware_resources(self):
     """
     :rtype: list[ApiResource]
     """
     resources = [
         ApiResourceProxy(r, self) for _, r in self.iteritems()
         if r.location
     ]
     return resources
    def odataid_lookup(self, *odata_id):
        ids = [re.sub(r'#.*$', '', str(id)) for id in odata_id]
        resources = [ApiResourceProxy(r, self) for r in self.itervalues() if r.odata_id in ids]

        if len(resources) < len(odata_id):
            found_ids = set([r.odata_id for r in resources])
            requested_ids = set(ids)
            diff = requested_ids.difference(found_ids)
            if len(diff) > 0:
                cts_error('References to unknown resources: {refs}', refs=', '.join(diff))

        return resources
    def odata_type_lookup(self, odata_type):
        """
        Find all resources with similar odata_type
        :param odata_type:
        :return:
        """
        def get_elements_with_proper_odata_type(elements):
            return [
                element for element in elements
                if element.odata_type is not None
            ]

        resources = [
            ApiResourceProxy(r, self)
            for r in get_elements_with_proper_odata_type(self.itervalues())
            if odata_type in r.odata_type
        ]
        return set([r.odata_type for r in resources])
 def __getitem__(self, item):
     obj = super(DiscoveryContainer, self).__getitem__(item)
     return ApiResourceProxy(obj, self)