module StrawberryAPI::Client::Projects

Public Instance Methods

add_team_to_project(id:, team_id:, write: false) click to toggle source

Assigns a team to a project

@param [Integer] id Id of the project to which the team should be added @param [Integer] team_id Id of the team to add to the project @param [Boolean] write false Write access to the project

@return [Boolean] Success

# 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') click to toggle source

Archives a project

@param [Integer] id Id of the project to archive

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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() click to toggle source

Fetches all archived projects

@return [Array<StrawberryAPI::Project>] A list of archived projects

# 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:) click to toggle source

Closes a project

@param [Integer] id Id of the project to close

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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) click to toggle source

Creates a project

@param [String] name Name of the project to create @param [String] templatename Name of the template to use

@return [StrawberryAPI::Project] The created project

# File lib/strawberry_api/client/projects.rb, line 80
def create_project(name:, templatename:, custom_metadata: nil)
  if custom_metadata
      custom_metadata = custom_metadata.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: custom_metadata
  }.to_json

  job = post("/projects", body: body).parse['job']

  project(id: job['project_id'])
end
delete_project(id:) click to toggle source

Deletes a project

@param [Integer] id Id of the project to delete

@return [Boolean] Success

# File lib/strawberry_api/client/projects.rb, line 116
def delete_project(id:)
  delete("/projects/#{id}").success?
end
forceclose_project(id:, edit:) click to toggle source

Forcecloses a project

@param [Integer] id Id of the project to forceclose

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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:) click to toggle source

Freezes a project

@param [Integer] id Id of the project to freeze

@return [Boolean] Success

# File lib/strawberry_api/client/projects.rb, line 147
def freeze_project(id:)
  put("/projects/#{id}/freeze").success?
end
library_projects() click to toggle source

Fetches all library projects

@return [Array<StrawberryAPI::Project>] A list of library projects

# 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:) click to toggle source

Mounts a project

@param [Integer] id Id of the project to mount

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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() click to toggle source

Fetches all online projects

@return [Array<StrawberryAPI::Project>] A list of online projects

# 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:) click to toggle source

Opens a project

@param [Integer] id Id of the project to open

@return [Boolean] Success

# File lib/strawberry_api/client/projects.rb, line 126
def open_project(id:)
  put("/projects/#{id}/open").success?
end
project(id:) click to toggle source

Fetches a project

@param [Integer] id Id of the project to retrieve

@return [StrawberryAPI::Project] The fetched project

# 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:) click to toggle source

Fetches a project assets

@param [Integer] id Id of the project to retrieve which to retrieve assets from

@return [Array<StrawberryAPI::Asset>] The fetched project assets

# 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:) click to toggle source

Fetches a project custom metadata

@param [Integer] id Id of the project to retrieve custom metadata from

@return [Array<StrawberryAPI::CustomMetadata>] The fetched project custom metadata

# File lib/strawberry_api/client/projects.rb, line 325
def project_custom_metadata(id:)
  custom_metadata = get("/projects/#{id}/custom_metadata").parse['array']
  custom_metadata.map do |custom_metadata|
    CustomMetadatum.new(custom_metadata)
  end
end
project_effective_access_rights(id:) click to toggle source

Fetches all access rights of a project

@param [Integer] id Id of the project to retrieve access rights from

@return [Array<StrawberryAPI::AccessRight>] The fetched project access rights

# 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:) click to toggle source

Fetches a project status flags

@param [Integer] id Id of the project to retrieve status flags from

@return [Hash] The fetched project status flags

# 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:) click to toggle source

Fetches all teams assigned to a project

@param [Interger] id If of the project to retrieve teams from

@return [Array<StrawberryAPI::Team>] The fetched project teams

# 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) click to toggle source

Fetches all projects

@option [Boolean] include_libraries false Include project libraries

@return [Array<StrawberryAPI::Project>] A list of projects

# 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() click to toggle source

Fetches projects report

@return [Hash] The fetched projects report

# File lib/strawberry_api/client/projects.rb, line 371
def projects_repor
  get("/projects_report").parse
end
projects_size() click to toggle source

Fetches projects size

@return [Hash] The fetched projects size

# File lib/strawberry_api/client/projects.rb, line 362
def projects_size
  get("/total_project_size").parse
end
refresh_mounted_project(id:) click to toggle source

Refreshes a mounted project

@param [Integer] id Id of the mounted project to refresh

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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:) click to toggle source

Removes a team from a project

@param [Integer] id Id of the project from which the team should be deleted @param [Integer] team_id Id of the team to remove from the project

@return [Boolean] Success

# 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:) click to toggle source

Searches for a substring in project names

@param [String] name Substring to look for

@return [Array<StrawberryAPI::Project>] A list of project matching the substring

# 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:) click to toggle source

Syncs a project

@param [Integer] id Id of the project to sync

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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:) click to toggle source

Unmounts a project

@param [Integer] id Id of the project to unmount

@return [StrawberryAPI::ProjectFeedback] The operation status

# 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:) click to toggle source

Unarchives a project

@param [Integer] id Id of the project to unarchive

@return [StrawberryAPI::ArchiveStrategyState] The operation status

# 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:) click to toggle source

Unfreezes a project

@param [Integer] id Id of the project to unfreeze

@return [Boolean] Success

# File lib/strawberry_api/client/projects.rb, line 157
def unfreeze_project(id:)
  delete("/projects/#{id}/unfreeze").success?
end
update_project(id:, options: {}) click to toggle source

Updates a project

@param [Interger] id Id of the project to update @param [Hash] options Hash of options

@return [StrawberryAPI::Project] The updated project

# File lib/strawberry_api/client/projects.rb, line 105
def update_project(id:, options: {})
  data = put("/projects/#{id}", body: options.to_json).parse['project']
  data.nil? ? nil : Project.new(data)
end
update_project_custom_metadata(id:, custom_metadata: nil) click to toggle source

Updates an project custom metadata

@param [Integer] id Id of the project which to update custom metadata @param [Hash] custom_metadata Custom metadata to update the project with

@return [Boolean] Success

# File lib/strawberry_api/client/projects.rb, line 339
def update_project_custom_metadata(id:, custom_metadata: nil)
  filthy_hash = StrawberryAPI::CustomMetadatum.filthify(custom_metadata: custom_metadata)
  put("/projects/#{id}/update_metadata", query: filthy_hash).success?
end