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)

    false Write access to the project

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Integer)

    Id of the project to archive

Returns:



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

Fetches all archived projects

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to close

Returns:



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

Parameters:

  • name (String)

    Name of the project to create

  • templatename (String)

    Name of the template to use

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to delete

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Integer)

    Id of the project to forceclose

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to freeze

Returns:

  • (Boolean)

    Success



147
148
149
# File 'lib/strawberry_api/client/projects.rb', line 147

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

#library_projectsArray<StrawberryAPI::Project>

Fetches all library projects

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to mount

Returns:



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

Fetches all online projects

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to open

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Integer)

    Id of the project to retrieve

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to retrieve which to retrieve assets from

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to retrieve custom metadata from

Returns:

  • (Array<StrawberryAPI::CustomMetadata>)

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

Parameters:

  • id (Integer)

    Id of the project to retrieve access rights from

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to retrieve status flags from

Returns:

  • (Hash)

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

Parameters:

  • id (Interger)

    If of the project to retrieve teams from

Returns:



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

Parameters:

  • [Boolean] (Hash)

    a customizable set of options

Returns:



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_reporHash

Fetches projects report

Returns:

  • (Hash)

    The fetched projects report



371
372
373
# File 'lib/strawberry_api/client/projects.rb', line 371

def projects_repor
  get("/projects_report").parse
end

#projects_sizeHash

Fetches projects size

Returns:

  • (Hash)

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

Parameters:

  • id (Integer)

    Id of the mounted project to refresh

Returns:



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

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



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

Parameters:

  • name (String)

    Substring to look for

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to sync

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to unmount

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to unarchive

Returns:



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

Parameters:

  • id (Integer)

    Id of the project to unfreeze

Returns:

  • (Boolean)

    Success



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

Parameters:

  • id (Interger)

    Id of the project to update

  • options (Hash)

    Hash of options

Returns:



105
106
107
108
# 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) ⇒ Boolean

Updates an project custom metadata

Parameters:

  • id (Integer)

    Id of the project which to update custom metadata

  • custom_metadata (Hash)

    Custom metadata to update the project with

Returns:

  • (Boolean)

    Success



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