Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions ibm_secrets_manager_sdk/secrets_manager_v2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

# (C) Copyright IBM Corp. 2025.
# (C) Copyright IBM Corp. 2026.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# IBM OpenAPI SDK Code Generator Version: 3.107.0-b68ebf7a-20250811-145645
# IBM OpenAPI SDK Code Generator Version: 3.114.0-a902401e-20260427-192904

"""
With IBM Cloud® Secrets Manager, you can create, lease, and centrally manage secrets that
Expand Down Expand Up @@ -80,7 +80,7 @@ def construct_service_url(

:param str instance_id: (optional) The Secrets Manager Instance ID assigned by the service provider
(default 'provide-here-your-smgr-instanceuuid')
:param str region: (optional) The region where you provisioned your Secrets Manager Instance. Available values: us-south, us-east, au-syd, jp-osa, jp-tok, eu-de, eu-gb, eu-es, ca-tor, ca-mon, br-sao
:param str region: (optional) The region where you provisioned your Secrets Manager Instance. Available values: us-south, us-east, au-syd, jp-osa, jp-tok, eu-de, eu-gb, eu-es, ca-tor, ca-mon, br-sao, in-che
(default 'us-south')
:return: The formatted URL with all variable placeholders replaced by values.
:rtype: str
Expand Down Expand Up @@ -3811,7 +3811,7 @@ class CustomCredentialsNewCredentials:
:param str id: An identifier of credentials in the credentials provider that is
used by the custom credentials secret type.
:param dict payload: The fields that can be passed to and from the custom
credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
credentials engine. Allowed types are string, integer, and boolean.
"""

