Class: IbmCloudResourceController::ResourceManagerV2
- Inherits:
-
IBMCloudSdkCore::BaseService
- Object
- IBMCloudSdkCore::BaseService
- IbmCloudResourceController::ResourceManagerV2
- Includes:
- Concurrent::Async
- Defined in:
- lib/ibm_cloud_resource_controller/resource_manager_v2.rb
Overview
The Resource Manager V2 service.
Constant Summary collapse
- DEFAULT_SERVICE_NAME =
"resource_manager"
- DEFAULT_SERVICE_URL =
"https://resource-controller.cloud.ibm.com/v2"
Instance Method Summary collapse
-
#create_resource_group(name: nil, account_id: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Create a resource group.
-
#delete_resource_group(id: ) ⇒ nil
Delete a resource group.
-
#get_quota_definition(id: ) ⇒ IBMCloudSdkCore::DetailedResponse
Get a quota definition.
-
#get_resource_group(id: ) ⇒ IBMCloudSdkCore::DetailedResponse
Get a resource group.
-
#initialize(args) ⇒ ResourceManagerV2
constructor
Construct a new client for the Resource Manager service.
-
#list_quota_definitions ⇒ IBMCloudSdkCore::DetailedResponse
List quota definitions.
-
#list_resource_groups(account_id: nil, date: nil, name: nil, default: nil, include_deleted: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Get a list of all resource groups.
-
#update_resource_group(id: , name: nil, state: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Update a resource group.
Constructor Details
#initialize(args) ⇒ ResourceManagerV2
Construct a new client for the Resource Manager service.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 44 def initialize(args = {}) @__async_initialized__ = false defaults = {} defaults[:service_url] = DEFAULT_SERVICE_URL defaults[:service_name] = DEFAULT_SERVICE_NAME defaults[:authenticator] = nil user_service_url = args[:service_url] unless args[:service_url].nil? args = defaults.merge(args) super @service_url = user_service_url unless user_service_url.nil? end |
Instance Method Details
#create_resource_group(name: nil, account_id: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Create a resource group. Create a resource group in an account to organize your account resources in
customizable groupings so that you can quickly assign users access to more than
one resource at a time. To learn what makes a good resource group strategy, see
[Best practices for organizing
resources](https://cloud.ibm.com/docs/account?topic=account-account_setup). A
default resource group is created when an account is created. If you have a Lite
account or 30-day trial, you cannot create extra resource groups, but you can
rename your default resource group. If you have a Pay-As-You-Go or Subscription
account, you can create multiple resource groups. You must be assigned an IAM
policy with the Administrator role on All Account Management services to create
extra resource groups.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 119 def create_resource_group(name: nil, account_id: nil) headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "create_resource_group") headers.merge!(sdk_headers) data = { "name" => name, "account_id" => account_id } method_url = "/resource_groups" response = request( method: "POST", url: method_url, headers: headers, json: data, accept_json: true ) response end |
#delete_resource_group(id: ) ⇒ nil
Delete a resource group. Delete a resource group by the alias ID. You can delete a resource group only if
the targeted resource group does not contain any resources or if it is not a
default resource group. When a user creates an account, a default resource group
is created in the account. If you want to delete a resource group that contains
resources, first [delete the resource
instances](https://cloud.ibm.com/apidocs/resource-controller/resource-controller?code=java#delete-resource-instance).
Then, delete the resource group when all resource instances in the group are
deleted.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 220 def delete_resource_group(id:) raise ArgumentError.new("id must be provided") if id.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "delete_resource_group") headers.merge!(sdk_headers) method_url = "/resource_groups/%s" % [ERB::Util.url_encode(id)] request( method: "DELETE", url: method_url, headers: headers, accept_json: false ) nil end |
#get_quota_definition(id: ) ⇒ IBMCloudSdkCore::DetailedResponse
Get a quota definition. Call this method to retrieve information about a particular quota by passing the
quota ID. The response can be used to identify the quota type, Standard or Paid.
Information about available resources, such as number of apps, number of service
instances, and memory, are returned in the response. Quotas for a resource group
limit the number of apps, instances, and memory allowed for that specific resource
group. Each resource group that you have on your account has a specific set of
quotas. Standard quotas are for resource groups that are created by users with a
Lite account, and Pay-As-You-Go quotas are for resource groups that are created
with a Pay-As-You-Go account.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 284 def get_quota_definition(id:) raise ArgumentError.new("id must be provided") if id.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "get_quota_definition") headers.merge!(sdk_headers) method_url = "/quota_definitions/%s" % [ERB::Util.url_encode(id)] response = request( method: "GET", url: method_url, headers: headers, accept_json: true ) response end |
#get_resource_group(id: ) ⇒ IBMCloudSdkCore::DetailedResponse
Get a resource group. Retrieve a resource group by alias ID. Call this method to get details about a
particular resource group, like the name of the resource group, associated quotas,
whether the state is active, the resource group ID and the CRN. The `id` returned
in the response can be used to [create a resource instance
later](https://cloud.ibm.com/apidocs/resource-controller/resource-controller?code=java#create-resource-instance).
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 152 def get_resource_group(id:) raise ArgumentError.new("id must be provided") if id.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "get_resource_group") headers.merge!(sdk_headers) method_url = "/resource_groups/%s" % [ERB::Util.url_encode(id)] response = request( method: "GET", url: method_url, headers: headers, accept_json: true ) response end |
#list_quota_definitions ⇒ IBMCloudSdkCore::DetailedResponse
List quota definitions. Get a list of all quota definitions. Quotas for a resource group limit the number
of apps, instances, and memory allowed for that specific resource group. Each
resource group that you have on your account has a specific set of quotas.
Standard quotas are for resource groups that are created by users with a Lite
account, and Pay-As-You-Go quotas are for resource groups that are created with a
Pay-As-You-Go account. This method provides list of all available quota
definitions.
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 253 def list_quota_definitions headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "list_quota_definitions") headers.merge!(sdk_headers) method_url = "/quota_definitions" response = request( method: "GET", url: method_url, headers: headers, accept_json: true ) response end |
#list_resource_groups(account_id: nil, date: nil, name: nil, default: nil, include_deleted: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Get a list of all resource groups. Call this method to retrieve information about all resource groups and associated
quotas in an account. The `id` returned in the response can be used to [create a
resource instance
later](https://cloud.ibm.com/apidocs/resource-controller/resource-controller?code=java#create-resource-instance).
The response can be filtered based on queryParams such as `account_id`, `name`,
`default`, and more to narrow your search.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 76 def list_resource_groups(account_id: nil, date: nil, name: nil, default: nil, include_deleted: nil) headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "list_resource_groups") headers.merge!(sdk_headers) params = { "account_id" => account_id, "date" => date, "name" => name, "default" => default, "include_deleted" => include_deleted } method_url = "/resource_groups" response = request( method: "GET", url: method_url, headers: headers, params: params, accept_json: true ) response end |
#update_resource_group(id: , name: nil, state: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Update a resource group. Update a resource group by the alias ID. Call this method to update information
about an existing resource group. You can rename a resource group and activate or
suspend a particular resource group. To update a resource group, users need to be
assigned with IAM policies with the Editor role or higher.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/ibm_cloud_resource_controller/resource_manager_v2.rb', line 182 def update_resource_group(id:, name: nil, state: nil) raise ArgumentError.new("id must be provided") if id.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("resource_manager", "V2", "update_resource_group") headers.merge!(sdk_headers) data = { "name" => name, "state" => state } method_url = "/resource_groups/%s" % [ERB::Util.url_encode(id)] response = request( method: "PATCH", url: method_url, headers: headers, json: data, accept_json: true ) response end |