Ejemplo n.º 1
0
    def spec(self, logger: AirbyteLogger) -> ConnectorSpecification:
        """Tries to find and remove a spec data about local storage settings"""

        parent_code_dir = os.path.dirname(source_file.source.__file__)
        parent_spec_file = os.path.join(parent_code_dir, "spec.json")
        with open(parent_spec_file, "r") as f:
            spec = ConnectorSpecification.parse_obj(json.load(f))

        # correction of  the "storage" property to const type
        for provider in spec.connectionSpecification["properties"]["provider"][
                "oneOf"]:
            storage = provider["properties"]["storage"]

            if "enum" in storage:
                storage.pop("enum")
                storage["const"] = storage.pop("default")

        for i in range(
                len(spec.connectionSpecification["properties"]["provider"]
                    ["oneOf"])):
            provider = spec.connectionSpecification["properties"]["provider"][
                "oneOf"][i]
            if provider["properties"]["storage"][
                    "const"] == LOCAL_STORAGE_NAME:
                spec.connectionSpecification["properties"]["provider"][
                    "oneOf"].pop(i)
        return spec
Ejemplo n.º 2
0
    def spec(self, logger: logging.Logger) -> ConnectorSpecification:
        """
        Returns the spec for this integration. The spec is a JSON-Schema object describing the required configurations (e.g: username and password)
        required to run this integration. By default, this will be loaded from a "spec.yaml" or a "spec.json" in the package root.
        """

        package = self.__class__.__module__.split(".")[0]

        yaml_spec = load_optional_package_file(package, "spec.yaml")
        json_spec = load_optional_package_file(package, "spec.json")

        if yaml_spec and json_spec:
            raise RuntimeError(
                "Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided."
            )

        if yaml_spec:
            spec_obj = yaml.load(yaml_spec, Loader=yaml.SafeLoader)
        elif json_spec:
            spec_obj = json.loads(json_spec)
        else:
            raise FileNotFoundError(
                "Unable to find spec.yaml or spec.json in the package.")

        return ConnectorSpecification.parse_obj(spec_obj)
Ejemplo n.º 3
0
 def spec(self, logger: AirbyteLogger) -> ConnectorSpecification:
     """
     Returns the spec for this integration. The spec is a JSON-Schema object describing the required configurations (e.g: username and password)
     required to run this integration.
     """
     raw_spec = pkgutil.get_data(
         self.__class__.__module__.split(".")[0], "spec.json")
     return ConnectorSpecification.parse_obj(json.loads(raw_spec))
Ejemplo n.º 4
0
 def spec(self, logger: logging.Logger) -> ConnectorSpecification:
     """
     Returns the spec for this integration. The spec is a JSON-Schema object describing the required configurations (e.g: username and password)
     required to run this integration.
     """
     raw_spec: Optional[bytes] = pkgutil.get_data(
         self.__class__.__module__.split(".")[0], "spec.json")
     if not raw_spec:
         raise ValueError("Unable to find spec.json.")
     return ConnectorSpecification.parse_obj(json.loads(raw_spec))
Ejemplo n.º 5
0
def connector_spec_fixture(connector_spec_path) -> ConnectorSpecification:
    spec_obj = load_yaml_or_json_path(connector_spec_path)
    return ConnectorSpecification.parse_obj(spec_obj)