def new_project(self, project_file=None, project_url=None, project_name=None, project_format='text/line-based/*sv', project_file_name=None, **opts): if (project_file and project_url) or (not project_file and not project_url): raise ValueError( 'Either a project_file or project_url must be set. Both cannot be used.' ) params = { 'project_name': self.set_project_name(project_name, project_file) } data = { 'format': project_format, 'options': self.set_options(project_format, **opts) } files = {'project-file': (project_file_name, open(project_file, 'rb'))} response = self.server.urlopen('create-project-from-upload', params=params, data=data, files=files) response.raise_for_status() project_id = self.get_project_id(response.url) files['project-file'][1].close() return RefineProject(self.server, project_id)
def request(self, path, method='GET', data=None, headers=None): logging.debug('request path: %s', path) try: response = self._raw_request(path, method, data, headers) response.raise_for_status() except requests.exceptions.HTTPError: if response.status_code == 401: self.get_refresh_token() response = self.request(path, method, data, headers) else: raise requests.exceptions.HTTPError return self.__adapt_response_content(response)
def delete_workspaces(accountId, encodedbase64, workspaceId): print('Deleting workspace = {}'.format(workspaceId)) # api-endpoint URL = "https://accounts.cloud.databricks.com/api/2.0/accounts/" + accountId + "/workspaces/" + workspaceId response = requests.delete( URL, headers={"Authorization": "Basic %s" % encodedbase64}) # Raise an Exception if the response is unsuccessful response.raise_for_status() print(response) return response
def delete_customer_managed_key(accountId, encodedbase64, managed_services_customer_managed_key_id): print('Deleting customer_managed_key_id - {}'.format( managed_services_customer_managed_key_id)) # api-endpoint URL = "https://accounts.cloud.databricks.com/api/2.0/accounts/" + accountId + "/customer-managed-keys/" + managed_services_customer_managed_key_id response = requests.delete( URL, headers={"Authorization": "Basic %s" % encodedbase64}) # Raise an Exception if the response is unsuccessful response.raise_for_status() print(response) return response
def delete_storage_configurations(accountId, encodedbase64, storage_configuration_id): print('Deleting Storage Configuration id - {}'.format( storage_configuration_id)) # api-endpoint URL = "https://accounts.cloud.databricks.com/api/2.0/accounts/" + accountId + "/storage-configurations/" + storage_configuration_id response = requests.delete( URL, headers={"Authorization": "Basic %s" % encodedbase64}) # Raise an Exception if the response is unsuccessful response.raise_for_status() print(response) return response