def update_branch(self, project_id, branch_id, properties): """Update the properties of a given project branch. Parameters ---------- project_id: string Unique project identifier branch_id: string Unique branch identifier properties: dict Properties update statements Returns ------- vizier.api.client.resources.branch.BranchResource """ # Get the request url and create the request body url = self.urls.update_branch(project_id, branch_id) data = {labels.PROPERTIES: serialize.PROPERTIES(properties)} # Send request. Raise exception if status code indicates that the # request was not successful r = requests.put(url, json=data) r.raise_for_status() # The result is the new project descriptor return BranchResource.from_dict(json.loads(r.text))
def create_branch(self, project_id, properties, branch_id=None, workflow_id=None, module_id=None): """Create a new project resource at the server. The combination of branch_id, workflow_id and module_id specifies the branch point. If all values are None an empty branch is created. Parameters ---------- project_id: string Unique project identifier properties: dict Dictionary of project properties branch_id: string Unique branch identifier workflow_id: string Unique workflow identifier module_id: string Unique module identifier Results ------- vizier.api.client.resources.branch.BranchResource """ # Get the request url and create the request body url = self.urls.create_branch(project_id) data = {labels.PROPERTIES: serialize.PROPERTIES(properties)} if not branch_id is None and not workflow_id is None and not module_id is None: data['source'] = { 'branchId': branch_id, 'workflowId': workflow_id, 'moduleId': module_id } elif not branch_id is None or not workflow_id is None or not module_id is None: raise ValueError('invalid branch source') # Send request. Raise exception if status code indicates that the # request was not successful r = requests.post(url, json=data) r.raise_for_status() # The result is the new branch descriptor return BranchResource.from_dict(json.loads(r.text))
def create_project(self, properties: Dict[str, Any]) -> ProjectResource: """Create a new project resource at the server. Parameters ---------- properties: dict Dictionary of project properties Results ------- vizier.api.client.resources.project.ProjectResource """ # Get the request url and create the request body url = self.urls.create_project() data = {labels.PROPERTIES: serialize.PROPERTIES(properties)} # Send request. Raise exception if status code indicates that the # request was not successful r = requests.post(url, json=data) r.raise_for_status() # The result is the new project descriptor return ProjectResource.from_dict(json.loads(r.text))