Class: Jenkins2::API::RoleStrategy::Proxy
- Inherits:
-
ResourceProxy
- Object
- ResourceProxy
- Jenkins2::API::RoleStrategy::Proxy
- Defined in:
- lib/jenkins2/api/role_strategy.rb
Instance Attribute Summary
Attributes inherited from ResourceProxy
Instance Method Summary collapse
-
#assign(role:, type:, rsuser:) ⇒ Object
- Assign role to user in role-strategy ==== Parameters:
role
-
Role name.
- Assign role to user in role-strategy ==== Parameters:
-
#create(role:, type:, permissions: [], pattern: nil) ⇒ Object
- Create a role in role-strategy ==== Parameters:
role
-
Role name.
- Create a role in role-strategy ==== Parameters:
-
#delete(role:, type:) ⇒ Object
- Delete role(s) in role-strategy ==== Parameters:
role
-
Role name or array of role names.
- Delete role(s) in role-strategy ==== Parameters:
-
#list ⇒ Object
Get existing roles and users assigned to them.
-
#unassign(role:, type:, rsuser:) ⇒ Object
- Unassign role from user in role-strategy ==== Parameters:
role
-
Role name.
- Unassign role from user in role-strategy ==== Parameters:
-
#unassign_all(type:, rsuser:) ⇒ Object
- Unassign all roles from user in role-strategy ==== Parameters:
type
-
Role type.
- Unassign all roles from user in role-strategy ==== Parameters:
Methods inherited from ResourceProxy
#initialize, #method_missing, #raw, #respond_to_missing?, #subject
Constructor Details
This class inherits a constructor from Jenkins2::ResourceProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jenkins2::ResourceProxy
Instance Method Details
#assign(role:, type:, rsuser:) ⇒ Object
Assign role to user in role-strategy
Parameters:
role
-
Role name.
type
-
Role type. Use RoleType enum values.
rsuser
-
Username.
Returns:
True on success
61 62 63 64 |
# File 'lib/jenkins2/api/role_strategy.rb', line 61 def assign(role:, type:, rsuser:) connection.post(build_path('assignRole'), nil, roleName: role, type: type, sid: rsuser). code == '200' end |
#create(role:, type:, permissions: [], pattern: nil) ⇒ Object
Create a role in role-strategy
Parameters:
role
-
Role name.
type
-
Role type. Use RoleType enum values.
permissions
-
Array of permission ids. Default is - no permissions.
pattern
-
Slave or project pattern. Ignored for global roles.
Returns:
True on success
37 38 39 40 41 |
# File 'lib/jenkins2/api/role_strategy.rb', line 37 def create(role:, type:, permissions: [], pattern: nil) connection.post(build_path('addRole'), nil, roleName: role, type: type, permissionIds: ( || []).join(','), pattern: pattern, overwrite: false). code == '200' end |
#delete(role:, type:) ⇒ Object
Delete role(s) in role-strategy
Parameters:
role
-
Role name or array of role names.
type
-
Role type. Use RoleType enum values.
Returns:
True on success
49 50 51 52 |
# File 'lib/jenkins2/api/role_strategy.rb', line 49 def delete(role:, type:) connection.post(build_path('removeRoles'), nil, roleNames: [role].flatten.join(','), type: type).code == '200' end |
#list ⇒ Object
Get existing roles and users assigned to them.
- Returns
-
Hash where keys are roles, and values are arrays of users assigned to role.
24 25 26 27 |
# File 'lib/jenkins2/api/role_strategy.rb', line 24 def list ::JSON.parse(connection.get(build_path('getAllRoles')).body, object_class: ::OpenStruct).to_h end |
#unassign(role:, type:, rsuser:) ⇒ Object
Unassign role from user in role-strategy
Parameters:
role
-
Role name.
type
-
Role type. Use RoleType enum values.
rsuser
-
Username.
Returns:
True on success
73 74 75 76 |
# File 'lib/jenkins2/api/role_strategy.rb', line 73 def unassign(role:, type:, rsuser:) connection.post(build_path('unassignRole'), nil, roleName: role, type: type, sid: rsuser). code == '200' end |
#unassign_all(type:, rsuser:) ⇒ Object
Unassign all roles from user in role-strategy
Parameters:
type
-
Role type. Use RoleType enum values.
rsuser
-
Username.
Returns:
True on success
84 85 86 |
# File 'lib/jenkins2/api/role_strategy.rb', line 84 def unassign_all(type:, rsuser:) connection.post(build_path('deleteSid'), nil, type: type, sid: rsuser).code == '200' end |