Coretex
coretex.entities.project.project.Project Class Reference
Inheritance diagram for coretex.entities.project.project.Project:
coretex.entities.project.base.BaseObject

Public Member Functions

Self createProject (cls, str name, ProjectType projectType, ProjectVisibility visiblity=ProjectVisibility.private, Optional[str] description=None)
 
bool addTask (self, str name, Optional[str] description)
 
Self fetchByName (cls, str name)
 
None updateVisibility (self, ProjectVisibility visibility)
 
- Public Member Functions inherited from coretex.entities.project.base.BaseObject
bool rename (self, str name)
 
bool updateDescription (self, str description)
 

Detailed Description

    Represents the project entity from Coretex.ai\n
    Contains properties that describe the project

Definition at line 30 of file project.py.

Member Function Documentation

◆ addTask()

bool coretex.entities.project.project.Project.addTask (   self,
str  name,
Optional[str]  description 
)
    Adds new task to the project

    Parameters
    ----------
    name : str
        task name
    description : Optional[str]
        task description

    Returns
    -------
    bool -> True if the task was added. False if the task was not added

Definition at line 105 of file project.py.

105  def addTask(self, name: str, description: Optional[str]) -> bool:
106  """
107  Adds new task to the project
108 
109  Parameters
110  ----------
111  name : str
112  task name
113  description : Optional[str]
114  task description
115 
116  Returns
117  -------
118  bool -> True if the task was added. False if the task was not added
119  """
120 
121  task = Task.createTask(name, self.id, description)
122  if task is None:
123  return False
124 
125  self.tasks.append(task)
126  return True
127 

◆ createProject()

Self coretex.entities.project.project.Project.createProject (   cls,
str  name,
ProjectType  projectType,
ProjectVisibility   visiblity = ProjectVisibility.private,
Optional[str]   description = None 
)
    Creates a new project with the provided name and description

    Parameters
    ----------
    name : str
        project name
    projectType : ProjectType
        type of the created Project
    visibility : ProjectVisibility
        visibility of the created Project
    description : Optional[str]
        project description

    Returns
    -------
    Self -> The created project object

    Raises
    ------
    NetworkRequestError -> If project creation failed

    Example
    -------
    >>> from coretex import Project, ProjectType
    \b
    >>> try:
    >>>     dummyProject = Project.createProject(
                name = "dummyProject",
                projectType = ProjectType.other,
                description = "This is dummy Coretex Project"
            )
        except:
            print("Failed to create project.")

Definition at line 43 of file project.py.

49  ) -> Self:
50  """
51  Creates a new project with the provided name and description
52 
53  Parameters
54  ----------
55  name : str
56  project name
57  projectType : ProjectType
58  type of the created Project
59  visibility : ProjectVisibility
60  visibility of the created Project
61  description : Optional[str]
62  project description
63 
64  Returns
65  -------
66  Self -> The created project object
67 
68  Raises
69  ------
70  NetworkRequestError -> If project creation failed
71 
72  Example
73  -------
74  >>> from coretex import Project, ProjectType
75  \b
76  >>> try:
77  >>> dummyProject = Project.createProject(
78  name = "dummyProject",
79  projectType = ProjectType.other,
80  description = "This is dummy Coretex Project"
81  )
82  except:
83  print("Failed to create project.")
84  """
85 
86  if not isEntityNameValid(name):
87  raise ValueError(">> [Coretex] Project name is invalid. Requirements: alphanumeric characters (\"a-z\", and \"0-9\") and dash (\"-\") with length between 3 to 50")
88 
89  return cls.create(
90  name = name,
91  project_task = projectType,
92  description = description,
93  visiblity = visiblity
94  )
95 

◆ fetchByName()

Self coretex.entities.project.project.Project.fetchByName (   cls,
str  name 
)
    Fetches Project based on specified name

    Parameters
    ----------
    name : str
        The name of the Project to fetch

    Returns
    -------
    Self -> Fetched Project

    Raises
    ------
    RuntimeError -> If the Project with specified name is not found

Definition at line 129 of file project.py.

129  def fetchByName(cls, name: str) -> Self:
130  """
131  Fetches Project based on specified name
132 
133  Parameters
134  ----------
135  name : str
136  The name of the Project to fetch
137 
138  Returns
139  -------
140  Self -> Fetched Project
141 
142  Raises
143  ------
144  RuntimeError -> If the Project with specified name is not found
145  """
146 
147  results = cls.fetchAll(name = f"={name}")
148  if len(results) == 0:
149  raise ValueError(f"Project with name \"{name}\" not found.")
150 
151  return results[0]
152 

◆ updateVisibility()

None coretex.entities.project.project.Project.updateVisibility (   self,
ProjectVisibility  visibility 
)
    Updates visibility of the project

    Parameters
    ----------
    visibility : ProjectVisibility
        visibility of the project

    Raises
    ------
    NetworkRequestError -> If request for updating the Project visibility failed

Definition at line 153 of file project.py.

153  def updateVisibility(self, visibility: ProjectVisibility) -> None:
154  """
155  Updates visibility of the project
156 
157  Parameters
158  ----------
159  visibility : ProjectVisibility
160  visibility of the project
161 
162  Raises
163  ------
164  NetworkRequestError -> If request for updating the Project visibility failed
165  """
166 
167  parameters = {
168  "entity_id": self.id,
169  "type": EntityVisibilityType.project,
170  "visibility": visibility
171  }
172 
173  response = networkManager.post("entity-visibility", parameters)
174 
175  if response.hasFailed():
176  raise NetworkRequestError(response, "Failed to update visibility of the Project.")
177 
178  self.visibility = visibility

The documentation for this class was generated from the following file: