コード例 #1
0
    def _build_api_extensions(self, group_version):
        response = yield self.http_client.get("/apis/%s" % group_version)
        for resource in json.loads(response.body).get("resources", []):
            if "/status" in resource["name"]:
                continue

            if resource["name"] in self.resources.keys():
                continue

            resource_name = resource["name"].split("/")[-1] if "/" in resource["name"] else resource["name"]
            if resource_name in self.RESOURCE_TO_KIND_MAPPING.keys():
                self.kind_to_resource[self.RESOURCE_TO_KIND_MAPPING[resource_name]] = resource_name

            if resource["namespaced"]:
                self.resources[resource["name"]] = NamespacedResource(
                    self, "/apis/%s" % group_version, resource["name"])
            else:
                self.resources[resource["name"]] = Resource(self, "/apis/%s" % group_version, resource["name"])
コード例 #2
0
    def _build_api_resources(self, api_version):
        response = yield self.http_client.get("/api/%s" % api_version)

        resources = json.loads(response.body).get("resources", [])
        for resource in resources:
            if "/" in resource["name"]:
                continue

            if resource["name"] in self.RESOURCE_TO_KIND_MAPPING.keys():
                self.kind_to_resource[self.RESOURCE_TO_KIND_MAPPING[resource["name"]]] = resource["name"]

            if resource["namespaced"]:
                # TODO: generate it from swagger api
                if resource["name"] == "pods":
                    self.resources[resource["name"]] = Pods(self, "/api/%s" % api_version, resource["name"])
                else:
                    self.resources[resource["name"]] = NamespacedResource(self,
                                                                          "/api/%s" % api_version,
                                                                          resource["name"])
            else:
                self.resources[resource["name"]] = Resource(self, "/api/%s" % api_version, resource["name"])