Class: Zavudev::Resources::SubAccounts
- Inherits:
-
Object
- Object
- Zavudev::Resources::SubAccounts
- Defined in:
- lib/zavudev/resources/sub_accounts.rb,
lib/zavudev/resources/sub_accounts/api_keys.rb
Defined Under Namespace
Classes: APIKeys
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(name:, credit_limit: nil, external_id: nil, metadata: nil, request_options: {}) ⇒ Zavudev::Models::SubAccountCreateResponse
Some parameter documentations has been truncated, see Models::SubAccountCreateParams for more details.
-
#deactivate(id, request_options: {}) ⇒ Zavudev::Models::SubAccountDeactivateResponse
Deactivate a sub-account.
-
#get_balance(id, request_options: {}) ⇒ Zavudev::Models::SubAccountGetBalanceResponse
Get spending information for a sub-account.
-
#initialize(client:) ⇒ SubAccounts
constructor
private
A new instance of SubAccounts.
-
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::SubAccount>
List sub-accounts for this team.
-
#retrieve(id, request_options: {}) ⇒ Zavudev::Models::SubAccountRetrieveResponse
Get sub-account.
-
#update(id, credit_limit: nil, external_id: nil, metadata: nil, name: nil, status: nil, request_options: {}) ⇒ Zavudev::Models::SubAccountUpdateResponse
Update sub-account.
Constructor Details
#initialize(client:) ⇒ SubAccounts
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SubAccounts.
169 170 171 172 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 169 def initialize(client:) @client = client @api_keys = Zavudev::Resources::SubAccounts::APIKeys.new(client: client) end |
Instance Attribute Details
#api_keys ⇒ Zavudev::Resources::SubAccounts::APIKeys (readonly)
7 8 9 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 7 def api_keys @api_keys end |
Instance Method Details
#create(name:, credit_limit: nil, external_id: nil, metadata: nil, request_options: {}) ⇒ Zavudev::Models::SubAccountCreateResponse
Some parameter documentations has been truncated, see Models::SubAccountCreateParams for more details.
Create a new sub-account (project) with its own API key. All charges are billed to the parent team’s balance. Use creditLimit to set a spending cap. The sub-account’s API key is returned only in the creation response. Requires a parent project API key; sub-account API keys receive HTTP 403.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 32 def create(params) parsed, = Zavudev::SubAccountCreateParams.dump_request(params) @client.request( method: :post, path: "v1/sub-accounts", body: parsed, model: Zavudev::Models::SubAccountCreateResponse, options: ) end |
#deactivate(id, request_options: {}) ⇒ Zavudev::Models::SubAccountDeactivateResponse
Deactivate a sub-account. Remaining balance is returned to the parent team and all API keys are revoked. Requires a parent project API key; sub-account API keys receive HTTP 403.
135 136 137 138 139 140 141 142 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 135 def deactivate(id, params = {}) @client.request( method: :delete, path: ["v1/sub-accounts/%1$s", id], model: Zavudev::Models::SubAccountDeactivateResponse, options: params[:request_options] ) end |
#get_balance(id, request_options: {}) ⇒ Zavudev::Models::SubAccountGetBalanceResponse
Get spending information for a sub-account. Returns the parent team’s balance, the sub-account’s total spending, and its credit limit (spending cap). Requires a parent project API key; sub-account API keys receive HTTP 403.
157 158 159 160 161 162 163 164 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 157 def get_balance(id, params = {}) @client.request( method: :get, path: ["v1/sub-accounts/%1$s/balance", id], model: Zavudev::Models::SubAccountGetBalanceResponse, options: params[:request_options] ) end |
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::SubAccount>
List sub-accounts for this team. Requires a parent project API key; sub-account API keys receive HTTP 403.
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 109 def list(params = {}) parsed, = Zavudev::SubAccountListParams.dump_request(params) query = Zavudev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/sub-accounts", query: query, page: Zavudev::Internal::Cursor, model: Zavudev::SubAccount, options: ) end |
#retrieve(id, request_options: {}) ⇒ Zavudev::Models::SubAccountRetrieveResponse
Get sub-account. Requires a parent project API key; sub-account API keys receive HTTP 403.
55 56 57 58 59 60 61 62 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 55 def retrieve(id, params = {}) @client.request( method: :get, path: ["v1/sub-accounts/%1$s", id], model: Zavudev::Models::SubAccountRetrieveResponse, options: params[:request_options] ) end |
#update(id, credit_limit: nil, external_id: nil, metadata: nil, name: nil, status: nil, request_options: {}) ⇒ Zavudev::Models::SubAccountUpdateResponse
Update sub-account. Requires a parent project API key; sub-account API keys receive HTTP 403.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/zavudev/resources/sub_accounts.rb', line 86 def update(id, params = {}) parsed, = Zavudev::SubAccountUpdateParams.dump_request(params) @client.request( method: :patch, path: ["v1/sub-accounts/%1$s", id], body: parsed, model: Zavudev::Models::SubAccountUpdateResponse, options: ) end |