Class: Plus4uCodebase::Hub

Inherits:
Object
  • Object
show all
Defined in:
lib/plus4u_codebase/hub.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, options = nil) ⇒ Hub

Returns a new instance of Hub



5
6
7
# File 'lib/plus4u_codebase/hub.rb', line 5

def initialize(session, options = nil)
  @cmd = UU::OS::CMD::CommandClient.new("plus4u-codebase", session, options)
end

Class Method Details

.add_access_group(hub_uri, params = {}) ⇒ Object



174
175
176
177
# File 'lib/plus4u_codebase/hub.rb', line 174

def self.add_access_group(hub_uri, params = {})
  session = UU::OS::Security::Session.current_session
  self.new(session).add_access_group(hub_uri, params)
end

.create(location_uri, params = {}) ⇒ Object

Static methods ===================


154
155
156
157
# File 'lib/plus4u_codebase/hub.rb', line 154

def self.create(location_uri, params = {})
  session = UU::OS::Security::Session.current_session
  self.new(session).create(location_uri, params)
end

.delete(hub_uri) ⇒ Object



169
170
171
172
# File 'lib/plus4u_codebase/hub.rb', line 169

def self.delete(hub_uri)
  session = UU::OS::Security::Session.current_session
  self.new(session).delete(hub_uri)
end

.get_access_group_list(hub_uri) ⇒ Object



189
190
191
192
# File 'lib/plus4u_codebase/hub.rb', line 189

def self.get_access_group_list(hub_uri)
  session = UU::OS::Security::Session.current_session
  self.new(session).get_access_group_list(hub_uri)
end

.get_attributes(hub_uri) ⇒ Object



159
160
161
162
# File 'lib/plus4u_codebase/hub.rb', line 159

def self.get_attributes(hub_uri)
  session = UU::OS::Security::Session.current_session
  self.new(session).get_attributes(hub_uri)
end

.get_repository_list(hub_uri) ⇒ Object



199
200
201
202
# File 'lib/plus4u_codebase/hub.rb', line 199

def self.get_repository_list(hub_uri)
  session = UU::OS::Security::Session.current_session
  self.new(session).get_repository_list(hub_uri)
end

.modify_access_group_relation(hub_uri, params = {}) ⇒ Object



184
185
186
187
# File 'lib/plus4u_codebase/hub.rb', line 184

def self.modify_access_group_relation(hub_uri, params = {})
  session = UU::OS::Security::Session.current_session
  self.new(session).modify_access_group_relation(hub_uri, params)
end

.refresh_access_rights(hub_uri) ⇒ Object



194
195
196
197
# File 'lib/plus4u_codebase/hub.rb', line 194

def self.refresh_access_rights(hub_uri)
  session = UU::OS::Security::Session.current_session
  self.new(session).refresh_access_rights(hub_uri)
end

.remove_access_group(hub_uri, params = {}) ⇒ Object



179
180
181
182
# File 'lib/plus4u_codebase/hub.rb', line 179

def self.remove_access_group(hub_uri, params = {})
  session = UU::OS::Security::Session.current_session
  self.new(session).remove_access_group(hub_uri, params)
end

.set_attributes(hub_uri, params = {}) ⇒ Object



164
165
166
167
# File 'lib/plus4u_codebase/hub.rb', line 164

def self.set_attributes(hub_uri, params = {})
  session = UU::OS::Security::Session.current_session
  self.new(session).set_attributes(hub_uri, params)
end

Instance Method Details

#add_access_group(hub_uri, params = {}) ⇒ Object

Adds an access group to the specified hub and users (casted in groups) get access to the hub. @@param parameters [Hash] Access Group with rights.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.add_access_group("ues:TER:HUB",
  access_group_uri: "ues:TER:AUTHORITIES", authorization: 'MANAGE')

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.

  • parameters (Hash)

    a customizable set of options



96
97
98
# File 'lib/plus4u_codebase/hub.rb', line 96

def add_access_group(hub_uri, params = {})
  @cmd.invoke('Hub/addAccessGroup', hub_uri, parameters: params.to_lower_camel_keys)
end

#create(location_uri, params = {}) ⇒ String

Creates a new hub in the specified location.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub_uri = hub.create("ues:TER:LOCATION",
  name: "My new HUB",
  code: "new_HUB",
  description: "this is HUB",
  repo_limit: 5
)

Parameters:

  • location_uri (String, UU::OS::UESURI)

    URI of the location to create the hub in.

  • params (Hash) (defaults to: {})

    Hub attributes.

Options Hash (params):

  • :name (String)

    Hub artifact name.

  • :code (String)

    Hub artifact code.

  • :description (String)

    Hub artifact description.

  • :repository_limit (Fixnum)

    Number of Repositories which can be created in the Hub.

Returns:

  • (String)

    URI of the created HUB.



27
28
29
# File 'lib/plus4u_codebase/hub.rb', line 27

def create(location_uri, params = {})
  @cmd.invoke('Hub/create', location_uri, parameters: params.to_lower_camel_keys)
