Skip to content

Commit eed85f5

Browse files
authored
Merge pull request #12 from IBM/update
Update API
2 parents 302c727 + 550c28f commit eed85f5

File tree

4 files changed

+323
-57
lines changed

4 files changed

+323
-57
lines changed

ibm_secrets_manager_sdk/secrets_manager_v1.py

Lines changed: 175 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# IBM OpenAPI SDK Code Generator Version: 3.29.0-cd9ba74f-20210305-183535
17+
# IBM OpenAPI SDK Code Generator Version: 3.30.0-bd714324-20210406-200538
1818

1919
"""
2020
With IBM Cloud® Secrets Manager, you can create, lease, and centrally manage secrets that
@@ -30,7 +30,7 @@
3030
from ibm_cloud_sdk_core import BaseService, DetailedResponse
3131
from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
3232
from ibm_cloud_sdk_core.get_authenticator import get_authenticator_from_environment
33-
from ibm_cloud_sdk_core.utils import convert_model, datetime_to_string, string_to_datetime
33+
from ibm_cloud_sdk_core.utils import convert_list, convert_model, datetime_to_string, string_to_datetime
3434

3535
from .common import get_sdk_headers
3636

@@ -100,6 +100,8 @@ def put_config(self,
100100
raise ValueError('secret_type must be provided')
101101
if engine_config_one_of is None:
102102
raise ValueError('engine_config_one_of must be provided')
103+
if isinstance(engine_config_one_of, EngineConfigOneOf):
104+
engine_config_one_of = convert_model(engine_config_one_of)
103105
headers = {}
104106
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
105107
service_version='V1',
@@ -136,7 +138,7 @@ def get_config(self,
136138
:param str secret_type: The secret type.
137139
:param dict headers: A `dict` containing the request headers
138140
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
139-
:rtype: DetailedResponse with `dict` result representing a `EngineConfigOneOf` object
141+
:rtype: DetailedResponse with `dict` result representing a `GetConfig` object
140142
"""
141143

142144
if secret_type is None:
@@ -653,6 +655,7 @@ def list_all_secrets(self,
653655
offset: int = None,
654656
search: str = None,
655657
sort_by: str = None,
658+
groups: List[str] = None,
656659
**kwargs
657660
) -> DetailedResponse:
658661
"""
@@ -682,6 +685,13 @@ def list_all_secrets(self,
682685
field.
683686
**Usage:** To sort a list of secrets by their creation date, use
684687
`../secrets/{secret-type}?sort_by=creation_date`.
688+
:param List[str] groups: (optional) Filter secrets by groups.
689+
You can apply multiple filters by using a comma-separated list of secret
690+
group IDs. If you need to filter secrets that are in the default secret
691+
group, use the `default` keyword.
692+
**Usage:** To retrieve a list of secrets that are associated with an
693+
existing secret group or the default group, use
694+
`../secrets?groups={secret_group_ID},default`.
685695
:param dict headers: A `dict` containing the request headers
686696
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
687697
:rtype: DetailedResponse with `dict` result representing a `ListSecrets` object
@@ -697,7 +707,8 @@ def list_all_secrets(self,
697707
'limit': limit,
698708
'offset': offset,
699709
'search': search,
700-
'sort_by': sort_by
710+
'sort_by': sort_by,
711+
'groups': convert_list(groups)
701712
}
702713

703714
if 'headers' in kwargs:
@@ -777,7 +788,7 @@ def update_secret(self,
777788
:param str secret_type: The secret type.
778789
:param str id: The v4 UUID that uniquely identifies the secret.
779790
:param str action: The action to perform on the specified secret.
780-
:param SecretActionOneOf secret_action_one_of: The base request for
791+
:param SecretActionOneOf secret_action_one_of: The base request body for
781792
invoking an action on a secret.
782793
:param dict headers: A `dict` containing the request headers
783794
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
@@ -792,6 +803,8 @@ def update_secret(self,
792803
raise ValueError('action must be provided')
793804
if secret_action_one_of is None:
794805
raise ValueError('secret_action_one_of must be provided')
806+
if isinstance(secret_action_one_of, SecretActionOneOf):
807+
secret_action_one_of = convert_model(secret_action_one_of)
795808
headers = {}
796809
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
797810
service_version='V1',
@@ -1329,6 +1342,76 @@ def __init__(self) -> None:
13291342
raise Exception(msg)
13301343

13311344

1345+
class GetConfig():
1346+
"""
1347+
Configuration that is used to generate IAM credentials.
1348+
1349+
:attr CollectionMetadata metadata: The metadata that describes the resource
1350+
array.
1351+
:attr List[IAMSecretEngineRootConfig] resources: A collection of resources.
1352+
"""
1353+
1354+
def __init__(self,
1355+
metadata: 'CollectionMetadata',
1356+
resources: List['IAMSecretEngineRootConfig']) -> None:
1357+
"""
1358+
Initialize a GetConfig object.
1359+
1360+
:param CollectionMetadata metadata: The metadata that describes the
1361+
resource array.
1362+
:param List[IAMSecretEngineRootConfig] resources: A collection of
1363+
resources.
1364+
"""
1365+
self.metadata = metadata
1366+
self.resources = resources
1367+
1368+
@classmethod
1369+
def from_dict(cls, _dict: Dict) -> 'GetConfig':
1370+
"""Initialize a GetConfig object from a json dictionary."""
1371+
args = {}
1372+
if 'metadata' in _dict:
1373+
args['metadata'] = CollectionMetadata.from_dict(_dict.get('metadata'))
1374+
else:
1375+
raise ValueError('Required property \'metadata\' not present in GetConfig JSON')
1376+
if 'resources' in _dict:
1377+
args['resources'] = [IAMSecretEngineRootConfig.from_dict(x) for x in _dict.get('resources')]
1378+
else:
1379+
raise ValueError('Required property \'resources\' not present in GetConfig JSON')
1380+
return cls(**args)
1381+
1382+
@classmethod
1383+
def _from_dict(cls, _dict):
1384+
"""Initialize a GetConfig object from a json dictionary."""
1385+
return cls.from_dict(_dict)
1386+
1387+
def to_dict(self) -> Dict:
1388+
"""Return a json dictionary representing this model."""
1389+
_dict = {}
1390+
if hasattr(self, 'metadata') and self.metadata is not None:
1391+
_dict['metadata'] = self.metadata.to_dict()
1392+
if hasattr(self, 'resources') and self.resources is not None:
1393+
_dict['resources'] = [x.to_dict() for x in self.resources]
1394+
return _dict
1395+
1396+
def _to_dict(self):
1397+
"""Return a json dictionary representing this model."""
1398+
return self.to_dict()
1399+
1400+
def __str__(self) -> str:
1401+
"""Return a `str` version of this GetConfig object."""
1402+
return json.dumps(self.to_dict(), indent=2)
1403+
1404+
def __eq__(self, other: 'GetConfig') -> bool:
1405+
"""Return `true` when self and other are equal, false otherwise."""
1406+
if not isinstance(other, self.__class__):
1407+
return False
1408+
return self.__dict__ == other.__dict__
1409+
1410+
def __ne__(self, other: 'GetConfig') -> bool:
1411+
"""Return `true` when self and other are not equal, false otherwise."""
1412+
return not self == other
1413+
1414+
13321415
class GetSecret():
13331416
"""
13341417
The base schema for retrieving a secret.
@@ -1551,6 +1634,82 @@ class TypeEnum(str, Enum):
15511634
APPLICATION_VND_IBM_SECRETS_MANAGER_SECRET_POLICY_JSON = 'application/vnd.ibm.secrets-manager.secret.policy+json'
15521635

