Module: StrawberryAPI::Client::Projects
- Included in:
- StrawberryAPI::Client
- Defined in:
- lib/strawberry_api/client/projects.rb
Instance Method Summary collapse
-
#add_team_to_project(id:, team_id:, write: false) ⇒ Boolean
Assigns a team to a project.
-
#archive_project(id:, archive_strategy_id:, exclude_linked_files: false) ⇒ StrawberryAPI::ProjectFeedback
Archives a project.
-
#archived_projects ⇒ Array<StrawberryAPI::Project>
Fetches all archived projects.
-
#close_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Closes a project.
-
#create_project(name:, templatename:) ⇒ StrawberryAPI::Project
Creates a project.
-
#destroy_project(id:) ⇒ Boolean
Deletes a project.
-
#forceclose_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Forcecloses a project.
-
#freeze_project(id:) ⇒ Boolean
Freezes a project.
-
#library_projects ⇒ Array<StrawberryAPI::Project>
Fetches all library projects.
-
#mount_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Mounts a project.
-
#online_projects ⇒ Array<StrawberryAPI::Project>
Fetches all online projects.
-
#open_project(id:) ⇒ Boolean
Opens a project.
-
#project(id:) ⇒ StrawberryAPI::Project
Fetches a project.
-
#project_assets(id:) ⇒ Array<StrawberryAPI::Asset>
Fetches a project assets.
-
#project_custom_metadata(id:) ⇒ Array<StrawberryAPI::CustomMetadata>
Fetches a project custom metadata.
-
#project_effective_access_rights(id:) ⇒ Array<StrawberryAPI::AccessRight>
Fetches all access rights of a project.
-
#project_status_flags(id:) ⇒ Hash
Fetches a project status flags.
-
#project_teams(id:) ⇒ Array<StrawberryAPI::Team>
Fetches all teams assigned to a project.
-
#projects(include_libraries: false) ⇒ Array<StrawberryAPI::Project>
Fetches all projects.
-
#projects_report ⇒ Hash
Fetches projects report.
-
#refresh_mounted_project(id:) ⇒ StrawberryAPI::ProjectFeedback
Refreshes a mounted project.
-
#remove_team_from_project(id:, team_id:) ⇒ Boolean
Removes a team from a project.
-
#search_project(name:) ⇒ Array<StrawberryAPI::Project>
Searches for a substring in project names.
-
#sync_project(id:) ⇒ StrawberryAPI::ProjectFeedback
Syncs a project.
-
#umount_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Unmounts a project.
-
#unarchive_project(id:) ⇒ StrawberryAPI::ArchiveStrategyState
Unarchives a project.
-
#unfreeze_project(id:) ⇒ Boolean
Unfreezes a project.
Instance Method Details
#add_team_to_project(id:, team_id:, write: false) ⇒ Boolean
Assigns a team to a project
266 267 268 269 270 271 272 273 |
# File 'lib/strawberry_api/client/projects.rb', line 266 def add_team_to_project(id:, team_id:, write: false) body = { team_id: team_id, write: write }.to_json put("/projects/#{id}/teams", body: body).success? end |
#archive_project(id:, archive_strategy_id:, exclude_linked_files: false) ⇒ StrawberryAPI::ProjectFeedback
Archives a project
199 200 201 202 203 204 205 206 207 |
# File 'lib/strawberry_api/client/projects.rb', line 199 def archive_project(id:, archive_strategy_id:, exclude_linked_files: false) body = { strategy: archive_strategy_id, exclude_linked_files: exclude_linked_files }.to_json data = put("/projects/#{id}/archive", body: body).parse['archivestrategystate'] data.nil? ? nil : ArchiveStrategyState.new(data) end |
#archived_projects ⇒ Array<StrawberryAPI::Project>
Fetches all archived projects
53 54 55 56 57 |
# File 'lib/strawberry_api/client/projects.rb', line 53 def archived_projects projects.select do |project| project.archive_strategy_id && !project.deleted && !project.is_library_project end end |
#close_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Closes a project
144 145 146 147 |
# File 'lib/strawberry_api/client/projects.rb', line 144 def close_project(id:, edit:) delete("/projects/#{id}/close", headers: {'X-FLAVOURSYS-EDIT' => edit}).parse['job'] data.nil? ? nil : ProjectFeedback.new(data) end |
#create_project(name:, templatename:) ⇒ StrawberryAPI::Project
Creates a project
77 78 79 80 81 82 83 84 85 |
# File 'lib/strawberry_api/client/projects.rb', line 77 def create_project(name:, templatename:) body = { name: name, templatename: templatename }.to_json data = post("/projects", body: body).parse['project'] data.nil? ? nil : Project.new(data) end |
#destroy_project(id:) ⇒ Boolean
Deletes a project
93 94 95 |
# File 'lib/strawberry_api/client/projects.rb', line 93 def destroy_project(id:) delete("/projects/#{id}").success? end |
#forceclose_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Forcecloses a project
155 156 157 158 |
# File 'lib/strawberry_api/client/projects.rb', line 155 def forceclose_project(id:, edit:) data = delete("/projects/#{id}/forceclose", headers: {'X-FLAVOURSYS-EDIT' => edit}).parse['job'] data.nil? ? nil : ProjectFeedback.new(data) end |
#freeze_project(id:) ⇒ Boolean
Freezes a project
124 125 126 |
# File 'lib/strawberry_api/client/projects.rb', line 124 def freeze_project(id:) put("/projects/#{id}/freeze").success? end |
#library_projects ⇒ Array<StrawberryAPI::Project>
Fetches all library projects
31 32 33 34 35 |
# File 'lib/strawberry_api/client/projects.rb', line 31 def library_projects projects.select do |project| !project.deleted && project.is_library_project end end |
#mount_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Mounts a project
166 167 168 169 |
# File 'lib/strawberry_api/client/projects.rb', line 166 def mount_project(id:, edit:) data = put("/projects/#{id}/mount", headers: {'X-FLAVOURSYS-EDIT' => edit}).parse['job'] data.nil? ? nil : ProjectFeedback.new(data) end |
#online_projects ⇒ Array<StrawberryAPI::Project>
Fetches all online projects
42 43 44 45 46 |
# File 'lib/strawberry_api/client/projects.rb', line 42 def online_projects projects.select do |project| project.archive_strategy_id.nil? && !project.deleted && !project.is_library_project end end |
#open_project(id:) ⇒ Boolean
Opens a project
103 104 105 |
# File 'lib/strawberry_api/client/projects.rb', line 103 def open_project(id:) put("/projects/#{id}/open").success? end |
#project(id:) ⇒ StrawberryAPI::Project
Fetches a project
65 66 67 68 |
# File 'lib/strawberry_api/client/projects.rb', line 65 def project(id:) data = get("/projects/#{id}").parse['project'] data.nil? ? nil : Project.new(data) end |
#project_assets(id:) ⇒ Array<StrawberryAPI::Asset>
Fetches a project assets
315 316 317 318 319 320 |
# File 'lib/strawberry_api/client/projects.rb', line 315 def project_assets(id:) assets = get("/projects/#{id}/assets").parse['assets'] assets.map do |asset| Asset.new(asset) end end |
#project_custom_metadata(id:) ⇒ Array<StrawberryAPI::CustomMetadata>
Fetches a project custom metadata
302 303 304 305 306 307 |
# File 'lib/strawberry_api/client/projects.rb', line 302 def (id:) = get("/projects/#{id}/custom_metadata").parse['array'] .map do || CustomMetadata.new() end end |
#project_effective_access_rights(id:) ⇒ Array<StrawberryAPI::AccessRight>
Fetches all access rights of a project
251 252 253 254 255 256 |
# File 'lib/strawberry_api/client/projects.rb', line 251 def project_effective_access_rights(id:) access_rights = get("/projects/#{id}/effective_access_rights").parse['hash'] access_rights.map do |accessright| AccessRight.new(accessright) end end |
#project_status_flags(id:) ⇒ Hash
Fetches a project status flags
292 293 294 |
# File 'lib/strawberry_api/client/projects.rb', line 292 def project_status_flags(id:) status_flags = get("/projects/#{id}/status_flags").parse['array'] end |
#project_teams(id:) ⇒ Array<StrawberryAPI::Team>
Fetches all teams assigned to a project
238 239 240 241 242 243 |
# File 'lib/strawberry_api/client/projects.rb', line 238 def project_teams(id:) teams = get("/projects/#{id}/teams").parse['array'] teams.map do |team| Team.new(team.first) end end |
#projects(include_libraries: false) ⇒ Array<StrawberryAPI::Project>
Fetches all projects
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/strawberry_api/client/projects.rb', line 11 def projects(include_libraries: false) projects = get("/projects").parse['projects']&.map do |project| Project.new(project) end if include_libraries projects.keep_if do |project| project.is_library_project end else projects end end |
#projects_report ⇒ Hash
Fetches projects report
327 328 329 |
# File 'lib/strawberry_api/client/projects.rb', line 327 def projects_report get("/projects_report").parse end |
#refresh_mounted_project(id:) ⇒ StrawberryAPI::ProjectFeedback
Refreshes a mounted project
188 189 190 191 |
# File 'lib/strawberry_api/client/projects.rb', line 188 def refresh_mounted_project(id:) data = put("/projects/#{id}/refreshmountedproject", headers: {'X-FLAVOURSYS-EDIT' => edit}).parse['job'] data.nil? ? nil : ProjectFeedback.new(data) end |
#remove_team_from_project(id:, team_id:) ⇒ Boolean
Removes a team from a project
282 283 284 |
# File 'lib/strawberry_api/client/projects.rb', line 282 def remove_team_from_project(id:, team_id:) delete("/projects/#{id}/teams/#{team_id}").success? end |
#search_project(name:) ⇒ Array<StrawberryAPI::Project>
Searches for a substring in project names
226 227 228 229 230 |
# File 'lib/strawberry_api/client/projects.rb', line 226 def search_project(name:) get("/projects/search", body: {name: name}).parse['projects']&.map do |project| Project.new(project) end end |
#sync_project(id:) ⇒ StrawberryAPI::ProjectFeedback
Syncs a project
113 114 115 116 |
# File 'lib/strawberry_api/client/projects.rb', line 113 def sync_project(id:) data = put("/projects/#{id}/sync").parse['job'] data.nil? ? nil : ProjectFeedback.new(data) end |
#umount_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Unmounts a project
177 178 179 180 |
# File 'lib/strawberry_api/client/projects.rb', line 177 def umount_project(id:, edit:) data = delete("/projects/#{id}/umount", headers: {'X-FLAVOURSYS-EDIT' => edit}).parse['job'] data.nil? ? nil : ProjectFeedback.new(data) end |
#unarchive_project(id:) ⇒ StrawberryAPI::ArchiveStrategyState
Unarchives a project
215 216 217 218 |
# File 'lib/strawberry_api/client/projects.rb', line 215 def unarchive_project(id:) data = put("/projects/#{id}/unarchive").parse['archivestrategystate'] data.nil? ? nil : ArchiveStrategyState.new(data) end |
#unfreeze_project(id:) ⇒ Boolean
Unfreezes a project
134 135 136 |
# File 'lib/strawberry_api/client/projects.rb', line 134 def unfreeze_project(id:) delete("/projects/#{id}/unfreeze").success? end |