1+ # coding: utf-8
2+
3+ # (C) Copyright IBM Corp. 2026.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # IBM OpenAPI SDK Code Generator Version: 3.70.0-7df966bf-20230419-195904
18+
19+ """
20+ Manage the lifecycle of your users using Account Management APIs.
21+
22+ API Version: 1.0
23+ """
24+
25+ from typing import Dict , List
26+ import json
27+
28+ from ibm_cloud_sdk_core import BaseService , DetailedResponse , get_query_param
29+ from ibm_cloud_sdk_core .authenticators .authenticator import Authenticator
30+ from ibm_cloud_sdk_core .get_authenticator import get_authenticator_from_environment
31+ from ibm_cloud_sdk_core .utils import convert_model
32+
33+ from .common import get_sdk_headers
34+
35+ class AccountManagementV4 (BaseService ):
36+ """The Account Management V4 service."""
37+
38+ DEFAULT_SERVICE_URL = 'https://accounts.cloud.ibm.com'
39+ DEFAULT_SERVICE_NAME = 'account_management'
40+
41+ @classmethod
42+ def new_instance (
43+ cls ,
44+ service_name : str = DEFAULT_SERVICE_NAME ,
45+ ) -> 'AccountManagementV4' :
46+ """
47+ Return a new client for the account management service using the specified
48+ parameters and external configuration.
49+ """
50+ authenticator = get_authenticator_from_environment (service_name )
51+ service = cls (authenticator )
52+ service .configure_service (service_name )
53+ return service
54+
55+ def __init__ (
56+ self ,
57+ authenticator : Authenticator = None ,
58+ ) -> None :
59+ """
60+ Construct a new client for the Account Management service.
61+
62+ :param Authenticator authenticator: The authenticator specifies the authentication mechanism.
63+ Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
64+ about initializing the authenticator of your choice.
65+ """
66+ BaseService .__init__ (self , service_url = self .DEFAULT_SERVICE_URL , authenticator = authenticator )
67+
68+ #########################
69+ # Accounts
70+ #########################
71+ def get_account_info (
72+ self ,
73+ account_id : str ,
74+ ** kwargs ,
75+ ) -> DetailedResponse :
76+ """
77+ Get account info.
78+
79+ Retrieve an account info by the account id in your account. You can use the
80+ IAM service token or an account user token for authorization. To use this method, the
81+ requesting user or service ID must have at least the viewer, editor, or
82+ administrator role on the Account management service.
83+
84+ :param str account_id: The account ID of the specified account.
85+ :param dict headers: A `dict` containing the request headers
86+ :return: A `DetailedResponse` containing the result, headers and HTTP status code.
87+ :rtype: DetailedResponse with `dict` result representing a `accountInfo` object
88+ """
89+
90+ if not account_id :
91+ raise ValueError ('account_id must be provided' )
92+ headers = {}
93+ sdk_headers = get_sdk_headers (
94+ service_name = self .DEFAULT_SERVICE_NAME ,
95+ service_version = 'V4' ,
96+ operation_id = 'get_account_info' ,
97+ )
98+ headers .update (sdk_headers )
99+
100+ if 'headers' in kwargs :
101+ headers .update (kwargs .get ('headers' ))
102+ del kwargs ['headers' ]
103+ headers ['Accept' ] = 'application/json'
104+
105+ path_param_keys = ['account_id' ]
106+ path_param_values = self .encode_path_vars (account_id )
107+ path_param_dict = dict (zip (path_param_keys , path_param_values ))
108+ url = '/v4/accounts/{account_id}' .format (** path_param_dict )
109+ request = self .prepare_request (
110+ method = 'GET' ,
111+ url = url ,
112+ headers = headers ,
113+ )
114+
115+ response = self .send (request , ** kwargs )
116+ return response
0 commit comments