Class: IbmCloudGlobalTagging::GlobalTaggingV1
- Inherits:
-
IBMCloudSdkCore::BaseService
- Object
- IBMCloudSdkCore::BaseService
- IbmCloudGlobalTagging::GlobalTaggingV1
- Includes:
- Concurrent::Async
- Defined in:
- lib/ibm_cloud_global_tagging/global_tagging_v1.rb
Overview
The global_tagging V1 service.
Constant Summary collapse
- DEFAULT_SERVICE_NAME =
"global_tagging"
- DEFAULT_SERVICE_URL =
"https://tags.global-search-tagging.cloud.ibm.com"
Instance Method Summary collapse
-
#attach_tag(resources: , tag_name: nil, tag_names: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Attach tags.
-
#delete_tag(tag_name: , providers: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Delete an unused tag.
-
#delete_tag_all(providers: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Delete all unused tags.
-
#detach_tag(resources: , tag_name: nil, tag_names: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Detach tags.
-
#initialize(args) ⇒ GlobalTaggingV1
constructor
Construct a new client for the global_tagging service.
-
#list_tags(account_id: nil, tag_type: nil, full_data: nil, providers: nil, attached_to: nil, offset: nil, limit: nil, timeout: nil, order_by_name: nil, attached_only: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Get all tags.
Constructor Details
#initialize(args) ⇒ GlobalTaggingV1
Construct a new client for the global_tagging service.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ibm_cloud_global_tagging/global_tagging_v1.rb', line 50 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
#attach_tag(resources: , tag_name: nil, tag_names: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Attach tags. Attaches one or more tags to one or more resources. To attach a ‘user` tag on a
resource, you must have the access listed in the [Granting users access to tag
resources](https://cloud.ibm.com/docs/account?topic=account-access) documentation.
To attach a `service` tag, you must be an authorized service. If that is the case,
then you can attach a `service` tag with your registered `prefix` to any resource
in any account. The account ID must be set through the `account_id` query
parameter.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/ibm_cloud_global_tagging/global_tagging_v1.rb', line 221 def attach_tag(resources:, tag_name: nil, tag_names: nil, account_id: nil, tag_type: nil) raise ArgumentError.new("resources must be provided") if resources.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("global_tagging", "V1", "attach_tag") headers.merge!(sdk_headers) params = { "account_id" => account_id, "tag_type" => tag_type } data = { "resources" => resources, "tag_name" => tag_name, "tag_names" => tag_names } method_url = "/v3/tags/attach" response = request( method: "POST", url: method_url, headers: headers, params: params, json: data, accept_json: true ) response end |
#delete_tag(tag_name: , providers: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Delete an unused tag. Delete an existing tag. A tag can be deleted only if it is not attached to any
resource.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/ibm_cloud_global_tagging/global_tagging_v1.rb', line 175 def delete_tag(tag_name:, providers: nil, account_id: nil, tag_type: nil) raise ArgumentError.new("tag_name must be provided") if tag_name.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("global_tagging", "V1", "delete_tag") headers.merge!(sdk_headers) providers *= "," unless providers.nil? params = { "providers" => providers, "account_id" => account_id, "tag_type" => tag_type } method_url = "/v3/tags/%s" % [ERB::Util.url_encode(tag_name)] response = request( method: "DELETE", url: method_url, headers: headers, params: params, accept_json: true ) response end |
#delete_tag_all(providers: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Delete all unused tags. Delete the tags that are not attached to any resource.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/ibm_cloud_global_tagging/global_tagging_v1.rb', line 137 def delete_tag_all(providers: nil, account_id: nil, tag_type: nil) headers = { } sdk_headers = Common.new.get_sdk_headers("global_tagging", "V1", "delete_tag_all") headers.merge!(sdk_headers) params = { "providers" => providers, "account_id" => account_id, "tag_type" => tag_type } method_url = "/v3/tags" response = request( method: "DELETE", url: method_url, headers: headers, params: params, accept_json: true ) response end |
#detach_tag(resources: , tag_name: nil, tag_names: nil, account_id: nil, tag_type: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Detach tags. Detaches one or more tags from one or more resources. To detach a ‘user` tag on a
resource you must have the permissions listed in the [Granting users access to tag
resources](https://cloud.ibm.com/docs/account?topic=account-access) documentation.
To detach a `service` tag you must be an authorized Service. If that is the case,
then you can detach a `service` tag with your registered `prefix` from any
resource in any account. The account ID must be set through the `account_id` query
parameter.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/ibm_cloud_global_tagging/global_tagging_v1.rb', line 272 def detach_tag(resources:, tag_name: nil, tag_names: nil, account_id: nil, tag_type: nil) raise ArgumentError.new("resources must be provided") if resources.nil? headers = { } sdk_headers = Common.new.get_sdk_headers("global_tagging", "V1", "detach_tag") headers.merge!(sdk_headers) params = { "account_id" => account_id, "tag_type" => tag_type } data = { "resources" => resources, "tag_name" => tag_name, "tag_names" => tag_names } method_url = "/v3/tags/detach" response = request( method: "POST", url: method_url, headers: headers, params: params, json: data, accept_json: true ) response end |
#list_tags(account_id: nil, tag_type: nil, full_data: nil, providers: nil, attached_to: nil, offset: nil, limit: nil, timeout: nil, order_by_name: nil, attached_only: nil) ⇒ IBMCloudSdkCore::DetailedResponse
Get all tags. Lists all tags in a billing account. Use the ‘attached_to` parameter to return the
list of tags attached to the specified resource.
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 |
# File 'lib/ibm_cloud_global_tagging/global_tagging_v1.rb', line 94 def (account_id: nil, tag_type: nil, full_data: nil, providers: nil, attached_to: nil, offset: nil, limit: nil, timeout: nil, order_by_name: nil, attached_only: nil) headers = { } sdk_headers = Common.new.get_sdk_headers("global_tagging", "V1", "list_tags") headers.merge!(sdk_headers) providers *= "," unless providers.nil? params = { "account_id" => account_id, "tag_type" => tag_type, "full_data" => full_data, "providers" => providers, "attached_to" => attached_to, "offset" => offset, "limit" => limit, "timeout" => timeout, "order_by_name" => order_by_name, "attached_only" => attached_only } method_url = "/v3/tags" response = request( method: "GET", url: method_url, headers: headers, params: params, accept_json: true ) response end |