Exemple #1
0
    def __deserialize(cls, body: Dict[str, str], *,
                      validate: bool) -> "Workflow":
        """Deserialize given object into a Workflow instance."""
        wf: models.V1alpha1Workflow
        if validate:
            attr = type("AttributeDict", (), body)

            wf = client.ApiClient().deserialize(attr, models.V1alpha1Workflow)

            instance = cls(
                api_version=wf.api_version,
                kind=wf.kind,
                metadata=wf.metadata,
                spec=wf.spec,
                status=wf.status,  # a small hack to overcome validation
            )
        else:
            _LOGGER.warning(
                "Validation is turned off. This may result in missing or invalid attributes."
            )
            obj = json.loads(body["data"])
            aux = to_snake_case(obj)

            instance = cls(
                api_version=aux.get("api_version"),
                kind=aux.get("kind"),
                metadata=aux.get("metadata"),
                spec=aux.get("spec"),
                status=aux.get("status"),
            )

        instance.__validated = validate
        return instance
Exemple #2
0
    def __deserialize(cls, body: Dict[str, str], *,
                      validate: bool) -> "Workflow":
        """Deserialize given object into a Workflow instance."""
        wf: Union[V1alpha1Workflow, Dict[str, Any]]
        if validate:
            attr = type("Response", (), body)

            wf = client.ApiClient().deserialize(attr, cls.__model__)
        else:
            _LOGGER.warning(
                "Validation is turned off. This may result in missing or invalid attributes."
            )
            wf = json.loads(body["data"])

        self = cls(compile=False)

        if isinstance(wf, V1alpha1Workflow):
            self.__dict__.update(
                api_version=wf.api_version,
                kind=wf.kind,
                metadata=wf.metadata,
                spec=wf.spec,
                status=wf.status,  # a small hack to overcome validation
            )
        else:
            self.__dict__.update(**wf)

        self.__validated = validate

        return self
Exemple #3
0
    def __init__(
        self,
        openshift: Optional[OpenShift] = None,
        openshift_config: Optional[Mapping[str, str]] = None,
    ):
        """Initialize WorkflowManager instance."""
        ocp_config = openshift_config or {}

        self.openshift = openshift or OpenShift(**ocp_config)
        self.api = client.V1alpha1Api(client.ApiClient(self.openshift.configuration))
def _deserialize_wrapper(dict_content, response_type):
    body = {"data": json.dumps(dict_content)}
    attr = type("Response", (), body)
    client.ApiClient().deserialize(attr, response_type)
Exemple #5
0
    def __init__(self, return_type=None):
        """Initialize Argo Watch."""
        super().__init__(return_type=return_type)

        self._api_client = client.ApiClient()