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:, custom_metadata: nil) ⇒ StrawberryAPI::Project
Creates a project.
-
#delete_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_repor ⇒ Hash
Fetches projects report.
-
#projects_size ⇒ Hash
Fetches projects size.
-
#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.
-
#update_project(id:, options: {}) ⇒ StrawberryAPI::Project
Updates a project.
-
#update_project_custom_metadata(id:, custom_metadata: nil) ⇒ Boolean
Updates an project custom metadata.
Instance Method Details
#add_team_to_project(id:, team_id:, write: false) ⇒ Boolean
Assigns a team to a project
289 290 291 292 293 294 295 296 |
# File 'lib/strawberry_api/client/projects.rb', line 289 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
222 223 224 225 226 227 228 229 230 |
# File 'lib/strawberry_api/client/projects.rb', line 222 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
56 57 58 59 60 |
# File 'lib/strawberry_api/client/projects.rb', line 56 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
167 168 169 170 |
# File 'lib/strawberry_api/client/projects.rb', line 167 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:, custom_metadata: nil) ⇒ StrawberryAPI::Project
Creates a project
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/strawberry_api/client/projects.rb', line 80 def create_project(name:, templatename:, custom_metadata: nil) if = .each_with_object(Array.new) do |field, memo| memo.push({custom_metadata_field: field[0], value: field[1]}) end end body = { name: name, templatename: templatename, custom_metadata: }.to_json job = post("/projects", body: body).parse['job'] project(id: job['project_id']) end |
#delete_project(id:) ⇒ Boolean
Deletes a project
116 117 118 |
# File 'lib/strawberry_api/client/projects.rb', line 116 def delete_project(id:) delete("/projects/#{id}").success? end |
#forceclose_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Forcecloses a project
178 179 180 181 |
# File 'lib/strawberry_api/client/projects.rb', line 178 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
147 148 149 |
# File 'lib/strawberry_api/client/projects.rb', line 147 def freeze_project(id:) put("/projects/#{id}/freeze").success? end |
#library_projects ⇒ Array<StrawberryAPI::Project>
Fetches all library projects
30 31 32 33 34 35 36 37 38 |
# File 'lib/strawberry_api/client/projects.rb', line 30 def library_projects projects = get("/projects").parse['projects']&.map do |project| Project.new(project) end projects.keep_if do |project| project.is_library_project end end |
#mount_project(id:, edit:) ⇒ StrawberryAPI::ProjectFeedback
Mounts a project
189 190 191 192 |
# File 'lib/strawberry_api/client/projects.rb', line 189 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
45 46 47 48 49 |
# File 'lib/strawberry_api/client/projects.rb', line 45 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
126 127 128 |
# File 'lib/strawberry_api/client/projects.rb', line 126 def open_project(id:) put("/projects/#{id}/open").success? end |
#project(id:) ⇒ StrawberryAPI::Project
Fetches a project
68 69 70 71 |
# File 'lib/strawberry_api/client/projects.rb', line 68 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
350 351 352 353 354 355 |
# File 'lib/strawberry_api/client/projects.rb', line 350 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
325 326 327 328 329 330 |
# File 'lib/strawberry_api/client/projects.rb', line 325 def (id:) = get("/projects/#{id}/custom_metadata").parse['array'] .map do || CustomMetadatum.new() end end |
#project_effective_access_rights(id:) ⇒ Array<StrawberryAPI::AccessRight>
Fetches all access rights of a project
274 275 276 277 278 279 |
# File 'lib/strawberry_api/client/projects.rb', line 274 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
315 316 317 |
# File 'lib/strawberry_api/client/projects.rb', line 315 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
261 262 263 264 265 266 |
# File 'lib/strawberry_api/client/projects.rb', line 261 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 |
# 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 else projects.keep_if do |project| !project.is_library_project end end end |
#projects_repor ⇒ Hash
Fetches projects report
371 372 373 |
# File 'lib/strawberry_api/client/projects.rb', line 371 def projects_repor get("/projects_report").parse end |
#projects_size ⇒ Hash
Fetches projects size
362 363 364 |
# File 'lib/strawberry_api/client/projects.rb', line 362 def projects_size get("/total_project_size").parse end |
#refresh_mounted_project(id:) ⇒ StrawberryAPI::ProjectFeedback
Refreshes a mounted project
211 212 213 214 |
# File 'lib/strawberry_api/client/projects.rb', line 211 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
305 306 307 |
# File 'lib/strawberry_api/client/projects.rb', line 305 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
249 250 251 252 253 |
# File 'lib/strawberry_api/client/projects.rb', line 249 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
136 137 138 139 |
# File 'lib/strawberry_api/client/projects.rb', line 136 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
200 201 202 203 |
# File 'lib/strawberry_api/client/projects.rb', line 200 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
238 239 240 241 |
# File 'lib/strawberry_api/client/projects.rb', line 238 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
157 158 159 |
# File 'lib/strawberry_api/client/projects.rb', line 157 def unfreeze_project(id:) delete("/projects/#{id}/unfreeze").success? end |
#update_project(id:, options: {}) ⇒ StrawberryAPI::Project
Updates a project
105 106 107 108 |
# File 'lib/strawberry_api/client/projects.rb', line 105 def update_project(id:, options: {}) data = put("/projects/#{id}", body: .to_json).parse['project'] data.nil? ? nil : Project.new(data) end |
#update_project_custom_metadata(id:, custom_metadata: nil) ⇒ Boolean
Updates an project custom metadata
339 340 341 342 |
# File 'lib/strawberry_api/client/projects.rb', line 339 def (id:, custom_metadata: nil) filthy_hash = StrawberryAPI::CustomMetadatum.filthify(custom_metadata: ) put("/projects/#{id}/update_metadata", query: filthy_hash).success? end |