Module: StrawberryAPI::Client::Projects

Included in:
StrawberryAPI::Client
Defined in:
lib/strawberry_api/client/projects.rb

Instance Method Summary collapse

Instance Method Details

#add_team_to_project(id:, team_id:, write: false) ⇒ Boolean

Assigns a team to a project

Parameters:

  • id (Integer)

    Id of the project to which the team should be added

  • team_id (Integer)

    Id of the team to add to the project

  • write (Boolean) (defaults to: false)

    false Write access to the project

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Integer)

    Id of the project to archive

Returns:



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_projectsArray<StrawberryAPI::Project>

Fetches all archived projects

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to close

Returns:



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

Parameters:

  • name (String)

    Name of the project to create

  • templatename (String)

    Name of the template to use

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to delete

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Integer)

    Id of the project to forceclose

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to freeze

Returns:

  • (Boolean)

    Success



124
125
126
# File 'lib/strawberry_api/client/projects.rb', line 124

def freeze_project(id:)
  put("/projects/#{id}/freeze").success?
end

#library_projectsArray<StrawberryAPI::Project>

Fetches all library projects

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to mount

Returns:



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_projectsArray<StrawberryAPI::Project>

Fetches all online projects

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to open

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Integer)

    Id of the project to retrieve

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to retrieve which to retrieve assets from

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to retrieve custom metadata from

Returns:

  • (Array<StrawberryAPI::CustomMetadata>)

    The fetched 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 ||
    .new()
  end
end

#project_effective_access_rights(id:) ⇒ Array<StrawberryAPI::AccessRight>

Fetches all access rights of a project

Parameters:

  • id (Integer)

    Id of the project to retrieve access rights from

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to retrieve status flags from

Returns:

  • (Hash)

    The fetched 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

Parameters:

  • id (Interger)

    If of the project to retrieve teams from

Returns:



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

Parameters:

  • [Boolean] (Hash)

    a customizable set of options

Returns:



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_reportHash

Fetches projects report

Returns:

  • (Hash)

    The fetched 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

Parameters:

  • id (Integer)

    Id of the mounted project to refresh

Returns:



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

Parameters:

  • id (Integer)

    Id of the project from which the team should be deleted

  • team_id (Integer)

    Id of the team to remove from the project

Returns:

  • (Boolean)

    Success



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

Parameters:

  • name (String)

    Substring to look for

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to sync

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to unmount

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to unarchive

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to unfreeze

Returns:

  • (Boolean)

    Success



134
135
136
# File 'lib/strawberry_api/client/projects.rb', line 134

def unfreeze_project(id:)
  delete("/projects/#{id}/unfreeze").success?
end