Class: API::Account
- Inherits:
-
Object
- Object
- API::Account
- Defined in:
- lib/puppet/functions/api.rb
Class Method Summary collapse
- .add(account_title: nil, account_type: nil, account_name: nil, personal_account: nil, password: nil, ipaddress: nil, notes: nil, tags: nil, folder_id: nil, account_expiration_date: nil, distinguished_name: nil, account_alias: nil, domain_name: nil) ⇒ Object
- .edit(account_id:, account_type:, account_title: nil, account_name: nil, personal_account: nil, password: nil, ipaddress: nil, notes: nil, tags: nil, folder_id: nil, account_expiration_date: nil, distinguished_name: nil, account_alias: nil, domain_name: nil) ⇒ Object
- .get(account_id: nil, account_title: nil, account_name: nil, account_type: nil, ticket_id: nil, reason: nil) ⇒ Object
Class Method Details
.add(account_title: nil, account_type: nil, account_name: nil, personal_account: nil, password: nil, ipaddress: nil, notes: nil, tags: nil, folder_id: nil, account_expiration_date: nil, distinguished_name: nil, account_alias: nil, domain_name: nil) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/puppet/functions/api.rb', line 91 def self.add(account_title: nil, account_type: nil, account_name: nil, personal_account: nil, password: nil, ipaddress: nil, notes: nil, tags: nil, folder_id: nil, account_expiration_date: nil, distinguished_name: nil, account_alias: nil, domain_name: nil) server = Init.initialized return nil if server == false if account_type.nil? Logger.log(ERROR, 'Required Account type') return nil elsif account_title.nil? Logger.log(ERROR, 'Required Account title') return nil end Logger.log(DEBUG, 'Creating account in abi') params = {} params['account_title'] = account_title params['account_type'] = account_type params['account_name'] = account_name unless account_name.nil? params['personal_account'] = personal_account unless personal_account.nil? params['ipaddress'] = ipaddress unless ipaddress.nil? params['notes'] = notes unless notes.nil? params['tags'] = unless .nil? params['folder_id'] = folder_id unless folder_id.nil? params['password'] = password unless password.nil? params['account_expiration_date'] = account_expiration_date unless account_expiration_date.nil? params['distinguished_name'] = distinguished_name unless distinguished_name.nil? params['account_alias'] = account_alias unless account_alias.nil? params['domain_name'] = domain_name unless domain_name.nil? account = Request.new.raise_request(params, '/api/add_account', POST) return nil unless account Logger.log(DEBUG, account['message']) if account['message'] account rescue StandardError => e Logger.log(ERROR, "Failed to add account: #{e.}") nil end |
.edit(account_id:, account_type:, account_title: nil, account_name: nil, personal_account: nil, password: nil, ipaddress: nil, notes: nil, tags: nil, folder_id: nil, account_expiration_date: nil, distinguished_name: nil, account_alias: nil, domain_name: nil) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/puppet/functions/api.rb', line 127 def self.edit(account_id:, account_type:, account_title: nil, account_name: nil, personal_account: nil, password: nil, ipaddress: nil, notes: nil, tags: nil, folder_id: nil, account_expiration_date: nil, distinguished_name: nil, account_alias: nil, domain_name: nil) server = Init.initialized return nil if server == false if account_id.nil? || account_type.nil? Logger.log(ERROR, 'Required account ID and Account type') return nil end Logger.log(DEBUG, 'Updating account in abi') params = {} params['account_id'] = account_id params['account_type'] = account_type params['account_title'] = account_title unless account_title.nil? params['account_name'] = account_name unless account_name.nil? params['password'] = password unless password.nil? params['ipaddress'] = ipaddress unless ipaddress.nil? params['personal_account'] = personal_account unless personal_account.nil? params['notes'] = notes unless notes.nil? params['tags'] = unless .nil? params['folder_id'] = folder_id unless folder_id.nil? params['account_expiration_date'] = account_expiration_date unless account_expiration_date.nil? params['distinguished_name'] = distinguished_name unless distinguished_name.nil? params['account_alias'] = account_alias unless account_alias.nil? params['domain_name'] = domain_name unless domain_name.nil? account = Request.new.raise_request(params, '/api/edit_account', PUT) if account Logger.log(DEBUG, account['message']) if account['message'] account else Logger.log(ERROR, 'Failed to update account') nil end rescue StandardError => e Logger.log(ERROR, "Could not update account: #{e}") nil end |
.get(account_id: nil, account_title: nil, account_name: nil, account_type: nil, ticket_id: nil, reason: nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/puppet/functions/api.rb', line 59 def self.get(account_id: nil, account_title: nil, account_name: nil, account_type: nil, ticket_id: nil, reason: nil) unless API.server_url && API.authtoken if server_url.nil? || authtoken.nil? Logger.log(ERROR, 'Abi is not initialized. Server URL and authtoken are required to initialize Abi') return nil else Init.new(server_url: server_url, authtoken: authtoken, org: org, certificate: certificate) end end if account_id.nil? && account_title.nil? && account_name.nil? && account_type.nil? Logger.log(ERROR, 'At least one of account_id, account_title, account_name is required') return nil end Logger.log(INFO, 'Fetching account data') params = {} params['account_id'] = account_id unless account_id.nil? params['account_title'] = account_title unless account_title.nil? params['account_name'] = account_name unless account_name.nil? params['account_type'] = account_type unless account_type.nil? params['ticket_id'] = ticket_id unless ticket_id.nil? params['reason'] = reason unless reason.nil? account = Request.new.raise_request(params, '/secretsmanagement/get_account', GET) return nil unless account Logger.log(INFO, account['message']) if account['message'] account rescue StandardError => e Logger.log(ERROR, "Failed to fetch account data: #{e.}") nil end |