示例#1
0
 def remove(self, share_id):
     share_id_object = sharing_res.ShareId(opaque_id=share_id)
     ref = sharing_res.ShareReference(id=share_id_object)
     remove_request = sharing.RemoveShareRequest(ref=ref)
     remove_response = self.cs3_api.RemoveShare(request=remove_request,
                                                metadata=[('x-access-token', self.get_token())])
     if remove_response.status.code == cs3_code.CODE_OK:
         self.log.info("Successfully removed share with ID: " + share_id)
         self.log.info(remove_response)
         return
     else:
         raise ShareNotExistsError("Error removing share with ID: " + share_id)
示例#2
0
 def update(self, share_id, role):
     share_permissions = self._get_share_permissions(role)
     share_id_object = sharing_res.ShareId(opaque_id=share_id)
     ref = sharing_res.ShareReference(id=share_id_object)
     update_request = sharing.UpdateShareRequest(ref=ref,
                                                 field=sharing.UpdateShareRequest.UpdateField(
                                                     permissions=share_permissions))
     update_response = self.cs3_api.UpdateShare(request=update_request,
                                                metadata=[('x-access-token', self.get_token())])
     if update_response.status.code == cs3_code.CODE_OK:
         self.log.info("Successfully updated share: " + share_id + " with role: " + role)
         self.log.info(update_response)
         return
     if update_response.status.code == cs3_code.CODE_INTERNAL:
         raise ShareNotExistsError("Error updating share: " + share_id)
示例#3
0
 def update_received(self, share_id, state=State.PENDING):
     share_id_object = sharing_res.ShareId(opaque_id=share_id)
     ref = sharing_res.ShareReference(id=share_id_object)
     share_state = self._map_share_state(state)
     update_request = sharing.UpdateReceivedShareRequest(ref=ref,
                                                         field=sharing.UpdateReceivedShareRequest.UpdateField(
                                                             state=share_state))
     update_response = self.cs3_api.UpdateReceivedShare(request=update_request,
                                                        metadata=[('x-access-token', self.get_token())])
     if self._is_code_ok(update_response):
         self.log.info("Successfully updated share: " + share_id + " with state " + state)
         self.log.info(update_response)
     else:
         self.log.error("Error updating received share: " + share_id + " with state " + state)
         self._handle_error(update_response)
     return