Ejemplo n.º 1
0
    def define_url(self):
        if not self.parent:
            parent_url = evaluate(EvaluationType.ENV_VAR, self.spec["base_url"])
        else:
            parent_url = self.parent.url

        if "path" not in self.spec:
            return parent_url

        populated_node_path = str(evaluate(EvaluationType.ENV_VAR, self.spec["path"]))
        return "/".join(s.strip("/") for s in [parent_url, populated_node_path])
Ejemplo n.º 2
0
 def evaluate_request(self):
     self.url = evaluate(EvaluationType.CUSTOM_VAR, self.url, self)
     self.url = evaluate(EvaluationType.PYTHON_CODE, self.url)
     self.headers = evaluate(EvaluationType.CUSTOM_VAR, self.headers, self)
     self.headers = evaluate(EvaluationType.PYTHON_CODE, self.headers)
     self.params = evaluate(EvaluationType.CUSTOM_VAR, self.params, self)
     self.params = evaluate(EvaluationType.PYTHON_CODE, self.params)
     self.body = evaluate(EvaluationType.CUSTOM_VAR, self.body, self)
     self.body = evaluate(EvaluationType.PYTHON_CODE, self.body)
Ejemplo n.º 3
0
    def define_params(self):
        parent_params = self.parent.params if self.parent else {}

        if "params" not in self.spec:
            return parent_params

        return {
            **parent_params,
            **evaluate(EvaluationType.ENV_VAR, self.spec["params"]),
        }
Ejemplo n.º 4
0
    def define_headers(self):
        parent_headers = self.parent.headers if self.parent else {}

        if "headers" not in self.spec:
            return parent_headers

        return {
            **parent_headers,
            **evaluate(EvaluationType.ENV_VAR, self.spec["headers"]),
        }
Ejemplo n.º 5
0
    def define_namespace(self):
        parent_namespace = self.parent.namespace if self.parent else ""

        if "namespace" not in self.spec:
            return parent_namespace

        populated_node_namespace = evaluate(
            EvaluationType.ENV_VAR, self.spec["namespace"]
        )

        return "_".join(filter(None, [parent_namespace, populated_node_namespace]))
Ejemplo n.º 6
0
    def save_custom_vars(self):
        parent_vars = self.parent.custom_vars

        if "vars" not in self.spec:
            return parent_vars

        node_vars = {}

        for var_name, var_value in self.spec["vars"].items():
            node_vars[var_name] = evaluate(EvaluationType.ENV_VAR, var_value)

        self.parent.custom_vars = {**parent_vars, **node_vars}
Ejemplo n.º 7
0
    def save_custom_vars(self, dynamic_chain=False):
        parent_vars = self.parent.custom_vars
        key = self.custom_vars_key(dynamic_chain)

        if key not in self.spec:
            return parent_vars

        node_vars = {}

        for var_name, var_value in self.spec[key].items():
            node_vars[var_name] = evaluate(EvaluationType.ENV_VAR, var_value)

        self.parent.custom_vars = {**parent_vars, **node_vars}
Ejemplo n.º 8
0
    def define_body(self):
        if "body" not in self.spec:
            return {}

        return evaluate(EvaluationType.ENV_VAR, self.spec["body"])