Exemplo n.º 1
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                context=f"{self.CONTEXT}/form").execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError("Error creating work package form") from re
Exemplo n.º 2
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                context=f"{self.CONTEXT}/form",
                                json=self.form.__dict__).execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError("Error updating version form") from re
Exemplo n.º 3
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                context=f"{self.CONTEXT}/{self.user.id}/lock",
                                headers={"Content-Type": "application/hal+json"}).execute()
         return u.User(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error locking user by id: {self.user.id}") from re
Exemplo n.º 4
0
 def execute(self):
     try:
         # TODO: Add attachment file to the post
         PostRequest(connection=self.connection,
                     context=f"{self.CONTEXT}/{self.wiki_page.id}/attachments",
                     json=self.attachment.__dict__).execute()
     except RequestError as re:
         raise BusinessError(f"Error adding new attachment: {self.attachment.title}") from re
Exemplo n.º 5
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={"Content-Type": "application/json"},
                                context=f"{self.CONTEXT}/form",
                                json=self.form).execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error creating form: {self.form}") from re
Exemplo n.º 6
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={"Content-Type": "application/json"},
                                context=f"{self.CONTEXT}/{self.grid.id}/form",
                                json=self.grid_form).execute()
         return Grid(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error updating grid by id: {self.grid.id}") from re
Exemplo n.º 7
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={"Content-Type": "application/json"},
                                context=f"{self.CONTEXT}",
                                json=self.user).execute()
         return usr.User(json_obj)
     except RequestError as re:
         raise BusinessError("Error creating new user") from re
Exemplo n.º 8
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={"Content-Type": "application/json"},
                                context=f"{self.CONTEXT}",
                                json=self.project.__dict__).execute()
         return p.Project(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error creating project: {self.project.name}") from re
Exemplo n.º 9
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                # context=f"{self.CONTEXT}/:{self.time_entry}/form",
                                context=f"{self.CONTEXT}/form",
                                json=self.form.__dict__).execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error updating form: {self.form.name}") from re
Exemplo n.º 10
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={"Content-Type": "application/json"},
                                context=f"{self.CONTEXT}/form",
                                json=self.membership.__dict__).execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error creating form from membership "
                             f"'{self.membership.__dict__['_links']['self']['href']}'") from re
Exemplo n.º 11
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={
                                    "Content-Type": "application/hal+json"
                                },
                                context=f"{self.CONTEXT}form").execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError("Error creating work package form") from re
Exemplo n.º 12
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             context=f"{self.CONTEXT}/{self.work_package.id}/form",
             json=json.dumps(self.relation.__dict__)).execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError(
             f"Error creating relation for work package {self.work_package.id}"
         ) from re
Exemplo n.º 13
0
 def execute(self):
     try:
         membership_id = self.membership.id
         self.__remove_readonly_attributes()
         json_obj = PostRequest(connection=self.connection,
                                headers={"Content-Type": "application/json"},
                                context=f"{self.CONTEXT}/{membership_id}/form",
                                json=self.membership.__dict__).execute()
         return Form(json_obj)
     except RequestError as re:
         raise BusinessError("Error updating membership form") from re
Exemplo n.º 14
0
 def execute(self):
     try:
         return PostRequest(connection=self.connection,
                            context=f"{self.CONTEXT}/plain",
                            data=self.text,
                            headers={
                                'Content-Type': 'text/plain'
                            }).execute()
     except RequestError as re:
         raise BusinessError(
             f"Error transform text to markdown: {self.text}") from re
Exemplo n.º 15
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={
                                    "Content-Type": "application/json"
                                },
                                context=f"{self.CONTEXT}",
                                json=self.version.__dict__).execute()
         return v.Version(json_obj)
     except RequestError as re:
         raise BusinessError("Error creating version") from re
Exemplo n.º 16
0
 def execute(self):
     try:
         json_obj = PostRequest(connection=self.connection,
                                headers={
                                    "Content-Type": "application/json"
                                },
                                context=f"{self.CONTEXT}",
                                json=self.time_entry.__dict__).execute()
         return te.TimeEntry(json_obj)
     except RequestError as re:
         raise BusinessError(
             f"Error creating a time entry with ID: {self.time_entry.id}"
         ) from re
Exemplo n.º 17
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             context=
             f"{self.custom_action.__dict__['_links']['self']['href']}/execute",
             json=self.custom_action.__dict__).execute()
         return CustomAction(json_obj)
     except RequestError as re:
         raise BusinessError(
             f"Error executing custom_action:"
             f" {self.custom_action.__dict__['_links']['self']['href']}/execute"
         ) from re
Exemplo n.º 18
0
 def execute(self):
     try:
         metadata = {"fileName": self.filename, "description": {"raw": self.description}}
         json_obj = PostRequest(connection=self.connection,
                                context=f"{self.CONTEXT}",
                                files={
                                    'file': ('attachment', self.file_content),
                                    'metadata': (None, json.dumps(metadata))
                                }
                                ).execute()
         return att.Attachment(json_obj)
     except RequestError as re:
         raise BusinessError(f"Error creating attachment : {self.filename}") from re
Exemplo n.º 19
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             headers={
                 "Content-Type": "application/json"
             },
             context=f"{self.CONTEXT}/{self.relation.id}/form",
             json=self.form).execute()
         return rel.Relation(json_obj)
     except RequestError as re:
         raise BusinessError(
             f"Error updating form for relation {self.relation.name}"
         ) from re
Exemplo n.º 20
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             headers={
                 "Content-Type": "application/json"
             },
             context=str(
                 URL(f"{self.CONTEXT}",
                     [URLParameter("notify", self.notify)])),
             json=self.work_package.__dict__).execute()
         return wp.WorkPackage(json_obj)
     except RequestError as re:
         raise BusinessError("Error creating work package") from re
Exemplo n.º 21
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             headers={
                 "Content-Type": "application/json"
             },
             context=f"{self.CONTEXT}{self.work_package.id}/watchers",
             json=self.watcher).execute()
         return usr.User(json_obj)
     except RequestError as re:
         raise BusinessError(
             f"Error creating watcher for the work package {self.work_package.id}"
         ) from re
Exemplo n.º 22
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             headers={
                 "Content-Type": "application/json"
             },
             context=f"{self.CONTEXT}{self.work_package_from.id}/relations",
             json=self.relation.__dict__).execute()
         return rel.Relation(json_obj)
     except RequestError as re:
         raise BusinessError(
             "Error creating relation for the work packages"
             f" [From: {self.relation.__dict__['from']['href']}]"
             f" [To: {self.relation.__dict__['to']['href']}]") from re
Exemplo n.º 23
0
 def execute(self):
     try:
         json_obj = PostRequest(
             connection=self.connection,
             headers={
                 "Content-Type": "application/json"
             },
             context=str(
                 URL(f"{self.CONTEXT}{self.work_package.id}/activities",
                     [URLParameter("notify", self.notify)])),
             json=self.comment).execute()
         return activity.Activity(json_obj)
     except RequestError as re:
         raise BusinessError(
             f"Error creating activity for the work package {self.work_package.id}"
         ) from re