def __init__(
Expand All @@ -3825,7 +3825,7 @@ def __init__(
:param str id: An identifier of credentials in the credentials provider
that is used by the custom credentials secret type.
:param dict payload: The fields that can be passed to and from the custom
credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
credentials engine. Allowed types are string, integer, and boolean.
"""
self.id = id
self.payload = payload
Expand Down Expand Up @@ -11429,9 +11429,9 @@ class CustomCredentialsSecret(Secret):
(automatic or manual) for the secret failed.
:param str configuration: The name of the custom credentials configuration.
:param dict parameters: (optional) The fields that can be passed to and from the
custom credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
custom credentials engine. Allowed types are string, integer, and boolean.
:param dict credentials_content: The fields that can be passed to and from the
custom credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
custom credentials engine. Allowed types are string, integer, and boolean.
"""

def __init__(
Expand Down Expand Up @@ -11486,8 +11486,8 @@ def __init__(
:param int versions_total: The number of versions of your secret.
:param str configuration: The name of the custom credentials configuration.
:param dict credentials_content: The fields that can be passed to and from
the custom credentials engine. Allowed types are 'string', 'integer' and
'boolean'.
the custom credentials engine. Allowed types are string, integer, and
boolean.
:param datetime retrieved_at: (optional) The date when the data of the
secret was last retrieved. The date format follows RFC 3339. Epoch date if
there is no record of secret data retrieval.
Expand Down Expand Up @@ -11522,8 +11522,8 @@ def __init__(
:param str last_failed_task_id: (optional) A Secret Manager task
identifier.
:param dict parameters: (optional) The fields that can be passed to and
from the custom credentials engine. Allowed types are 'string', 'integer'
and 'boolean'.
from the custom credentials engine. Allowed types are string, integer, and
boolean.
"""
# pylint: disable=super-init-not-called
self.created_by = created_by
Expand Down Expand Up @@ -11840,7 +11840,7 @@ class CustomCredentialsSecretMetadata(SecretMetadata):
(automatic or manual) for the secret failed.
:param str configuration: The name of the custom credentials configuration.
:param dict parameters: (optional) The fields that can be passed to and from the
custom credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
custom credentials engine. Allowed types are string, integer, and boolean.
"""

def __init__(
Expand Down Expand Up @@ -11927,8 +11927,8 @@ def __init__(
:param str last_failed_task_id: (optional) A Secret Manager task
identifier.
:param dict parameters: (optional) The fields that can be passed to and
from the custom credentials engine. Allowed types are 'string', 'integer'
and 'boolean'.
from the custom credentials engine. Allowed types are string, integer, and
boolean.
"""
# pylint: disable=super-init-not-called
self.created_by = created_by
Expand Down Expand Up @@ -12196,7 +12196,7 @@ class CustomCredentialsSecretMetadataPatch(SecretMetadataPatch):
rotation. For the custom_credentials secret type, the TTL field is optional. The
minimum duration is 1 day. The maximum is 90 days.
:param dict parameters: (optional) The parameters that are passed to custom
credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
credentials engine. Allowed types are string, integer, and boolean.
"""

def __init__(
Expand Down Expand Up @@ -12244,7 +12244,7 @@ def __init__(
secret type, the TTL field is optional. The minimum duration is 1 day. The
maximum is 90 days.
:param dict parameters: (optional) The parameters that are passed to custom
credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
credentials engine. Allowed types are string, integer, and boolean.
"""
# pylint: disable=super-init-not-called
self.custom_metadata = custom_metadata
Expand Down Expand Up @@ -12363,7 +12363,7 @@ class CustomCredentialsSecretPrototype(SecretPrototype):
a user can customize.
:param str configuration: The name of the custom credentials configuration.
:param dict parameters: (optional) The parameters that are passed to custom
credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
credentials engine. Allowed types are string, integer, and boolean.
"""

def __init__(
Expand Down Expand Up @@ -12423,7 +12423,7 @@ def __init__(
:param dict version_custom_metadata: (optional) The secret version metadata
that a user can customize.
:param dict parameters: (optional) The parameters that are passed to custom
credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
credentials engine. Allowed types are string, integer, and boolean.
"""
# pylint: disable=super-init-not-called
self.custom_metadata = custom_metadata
Expand Down Expand Up @@ -12577,7 +12577,7 @@ class CustomCredentialsSecretVersion(SecretVersion):
:param str credentials_id: (optional) Credentials created by the custom
credentials system.
:param dict credentials_content: The fields that can be passed to and from the
custom credentials engine. Allowed types are 'string', 'integer' and 'boolean'.
custom credentials engine. Allowed types are string, integer, and boolean.
"""

def __init__(
Expand Down Expand Up @@ -12615,8 +12615,8 @@ def __init__(
available in this secret version.
:param str secret_id: A UUID identifier.
:param dict credentials_content: The fields that can be passed to and from
the custom credentials engine. Allowed types are 'string', 'integer' and
'boolean'.
the custom credentials engine. Allowed types are string, integer, and
boolean.
:param bool auto_rotated: (optional) Indicates whether the version of the
secret was created by automatic rotation.
:param str alias: (optional) A human-readable alias that describes the
Expand Down
5 changes: 2 additions & 3 deletions test/integration/test_manual_secrets_manager_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def config_private_cert_engine(secrets_manager_service):
if "already exists" not in err.message:
raise AssertionError("Failed to create template_configuration")


def create_private_certificate(secrets_manager_service, secret_name):
secret_prototype_model = {
'secret_type': 'private_cert',
Expand Down Expand Up @@ -191,6 +190,7 @@ def setup_class(cls):
)
assert cls.secrets_manager_service is not None


cls.config = read_external_sources(
SecretsManagerV2.DEFAULT_SERVICE_NAME)
assert cls.config is not None
Expand All @@ -202,8 +202,7 @@ def setup_class(cls):
cls.privateCertSecretId2 = create_private_certificate(cls.secrets_manager_service, "private-cert-secret2")

# IAM Credentials tests setup
cls.iamSecretId = config_iam_credentials_engine(cls.secrets_manager_service, cls.config['APIKEY'],
cls.config['ACCESS_GROUP'])
cls.iamSecretId = config_iam_credentials_engine(cls.secrets_manager_service, cls.config['APIKEY'], cls.config['ACCESS_GROUP'])

print('Setup complete.')

Expand Down
114 changes: 57 additions & 57 deletions test/integration/test_secrets_manager_v2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (C) Copyright IBM Corp. 2025.
# (C) Copyright IBM Corp. 2026.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -112,6 +112,57 @@ def test_create_secret(self):
secret_id_for_get_secret_link = secret['id']
secret_id_for_get_secret_version_link = secret['id']

@needscredentials
def test_list_secrets(self):
response = self.secrets_manager_service.list_secrets(
offset=0,
limit=200,
sort='created_at',
search='example',
groups=['default', 'cac40995-c37a-4dcb-9506-472869077634'],
secret_types=['arbitrary', 'kv'],
match_all_labels=['dev', 'us-south'],
)

assert response.get_status_code() == 200
secret_metadata_paginated_collection = response.get_result()
assert secret_metadata_paginated_collection is not None

@needscredentials
def test_list_secrets_with_pager(self):
all_results = []

# Test get_next().
pager = SecretsPager(
client=self.secrets_manager_service,
limit=10,
sort='created_at',
search='example',
groups=['default', 'cac40995-c37a-4dcb-9506-472869077634'],
secret_types=['arbitrary', 'kv'],
match_all_labels=['dev', 'us-south'],
)
while pager.has_next():
next_page = pager.get_next()
assert next_page is not None
all_results.extend(next_page)

# Test get_all().
pager = SecretsPager(
client=self.secrets_manager_service,
limit=10,
sort='created_at',
search='example',
groups=['default', 'cac40995-c37a-4dcb-9506-472869077634'],
secret_types=['arbitrary', 'kv'],
match_all_labels=['dev', 'us-south'],
)
all_items = pager.get_all()
assert all_items is not None

assert len(all_results) == len(all_items)
print(f'\nlist_secrets() returned a total of {len(all_results)} items(s) using SecretsPager.')

@needscredentials
def test_update_secret_metadata(self):
global secret_name_link
Expand Down Expand Up @@ -246,57 +297,6 @@ def test_update_secret_group(self):
secret_group = response.get_result()
assert secret_group is not None

@needscredentials
def test_list_secrets(self):
response = self.secrets_manager_service.list_secrets(
offset=0,
limit=200,
sort='created_at',
search='example',
groups=['default', 'cac40995-c37a-4dcb-9506-472869077634'],
secret_types=['arbitrary', 'kv'],
match_all_labels=['dev', 'us-south'],
)

assert response.get_status_code() == 200
secret_metadata_paginated_collection = response.get_result()
assert secret_metadata_paginated_collection is not None

@needscredentials
def test_list_secrets_with_pager(self):
all_results = []

# Test get_next().
pager = SecretsPager(
client=self.secrets_manager_service,
limit=10,
sort='created_at',
search='example',
groups=['default', 'cac40995-c37a-4dcb-9506-472869077634'],
secret_types=['arbitrary', 'kv'],
match_all_labels=['dev', 'us-south'],
)
while pager.has_next():
next_page = pager.get_next()
assert next_page is not None
all_results.extend(next_page)

# Test get_all().
pager = SecretsPager(
client=self.secrets_manager_service,
limit=10,
sort='created_at',
search='example',
groups=['default', 'cac40995-c37a-4dcb-9506-472869077634'],
secret_types=['arbitrary', 'kv'],
match_all_labels=['dev', 'us-south'],
)
all_items = pager.get_all()
assert all_items is not None

assert len(all_results) == len(all_items)
print(f'\nlist_secrets() returned a total of {len(all_results)} items(s) using SecretsPager.')

@needscredentials
def test_get_secret(self):
response = self.secrets_manager_service.get_secret(
Expand Down Expand Up @@ -678,11 +678,6 @@ def test_delete_secret_group(self):

assert response.get_status_code() == 204

# The integration test for delete_secret_version_data has been explicitly excluded from generation.
# A test for this operation must be developed manually.
# @needscredentials
# def test_delete_secret_version_data(self):

@needscredentials
def test_delete_secret_locks_bulk(self):
response = self.secrets_manager_service.delete_secret_locks_bulk(
Expand Down Expand Up @@ -715,6 +710,11 @@ def test_delete_secret(self):

assert response.get_status_code() == 204

# The integration test for delete_secret_version_data has been explicitly excluded from generation.
# A test for this operation must be developed manually.
# @needscredentials
# def test_delete_secret_version_data(self):

# The integration test for delete_secret_task has been explicitly excluded from generation.
# A test for this operation must be developed manually.
# @needscredentials
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_secrets_manager_v2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (C) Copyright IBM Corp. 2025.
# (C) Copyright IBM Corp. 2026.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading