def tag(self, repository: str, origin_tag: str, destination_tag: str): """ In V2 API there is no tagging. To tag we need to copy a manifest. :param repository: :param origin_tag: :param destination_tag: :return: """ auth = self._setup_auth(repository, scope='*') origin_manifest_req = http_get( url=self._get_url('/' + repository + '/manifests/' + origin_tag), auth=auth) response = origin_manifest_req.text with self.error_handling(response): origin_manifest = origin_manifest_req.json() if "errors" in origin_manifest and "MANIFEST_UNKNOWN" in response: raise RegistryException( 'Unknown tag "' + origin_tag + '" in "' + repository + '" repository', response) # correct the manifest manifest = {} manifest.update(origin_manifest) manifest.update({'name': repository, 'tag': destination_tag}) dest_result = http_put( url=self._get_url('/' + repository + '/manifests/' + destination_tag), auth=auth, data=sign_manifest(manifest), headers={ 'Content-Type': 'application/vnd.docker.distribution.manifest.v1+prettyjws' }) if "MANIFEST_INVALID" in dest_result.text: raise RegistryException('Tag manifest is invalid', dest_result.text) if dest_result.status_code != 202: raise RegistryException( 'Cannot push docker tag "%s", got non-202 response code' % destination_tag, dest_result.text)
def replace_data(self, filename=None): """ Replace the data attached to this slice with the rows_cache specified """ self._requires_sliceboard() assert filename is not None headers = {"content-type": "application/json; charset=utf8"} put_url = "http://" + self.server + self.sliceboard_obj[ 'data'] + '/set_rows_cache' + self.auth_params data = {'s3_rows_cache': filename} self.logger.info('Replacing data: ' + put_url) response = http_put(put_url, data=json.dumps(data), headers=headers) self.logger.info('Replacing data: status code ' + str(response.status_code)) return self
def replace_data(self, filename=None): """ Replace the data attached to this slice with the rows_cache specified """ self._requires_sliceboard() assert filename is not None headers = {"content-type": "application/json; charset=utf8"} put_url = "http://" + self.server + self.sliceboard_obj[ 'data'] + '/set_rows_cache' + self.auth_params data = {'s3_rows_cache': filename} self.logger.info('Replacing data: ' + put_url) response = http_put(put_url, data=json.dumps(data), headers=headers) self.logger.info( 'Replacing data: status code ' + str(response.status_code)) return self
def title(self, new_title="Untitled"): """ Change the title of the sliceboard You can use the sliceboard to build the title. For instance sliceboard(100).title("Copy of {0[title]}") will rename from "Untitled" to "Copy of Untitled" """ assert self.sliceboard_obj is not None assert new_title is not None headers = {"content-type": "application/json; charset=utf8"} put_url = self.sliceboard_detail_uri + self.auth_params data = {"title": new_title.format(self.sliceboard_obj)} response = http_put(put_url, data=json.dumps(data), headers=headers) assert response.status_code == 202 return self