end

#delete(hub_uri) ⇒ Object

Deletes the specified hub.

Examples:

Basic usage

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.delete("ues:TER:HUB")

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.



70
71
72
# File 'lib/plus4u_codebase/hub.rb', line 70

def delete(hub_uri)
  @cmd.invoke('Hub/delete', hub_uri)
end

#get_access_group_list(hub_uri) ⇒ Array

Gets list of access groups related to the specified hub. :access_group_uri [String, UU::OS::UESURI] - Canonical URI of access group. :authorization [String] - Type of access. Possible values: 'MANAGE', 'READWRITE' and 'READ'.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
groups = hub.get_access_group_list("ues:TER:HUB")

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.

Returns:

  • (Array)

    Attributes of the connected access groups.



135
136
137
# File 'lib/plus4u_codebase/hub.rb', line 135

def get_access_group_list(hub_uri)
  @cmd.invoke('Hub/getAccessGroupList', hub_uri.to_lower_camel_keys).to_snake_keys
end

#get_attributes(hub_uri) ⇒ Hash

Returns basic attributes of the specified hub. :name [String] - Name of the hub artifact. :code [String] - Code of the hub artifact. :description [String] - Description of the hub artifact. :repository_limit [Fixnum] - Number of Repositories which can be created in the hub. :repository_count [Fixnum] - Number of repositories in the hub.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub_attributes = hub.get_attributes("ues:TER:HUB")

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub

Returns:

  • (Hash)

    Attributes of the specified hub.



43
44
45
# File 'lib/plus4u_codebase/hub.rb', line 43

def get_attributes(hub_uri)
  @cmd.invoke('Hub/getAttributes', hub_uri).to_snake_keys
end

#get_repository_list(hub_uri) ⇒ Object

Returns list of repositories of specified hub.

Examples:

Basic usage

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.get_repository_list("ues:TER:HUB")

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.



80
81
82
# File 'lib/plus4u_codebase/hub.rb', line 80

def get_repository_list(hub_uri)
  @cmd.invoke('Hub/getRepositoryList', hub_uri).map{|item| item.to_snake_keys} || []
end

#modify_access_group_relation(hub_uri, params = {}) ⇒ Object

Modifies relation (access rights) of the specified access group and the specified hub. @@param params [Hash] Attributes of the specified access group.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.modify_access_group_relation("ues:TER:HUB",
  access_group_uri: "ues:TER:AUTHORITIES", authorization: 'MANAGE')

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :access_group_uri (String, UU::OS::UESURI)

    Canonical URI of access group.

  • :authorization (String)

    Type of access. Possible values: ‘MANAGE’, ‘READWRITE’ and ‘READ’.



122
123
124
# File 'lib/plus4u_codebase/hub.rb', line 122

def modify_access_group_relation(hub_uri, params = {})
  @cmd.invoke('Hub/modifyAccessGroupRelation', hub_uri, parameters: params.to_lower_camel_keys)
end

#refresh_access_rights(hub_uri) ⇒ Object

Gets access groups related to the specified hub and sets access rights for casted user again.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.refresh_accesses("ues:TER:HUB")

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.



147
148
149
# File 'lib/plus4u_codebase/hub.rb', line 147

def refresh_access_rights(hub_uri)
  @cmd.invoke('Hub/refreshAccesses', hub_uri.to_lower_camel_keys)
end

#remove_access_group(hub_uri, params = {}) ⇒ Object

Removes an access group from the specified hub and users (casted in groups) loose access to the hub. @@param params [Hash] Access Group.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.remove_access_group("ues:TER:HUB", access_group_uri: "ues:TER:AUTHORITIES")

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub.

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :access_group_uri (String, UU::OS::UESURI)

    URI of access group.



108
109
110
# File 'lib/plus4u_codebase/hub.rb', line 108

def remove_access_group(hub_uri, params = {})
  @cmd.invoke('Hub/removeAccessGroup', hub_uri, parameters: params.to_lower_camel_keys)
end

#set_attributes(hub_uri, params = {}) ⇒ String

Sets basic attributes of the specified hub.

Examples:

hub = Plus4uCodebase::Hub.new(UU::OS::Security::Session.current_session)
hub.set_attributes("ues:TER:HUB",
  name: "New hub name",
  description: "New hub description"
)

Parameters:

  • hub_uri (String, UU::OS::UESURI)

    URI of the hub to be modified.

  • params (Hash) (defaults to: {})

    Hub attributes.

Options Hash (params):

  • :name (String)

    New hub artifact name.

  • :description (String)

    New hub artifact description.

  • :repo_limit (Fixnum)

    Number of Repositories which can be created in the hub.

Returns:

  • (String)

    URI of the modified hub.



60
61
62
# File 'lib/plus4u_codebase/hub.rb', line 60

def set_attributes(hub_uri, params = {})
  @cmd.invoke('Hub/setAttributes', hub_uri, parameters: params.to_lower_camel_keys)
end