15531636

1637+
class IAMSecretEngineRootConfig():
1638+
"""
1639+
Configuration that is used to generate IAM credentials.
1640+
1641+
:attr str api_key: An IBM Cloud API key that has the capability to create and
1642+
manage service IDs.
1643+
The API key must be assigned the Editor platform role on the Access Groups
1644+
Service and the Operator platform role on the IAM Identity Service. For more
1645+
information, see [Enabling the IAM secrets
1646+
engine](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-secret-engines#configure-iam-engine).
1647+
:attr str api_key_hash: (optional) The hash value of the IBM Cloud API key that
1648+
is used to create and manage service IDs.
1649+
"""
1650+
1651+
def __init__(self,
1652+
api_key: str,
1653+
*,
1654+
api_key_hash: str = None) -> None:
1655+
"""
1656+
Initialize a IAMSecretEngineRootConfig object.
1657+
1658+
:param str api_key: An IBM Cloud API key that has the capability to create
1659+
and manage service IDs.
1660+
The API key must be assigned the Editor platform role on the Access Groups
1661+
Service and the Operator platform role on the IAM Identity Service. For
1662+
more information, see [Enabling the IAM secrets
1663+
engine](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-secret-engines#configure-iam-engine).
1664+
"""
1665+
self.api_key = api_key
1666+
self.api_key_hash = api_key_hash
1667+
1668+
@classmethod
1669+
def from_dict(cls, _dict: Dict) -> 'IAMSecretEngineRootConfig':
1670+
"""Initialize a IAMSecretEngineRootConfig object from a json dictionary."""
1671+
args = {}
1672+
if 'api_key' in _dict:
1673+
args['api_key'] = _dict.get('api_key')
1674+
else:
1675+
raise ValueError('Required property \'api_key\' not present in IAMSecretEngineRootConfig JSON')
1676+
if 'api_key_hash' in _dict:
1677+
args['api_key_hash'] = _dict.get('api_key_hash')
1678+
return cls(**args)
1679+
1680+
@classmethod
1681+
def _from_dict(cls, _dict):
1682+
"""Initialize a IAMSecretEngineRootConfig object from a json dictionary."""
1683+
return cls.from_dict(_dict)
1684+
1685+
def to_dict(self) -> Dict:
1686+
"""Return a json dictionary representing this model."""
1687+
_dict = {}
1688+
if hasattr(self, 'api_key') and self.api_key is not None:
1689+
_dict['api_key'] = self.api_key
1690+
if hasattr(self, 'api_key_hash') and getattr(self, 'api_key_hash') is not None:
1691+
_dict['api_key_hash'] = getattr(self, 'api_key_hash')
1692+
return _dict
1693+
1694+
def _to_dict(self):
1695+
"""Return a json dictionary representing this model."""
1696+
return self.to_dict()
1697+
1698+
def __str__(self) -> str:
1699+
"""Return a `str` version of this IAMSecretEngineRootConfig object."""
1700+
return json.dumps(self.to_dict(), indent=2)
1701+
1702+
def __eq__(self, other: 'IAMSecretEngineRootConfig') -> bool:
1703+
"""Return `true` when self and other are equal, false otherwise."""
1704+
if not isinstance(other, self.__class__):
1705+
return False
1706+
return self.__dict__ == other.__dict__
1707+
1708+
def __ne__(self, other: 'IAMSecretEngineRootConfig') -> bool:
1709+
"""Return `true` when self and other are not equal, false otherwise."""
1710+
return not self == other
1711+
1712+
15541713
class ListSecrets():
15551714
"""
15561715
The base schema for listing secrets.
@@ -1942,6 +2101,11 @@ class SecretMetadata():
19422101
For `iam_credentials` secrets, the TTL defines for how long each generated API
19432102
key remains valid. The value can be either an integer that specifies the number
19442103
of seconds, or the string representation of a duration, such as `120m` or `24h`.
2104+
:attr bool reuse_api_key: (optional) For `iam_credentials` secrets, this field
2105+
controls whether to use the same service ID and API key for future read
2106+
operations on this secret. If set to `true`, the service reuses the current
2107+
credentials. If set to `false`, a new service ID and API key is generated each
2108+
time that the secret is read or accessed.
19452109
:attr str crn: (optional) The Cloud Resource Name (CRN) that uniquely identifies
19462110
the resource.
19472111
:attr datetime creation_date: (optional) The date the secret was created. The
@@ -1964,6 +2128,7 @@ def __init__(self,
19642128
secret_type: str = None,
19652129
expiration_date: datetime = None,
19662130
ttl: object = None,
2131+
reuse_api_key: bool = None,
19672132
crn: str = None,
19682133
creation_date: datetime = None,
19692134
created_by: str = None,
@@ -2009,6 +2174,7 @@ def __init__(self,
20092174
self.secret_type = secret_type
20102175
self.expiration_date = expiration_date
20112176
self.ttl = ttl
2177+
self.reuse_api_key = reuse_api_key
20122178
self.crn = crn
20132179
self.creation_date = creation_date
20142180
self.created_by = created_by
@@ -2040,6 +2206,8 @@ def from_dict(cls, _dict: Dict) -> 'SecretMetadata':
20402206
args['expiration_date'] = string_to_datetime(_dict.get('expiration_date'))
20412207
if 'ttl' in _dict:
20422208
args['ttl'] = _dict.get('ttl')
2209+
if 'reuse_api_key' in _dict:
2210+
args['reuse_api_key'] = _dict.get('reuse_api_key')
20432211
if 'crn' in _dict:
20442212
args['crn'] = _dict.get('crn')
20452213
if 'creation_date' in _dict:
@@ -2078,6 +2246,8 @@ def to_dict(self) -> Dict:
20782246
_dict['expiration_date'] = datetime_to_string(self.expiration_date)
20792247
if hasattr(self, 'ttl') and self.ttl is not None:
20802248
_dict['ttl'] = self.ttl
2249+
if hasattr(self, 'reuse_api_key') and getattr(self, 'reuse_api_key') is not None:
2250+
_dict['reuse_api_key'] = getattr(self, 'reuse_api_key')
20812251
if hasattr(self, 'crn') and getattr(self, 'crn') is not None:
20822252
_dict['crn'] = getattr(self, 'crn')
20832253
if hasattr(self, 'creation_date') and getattr(self, 'creation_date') is not None:

ibm_secrets_manager_sdk/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"""
1818
Version of ibm_secrets_manager_sdk
1919
"""
20-
__version__ = '0.1.0'
20+
__version__ = '0.1.1'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import sys
2020
import pkg_resources
2121

22-
__version__ = '0.1.0'
22+
__version__ = '0.1.1'
2323
PACKAGE_NAME = 'ibm_secrets_manager_sdk'
2424
PACKAGE_DESC = 'IBM Cloud Secrets Manager Python SDK'
2525

0 commit comments

Comments
 (0)