Example #1
0
    def get_custom_publish_text(self):
        resp = requests.get(
            '{0}/info/settings/:DatasetPublishPopupCustomText'.format(
                self.native_base_url),
            params={'key': self.token})
        if resp.status_code != 200:
            raise exceptions.OperationFailedError(
                'Custom publish text could not be found.')

        return json.loads(resp.content)['data']['message']
Example #2
0
    def delete_dataverse(self, dataverse):

        resp = requests.delete(
            '{0}/dataverses/{1}'.format(self.native_base_url, dataverse.alias),
            params={'key': self.token},
        )

        if resp.status_code == 401:
            raise exceptions.UnauthorizedError(
                'Delete Dataverse {0} unauthorized.'.format(dataverse.alias))
        elif resp.status_code == 404:
            raise exceptions.DataverseNotFoundError(
                'Dataverse {0} was not found.'.format(dataverse.alias))
        elif resp.status_code != 200:
            raise exceptions.OperationFailedError(
                'Dataverse {0} could not be deleted.'.format(dataverse.alias))

        self.get_service_document(refresh=True)
    def create_dataverse(self, alias, name, email, parent=':root'):
        resp = requests.post(
            '{0}/dataverses/{1}'.format(self.native_base_url, parent),
            json={
                'alias': alias,
                'name': name,
                'dataverseContacts': [{'contactEmail': email}],
            },
            params={'key': self.token},
        )

        if resp.status_code == 404:
            raise exceptions.DataverseNotFoundError(
                'Dataverse {0} was not found.'.format(parent)
            )
        elif resp.status_code != 201:
            raise exceptions.OperationFailedError(
                '{0} Dataverse could not be created.'.format(name)
            )

        self.get_service_document(refresh=True)
        return self.get_dataverse(alias)