Esempio n. 1
0
    def update(self, uri, body):
        """
        Set the metadata to be applied to the view
        when this revision is applied

        Args:
        ```
            body (dict): The changes to make to this revision
        ```

        Returns:
        ```
            result (bool, dict | Revision): The updated Revision as a result of this API call, or an error
        ```

        Examples:
        ```python
            (ok, revision) = revision.update({
                'metadata': {
                    'name': 'new name',
                    'description': 'new description'
                }
            })
        ```
        """
        return self._mutate(put(
            self.path(uri),
            auth = self.auth,
            data = json.dumps(body),
        ))
Esempio n. 2
0
    def apply(self, uri, output_schema = None):
        """
        Apply the Revision to the view that it was opened on

        Args:
        ```
            output_schema (OutputSchema): Optional output schema. If your revision includes
                data changes, this should be included. If it is a metadata only revision,
                then you will not have an output schema, and you do not need to pass anything
                here
        ```

        Returns:
        ```
            result (bool, dict | Job): Returns the job that is being run to apply the revision
        ```

        Examples:
        ```
        (ok, job) = revision.apply(output_schema = my_output_schema)
        ```
        """

        if output_schema:
            if not output_schema.attributes['finished_at']:
                (ok, source) = result = output_schema.parent.parent.show()
                if not ok:
                    return result

                source_type = source.attributes['source_type']
                if source_type['type'] == 'view' and not source_type['loaded']:
                    pass
                else:
                    (ok, output_schema) = result = output_schema.wait_for_finish()
                    if not ok:
                        return result

        body = {}

        if output_schema:
            body.update({
                'output_schema_id': output_schema.attributes['id']
            })

        result = self._subresource(Job, put(
            self.path(uri),
            auth = self.auth,
            data = json.dumps(body)
        ))

        self.show() # To mutate ourself and get the job to show up in our attrs

        return result
Esempio n. 3
0
    def load(self, uri=None):
        """
        Forces the source to load, if it's a view source.

        Returns:
        ```
            Source: Returns the new Source
        ```
        """
        return self._mutate(
            put(self.path(uri or (self.links['show'] + "/load")),
                auth=self.auth,
                data={},
                headers={'content-type': 'application/json'}))
Esempio n. 4
0
    def load(self, uri=None):
        """
        Forces the source to load, if it's a view source.

        Returns:
        ```
            result (bool, Source | dict): Returns an API Result; the new Source or an error response
        ```
        """
        return self._mutate(
            put(self.path(uri or (self.links['show'] + "/load")),
                auth=self.auth,
                data={},
                headers={'content-type': 'application/json'}))