Class: Sem::API::SharedConfigs

Inherits:
Base
  • Object
show all
Extended by:
Traits::AssociatedWithOrg, Traits::AssociatedWithTeam
Defined in:
lib/sem/api/shared_configs.rb

Constant Summary

Constants inherited from Base

Base::CREDENTIALS_PATH

Class Method Summary collapse

Methods included from Traits::AssociatedWithTeam

add_to_team, list_for_team, remove_from_team

Methods included from Traits::AssociatedWithOrg

list_for_org

Methods inherited from Base

client

Class Method Details

.apiObject



47
48
49
# File 'lib/sem/api/shared_configs.rb', line 47

def self.api
  client.shared_configs
end

.create(org_name, args) ⇒ Object



19
20
21
22
23
# File 'lib/sem/api/shared_configs.rb', line 19

def self.create(org_name, args)
  config = api.create_for_org(org_name, args)

  to_hash(config)
end

.delete(path) ⇒ Object



33
34
35
36
37
# File 'lib/sem/api/shared_configs.rb', line 33

def self.delete(path)
  id = info(path)[:id]

  api.delete(id)
end

.info(path) ⇒ Object



13
14
15
16
17
# File 'lib/sem/api/shared_configs.rb', line 13

def self.info(path)
  org_name, config_name = path.split("/")

  list_for_org(org_name).find { |config| config[:name] == config_name }
end

.listObject



7
8
9
10
11
# File 'lib/sem/api/shared_configs.rb', line 7

def self.list
  org_names = Orgs.list.map { |org| org[:username] }

  org_names.map { |name| list_for_org(name) }.flatten
end

.list_env_vars(path) ⇒ Object



39
40
41
# File 'lib/sem/api/shared_configs.rb', line 39

def self.list_env_vars(path)
  Sem::API::EnvVars.list_for_shared_config(path)
end

.list_files(path) ⇒ Object



43
44
45
# File 'lib/sem/api/shared_configs.rb', line 43

def self.list_files(path)
  Sem::API::Files.list_for_shared_config(path)
end

.to_hash(config) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/sem/api/shared_configs.rb', line 51

def self.to_hash(config)
  {
    :id => config.id,
    :name => config.name,
    :config_files => config_files_count(config.id),
    :env_vars => env_vars_count(config.id),
    :created_at => config.created_at,
    :updated_at => config.updated_at
  }
end

.update(path, args) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/sem/api/shared_configs.rb', line 25

def self.update(path, args)
  shared_config = info(path)

  shared_config = api.update(shared_config[:id], args)

  to_hash(shared_config)
end