Class: Artifactory::Permissions::V2::ApiClient
- Inherits:
-
Object
- Object
- Artifactory::Permissions::V2::ApiClient
- Includes:
- HTTParty
- Defined in:
- lib/artifactory/permissions/v2/api_client.rb
Constant Summary collapse
- HTTP_ERRORS =
[ EOFError, Errno::ECONNRESET, Errno::EINVAL, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Timeout::Error, ]
- HANDLED_ERRORS =
[SocketError] + HTTP_ERRORS
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #find_permission(name:) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(endpoint:, api_key:) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #list_permissions ⇒ Object
- #put(path, data) ⇒ Object
- #save_permission_target(permission_target) ⇒ Object
Constructor Details
#initialize(endpoint:, api_key:) ⇒ ApiClient
Returns a new instance of ApiClient.
25 26 27 28 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 25 def initialize(endpoint:, api_key:) @endpoint = endpoint @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 23 def api_key @api_key end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
23 24 25 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 23 def endpoint @endpoint end |
Instance Method Details
#find_permission(name:) ⇒ Object
34 35 36 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 34 def (name:) get "/api/v2/security/permissions/#{url_safe name}" end |
#get(path) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 43 def get(path) response = self.class.get uri_for(path), headers: headers handle_response response rescue *handled_errors => err raise FatalError, err. end |
#list_permissions ⇒ Object
30 31 32 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 30 def get "/api/v2/security/permissions" end |
#put(path, data) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 51 def put(path, data) response = self.class.put uri_for(path), body: data.to_json, headers: headers handle_response response rescue *handled_errors => err raise FatalError, err. end |
#save_permission_target(permission_target) ⇒ Object
38 39 40 41 |
# File 'lib/artifactory/permissions/v2/api_client.rb', line 38 def () put "/api/v2/security/permissions/#{url_safe .name}", .payload end |