diff --git a/.gitignore b/.gitignore index 094a138..b4ec488 100644 --- a/.gitignore +++ b/.gitignore @@ -82,4 +82,11 @@ package-lock.json node_modules/ # ignore the generated integration test files, as they cannot be used without manual editing -test/integration/test_code_engine_v2.py \ No newline at end of file +test/integration/test_code_engine_v2.py + +# ignore the generated SSH and TLS keys and certs +test/integration/domain* +test/integration/sshkey* + +# API repo (pulled from Github) +api \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1a26441..9fd21dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,10 @@ notifications: matrix: include: - - python: '3.7' - - python: '3.8' - python: '3.9' - python: '3.10' + - python: '3.11' + - python: '3.12' install: - sudo apt-get update @@ -38,5 +38,5 @@ deploy: repository: https://upload.pypi.org/legacy skip_cleanup: true on: - python: '3.10' + python: '3.11' tags: true \ No newline at end of file diff --git a/Makefile b/Makefile index 2b349d4..496e8be 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ test-unit: python3 -m pytest --cov=ibm_code_engine_sdk test/unit test-int: - python3 -m pytest test/integration + ./test/integration/prepare-integration-tests.sh + python3 -m pytest --ignore test/integration/test_code_engine_v2.py test/integration test-examples: python3 -m pytest example diff --git a/README.md b/README.md index 447feb0..c37fa4c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -# Python SDK for IBM Cloud Code Engine 3.1.0 +# Python SDK for IBM Cloud Code Engine 4.0.0 Python client library to interact with the [IBM Cloud Code Engine API](https://cloud.ibm.com/apidocs/codeengine). @@ -41,8 +41,8 @@ IBM Cloud services: Service Name | Imported Class Name --- | --- -[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v3.1.0) | CodeEngineV2 -[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v3.1.0) | IbmCloudCodeEngineV1 +[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.0.0) | CodeEngineV2 +[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.0.0) | IbmCloudCodeEngineV1 ## Prerequisites @@ -50,20 +50,20 @@ Service Name | Imported Class Name * An [IBM Cloud][ibm-cloud-onboarding] account. * An IAM API key to allow the SDK to access your account. Create one [here](https://cloud.ibm.com/iam/apikeys). -* Python 3.7 or above. +* Python 3.9 or above. ## Installation To install, use `pip` or `easy_install`: ```bash -pip install --upgrade "ibm_code_engine_sdk>=3.1.0" +pip install --upgrade "ibm_code_engine_sdk>=4.0.0" ``` or ```bash -easy_install --upgrade "ibm_code_engine_sdk>=3.1.0" +easy_install --upgrade "ibm_code_engine_sdk>=4.0.0" ``` ## Using the SDK diff --git a/examples/test_code_engine_v2_examples.py b/examples/test_code_engine_v2_examples.py index 6054acc..60a20d0 100644 --- a/examples/test_code_engine_v2_examples.py +++ b/examples/test_code_engine_v2_examples.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2023. +# (C) Copyright IBM Corp. 2024. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,6 +22,8 @@ import pytest from ibm_code_engine_sdk.code_engine_v2 import * +version = '2024-09-24' + # # This file provides an example of how to use the Code Engine service. # @@ -81,6 +83,7 @@ def test_list_projects_example(self): """ try: print('\nlist_projects() result:') + # begin-list_projects all_results = [] @@ -106,6 +109,7 @@ def test_create_project_example(self): """ try: print('\ncreate_project() result:') + # begin-create_project response = code_engine_service.create_project( @@ -127,6 +131,7 @@ def test_get_project_example(self): """ try: print('\nget_project() result:') + # begin-get_project response = code_engine_service.get_project( @@ -148,6 +153,7 @@ def test_get_project_egress_ips_example(self): """ try: print('\nget_project_egress_ips() result:') + # begin-get_project_egress_ips response = code_engine_service.get_project_egress_ips( @@ -162,6 +168,28 @@ def test_get_project_egress_ips_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_get_project_status_details_example(self): + """ + get_project_status_details request example + """ + try: + print('\nget_project_status_details() result:') + + # begin-get_project_status_details + + response = code_engine_service.get_project_status_details( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + ) + project_status_details = response.get_result() + + print(json.dumps(project_status_details, indent=2)) + + # end-get_project_status_details + + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_list_apps_example(self): """ @@ -169,6 +197,7 @@ def test_list_apps_example(self): """ try: print('\nlist_apps() result:') + # begin-list_apps all_results = [] @@ -195,6 +224,7 @@ def test_create_app_example(self): """ try: print('\ncreate_app() result:') + # begin-create_app response = code_engine_service.create_app( @@ -218,6 +248,7 @@ def test_get_app_example(self): """ try: print('\nget_app() result:') + # begin-get_app response = code_engine_service.get_app( @@ -240,6 +271,7 @@ def test_update_app_example(self): """ try: print('\nupdate_app() result:') + # begin-update_app app_patch_model = {} @@ -266,6 +298,7 @@ def test_list_app_revisions_example(self): """ try: print('\nlist_app_revisions() result:') + # begin-list_app_revisions all_results = [] @@ -293,6 +326,7 @@ def test_get_app_revision_example(self): """ try: print('\nget_app_revision() result:') + # begin-get_app_revision response = code_engine_service.get_app_revision( @@ -309,6 +343,34 @@ def test_get_app_revision_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_list_app_instances_example(self): + """ + list_app_instances request example + """ + try: + print('\nlist_app_instances() result:') + + # begin-list_app_instances + + all_results = [] + pager = AppInstancesPager( + client=code_engine_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + app_name='my-app', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_app_instances + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_list_jobs_example(self): """ @@ -316,6 +378,7 @@ def test_list_jobs_example(self): """ try: print('\nlist_jobs() result:') + # begin-list_jobs all_results = [] @@ -342,6 +405,7 @@ def test_create_job_example(self): """ try: print('\ncreate_job() result:') + # begin-create_job response = code_engine_service.create_job( @@ -365,6 +429,7 @@ def test_get_job_example(self): """ try: print('\nget_job() result:') + # begin-get_job response = code_engine_service.get_job( @@ -387,6 +452,7 @@ def test_update_job_example(self): """ try: print('\nupdate_job() result:') + # begin-update_job job_patch_model = {} @@ -413,6 +479,7 @@ def test_list_job_runs_example(self): """ try: print('\nlist_job_runs() result:') + # begin-list_job_runs all_results = [] @@ -440,6 +507,7 @@ def test_create_job_run_example(self): """ try: print('\ncreate_job_run() result:') + # begin-create_job_run response = code_engine_service.create_job_run( @@ -461,6 +529,7 @@ def test_get_job_run_example(self): """ try: print('\nget_job_run() result:') + # begin-get_job_run response = code_engine_service.get_job_run( @@ -476,6 +545,208 @@ def test_get_job_run_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_list_function_runtimes_example(self): + """ + list_function_runtimes request example + """ + try: + print('\nlist_function_runtimes() result:') + + # begin-list_function_runtimes + + response = code_engine_service.list_function_runtimes() + function_runtime_list = response.get_result() + + print(json.dumps(function_runtime_list, indent=2)) + + # end-list_function_runtimes + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_list_functions_example(self): + """ + list_functions request example + """ + try: + print('\nlist_functions() result:') + + # begin-list_functions + + all_results = [] + pager = FunctionsPager( + client=code_engine_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_functions + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_create_function_example(self): + """ + create_function request example + """ + try: + print('\ncreate_function() result:') + + # begin-create_function + + response = code_engine_service.create_function( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + code_reference='data:text/plain;base64,', + name='my-function', + runtime='nodejs-18', + ) + function = response.get_result() + + print(json.dumps(function, indent=2)) + + # end-create_function + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_function_example(self): + """ + get_function request example + """ + try: + print('\nget_function() result:') + + # begin-get_function + + response = code_engine_service.get_function( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + name='my-function', + ) + function = response.get_result() + + print(json.dumps(function, indent=2)) + + # end-get_function + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_update_function_example(self): + """ + update_function request example + """ + try: + print('\nupdate_function() result:') + + # begin-update_function + + function_patch_model = {} + + response = code_engine_service.update_function( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + name='my-function', + if_match='testString', + function=function_patch_model, + ) + function = response.get_result() + + print(json.dumps(function, indent=2)) + + # end-update_function + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_list_bindings_example(self): + """ + list_bindings request example + """ + try: + print('\nlist_bindings() result:') + + # begin-list_bindings + + all_results = [] + pager = BindingsPager( + client=code_engine_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_bindings + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_create_binding_example(self): + """ + create_binding request example + """ + try: + print('\ncreate_binding() result:') + + # begin-create_binding + + component_ref_model = { + 'name': 'my-app-1', + 'resource_type': 'app_v2', + } + + response = code_engine_service.create_binding( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + component=component_ref_model, + prefix='MY_COS', + secret_name='my-service-access', + ) + binding = response.get_result() + + print(json.dumps(binding, indent=2)) + + # end-create_binding + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_binding_example(self): + """ + get_binding request example + """ + try: + print('\nget_binding() result:') + + # begin-get_binding + + response = code_engine_service.get_binding( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + id='a172ced-b5f21bc-71ba50c-1638604', + ) + binding = response.get_result() + + print(json.dumps(binding, indent=2)) + + # end-get_binding + + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_list_builds_example(self): """ @@ -483,6 +754,7 @@ def test_list_builds_example(self): """ try: print('\nlist_builds() result:') + # begin-list_builds all_results = [] @@ -509,6 +781,7 @@ def test_create_build_example(self): """ try: print('\ncreate_build() result:') + # begin-create_build response = code_engine_service.create_build( @@ -516,7 +789,6 @@ def test_create_build_example(self): name='my-build', output_image='private.de.icr.io/icr_namespace/image-name', output_secret='ce-auto-icr-private-eu-de', - source_url='https://github.com/IBM/CodeEngine', strategy_type='dockerfile', ) build = response.get_result() @@ -535,6 +807,7 @@ def test_get_build_example(self): """ try: print('\nget_build() result:') + # begin-get_build response = code_engine_service.get_build( @@ -557,6 +830,7 @@ def test_update_build_example(self): """ try: print('\nupdate_build() result:') + # begin-update_build build_patch_model = {} @@ -583,6 +857,7 @@ def test_list_build_runs_example(self): """ try: print('\nlist_build_runs() result:') + # begin-list_build_runs all_results = [] @@ -610,6 +885,7 @@ def test_create_build_run_example(self): """ try: print('\ncreate_build_run() result:') + # begin-create_build_run response = code_engine_service.create_build_run( @@ -631,6 +907,7 @@ def test_get_build_run_example(self): """ try: print('\nget_build_run() result:') + # begin-get_build_run response = code_engine_service.get_build_run( @@ -646,6 +923,113 @@ def test_get_build_run_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_list_domain_mappings_example(self): + """ + list_domain_mappings request example + """ + try: + print('\nlist_domain_mappings() result:') + + # begin-list_domain_mappings + + all_results = [] + pager = DomainMappingsPager( + client=code_engine_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_domain_mappings + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_create_domain_mapping_example(self): + """ + create_domain_mapping request example + """ + try: + print('\ncreate_domain_mapping() result:') + + # begin-create_domain_mapping + + component_ref_model = { + 'name': 'my-app-1', + 'resource_type': 'app_v2', + } + + response = code_engine_service.create_domain_mapping( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + component=component_ref_model, + name='www.example.com', + tls_secret='my-tls-secret', + ) + domain_mapping = response.get_result() + + print(json.dumps(domain_mapping, indent=2)) + + # end-create_domain_mapping + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_domain_mapping_example(self): + """ + get_domain_mapping request example + """ + try: + print('\nget_domain_mapping() result:') + + # begin-get_domain_mapping + + response = code_engine_service.get_domain_mapping( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + name='www.example.com', + ) + domain_mapping = response.get_result() + + print(json.dumps(domain_mapping, indent=2)) + + # end-get_domain_mapping + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_update_domain_mapping_example(self): + """ + update_domain_mapping request example + """ + try: + print('\nupdate_domain_mapping() result:') + + # begin-update_domain_mapping + + domain_mapping_patch_model = {} + + response = code_engine_service.update_domain_mapping( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + name='www.example.com', + if_match='testString', + domain_mapping=domain_mapping_patch_model, + ) + domain_mapping = response.get_result() + + print(json.dumps(domain_mapping, indent=2)) + + # end-update_domain_mapping + + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_list_config_maps_example(self): """ @@ -653,6 +1037,7 @@ def test_list_config_maps_example(self): """ try: print('\nlist_config_maps() result:') + # begin-list_config_maps all_results = [] @@ -679,6 +1064,7 @@ def test_create_config_map_example(self): """ try: print('\ncreate_config_map() result:') + # begin-create_config_map response = code_engine_service.create_config_map( @@ -701,6 +1087,7 @@ def test_get_config_map_example(self): """ try: print('\nget_config_map() result:') + # begin-get_config_map response = code_engine_service.get_config_map( @@ -723,6 +1110,7 @@ def test_replace_config_map_example(self): """ try: print('\nreplace_config_map() result:') + # begin-replace_config_map response = code_engine_service.replace_config_map( @@ -746,6 +1134,7 @@ def test_list_secrets_example(self): """ try: print('\nlist_secrets() result:') + # begin-list_secrets all_results = [] @@ -772,6 +1161,7 @@ def test_create_secret_example(self): """ try: print('\ncreate_secret() result:') + # begin-create_secret response = code_engine_service.create_secret( @@ -795,6 +1185,7 @@ def test_get_secret_example(self): """ try: print('\nget_secret() result:') + # begin-get_secret response = code_engine_service.get_secret( @@ -817,12 +1208,14 @@ def test_replace_secret_example(self): """ try: print('\nreplace_secret() result:') + # begin-replace_secret response = code_engine_service.replace_secret( project_id='15314cc3-85b4-4338-903f-c28cdee6d005', name='my-secret', if_match='testString', + format='generic', ) secret = response.get_result() @@ -928,6 +1321,44 @@ def test_delete_job_run_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_delete_function_example(self): + """ + delete_function request example + """ + try: + # begin-delete_function + + response = code_engine_service.delete_function( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + name='my-function', + ) + + # end-delete_function + print('\ndelete_function() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_delete_binding_example(self): + """ + delete_binding request example + """ + try: + # begin-delete_binding + + response = code_engine_service.delete_binding( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + id='a172ced-b5f21bc-71ba50c-1638604', + ) + + # end-delete_binding + print('\ndelete_binding() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_delete_build_example(self): """ @@ -966,6 +1397,25 @@ def test_delete_build_run_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_delete_domain_mapping_example(self): + """ + delete_domain_mapping request example + """ + try: + # begin-delete_domain_mapping + + response = code_engine_service.delete_domain_mapping( + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + name='www.example.com', + ) + + # end-delete_domain_mapping + print('\ndelete_domain_mapping() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_delete_config_map_example(self): """ diff --git a/ibm_code_engine_sdk/code_engine_v2.py b/ibm_code_engine_sdk/code_engine_v2.py index 0700044..126f367 100644 --- a/ibm_code_engine_sdk/code_engine_v2.py +++ b/ibm_code_engine_sdk/code_engine_v2.py @@ -1,6 +1,6 @@ # coding: utf-8 -# (C) Copyright IBM Corp. 2023. +# (C) Copyright IBM Corp. 2024. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -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.66.0-d6c2d7e0-20230215-221247 +# IBM OpenAPI SDK Code Generator Version: 3.94.1-71478489-20240820-161623 """ REST API for Code Engine @@ -23,7 +23,7 @@ """ from enum import Enum -from typing import Dict, List +from typing import Dict, List, Optional import json from ibm_cloud_sdk_core import BaseService, DetailedResponse @@ -48,19 +48,28 @@ class CodeEngineV2(BaseService): def new_instance( cls, service_name: str = DEFAULT_SERVICE_NAME, + version: Optional[str] = None, ) -> 'CodeEngineV2': """ Return a new client for the Code Engine service using the specified parameters and external configuration. + + :param str version: (optional) The API version, in format `YYYY-MM-DD`. For + the API behavior documented here, specify any date between `2021-03-31` and + `2024-09-24`. """ authenticator = get_authenticator_from_environment(service_name) - service = cls(authenticator) + service = cls( + authenticator, + version, + ) service.configure_service(service_name) return service def __init__( self, authenticator: Authenticator = None, + version: Optional[str] = None, ) -> None: """ Construct a new client for the Code Engine service. @@ -68,14 +77,25 @@ def __init__( :param Authenticator authenticator: The authenticator specifies the authentication mechanism. Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. + + :param str version: (optional) The API version, in format `YYYY-MM-DD`. For + the API behavior documented here, specify any date between `2021-03-31` and + `2024-09-24`. """ BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) + self.version = version ######################### # Projects ######################### - def list_projects(self, *, limit: int = None, start: str = None, **kwargs) -> DetailedResponse: + def list_projects( + self, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ List all projects. @@ -86,7 +106,7 @@ def list_projects(self, *, limit: int = None, start: str = None, **kwargs) -> De of the page of results to be returned. Any additional query parameters are ignored if a page token is present. If omitted, the first page of results is returned. This value is obtained from the 'start' query parameter in the - 'next_url' field of the operation response. + `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ProjectList` object @@ -94,7 +114,9 @@ def list_projects(self, *, limit: int = None, start: str = None, **kwargs) -> De headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_projects' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_projects', ) headers.update(sdk_headers) @@ -109,13 +131,23 @@ def list_projects(self, *, limit: int = None, start: str = None, **kwargs) -> De headers['Accept'] = 'application/json' url = '/projects' - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response def create_project( - self, name: str, *, resource_group_id: str = None, tags: List[str] = None, **kwargs + self, + name: str, + *, + resource_group_id: Optional[str] = None, + tags: Optional[List[str]] = None, + **kwargs, ) -> DetailedResponse: """ Create a project. @@ -141,7 +173,9 @@ def create_project( raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_project' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_project', ) headers.update(sdk_headers) @@ -160,12 +194,21 @@ def create_project( headers['Accept'] = 'application/json' url = '/projects' - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) response = self.send(request, **kwargs) return response - def get_project(self, id: str, **kwargs) -> DetailedResponse: + def get_project( + self, + id: str, + **kwargs, + ) -> DetailedResponse: """ Get a project. @@ -181,7 +224,9 @@ def get_project(self, id: str, **kwargs) -> DetailedResponse: raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_project' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_project', ) headers.update(sdk_headers) @@ -194,12 +239,20 @@ def get_project(self, id: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def delete_project(self, id: str, **kwargs) -> DetailedResponse: + def delete_project( + self, + id: str, + **kwargs, + ) -> DetailedResponse: """ Delete a project. @@ -215,7 +268,9 @@ def delete_project(self, id: str, **kwargs) -> DetailedResponse: raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_project' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_project', ) headers.update(sdk_headers) @@ -227,17 +282,27 @@ def delete_project(self, id: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def get_project_egress_ips(self, project_id: str, **kwargs) -> DetailedResponse: + def get_project_egress_ips( + self, + project_id: str, + **kwargs, + ) -> DetailedResponse: """ List egress IP addresses. Lists all egress IP addresses (public and private) that are used by components - running in this project. + running in this project. For information about using egress IP addresses, see + [Code Engine public and private IP + addresses](https://cloud.ibm.com/docs/codeengine?topic=codeengine-network-addresses). :param str project_id: The ID of the project. :param dict headers: A `dict` containing the request headers @@ -249,7 +314,9 @@ def get_project_egress_ips(self, project_id: str, **kwargs) -> DetailedResponse: raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_project_egress_ips' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_project_egress_ips', ) headers.update(sdk_headers) @@ -262,7 +329,55 @@ def get_project_egress_ips(self, project_id: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/egress_ips'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_project_status_details( + self, + project_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Get the status details for a project. + + Retrieves status details about the given project. + + :param str project_id: The ID of the project. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `ProjectStatusDetails` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_project_status_details', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/status_details'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response @@ -271,7 +386,14 @@ def get_project_egress_ips(self, project_id: str, **kwargs) -> DetailedResponse: # Applications ######################### - def list_apps(self, project_id: str, *, limit: int = None, start: str = None, **kwargs) -> DetailedResponse: + def list_apps( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ List applications. @@ -282,7 +404,7 @@ def list_apps(self, project_id: str, *, limit: int = None, start: str = None, ** :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AppList` object @@ -292,11 +414,14 @@ def list_apps(self, project_id: str, *, limit: int = None, start: str = None, ** raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_apps' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_apps', ) headers.update(sdk_headers) params = { + 'version': self.version, 'limit': limit, 'start': start, } @@ -310,7 +435,12 @@ def list_apps(self, project_id: str, *, limit: int = None, start: str = None, ** path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response @@ -321,24 +451,27 @@ def create_app( image_reference: str, name: str, *, - image_port: int = None, - image_secret: str = None, - managed_domain_mappings: str = None, - run_arguments: List[str] = None, - run_as_user: int = None, - run_commands: List[str] = None, - run_env_variables: List['EnvVarPrototype'] = None, - run_service_account: str = None, - run_volume_mounts: List['VolumeMountPrototype'] = None, - scale_concurrency: int = None, - scale_concurrency_target: int = None, - scale_cpu_limit: str = None, - scale_ephemeral_storage_limit: str = None, - scale_initial_instances: int = None, - scale_max_instances: int = None, - scale_memory_limit: str = None, - scale_min_instances: int = None, - scale_request_timeout: int = None, + image_port: Optional[int] = None, + image_secret: Optional[str] = None, + managed_domain_mappings: Optional[str] = None, + probe_liveness: Optional['ProbePrototype'] = None, + probe_readiness: Optional['ProbePrototype'] = None, + run_arguments: Optional[List[str]] = None, + run_as_user: Optional[int] = None, + run_commands: Optional[List[str]] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + run_service_account: Optional[str] = None, + run_volume_mounts: Optional[List['VolumeMountPrototype']] = None, + scale_concurrency: Optional[int] = None, + scale_concurrency_target: Optional[int] = None, + scale_cpu_limit: Optional[str] = None, + scale_down_delay: Optional[int] = None, + scale_ephemeral_storage_limit: Optional[str] = None, + scale_initial_instances: Optional[int] = None, + scale_max_instances: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + scale_min_instances: Optional[int] = None, + scale_request_timeout: Optional[int] = None, **kwargs, ) -> DetailedResponse: """ @@ -348,7 +481,7 @@ def create_app( :param str project_id: The ID of the project. :param str image_reference: The name of the image that is used for this - job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. If the image reference points to a registry that requires authentication, make @@ -369,18 +502,19 @@ def create_app( application. Valid values are 'local_public', 'local_private' and 'local'. Visibility can only be 'local_private' if the project supports application private visibility. + :param ProbePrototype probe_liveness: (optional) Request model for probes. + :param ProbePrototype probe_readiness: (optional) Request model for probes. :param List[str] run_arguments: (optional) Optional arguments for the app that are passed to start the container. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container. - :param int run_as_user: (optional) Optional user ID (UID) to run the app - (e.g., `1001`). + :param int run_as_user: (optional) Optional user ID (UID) to run the app. :param List[str] run_commands: (optional) Optional commands for the app that are passed to start the container. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. :param List[EnvVarPrototype] run_env_variables: (optional) Optional - references to config maps, secrets or a literal values that are exposed as + references to config maps, secrets or literal values that are exposed as environment variables within the running application. :param str run_service_account: (optional) Optional name of the service account. For built-in service accounts, you can use the shortened names @@ -397,6 +531,8 @@ def create_app( :param str scale_cpu_limit: (optional) Optional number of CPU set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds + that delays the scale-down behavior for an app instance. :param str scale_ephemeral_storage_limit: (optional) Optional amount of ephemeral storage to set for the instance of the app. The amount specified as ephemeral storage, must not exceed the amount of `scale_memory_limit`. @@ -434,22 +570,34 @@ def create_app( raise ValueError('image_reference must be provided') if name is None: raise ValueError('name must be provided') + if probe_liveness is not None: + probe_liveness = convert_model(probe_liveness) + if probe_readiness is not None: + probe_readiness = convert_model(probe_readiness) if run_env_variables is not None: run_env_variables = [convert_model(x) for x in run_env_variables] if run_volume_mounts is not None: run_volume_mounts = [convert_model(x) for x in run_volume_mounts] headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_app' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_app', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + data = { 'image_reference': image_reference, 'name': name, 'image_port': image_port, 'image_secret': image_secret, 'managed_domain_mappings': managed_domain_mappings, + 'probe_liveness': probe_liveness, + 'probe_readiness': probe_readiness, 'run_arguments': run_arguments, 'run_as_user': run_as_user, 'run_commands': run_commands, @@ -459,6 +607,7 @@ def create_app( 'scale_concurrency': scale_concurrency, 'scale_concurrency_target': scale_concurrency_target, 'scale_cpu_limit': scale_cpu_limit, + 'scale_down_delay': scale_down_delay, 'scale_ephemeral_storage_limit': scale_ephemeral_storage_limit, 'scale_initial_instances': scale_initial_instances, 'scale_max_instances': scale_max_instances, @@ -479,12 +628,23 @@ def create_app( path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response - def get_app(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_app( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Get an application. @@ -503,10 +663,16 @@ def get_app(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_app' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_app', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -516,12 +682,22 @@ def get_app(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def delete_app(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def delete_app( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Delete an application. @@ -540,10 +716,16 @@ def delete_app(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_app' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_app', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -552,12 +734,24 @@ def delete_app(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def update_app(self, project_id: str, name: str, if_match: str, app: 'AppPatch', **kwargs) -> DetailedResponse: + def update_app( + self, + project_id: str, + name: str, + if_match: str, + app: 'AppPatch', + **kwargs, + ) -> DetailedResponse: """ Update an application. @@ -593,10 +787,16 @@ def update_app(self, project_id: str, name: str, if_match: str, app: 'AppPatch', 'If-Match': if_match, } sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_app' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_app', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + data = json.dumps(app) headers['content-type'] = 'application/merge-patch+json' @@ -609,13 +809,25 @@ def update_app(self, project_id: str, name: str, if_match: str, app: 'AppPatch', path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps/{name}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response def list_app_revisions( - self, project_id: str, app_name: str, *, limit: int = None, start: str = None, **kwargs + self, + project_id: str, + app_name: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, ) -> DetailedResponse: """ List application revisions. @@ -628,7 +840,7 @@ def list_app_revisions( :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AppRevisionList` object @@ -640,13 +852,16 @@ def list_app_revisions( raise ValueError('app_name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_app_revisions' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_app_revisions', ) headers.update(sdk_headers) params = { 'limit': limit, 'start': start, + 'version': self.version, } if 'headers' in kwargs: @@ -658,12 +873,23 @@ def list_app_revisions( path_param_values = self.encode_path_vars(project_id, app_name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps/{app_name}/revisions'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def get_app_revision(self, project_id: str, app_name: str, name: str, **kwargs) -> DetailedResponse: + def get_app_revision( + self, + project_id: str, + app_name: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Get an application revision. @@ -685,10 +911,16 @@ def get_app_revision(self, project_id: str, app_name: str, name: str, **kwargs) raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_app_revision' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_app_revision', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -698,12 +930,23 @@ def get_app_revision(self, project_id: str, app_name: str, name: str, **kwargs) path_param_values = self.encode_path_vars(project_id, app_name, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps/{app_name}/revisions/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def delete_app_revision(self, project_id: str, app_name: str, name: str, **kwargs) -> DetailedResponse: + def delete_app_revision( + self, + project_id: str, + app_name: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Delete an application revision. @@ -725,7 +968,9 @@ def delete_app_revision(self, project_id: str, app_name: str, name: str, **kwarg raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_app_revision' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_app_revision', ) headers.update(sdk_headers) @@ -737,7 +982,73 @@ def delete_app_revision(self, project_id: str, app_name: str, name: str, **kwarg path_param_values = self.encode_path_vars(project_id, app_name, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/apps/{app_name}/revisions/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def list_app_instances( + self, + project_id: str, + app_name: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + List application instances. + + List all instances of an application. + + :param str project_id: The ID of the project. + :param str app_name: The name of your application. + :param int limit: (optional) Optional maximum number of apps per page. + :param str start: (optional) An optional token that indicates the beginning + of the page of results to be returned. If omitted, the first page of + results is returned. This value is obtained from the 'start' query + parameter in the `next` object of the operation response. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `AppInstanceList` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not app_name: + raise ValueError('app_name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_app_instances', + ) + headers.update(sdk_headers) + + params = { + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id', 'app_name'] + path_param_values = self.encode_path_vars(project_id, app_name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/apps/{app_name}/instances'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response @@ -746,7 +1057,14 @@ def delete_app_revision(self, project_id: str, app_name: str, name: str, **kwarg # Jobs ######################### - def list_jobs(self, project_id: str, *, limit: int = None, start: str = None, **kwargs) -> DetailedResponse: + def list_jobs( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ List jobs. @@ -757,7 +1075,7 @@ def list_jobs(self, project_id: str, *, limit: int = None, start: str = None, ** :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `JobList` object @@ -767,11 +1085,14 @@ def list_jobs(self, project_id: str, *, limit: int = None, start: str = None, ** raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_jobs' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_jobs', ) headers.update(sdk_headers) params = { + 'version': self.version, 'limit': limit, 'start': start, } @@ -785,7 +1106,12 @@ def list_jobs(self, project_id: str, *, limit: int = None, start: str = None, ** path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/jobs'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response @@ -796,20 +1122,20 @@ def create_job( image_reference: str, name: str, *, - image_secret: str = None, - run_arguments: List[str] = None, - run_as_user: int = None, - run_commands: List[str] = None, - run_env_variables: List['EnvVarPrototype'] = None, - run_mode: str = None, - run_service_account: str = None, - run_volume_mounts: List['VolumeMountPrototype'] = None, - scale_array_spec: str = None, - scale_cpu_limit: str = None, - scale_ephemeral_storage_limit: str = None, - scale_max_execution_time: int = None, - scale_memory_limit: str = None, - scale_retry_limit: int = None, + image_secret: Optional[str] = None, + run_arguments: Optional[List[str]] = None, + run_as_user: Optional[int] = None, + run_commands: Optional[List[str]] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + run_mode: Optional[str] = None, + run_service_account: Optional[str] = None, + run_volume_mounts: Optional[List['VolumeMountPrototype']] = None, + scale_array_spec: Optional[str] = None, + scale_cpu_limit: Optional[str] = None, + scale_ephemeral_storage_limit: Optional[str] = None, + scale_max_execution_time: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + scale_retry_limit: Optional[int] = None, **kwargs, ) -> DetailedResponse: """ @@ -837,14 +1163,13 @@ def create_job( are passed to start job run containers. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container. - :param int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). + :param int run_as_user: (optional) The user ID (UID) to run the job. :param List[str] run_commands: (optional) Set commands for the job that are passed to start job run containers. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. :param List[EnvVarPrototype] run_env_variables: (optional) Optional - references to config maps, secrets or a literal values. + references to config maps, secrets or literal values. :param str run_mode: (optional) The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` mode, since there is no timeout @@ -857,10 +1182,11 @@ def create_job( :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional mounts of config maps or a secrets. :param str scale_array_spec: (optional) Define a custom set of array - indices as comma-separated list containing single values and - hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its - array index via environment variable `JOB_INDEX`. The number of unique - array indices specified here determines the number of job instances to run. + indices as a comma-separated list containing single values and + hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its + array index value from the environment variable JOB_INDEX. The number of + unique array indices that you specify with this parameter determines the + number of job instances to run. :param str scale_cpu_limit: (optional) Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). @@ -901,10 +1227,16 @@ def create_job( run_volume_mounts = [convert_model(x) for x in run_volume_mounts] headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_job' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_job', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + data = { 'image_reference': image_reference, 'name': name, @@ -936,12 +1268,23 @@ def create_job( path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/jobs'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response - def get_job(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_job( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Get a job. @@ -960,10 +1303,16 @@ def get_job(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_job' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_job', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -973,12 +1322,22 @@ def get_job(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/jobs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def delete_job(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def delete_job( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Delete a job. @@ -997,10 +1356,16 @@ def delete_job(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_job' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_job', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -1009,12 +1374,24 @@ def delete_job(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/jobs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def update_job(self, project_id: str, name: str, if_match: str, job: 'JobPatch', **kwargs) -> DetailedResponse: + def update_job( + self, + project_id: str, + name: str, + if_match: str, + job: 'JobPatch', + **kwargs, + ) -> DetailedResponse: """ Update a job. @@ -1047,10 +1424,16 @@ def update_job(self, project_id: str, name: str, if_match: str, job: 'JobPatch', 'If-Match': if_match, } sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_job' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_job', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + data = json.dumps(job) headers['content-type'] = 'application/merge-patch+json' @@ -1063,13 +1446,25 @@ def update_job(self, project_id: str, name: str, if_match: str, job: 'JobPatch', path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/jobs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response def list_job_runs( - self, project_id: str, *, job_name: str = None, limit: int = None, start: str = None, **kwargs + self, + project_id: str, + *, + job_name: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, ) -> DetailedResponse: """ List job runs. @@ -1077,13 +1472,13 @@ def list_job_runs( List all job runs in a project. :param str project_id: The ID of the project. - :param str job_name: (optional) Optional name of the job that should be - filtered for. + :param str job_name: (optional) Optional name of the job that you want to + use to filter. :param int limit: (optional) Optional maximum number of job runs per page. :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `JobRunList` object @@ -1093,11 +1488,14 @@ def list_job_runs( raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_job_runs' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_job_runs', ) headers.update(sdk_headers) params = { + 'version': self.version, 'job_name': job_name, 'limit': limit, 'start': start, @@ -1112,7 +1510,12 @@ def list_job_runs( path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/job_runs'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response @@ -1121,23 +1524,24 @@ def create_job_run( self, project_id: str, *, - image_reference: str = None, - image_secret: str = None, - job_name: str = None, - name: str = None, - run_arguments: List[str] = None, - run_as_user: int = None, - run_commands: List[str] = None, - run_env_variables: List['EnvVarPrototype'] = None, - run_mode: str = None, - run_service_account: str = None, - run_volume_mounts: List['VolumeMountPrototype'] = None, - scale_array_spec: str = None, - scale_cpu_limit: str = None, - scale_ephemeral_storage_limit: str = None, - scale_max_execution_time: int = None, - scale_memory_limit: str = None, - scale_retry_limit: int = None, + image_reference: Optional[str] = None, + image_secret: Optional[str] = None, + job_name: Optional[str] = None, + name: Optional[str] = None, + run_arguments: Optional[List[str]] = None, + run_as_user: Optional[int] = None, + run_commands: Optional[List[str]] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + run_mode: Optional[str] = None, + run_service_account: Optional[str] = None, + run_volume_mounts: Optional[List['VolumeMountPrototype']] = None, + scale_array_size_variable_override: Optional[int] = None, + scale_array_spec: Optional[str] = None, + scale_cpu_limit: Optional[str] = None, + scale_ephemeral_storage_limit: Optional[str] = None, + scale_max_execution_time: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + scale_retry_limit: Optional[int] = None, **kwargs, ) -> DetailedResponse: """ @@ -1168,14 +1572,13 @@ def create_job_run( are passed to start job run containers. If not specified an empty string array will be applied and the arguments specified by the container image, will be used to start the container. - :param int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). + :param int run_as_user: (optional) The user ID (UID) to run the job. :param List[str] run_commands: (optional) Set commands for the job that are passed to start job run containers. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. :param List[EnvVarPrototype] run_env_variables: (optional) Optional - references to config maps, secrets or a literal values. + references to config maps, secrets or literal values. :param str run_mode: (optional) The mode for runs of the job. Valid values are `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` mode, since there is no timeout @@ -1187,11 +1590,14 @@ def create_job_run( which references a job template. :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional mounts of config maps or a secrets. + :param int scale_array_size_variable_override: (optional) Optional value to + override the JOB_ARRAY_SIZE environment variable for a job run. :param str scale_array_spec: (optional) Define a custom set of array - indices as comma-separated list containing single values and - hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its - array index via environment variable `JOB_INDEX`. The number of unique - array indices specified here determines the number of job instances to run. + indices as a comma-separated list containing single values and + hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its + array index value from the environment variable JOB_INDEX. The number of + unique array indices that you specify with this parameter determines the + number of job instances to run. :param str scale_cpu_limit: (optional) Optional amount of CPU set for the instance of the job. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). @@ -1228,10 +1634,16 @@ def create_job_run( run_volume_mounts = [convert_model(x) for x in run_volume_mounts] headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_job_run' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_job_run', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + data = { 'image_reference': image_reference, 'image_secret': image_secret, @@ -1244,6 +1656,7 @@ def create_job_run( 'run_mode': run_mode, 'run_service_account': run_service_account, 'run_volume_mounts': run_volume_mounts, + 'scale_array_size_variable_override': scale_array_size_variable_override, 'scale_array_spec': scale_array_spec, 'scale_cpu_limit': scale_cpu_limit, 'scale_ephemeral_storage_limit': scale_ephemeral_storage_limit, @@ -1264,12 +1677,23 @@ def create_job_run( path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/job_runs'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response - def get_job_run(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_job_run( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Get a job run. @@ -1288,10 +1712,16 @@ def get_job_run(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_job_run' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_job_run', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -1301,12 +1731,22 @@ def get_job_run(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/job_runs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def delete_job_run(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def delete_job_run( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ Delete a job run. @@ -1325,7 +1765,9 @@ def delete_job_run(self, project_id: str, name: str, **kwargs) -> DetailedRespon raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_job_run' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_job_run', ) headers.update(sdk_headers) @@ -1337,156 +1779,220 @@ def delete_job_run(self, project_id: str, name: str, **kwargs) -> DetailedRespon path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/projects/{project_id}/job_runs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response ######################### - # Builds + # Functions ######################### - def list_builds(self, project_id: str, *, limit: int = None, start: str = None, **kwargs) -> DetailedResponse: + def list_function_runtimes( + self, + **kwargs, + ) -> DetailedResponse: """ - List builds. + List the function runtimes. - List all builds in a project. + List all valid function runtimes. - :param str project_id: The ID of the project. - :param int limit: (optional) Optional maximum number of builds per page. - :param str start: (optional) The token to continue traversing paginated - list of builds. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `BuildList` object + :rtype: DetailedResponse with `dict` result representing a `FunctionRuntimeList` object """ - if not project_id: - raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_builds' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_function_runtimes', ) headers.update(sdk_headers) - params = { - 'limit': limit, - 'start': start, - } - if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['project_id'] - path_param_values = self.encode_path_vars(project_id) - path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/builds'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + url = '/function_runtimes' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def create_build( + def list_functions( self, project_id: str, - name: str, - output_image: str, - output_secret: str, - source_url: str, - strategy_type: str, *, - source_context_dir: str = None, - source_revision: str = None, - source_secret: str = None, - source_type: str = None, - strategy_size: str = None, - strategy_spec_file: str = None, - timeout: int = None, + limit: Optional[int] = None, + start: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ - Create a build. + List functions. - Create a build. + List all functions in a project. :param str project_id: The ID of the project. - :param str name: The name of the build. Use a name that is unique within + :param int limit: (optional) Optional maximum number of functions per page. + :param str start: (optional) An optional token that indicates the beginning + of the page of results to be returned. If omitted, the first page of + results is returned. This value is obtained from the 'start' query + parameter in the 'next_url' field of the operation response. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `FunctionList` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_functions', + ) + headers.update(sdk_headers) + + params = { + 'version': self.version, + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/functions'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_function( + self, + project_id: str, + code_reference: str, + name: str, + runtime: str, + *, + code_binary: Optional[bool] = None, + code_main: Optional[str] = None, + code_secret: Optional[str] = None, + managed_domain_mappings: Optional[str] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + scale_concurrency: Optional[int] = None, + scale_cpu_limit: Optional[str] = None, + scale_down_delay: Optional[int] = None, + scale_max_execution_time: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create a function. + + Create a function. + + :param str project_id: The ID of the project. + :param str code_reference: Specifies either a reference to a code bundle or + the source code itself. To specify the source code, use the data URL scheme + and include the source code as base64 encoded. The data URL scheme is + defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). + :param str name: The name of the function. Use a name that is unique within the project. - :param str output_image: The name of the image. - :param str output_secret: The secret that is required to access the image - registry. Make sure that the secret is granted with push permissions - towards the specified container registry namespace. - :param str source_url: The URL of the code repository. This field is - required if the `source_type` is `git`. If the `source_type` value is - `local`, this field must be omitted. If the repository is publicly - available you can provide a 'https' URL like - `https://github.com/IBM/CodeEngine`. If the repository requires - authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that - points to a secret of format `ssh_auth`. - :param str strategy_type: The strategy to use for building the image. - :param str source_context_dir: (optional) Option directory in the - repository that contains the buildpacks file or the Dockerfile. - :param str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` - and uses the HEAD of default branch if not specified. If the `source_type` - value is `local`, this field must be omitted. - :param str source_secret: (optional) Name of the secret that is used access - the repository source. This field is optional if the `source_type` is - `git`. Additionally, if the `source_url` points to a repository that - requires authentication, the build will be created but cannot access any - source code, until this property is provided, too. If the `source_type` - value is `local`, this field must be omitted. - :param str source_type: (optional) Specifies the type of source to - determine if your build source is in a repository or based on local source - code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :param str strategy_size: (optional) Optional size for the build, which - determines the amount of resources used. Build sizes are `small`, `medium`, - `large`, `xlarge`. - :param str strategy_spec_file: (optional) Optional path to the - specification file that is used for build strategies for building an image. - :param int timeout: (optional) The maximum amount of time, in seconds, that - can pass before the build must succeed or fail. + :param str runtime: The managed runtime used to execute the injected code. + :param bool code_binary: (optional) Specifies whether the code is binary or + not. Defaults to false when `code_reference` is set to a data URL. When + `code_reference` is set to a code bundle URL, this field is always true. + :param str code_main: (optional) Specifies the name of the function that + should be invoked. + :param str code_secret: (optional) The name of the secret that is used to + access the specified `code_reference`. The secret is used to authenticate + with a non-public endpoint that is specified as`code_reference`. + :param str managed_domain_mappings: (optional) Optional value controlling + which of the system managed domain mappings will be setup for the function. + Valid values are 'local_public', 'local_private' and 'local'. Visibility + can only be 'local_private' if the project supports function private + visibility. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional + references to config maps, secrets or literal values. + :param int scale_concurrency: (optional) Number of parallel requests + handled by a single instance, supported only by Node.js, default is `1`. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the function. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds + that delays the scale down behavior for a function. + :param int scale_max_execution_time: (optional) Timeout in secs after which + the function is terminated. + :param str scale_memory_limit: (optional) Optional amount of memory set for + the instance of the function. For valid values see [Supported memory and + CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Build` object + :rtype: DetailedResponse with `dict` result representing a `Function` object """ if not project_id: raise ValueError('project_id must be provided') + if code_reference is None: + raise ValueError('code_reference must be provided') if name is None: raise ValueError('name must be provided') - if output_image is None: - raise ValueError('output_image must be provided') - if output_secret is None: - raise ValueError('output_secret must be provided') - if source_url is None: - raise ValueError('source_url must be provided') - if strategy_type is None: - raise ValueError('strategy_type must be provided') + if runtime is None: + raise ValueError('runtime must be provided') + if run_env_variables is not None: + run_env_variables = [convert_model(x) for x in run_env_variables] headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_build' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_function', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + data = { + 'code_reference': code_reference, 'name': name, - 'output_image': output_image, - 'output_secret': output_secret, - 'source_url': source_url, - 'strategy_type': strategy_type, - 'source_context_dir': source_context_dir, - 'source_revision': source_revision, - 'source_secret': source_secret, - 'source_type': source_type, - 'strategy_size': strategy_size, - 'strategy_spec_file': strategy_spec_file, - 'timeout': timeout, + 'runtime': runtime, + 'code_binary': code_binary, + 'code_main': code_main, + 'code_secret': code_secret, + 'managed_domain_mappings': managed_domain_mappings, + 'run_env_variables': run_env_variables, + 'scale_concurrency': scale_concurrency, + 'scale_cpu_limit': scale_cpu_limit, + 'scale_down_delay': scale_down_delay, + 'scale_max_execution_time': scale_max_execution_time, + 'scale_memory_limit': scale_memory_limit, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1500,23 +2006,34 @@ def create_build( path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/builds'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + url = '/projects/{project_id}/functions'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response - def get_build(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_function( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ - Get a build. + Get a function. - Display the details of a build. + Display the details of a function. :param str project_id: The ID of the project. - :param str name: The name of your build. + :param str name: The name of your function. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Build` object + :rtype: DetailedResponse with `dict` result representing a `Function` object """ if not project_id: @@ -1525,10 +2042,16 @@ def get_build(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_build' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_function', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -1537,20 +2060,30 @@ def get_build(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/builds/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + url = '/projects/{project_id}/functions/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def delete_build(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def delete_function( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ - Delete a build. + Delete a function. - Delete a build. + Delete a function. :param str project_id: The ID of the project. - :param str name: The name of your build. + :param str name: The name of your function. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -1562,10 +2095,16 @@ def delete_build(self, project_id: str, name: str, **kwargs) -> DetailedResponse raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_build' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_function', ) headers.update(sdk_headers) + params = { + 'version': self.version, + } + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] @@ -1573,31 +2112,41 @@ def delete_build(self, project_id: str, name: str, **kwargs) -> DetailedResponse path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/builds/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + url = '/projects/{project_id}/functions/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def update_build( - self, project_id: str, name: str, if_match: str, build: 'BuildPatch', **kwargs + def update_function( + self, + project_id: str, + name: str, + if_match: str, + function: 'FunctionPatch', + **kwargs, ) -> DetailedResponse: """ - Update a build. + Update a function. - Update a build. + Update the given function. :param str project_id: The ID of the project. - :param str name: The name of your build. - :param str if_match: Version of the build settings to be updated. Specify - the version that you retrieved as entity_tag (ETag header) when reading the - build. This value helps identifying parallel usage of this API. Pass * to - indicate to update any version available. This might result in stale - updates. - :param BuildPatch build: Build patch. + :param str name: The name of your function. + :param str if_match: Version of the function settings to be updated. + Specify the version that you retrieved as entity_tag (ETag header) when + reading the function. This value helps identifying parallel usage of this + API. Pass * to indicate to update any version available. This might result + in stale updates. + :param FunctionPatch function: Function patch. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Build` object + :rtype: DetailedResponse with `dict` result representing a `Function` object """ if not project_id: @@ -1606,19 +2155,25 @@ def update_build( raise ValueError('name must be provided') if not if_match: raise ValueError('if_match must be provided') - if build is None: - raise ValueError('build must be provided') - if isinstance(build, BuildPatch): - build = convert_model(build) + if function is None: + raise ValueError('function must be provided') + if isinstance(function, FunctionPatch): + function = convert_model(function) headers = { 'If-Match': if_match, } sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_build' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_function', ) headers.update(sdk_headers) - data = json.dumps(build) + params = { + 'version': self.version, + } + + data = json.dumps(function) headers['content-type'] = 'application/merge-patch+json' if 'headers' in kwargs: @@ -1629,44 +2184,57 @@ def update_build( path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/builds/{name}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) + url = '/projects/{project_id}/functions/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + params=params, + data=data, + ) response = self.send(request, **kwargs) return response - def list_build_runs( - self, project_id: str, *, build_name: str = None, limit: int = None, start: str = None, **kwargs + ######################### + # Service bindings + ######################### + + def list_bindings( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, ) -> DetailedResponse: """ - List build runs. + List bindings. - List all build runs in a project. + List all bindings in a project. :param str project_id: The ID of the project. - :param str build_name: (optional) Optional name of the build that should be - filtered for. - :param int limit: (optional) Optional maximum number of build runs per - page. + :param int limit: (optional) Optional maximum number of bindings per page. :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `BuildRunList` object + :rtype: DetailedResponse with `dict` result representing a `BindingList` object """ if not project_id: raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_build_runs' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_bindings', ) headers.update(sdk_headers) params = { - 'build_name': build_name, 'limit': limit, 'start': start, } @@ -1679,114 +2247,64 @@ def list_build_runs( path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/build_runs'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + url = '/projects/{project_id}/bindings'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def create_build_run( + def create_binding( self, project_id: str, - *, - build_name: str = None, - name: str = None, - output_image: str = None, - output_secret: str = None, - service_account: str = None, - source_context_dir: str = None, - source_revision: str = None, - source_secret: str = None, - source_type: str = None, - source_url: str = None, - strategy_size: str = None, - strategy_spec_file: str = None, - strategy_type: str = None, - timeout: int = None, + component: 'ComponentRef', + prefix: str, + secret_name: str, **kwargs, ) -> DetailedResponse: """ - Create a build run. + Create a binding. - Create a build run. + Create a binding. Creating a service binding with a Code Engine app will update + the app, creating a new revision. For more information see the + [documentaion](https://cloud.ibm.com/docs/codeengine?topic=codeengine-service-binding). :param str project_id: The ID of the project. - :param str build_name: (optional) Optional name of the build on which this - build run is based on. If specified, the build run will inherit the - configuration of the referenced build. If not specified, make sure to - specify at least the fields `strategy_type`, `source_url`, `output_image` - and `output_secret` to describe the build run. - :param str name: (optional) Name of the build run. This field is optional, - if the field `build_name` is specified and its value will be generated like - so: `[BUILD_NAME]-run-[timestamp with format: YYMMDD-hhmmss] if not set.`. - :param str output_image: (optional) The name of the image. - :param str output_secret: (optional) The secret that is required to access - the image registry. Make sure that the secret is granted with push - permissions towards the specified container registry namespace. - :param str service_account: (optional) Optional service account which is - used for resource control. - :param str source_context_dir: (optional) Option directory in the - repository that contains the buildpacks file or the Dockerfile. - :param str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` - and uses the HEAD of default branch if not specified. If the `source_type` - value is `local`, this field must be omitted. - :param str source_secret: (optional) Name of the secret that is used access - the repository source. This field is optional if the `source_type` is - `git`. Additionally, if the `source_url` points to a repository that - requires authentication, the build will be created but cannot access any - source code, until this property is provided, too. If the `source_type` - value is `local`, this field must be omitted. - :param str source_type: (optional) Specifies the type of source to - determine if your build source is in a repository or based on local source - code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :param str source_url: (optional) The URL of the code repository. This - field is required if the `source_type` is `git`. If the `source_type` value - is `local`, this field must be omitted. If the repository is publicly - available you can provide a 'https' URL like - `https://github.com/IBM/CodeEngine`. If the repository requires - authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that - points to a secret of format `ssh_auth`. - :param str strategy_size: (optional) Optional size for the build, which - determines the amount of resources used. Build sizes are `small`, `medium`, - `large`, `xlarge`. - :param str strategy_spec_file: (optional) Optional path to the - specification file that is used for build strategies for building an image. - :param str strategy_type: (optional) The strategy to use for building the - image. - :param int timeout: (optional) The maximum amount of time, in seconds, that - can pass before the build must succeed or fail. + :param ComponentRef component: A reference to another component. + :param str prefix: Optional value that is set as prefix in the component + that is bound. Will be generated if not provided. + :param str secret_name: The service access secret that is bound to a + component. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `BuildRun` object + :rtype: DetailedResponse with `dict` result representing a `Binding` object """ if not project_id: raise ValueError('project_id must be provided') + if component is None: + raise ValueError('component must be provided') + if prefix is None: + raise ValueError('prefix must be provided') + if secret_name is None: + raise ValueError('secret_name must be provided') + component = convert_model(component) headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_build_run' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_binding', ) headers.update(sdk_headers) data = { - 'build_name': build_name, - 'name': name, - 'output_image': output_image, - 'output_secret': output_secret, - 'service_account': service_account, - 'source_context_dir': source_context_dir, - 'source_revision': source_revision, - 'source_secret': source_secret, - 'source_type': source_type, - 'source_url': source_url, - 'strategy_size': strategy_size, - 'strategy_spec_file': strategy_spec_file, - 'strategy_type': strategy_type, - 'timeout': timeout, + 'component': component, + 'prefix': prefix, + 'secret_name': secret_name, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1800,32 +2318,44 @@ def create_build_run( path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/build_runs'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + url = '/projects/{project_id}/bindings'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) response = self.send(request, **kwargs) return response - def get_build_run(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_binding( + self, + project_id: str, + id: str, + **kwargs, + ) -> DetailedResponse: """ - Get a build run. + Get a binding. - Display the details of a build run. + Display the details of a binding. :param str project_id: The ID of the project. - :param str name: The name of your build run. + :param str id: The id of your binding. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `BuildRun` object + :rtype: DetailedResponse with `dict` result representing a `Binding` object """ if not project_id: raise ValueError('project_id must be provided') - if not name: - raise ValueError('name must be provided') + if not id: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_build_run' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_binding', ) headers.update(sdk_headers) @@ -1834,23 +2364,32 @@ def get_build_run(self, project_id: str, name: str, **kwargs) -> DetailedRespons del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['project_id', 'name'] - path_param_values = self.encode_path_vars(project_id, name) + path_param_keys = ['project_id', 'id'] + path_param_values = self.encode_path_vars(project_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/build_runs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + url = '/projects/{project_id}/bindings/{id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def delete_build_run(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def delete_binding( + self, + project_id: str, + id: str, + **kwargs, + ) -> DetailedResponse: """ - Delete a build run. + Delete a binding. - Delete a build run. + Delete a binding. :param str project_id: The ID of the project. - :param str name: The name of your build run. + :param str id: The id of your binding. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -1858,11 +2397,13 @@ def delete_build_run(self, project_id: str, name: str, **kwargs) -> DetailedResp if not project_id: raise ValueError('project_id must be provided') - if not name: - raise ValueError('name must be provided') + if not id: + raise ValueError('id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_build_run' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_binding', ) headers.update(sdk_headers) @@ -1870,42 +2411,54 @@ def delete_build_run(self, project_id: str, name: str, **kwargs) -> DetailedResp headers.update(kwargs.get('headers')) del kwargs['headers'] - path_param_keys = ['project_id', 'name'] - path_param_values = self.encode_path_vars(project_id, name) + path_param_keys = ['project_id', 'id'] + path_param_values = self.encode_path_vars(project_id, id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/build_runs/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + url = '/projects/{project_id}/bindings/{id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response ######################### - # Secrets and config maps + # Image builds ######################### - def list_config_maps(self, project_id: str, *, limit: int = None, start: str = None, **kwargs) -> DetailedResponse: + def list_builds( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ - List config maps. + List builds. - List all config maps in a project. + List all builds in a project. :param str project_id: The ID of the project. - :param int limit: (optional) Optional maximum number of config maps per - page. + :param int limit: (optional) Optional maximum number of builds per page. :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `ConfigMapList` object + :rtype: DetailedResponse with `dict` result representing a `BuildList` object """ if not project_id: raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_config_maps' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_builds', ) headers.update(sdk_headers) @@ -1922,44 +2475,116 @@ def list_config_maps(self, project_id: str, *, limit: int = None, start: str = N path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/config_maps'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + url = '/projects/{project_id}/builds'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def create_config_map(self, project_id: str, name: str, *, data: dict = None, **kwargs) -> DetailedResponse: + def create_build( + self, + project_id: str, + name: str, + output_image: str, + output_secret: str, + strategy_type: str, + *, + source_context_dir: Optional[str] = None, + source_revision: Optional[str] = None, + source_secret: Optional[str] = None, + source_type: Optional[str] = None, + source_url: Optional[str] = None, + strategy_size: Optional[str] = None, + strategy_spec_file: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs, + ) -> DetailedResponse: """ - Create a config map. + Create a build. - Create a config map. + Create a build. :param str project_id: The ID of the project. - :param str name: The name of the configmap. Use a name that is unique - within the project. - :param dict data: (optional) The key-value pair for the config map. Values - must be specified in `KEY=VALUE` format. Each `KEY` field must consist of - alphanumeric characters, `-`, `_` or `.` and must not be exceed a max - length of 253 characters. Each `VALUE` field can consists of any character - and must not be exceed a max length of 1048576 characters. + :param str name: The name of the build. Use a name that is unique within + the project. + :param str output_image: The name of the image. + :param str output_secret: The secret that is required to access the image + registry. Make sure that the secret is granted with push permissions + towards the specified container registry namespace. + :param str strategy_type: The strategy to use for building the image. + :param str source_context_dir: (optional) Optional directory in the + repository that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` + and uses the HEAD of default branch if not specified. If the `source_type` + value is `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access + the repository source. This field is optional if the `source_type` is + `git`. Additionally, if the `source_url` points to a repository that + requires authentication, the build will be created but cannot access any + source code, until this property is provided, too. If the `source_type` + value is `local`, this field must be omitted. + :param str source_type: (optional) Specifies the type of source to + determine if your build source is in a repository or based on local source + code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This + field is required if the `source_type` is `git`. If the `source_type` value + is `local`, this field must be omitted. If the repository is publicly + available you can provide a 'https' URL like + `https://github.com/IBM/CodeEngine`. If the repository requires + authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that + points to a secret of format `ssh_auth`. + :param str strategy_size: (optional) Optional size for the build, which + determines the amount of resources used. Build sizes are `small`, `medium`, + `large`, `xlarge`, `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the + specification file that is used for build strategies for building an image. + :param int timeout: (optional) The maximum amount of time, in seconds, that + can pass before the build must succeed or fail. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `ConfigMap` object + :rtype: DetailedResponse with `dict` result representing a `Build` object """ if not project_id: raise ValueError('project_id must be provided') if name is None: raise ValueError('name must be provided') + if output_image is None: + raise ValueError('output_image must be provided') + if output_secret is None: + raise ValueError('output_secret must be provided') + if strategy_type is None: + raise ValueError('strategy_type must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_config_map' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_build', ) headers.update(sdk_headers) data = { 'name': name, - 'data': data, + 'output_image': output_image, + 'output_secret': output_secret, + 'strategy_type': strategy_type, + 'source_context_dir': source_context_dir, + 'source_revision': source_revision, + 'source_secret': source_secret, + 'source_type': source_type, + 'source_url': source_url, + 'strategy_size': strategy_size, + 'strategy_spec_file': strategy_spec_file, + 'timeout': timeout, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1973,23 +2598,33 @@ def create_config_map(self, project_id: str, name: str, *, data: dict = None, ** path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/config_maps'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + url = '/projects/{project_id}/builds'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) response = self.send(request, **kwargs) return response - def get_config_map(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_build( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ - Get a config map. + Get a build. - Display the details of a config map. + Display the details of a build. :param str project_id: The ID of the project. - :param str name: The name of your configmap. + :param str name: The name of your build. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `ConfigMap` object + :rtype: DetailedResponse with `dict` result representing a `Build` object """ if not project_id: @@ -1998,7 +2633,9 @@ def get_config_map(self, project_id: str, name: str, **kwargs) -> DetailedRespon raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_config_map' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_build', ) headers.update(sdk_headers) @@ -2010,134 +2647,171 @@ def get_config_map(self, project_id: str, name: str, **kwargs) -> DetailedRespon path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/config_maps/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + url = '/projects/{project_id}/builds/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def replace_config_map( - self, project_id: str, name: str, if_match: str, *, data: dict = None, **kwargs + def delete_build( + self, + project_id: str, + name: str, + **kwargs, ) -> DetailedResponse: """ - Update a config map. + Delete a build. - Update a config map. + Delete a build. :param str project_id: The ID of the project. - :param str name: The name of your configmap. - :param str if_match: Version of the config map settings to be updated. - Specify the version that you retrieved as entity_tag (ETag header) when - reading the config map. This value helps identifying parallel usage of this - API. Pass * to indicate to update any version available. This might result - in stale updates. - :param dict data: (optional) The key-value pair for the config map. Values - must be specified in `KEY=VALUE` format. Each `KEY` field must consist of - alphanumeric characters, `-`, `_` or `.` and must not be exceed a max - length of 253 characters. Each `VALUE` field can consists of any character - and must not be exceed a max length of 1048576 characters. + :param str name: The name of your build. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `ConfigMap` object + :rtype: DetailedResponse """ if not project_id: raise ValueError('project_id must be provided') if not name: raise ValueError('name must be provided') - if not if_match: - raise ValueError('if_match must be provided') - headers = { - 'If-Match': if_match, - } + headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='replace_config_map' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_build', ) headers.update(sdk_headers) - data = { - 'data': data, - } - data = {k: v for (k, v) in data.items() if v is not None} - data = json.dumps(data) - headers['content-type'] = 'application/json' - if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] - headers['Accept'] = 'application/json' path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/config_maps/{name}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) + url = '/projects/{project_id}/builds/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def delete_config_map(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def update_build( + self, + project_id: str, + name: str, + if_match: str, + build: 'BuildPatch', + **kwargs, + ) -> DetailedResponse: """ - Delete a config map. + Update a build. - Delete a config map. + Update a build. :param str project_id: The ID of the project. - :param str name: The name of your configmap. + :param str name: The name of your build. + :param str if_match: Version of the build settings to be updated. Specify + the version that you retrieved as entity_tag (ETag header) when reading the + build. This value helps identifying parallel usage of this API. Pass * to + indicate to update any version available. This might result in stale + updates. + :param BuildPatch build: Build patch. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse + :rtype: DetailedResponse with `dict` result representing a `Build` object """ if not project_id: raise ValueError('project_id must be provided') if not name: raise ValueError('name must be provided') - headers = {} + if not if_match: + raise ValueError('if_match must be provided') + if build is None: + raise ValueError('build must be provided') + if isinstance(build, BuildPatch): + build = convert_model(build) + headers = { + 'If-Match': if_match, + } sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_config_map' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_build', ) headers.update(sdk_headers) + data = json.dumps(build) + headers['content-type'] = 'application/merge-patch+json' + if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] + headers['Accept'] = 'application/json' path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/config_maps/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + url = '/projects/{project_id}/builds/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) response = self.send(request, **kwargs) return response - def list_secrets(self, project_id: str, *, limit: int = None, start: str = None, **kwargs) -> DetailedResponse: + def list_build_runs( + self, + project_id: str, + *, + build_name: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ - List secrets. + List build runs. - List all secrets in a project. + List all build runs in a project. :param str project_id: The ID of the project. - :param int limit: (optional) Optional maximum number of secrets per page. + :param str build_name: (optional) Optional name of the build that should be + filtered for. + :param int limit: (optional) Optional maximum number of build runs per + page. :param str start: (optional) An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of results is returned. This value is obtained from the 'start' query - parameter in the 'next_url' field of the operation response. + parameter in the `next` object of the operation response. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `SecretList` object + :rtype: DetailedResponse with `dict` result representing a `BuildRunList` object """ if not project_id: raise ValueError('project_id must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_secrets' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_build_runs', ) headers.update(sdk_headers) params = { + 'build_name': build_name, 'limit': limit, 'start': start, } @@ -2150,51 +2824,122 @@ def list_secrets(self, project_id: str, *, limit: int = None, start: str = None, path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/secrets'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers, params=params) + url = '/projects/{project_id}/build_runs'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) response = self.send(request, **kwargs) return response - def create_secret( - self, project_id: str, format: str, name: str, *, data: 'SecretData' = None, **kwargs + def create_build_run( + self, + project_id: str, + *, + build_name: Optional[str] = None, + name: Optional[str] = None, + output_image: Optional[str] = None, + output_secret: Optional[str] = None, + service_account: Optional[str] = None, + source_context_dir: Optional[str] = None, + source_revision: Optional[str] = None, + source_secret: Optional[str] = None, + source_type: Optional[str] = None, + source_url: Optional[str] = None, + strategy_size: Optional[str] = None, + strategy_spec_file: Optional[str] = None, + strategy_type: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs, ) -> DetailedResponse: """ - Create a secret. + Create a build run. - Create a secret. + Create a build run. :param str project_id: The ID of the project. - :param str format: Specify the format of the secret. - :param str name: The name of the secret. - :param SecretData data: (optional) Data container that allows to specify - config parameters and their values as a key-value map. Each key field must - consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed - a max length of 253 characters. Each value field can consists of any - character and must not be exceed a max length of 1048576 characters. + :param str build_name: (optional) Optional name of the build on which this + build run is based on. If specified, the build run will inherit the + configuration of the referenced build. If not specified, make sure to + specify at least the fields `strategy_type`, `source_url`, `output_image` + and `output_secret` to describe the build run. + :param str name: (optional) Name of the build run. This field is optional, + if the field `build_name` is specified and its value will be generated like + so: `[BUILD_NAME]-run-[timestamp with format: YYMMDD-hhmmss] if not set.`. + :param str output_image: (optional) The name of the image. + :param str output_secret: (optional) The secret that is required to access + the image registry. Make sure that the secret is granted with push + permissions towards the specified container registry namespace. + :param str service_account: (optional) Optional service account, which is + used for resource control.” or “Optional service account that is used for + resource control. + :param str source_context_dir: (optional) Optional directory in the + repository that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` + and uses the HEAD of default branch if not specified. If the `source_type` + value is `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access + the repository source. This field is optional if the `source_type` is + `git`. Additionally, if the `source_url` points to a repository that + requires authentication, the build will be created but cannot access any + source code, until this property is provided, too. If the `source_type` + value is `local`, this field must be omitted. + :param str source_type: (optional) Specifies the type of source to + determine if your build source is in a repository or based on local source + code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This + field is required if the `source_type` is `git`. If the `source_type` value + is `local`, this field must be omitted. If the repository is publicly + available you can provide a 'https' URL like + `https://github.com/IBM/CodeEngine`. If the repository requires + authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that + points to a secret of format `ssh_auth`. + :param str strategy_size: (optional) Optional size for the build, which + determines the amount of resources used. Build sizes are `small`, `medium`, + `large`, `xlarge`, `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the + specification file that is used for build strategies for building an image. + :param str strategy_type: (optional) The strategy to use for building the + image. + :param int timeout: (optional) The maximum amount of time, in seconds, that + can pass before the build must succeed or fail. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Secret` object + :rtype: DetailedResponse with `dict` result representing a `BuildRun` object """ if not project_id: raise ValueError('project_id must be provided') - if format is None: - raise ValueError('format must be provided') - if name is None: - raise ValueError('name must be provided') - if data is not None: - data = convert_model(data) headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_secret' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_build_run', ) headers.update(sdk_headers) data = { - 'format': format, + 'build_name': build_name, 'name': name, - 'data': data, + 'output_image': output_image, + 'output_secret': output_secret, + 'service_account': service_account, + 'source_context_dir': source_context_dir, + 'source_revision': source_revision, + 'source_secret': source_secret, + 'source_type': source_type, + 'source_url': source_url, + 'strategy_size': strategy_size, + 'strategy_spec_file': strategy_spec_file, + 'strategy_type': strategy_type, + 'timeout': timeout, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -2208,23 +2953,33 @@ def create_secret( path_param_keys = ['project_id'] path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/secrets'.format(**path_param_dict) - request = self.prepare_request(method='POST', url=url, headers=headers, data=data) + url = '/projects/{project_id}/build_runs'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) response = self.send(request, **kwargs) return response - def get_secret(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_build_run( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ - Get a secret. + Get a build run. - Get a secret. + Display the details of a build run. :param str project_id: The ID of the project. - :param str name: The name of your secret. + :param str name: The name of your build run. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Secret` object + :rtype: DetailedResponse with `dict` result representing a `BuildRun` object """ if not project_id: @@ -2233,7 +2988,9 @@ def get_secret(self, project_id: str, name: str, **kwargs) -> DetailedResponse: raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_secret' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_build_run', ) headers.update(sdk_headers) @@ -2245,57 +3002,170 @@ def get_secret(self, project_id: str, name: str, **kwargs) -> DetailedResponse: path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/secrets/{name}'.format(**path_param_dict) - request = self.prepare_request(method='GET', url=url, headers=headers) + url = '/projects/{project_id}/build_runs/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response - def replace_secret( - self, project_id: str, name: str, if_match: str, *, data: 'SecretData' = None, format: str = None, **kwargs + def delete_build_run( + self, + project_id: str, + name: str, + **kwargs, ) -> DetailedResponse: """ - Update a secret. + Delete a build run. - Update a secret. + Delete a build run. :param str project_id: The ID of the project. - :param str name: The name of your secret. - :param str if_match: Version of the secret settings to be updated. Specify - the version that you retrieved as entity_tag (ETag header) when reading the - secret. This value helps identifying parallel usage of this API. Pass * to - indicate to update any version available. This might result in stale - updates. - :param SecretData data: (optional) Data container that allows to specify - config parameters and their values as a key-value map. Each key field must - consist of alphanumeric characters, `-`, `_` or `.` and must not be exceed - a max length of 253 characters. Each value field can consists of any - character and must not be exceed a max length of 1048576 characters. - :param str format: (optional) Specify the format of the secret. + :param str name: The name of your build run. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Secret` object + :rtype: DetailedResponse """ if not project_id: raise ValueError('project_id must be provided') if not name: raise ValueError('name must be provided') - if not if_match: - raise ValueError('if_match must be provided') - if data is not None: - data = convert_model(data) - headers = { - 'If-Match': if_match, + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_build_run', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/build_runs/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + ######################### + # Domain mappings + ######################### + + def list_domain_mappings( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + List domain mappings. + + List all domain mappings in a project. + + :param str project_id: The ID of the project. + :param int limit: (optional) Optional maximum number of domain mappings per + page. + :param str start: (optional) An optional token that indicates the beginning + of the page of results to be returned. If omitted, the first page of + results is returned. This value is obtained from the 'start' query + parameter in the `next` object of the operation response. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `DomainMappingList` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_domain_mappings', + ) + headers.update(sdk_headers) + + params = { + 'limit': limit, + 'start': start, } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/domain_mappings'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_domain_mapping( + self, + project_id: str, + component: 'ComponentRef', + name: str, + tls_secret: str, + **kwargs, + ) -> DetailedResponse: + """ + Create a domain mapping. + + Create a domain mapping. + + :param str project_id: The ID of the project. + :param ComponentRef component: A reference to another component. + :param str name: The name of the domain mapping. + :param str tls_secret: The name of the TLS secret that includes the + certificate and private key of this domain mapping. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `DomainMapping` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if component is None: + raise ValueError('component must be provided') + if name is None: + raise ValueError('name must be provided') + if tls_secret is None: + raise ValueError('tls_secret must be provided') + component = convert_model(component) + headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='replace_secret' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_domain_mapping', ) headers.update(sdk_headers) data = { - 'data': data, - 'format': format, + 'component': component, + 'name': name, + 'tls_secret': tls_secret, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -2306,26 +3176,36 @@ def replace_secret( del kwargs['headers'] headers['Accept'] = 'application/json' - path_param_keys = ['project_id', 'name'] - path_param_values = self.encode_path_vars(project_id, name) + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/secrets/{name}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) + url = '/projects/{project_id}/domain_mappings'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) response = self.send(request, **kwargs) return response - def delete_secret(self, project_id: str, name: str, **kwargs) -> DetailedResponse: + def get_domain_mapping( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: """ - Delete a secret. + Get a domain mapping. - Delete a secret. + Get domain mapping. :param str project_id: The ID of the project. - :param str name: The name of your secret. + :param str name: The name of your domain mapping. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse + :rtype: DetailedResponse with `dict` result representing a `DomainMapping` object """ if not project_id: @@ -2334,439 +3214,5006 @@ def delete_secret(self, project_id: str, name: str, **kwargs) -> DetailedRespons raise ValueError('name must be provided') headers = {} sdk_headers = get_sdk_headers( - service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_secret' + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_domain_mapping', ) headers.update(sdk_headers) if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] + headers['Accept'] = 'application/json' path_param_keys = ['project_id', 'name'] path_param_values = self.encode_path_vars(project_id, name) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/projects/{project_id}/secrets/{name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', url=url, headers=headers) + url = '/projects/{project_id}/domain_mappings/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) response = self.send(request, **kwargs) return response + def delete_domain_mapping( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete a domain mapping. -############################################################################## -# Models -############################################################################## + Delete a domain mapping. + :param str project_id: The ID of the project. + :param str name: The name of your domain mapping. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ -class App: - """ - App is the response model for app resources. + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_domain_mapping', + ) + headers.update(sdk_headers) - :attr str created_at: (optional) The date when the resource was created. - :attr str endpoint: (optional) Optional URL to invoke app. Depending on - visibility this is accessible publicly ot in the private network only. Empty in - case 'managed_domain_mappings' is set to 'local'. - :attr str endpoint_internal: (optional) URL to app that is only visible within - the project. - :attr str entity_tag: The version of the app instance, which is used to achieve - optimistic locking. - :attr str href: (optional) When you provision a new app, a URL is created - identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr int image_port: (optional) Optional port the app listens on. While the app - will always be exposed via port `443` for end users, this port is used to - connect to the port that is exposed by the container image. - :attr str image_reference: The name of the image that is used for this job. The - format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are - optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` - is not specified, the default is `latest`. If the image reference points to a - registry that requires authentication, make sure to also specify the property - `image_secret`. - :attr str image_secret: (optional) Optional name of the image registry access - secret. The image registry access secret is used to authenticate with a private - registry when you download the container image. If the image reference points to - a registry that requires authentication, the app will be created but cannot + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/domain_mappings/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_domain_mapping( + self, + project_id: str, + name: str, + if_match: str, + domain_mapping: 'DomainMappingPatch', + **kwargs, + ) -> DetailedResponse: + """ + Update a domain mapping. + + Update a domain mapping. + + :param str project_id: The ID of the project. + :param str name: The name of your domain mapping. + :param str if_match: Version of the domain mapping to be updated. Specify + the version that you retrieved as entity_tag (ETag header) when reading the + domain mapping. This value helps identify parallel usage of this API. Pass + * to indicate to update any version available. This might result in stale + updates. + :param DomainMappingPatch domain_mapping: DomainMapping patch. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `DomainMapping` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if domain_mapping is None: + raise ValueError('domain_mapping must be provided') + if isinstance(domain_mapping, DomainMappingPatch): + domain_mapping = convert_model(domain_mapping) + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_domain_mapping', + ) + headers.update(sdk_headers) + + data = json.dumps(domain_mapping) + headers['content-type'] = 'application/merge-patch+json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/domain_mappings/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + ######################### + # Secrets and configmaps + ######################### + + def list_config_maps( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + List config maps. + + List all config maps in a project. + + :param str project_id: The ID of the project. + :param int limit: (optional) Optional maximum number of config maps per + page. + :param str start: (optional) An optional token that indicates the beginning + of the page of results to be returned. If omitted, the first page of + results is returned. This value is obtained from the 'start' query + parameter in the `next` object of the operation response. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `ConfigMapList` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_config_maps', + ) + headers.update(sdk_headers) + + params = { + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/config_maps'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_config_map( + self, + project_id: str, + name: str, + *, + data: Optional[dict] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create a config map. + + Create a config map. + + :param str project_id: The ID of the project. + :param str name: The name of the configmap. Use a name that is unique + within the project. + :param dict data: (optional) The key-value pair for the config map. Values + must be specified in `KEY=VALUE` format. Each `KEY` field must consist of + alphanumeric characters, `-`, `_` or `.` and must not be exceed a max + length of 253 characters. Each `VALUE` field can consists of any character + and must not be exceed a max length of 1048576 characters. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `ConfigMap` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if name is None: + raise ValueError('name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_config_map', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'data': data, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/config_maps'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_config_map( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: + """ + Get a config map. + + Display the details of a config map. + + :param str project_id: The ID of the project. + :param str name: The name of your configmap. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `ConfigMap` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_config_map', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/config_maps/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def replace_config_map( + self, + project_id: str, + name: str, + if_match: str, + *, + data: Optional[dict] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update a config map. + + Update a config map. + + :param str project_id: The ID of the project. + :param str name: The name of your configmap. + :param str if_match: Version of the config map settings to be updated. + Specify the version that you retrieved as entity_tag (ETag header) when + reading the config map. This value helps identifying parallel usage of this + API. Pass * to indicate to update any version available. This might result + in stale updates. + :param dict data: (optional) The key-value pair for the config map. Values + must be specified in `KEY=VALUE` format. Each `KEY` field must consist of + alphanumeric characters, `-`, `_` or `.` and must not be exceed a max + length of 253 characters. Each `VALUE` field can consists of any character + and must not be exceed a max length of 1048576 characters. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `ConfigMap` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + if not if_match: + raise ValueError('if_match must be provided') + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='replace_config_map', + ) + headers.update(sdk_headers) + + data = { + 'data': data, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/config_maps/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_config_map( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete a config map. + + Delete a config map. + + :param str project_id: The ID of the project. + :param str name: The name of your configmap. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_config_map', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/config_maps/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def list_secrets( + self, + project_id: str, + *, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + List secrets. + + List all secrets in a project. + + :param str project_id: The ID of the project. + :param int limit: (optional) Optional maximum number of secrets per page. + :param str start: (optional) An optional token that indicates the beginning + of the page of results to be returned. If omitted, the first page of + results is returned. This value is obtained from the 'start' query + parameter in the `next` object of the operation response. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `SecretList` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_secrets', + ) + headers.update(sdk_headers) + + params = { + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/secrets'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_secret( + self, + project_id: str, + format: str, + name: str, + *, + data: Optional['SecretData'] = None, + service_access: Optional['ServiceAccessSecretPrototypeProps'] = None, + service_operator: Optional['OperatorSecretPrototypeProps'] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create a secret. + + Create a secret. + + :param str project_id: The ID of the project. + :param str format: Specify the format of the secret. The format of the + secret will determine how the secret is used. + :param str name: The name of the secret. + :param SecretData data: (optional) Data container that allows to specify + config parameters and their values as a key-value map. Each key field must + consist of alphanumeric characters, `-`, `_` or `.` and must not exceed a + max length of 253 characters. Each value field can consists of any + character and must not exceed a max length of 1048576 characters. + :param ServiceAccessSecretPrototypeProps service_access: (optional) + Properties for Service Access Secrets. + :param OperatorSecretPrototypeProps service_operator: (optional) Properties + for the IBM Cloud Operator Secrets. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `Secret` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if format is None: + raise ValueError('format must be provided') + if name is None: + raise ValueError('name must be provided') + if data is not None: + data = convert_model(data) + if service_access is not None: + service_access = convert_model(service_access) + if service_operator is not None: + service_operator = convert_model(service_operator) + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_secret', + ) + headers.update(sdk_headers) + + data = { + 'format': format, + 'name': name, + 'data': data, + 'service_access': service_access, + 'service_operator': service_operator, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id'] + path_param_values = self.encode_path_vars(project_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/secrets'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_secret( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: + """ + Get a secret. + + Get a secret. + + :param str project_id: The ID of the project. + :param str name: The name of your secret. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `Secret` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_secret', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/secrets/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def replace_secret( + self, + project_id: str, + name: str, + if_match: str, + format: str, + *, + data: Optional['SecretData'] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update a secret. + + Update a secret. + + :param str project_id: The ID of the project. + :param str name: The name of your secret. + :param str if_match: Version of the secret settings to be updated. Specify + the version that you retrieved as entity_tag (ETag header) when reading the + secret. This value helps identifying parallel usage of this API. Pass * to + indicate to update any version available. This might result in stale + updates. + :param str format: Specify the format of the secret. The format of the + secret will determine how the secret is used. + :param SecretData data: (optional) Data container that allows to specify + config parameters and their values as a key-value map. Each key field must + consist of alphanumeric characters, `-`, `_` or `.` and must not exceed a + max length of 253 characters. Each value field can consists of any + character and must not exceed a max length of 1048576 characters. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `Secret` object + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if format is None: + raise ValueError('format must be provided') + if data is not None: + data = convert_model(data) + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='replace_secret', + ) + headers.update(sdk_headers) + + data = { + 'format': format, + 'data': data, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/secrets/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_secret( + self, + project_id: str, + name: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete a secret. + + Delete a secret. + + :param str project_id: The ID of the project. + :param str name: The name of your secret. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not project_id: + raise ValueError('project_id must be provided') + if not name: + raise ValueError('name must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_secret', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['project_id', 'name'] + path_param_values = self.encode_path_vars(project_id, name) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/projects/{project_id}/secrets/{name}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + +############################################################################## +# Models +############################################################################## + + +class App: + """ + App is the response model for app resources. + + :param str build: (optional) Reference to a build that is associated with the + application. + :param str build_run: (optional) Reference to a build run that is associated + with the application. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine and + are exposed as environment variables in the application. + :param str created_at: (optional) The timestamp when the resource was created. + :param str endpoint: (optional) Optional URL to invoke the app. Depending on + visibility, this is accessible publicly or in the private network only. Empty + in case 'managed_domain_mappings' is set to 'local'. + :param str endpoint_internal: (optional) The URL to the app that is only visible + within the project. + :param str entity_tag: The version of the app instance, which is used to achieve + optimistic locking. + :param str href: (optional) When you provision a new app, a URL is created + identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param int image_port: (optional) Optional port the app listens on. While the + app will always be exposed via port `443` for end users, this port is used to + connect to the port that is exposed by the container image. + :param str image_reference: The name of the image that is used for this app. The + format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are + optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` + is not specified, the default is `latest`. If the image reference points to a + registry that requires authentication, make sure to also specify the property + `image_secret`. + :param str image_secret: (optional) Optional name of the image registry access + secret. The image registry access secret is used to authenticate with a private + registry when you download the container image. If the image reference points to + a registry that requires authentication, the app will be created but cannot + reach the ready status, until this property is provided, too. + :param str managed_domain_mappings: Optional value controlling which of the + system managed domain mappings will be setup for the application. Valid values + are 'local_public', 'local_private' and 'local'. Visibility can only be + 'local_private' if the project supports application private visibility. + :param str name: The name of the app. + :param Probe probe_liveness: (optional) Response model for probes. + :param Probe probe_readiness: (optional) Response model for probes. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the app. + :param List[str] run_arguments: Optional arguments for the app that are passed + to start the container. If not specified an empty string array will be applied + and the arguments specified by the container image, will be used to start the + container. + :param int run_as_user: (optional) Optional user ID (UID) to run the app. + :param List[str] run_commands: Optional commands for the app that are passed to + start the container. If not specified an empty string array will be applied and + the command specified by the container image, will be used to start the + container. + :param List[EnvVar] run_env_variables: References to config maps, secrets or + literal values, which are defined by the app owner and are exposed as + environment variables in the application. + :param str run_service_account: (optional) Optional name of the service account. + For built-in service accounts, you can use the shortened names `manager` , + `none`, `reader`, and `writer`. + :param List[VolumeMount] run_volume_mounts: Mounts of config maps or secrets. + :param int scale_concurrency: (optional) Optional maximum number of requests + that can be processed concurrently per instance. + :param int scale_concurrency_target: (optional) Optional threshold of concurrent + requests per instance at which one or more additional instances are created. Use + this value to scale up instances based on concurrent number of requests. This + option defaults to the value of the `scale_concurrency` option, if not + specified. + :param str scale_cpu_limit: Optional number of CPU set for the instance of the + app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds that + delays the scale-down behavior for an app instance. + :param str scale_ephemeral_storage_limit: Optional amount of ephemeral storage + to set for the instance of the app. The amount specified as ephemeral storage, + must not exceed the amount of `scale_memory_limit`. The units for specifying + ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the + shorthand expressions for GB and MB. For more information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_initial_instances: (optional) Optional initial number of + instances that are created upon app creation or app update. + :param int scale_max_instances: Optional maximum number of instances for this + app. If you set this value to `0`, this property does not set a upper scaling + limit. However, the app scaling is still limited by the project quota for + instances. See [Limits and quotas for Code + Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). + :param str scale_memory_limit: Optional amount of memory set for the instance of + the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_min_instances: Optional minimum number of instances for this + app. If you set this value to `0`, the app will scale down to zero, if not hit + by any request for some time. + :param int scale_request_timeout: Optional amount of time in seconds that is + allowed for a running app to respond to a request. + :param str status: (optional) The current status of the app. + :param AppStatus status_details: (optional) The detailed status of the + application. + """ + + def __init__( + self, + entity_tag: str, + image_reference: str, + managed_domain_mappings: str, + name: str, + run_arguments: List[str], + run_commands: List[str], + run_env_variables: List['EnvVar'], + run_volume_mounts: List['VolumeMount'], + scale_cpu_limit: str, + scale_ephemeral_storage_limit: str, + scale_max_instances: int, + scale_memory_limit: str, + scale_min_instances: int, + scale_request_timeout: int, + *, + build: Optional[str] = None, + build_run: Optional[str] = None, + computed_env_variables: Optional[List['EnvVar']] = None, + created_at: Optional[str] = None, + endpoint: Optional[str] = None, + endpoint_internal: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + image_port: Optional[int] = None, + image_secret: Optional[str] = None, + probe_liveness: Optional['Probe'] = None, + probe_readiness: Optional['Probe'] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + run_as_user: Optional[int] = None, + run_service_account: Optional[str] = None, + scale_concurrency: Optional[int] = None, + scale_concurrency_target: Optional[int] = None, + scale_down_delay: Optional[int] = None, + scale_initial_instances: Optional[int] = None, + status: Optional[str] = None, + status_details: Optional['AppStatus'] = None, + ) -> None: + """ + Initialize a App object. + + :param str entity_tag: The version of the app instance, which is used to + achieve optimistic locking. + :param str image_reference: The name of the image that is used for this + app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + `TAG` are optional. If `REGISTRY` is not specified, the default is + `docker.io`. If `TAG` is not specified, the default is `latest`. If the + image reference points to a registry that requires authentication, make + sure to also specify the property `image_secret`. + :param str managed_domain_mappings: Optional value controlling which of the + system managed domain mappings will be setup for the application. Valid + values are 'local_public', 'local_private' and 'local'. Visibility can only + be 'local_private' if the project supports application private visibility. + :param str name: The name of the app. + :param List[str] run_arguments: Optional arguments for the app that are + passed to start the container. If not specified an empty string array will + be applied and the arguments specified by the container image, will be used + to start the container. + :param List[str] run_commands: Optional commands for the app that are + passed to start the container. If not specified an empty string array will + be applied and the command specified by the container image, will be used + to start the container. + :param List[EnvVar] run_env_variables: References to config maps, secrets + or literal values, which are defined by the app owner and are exposed as + environment variables in the application. + :param List[VolumeMount] run_volume_mounts: Mounts of config maps or + secrets. + :param str scale_cpu_limit: Optional number of CPU set for the instance of + the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: Optional amount of ephemeral + storage to set for the instance of the app. The amount specified as + ephemeral storage, must not exceed the amount of `scale_memory_limit`. The + units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), + whereas G and M are the shorthand expressions for GB and MB. For more + information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_instances: Optional maximum number of instances for + this app. If you set this value to `0`, this property does not set a upper + scaling limit. However, the app scaling is still limited by the project + quota for instances. See [Limits and quotas for Code + Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). + :param str scale_memory_limit: Optional amount of memory set for the + instance of the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_min_instances: Optional minimum number of instances for + this app. If you set this value to `0`, the app will scale down to zero, if + not hit by any request for some time. + :param int scale_request_timeout: Optional amount of time in seconds that + is allowed for a running app to respond to a request. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine + and are exposed as environment variables in the application. + :param int image_port: (optional) Optional port the app listens on. While + the app will always be exposed via port `443` for end users, this port is + used to connect to the port that is exposed by the container image. + :param str image_secret: (optional) Optional name of the image registry + access secret. The image registry access secret is used to authenticate + with a private registry when you download the container image. If the image + reference points to a registry that requires authentication, the app will + be created but cannot reach the ready status, until this property is + provided, too. + :param Probe probe_liveness: (optional) Response model for probes. + :param Probe probe_readiness: (optional) Response model for probes. + :param int run_as_user: (optional) Optional user ID (UID) to run the app. + :param str run_service_account: (optional) Optional name of the service + account. For built-in service accounts, you can use the shortened names + `manager` , `none`, `reader`, and `writer`. + :param int scale_concurrency: (optional) Optional maximum number of + requests that can be processed concurrently per instance. + :param int scale_concurrency_target: (optional) Optional threshold of + concurrent requests per instance at which one or more additional instances + are created. Use this value to scale up instances based on concurrent + number of requests. This option defaults to the value of the + `scale_concurrency` option, if not specified. + :param int scale_down_delay: (optional) Optional amount of time in seconds + that delays the scale-down behavior for an app instance. + :param int scale_initial_instances: (optional) Optional initial number of + instances that are created upon app creation or app update. + :param AppStatus status_details: (optional) The detailed status of the + application. + """ + self.build = build + self.build_run = build_run + self.computed_env_variables = computed_env_variables + self.created_at = created_at + self.endpoint = endpoint + self.endpoint_internal = endpoint_internal + self.entity_tag = entity_tag + self.href = href + self.id = id + self.image_port = image_port + self.image_reference = image_reference + self.image_secret = image_secret + self.managed_domain_mappings = managed_domain_mappings + self.name = name + self.probe_liveness = probe_liveness + self.probe_readiness = probe_readiness + self.project_id = project_id + self.region = region + self.resource_type = resource_type + self.run_arguments = run_arguments + self.run_as_user = run_as_user + self.run_commands = run_commands + self.run_env_variables = run_env_variables + self.run_service_account = run_service_account + self.run_volume_mounts = run_volume_mounts + self.scale_concurrency = scale_concurrency + self.scale_concurrency_target = scale_concurrency_target + self.scale_cpu_limit = scale_cpu_limit + self.scale_down_delay = scale_down_delay + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_initial_instances = scale_initial_instances + self.scale_max_instances = scale_max_instances + self.scale_memory_limit = scale_memory_limit + self.scale_min_instances = scale_min_instances + self.scale_request_timeout = scale_request_timeout + self.status = status + self.status_details = status_details + + @classmethod + def from_dict(cls, _dict: Dict) -> 'App': + """Initialize a App object from a json dictionary.""" + args = {} + if (build := _dict.get('build')) is not None: + args['build'] = build + if (build_run := _dict.get('build_run')) is not None: + args['build_run'] = build_run + if (computed_env_variables := _dict.get('computed_env_variables')) is not None: + args['computed_env_variables'] = [EnvVar.from_dict(v) for v in computed_env_variables] + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (endpoint := _dict.get('endpoint')) is not None: + args['endpoint'] = endpoint + if (endpoint_internal := _dict.get('endpoint_internal')) is not None: + args['endpoint_internal'] = endpoint_internal + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag + else: + raise ValueError('Required property \'entity_tag\' not present in App JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (image_port := _dict.get('image_port')) is not None: + args['image_port'] = image_port + if (image_reference := _dict.get('image_reference')) is not None: + args['image_reference'] = image_reference + else: + raise ValueError('Required property \'image_reference\' not present in App JSON') + if (image_secret := _dict.get('image_secret')) is not None: + args['image_secret'] = image_secret + if (managed_domain_mappings := _dict.get('managed_domain_mappings')) is not None: + args['managed_domain_mappings'] = managed_domain_mappings + else: + raise ValueError('Required property \'managed_domain_mappings\' not present in App JSON') + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in App JSON') + if (probe_liveness := _dict.get('probe_liveness')) is not None: + args['probe_liveness'] = Probe.from_dict(probe_liveness) + if (probe_readiness := _dict.get('probe_readiness')) is not None: + args['probe_readiness'] = Probe.from_dict(probe_readiness) + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (run_arguments := _dict.get('run_arguments')) is not None: + args['run_arguments'] = run_arguments + else: + raise ValueError('Required property \'run_arguments\' not present in App JSON') + if (run_as_user := _dict.get('run_as_user')) is not None: + args['run_as_user'] = run_as_user + if (run_commands := _dict.get('run_commands')) is not None: + args['run_commands'] = run_commands + else: + raise ValueError('Required property \'run_commands\' not present in App JSON') + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVar.from_dict(v) for v in run_env_variables] + else: + raise ValueError('Required property \'run_env_variables\' not present in App JSON') + if (run_service_account := _dict.get('run_service_account')) is not None: + args['run_service_account'] = run_service_account + if (run_volume_mounts := _dict.get('run_volume_mounts')) is not None: + args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in run_volume_mounts] + else: + raise ValueError('Required property \'run_volume_mounts\' not present in App JSON') + if (scale_concurrency := _dict.get('scale_concurrency')) is not None: + args['scale_concurrency'] = scale_concurrency + if (scale_concurrency_target := _dict.get('scale_concurrency_target')) is not None: + args['scale_concurrency_target'] = scale_concurrency_target + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + else: + raise ValueError('Required property \'scale_cpu_limit\' not present in App JSON') + if (scale_down_delay := _dict.get('scale_down_delay')) is not None: + args['scale_down_delay'] = scale_down_delay + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + else: + raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in App JSON') + if (scale_initial_instances := _dict.get('scale_initial_instances')) is not None: + args['scale_initial_instances'] = scale_initial_instances + if (scale_max_instances := _dict.get('scale_max_instances')) is not None: + args['scale_max_instances'] = scale_max_instances + else: + raise ValueError('Required property \'scale_max_instances\' not present in App JSON') + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + else: + raise ValueError('Required property \'scale_memory_limit\' not present in App JSON') + if (scale_min_instances := _dict.get('scale_min_instances')) is not None: + args['scale_min_instances'] = scale_min_instances + else: + raise ValueError('Required property \'scale_min_instances\' not present in App JSON') + if (scale_request_timeout := _dict.get('scale_request_timeout')) is not None: + args['scale_request_timeout'] = scale_request_timeout + else: + raise ValueError('Required property \'scale_request_timeout\' not present in App JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = AppStatus.from_dict(status_details) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a App object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'build') and getattr(self, 'build') is not None: + _dict['build'] = getattr(self, 'build') + if hasattr(self, 'build_run') and getattr(self, 'build_run') is not None: + _dict['build_run'] = getattr(self, 'build_run') + if hasattr(self, 'computed_env_variables') and self.computed_env_variables is not None: + computed_env_variables_list = [] + for v in self.computed_env_variables: + if isinstance(v, dict): + computed_env_variables_list.append(v) + else: + computed_env_variables_list.append(v.to_dict()) + _dict['computed_env_variables'] = computed_env_variables_list + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'endpoint') and getattr(self, 'endpoint') is not None: + _dict['endpoint'] = getattr(self, 'endpoint') + if hasattr(self, 'endpoint_internal') and getattr(self, 'endpoint_internal') is not None: + _dict['endpoint_internal'] = getattr(self, 'endpoint_internal') + if hasattr(self, 'entity_tag') and self.entity_tag is not None: + _dict['entity_tag'] = self.entity_tag + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'image_port') and self.image_port is not None: + _dict['image_port'] = self.image_port + if hasattr(self, 'image_reference') and self.image_reference is not None: + _dict['image_reference'] = self.image_reference + if hasattr(self, 'image_secret') and self.image_secret is not None: + _dict['image_secret'] = self.image_secret + if hasattr(self, 'managed_domain_mappings') and self.managed_domain_mappings is not None: + _dict['managed_domain_mappings'] = self.managed_domain_mappings + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'probe_liveness') and self.probe_liveness is not None: + if isinstance(self.probe_liveness, dict): + _dict['probe_liveness'] = self.probe_liveness + else: + _dict['probe_liveness'] = self.probe_liveness.to_dict() + if hasattr(self, 'probe_readiness') and self.probe_readiness is not None: + if isinstance(self.probe_readiness, dict): + _dict['probe_readiness'] = self.probe_readiness + else: + _dict['probe_readiness'] = self.probe_readiness.to_dict() + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'run_arguments') and self.run_arguments is not None: + _dict['run_arguments'] = self.run_arguments + if hasattr(self, 'run_as_user') and self.run_as_user is not None: + _dict['run_as_user'] = self.run_as_user + if hasattr(self, 'run_commands') and self.run_commands is not None: + _dict['run_commands'] = self.run_commands + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: + if isinstance(v, dict): + run_env_variables_list.append(v) + else: + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'run_service_account') and self.run_service_account is not None: + _dict['run_service_account'] = self.run_service_account + if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: + run_volume_mounts_list = [] + for v in self.run_volume_mounts: + if isinstance(v, dict): + run_volume_mounts_list.append(v) + else: + run_volume_mounts_list.append(v.to_dict()) + _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: + _dict['scale_concurrency'] = self.scale_concurrency + if hasattr(self, 'scale_concurrency_target') and self.scale_concurrency_target is not None: + _dict['scale_concurrency_target'] = self.scale_concurrency_target + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_down_delay') and self.scale_down_delay is not None: + _dict['scale_down_delay'] = self.scale_down_delay + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_initial_instances') and self.scale_initial_instances is not None: + _dict['scale_initial_instances'] = self.scale_initial_instances + if hasattr(self, 'scale_max_instances') and self.scale_max_instances is not None: + _dict['scale_max_instances'] = self.scale_max_instances + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'scale_min_instances') and self.scale_min_instances is not None: + _dict['scale_min_instances'] = self.scale_min_instances + if hasattr(self, 'scale_request_timeout') and self.scale_request_timeout is not None: + _dict['scale_request_timeout'] = self.scale_request_timeout + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + if hasattr(self, 'status_details') and self.status_details is not None: + if isinstance(self.status_details, dict): + _dict['status_details'] = self.status_details + else: + _dict['status_details'] = self.status_details.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this App object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'App') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'App') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ManagedDomainMappingsEnum(str, Enum): + """ + Optional value controlling which of the system managed domain mappings will be + setup for the application. Valid values are 'local_public', 'local_private' and + 'local'. Visibility can only be 'local_private' if the project supports + application private visibility. + """ + + LOCAL = 'local' + LOCAL_PRIVATE = 'local_private' + LOCAL_PUBLIC = 'local_public' + + class ResourceTypeEnum(str, Enum): + """ + The type of the app. + """ + + APP_V2 = 'app_v2' + + class RunServiceAccountEnum(str, Enum): + """ + Optional name of the service account. For built-in service accounts, you can use + the shortened names `manager` , `none`, `reader`, and `writer`. + """ + + DEFAULT = 'default' + MANAGER = 'manager' + READER = 'reader' + WRITER = 'writer' + NONE = 'none' + + class StatusEnum(str, Enum): + """ + The current status of the app. + """ + + READY = 'ready' + DEPLOYING = 'deploying' + FAILED = 'failed' + WARNING = 'warning' + + +class AppInstance: + """ + AppInstance is the response model for app instance resources. + + :param str app_name: The name of the application that is associated with this + instance. + :param str created_at: (optional) The timestamp when the resource was created. + :param str href: (optional) When you provision a new app instance, a URL is + created identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str name: (optional) The name of the app instance. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the app instance. + :param int restarts: (optional) The number of restarts of the app instance. + :param str revision_name: The name of the revision that is associated with this + instance. + :param str scale_cpu_limit: The number of CPU set for the instance. For valid + values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: The amount of ephemeral storage set + for the instance. The amount specified as ephemeral storage, must not exceed the + amount of `scale_memory_limit`. The units for specifying ephemeral storage are + Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for + GB and MB. For more information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param str scale_memory_limit: The amount of memory set for the instance. For + valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param str status: (optional) The current status of the instance. + :param ContainerStatus system_container: (optional) The status of a container. + :param ContainerStatus user_container: (optional) The status of a container. + """ + + def __init__( + self, + app_name: str, + revision_name: str, + scale_cpu_limit: str, + scale_ephemeral_storage_limit: str, + scale_memory_limit: str, + *, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + restarts: Optional[int] = None, + status: Optional[str] = None, + system_container: Optional['ContainerStatus'] = None, + user_container: Optional['ContainerStatus'] = None, + ) -> None: + """ + Initialize a AppInstance object. + + :param str app_name: The name of the application that is associated with + this instance. + :param str revision_name: The name of the revision that is associated with + this instance. + :param str scale_cpu_limit: The number of CPU set for the instance. For + valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: The amount of ephemeral storage + set for the instance. The amount specified as ephemeral storage, must not + exceed the amount of `scale_memory_limit`. The units for specifying + ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the + shorthand expressions for GB and MB. For more information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param str scale_memory_limit: The amount of memory set for the instance. + For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param ContainerStatus system_container: (optional) The status of a + container. + :param ContainerStatus user_container: (optional) The status of a + container. + """ + self.app_name = app_name + self.created_at = created_at + self.href = href + self.id = id + self.name = name + self.project_id = project_id + self.region = region + self.resource_type = resource_type + self.restarts = restarts + self.revision_name = revision_name + self.scale_cpu_limit = scale_cpu_limit + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_memory_limit = scale_memory_limit + self.status = status + self.system_container = system_container + self.user_container = user_container + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppInstance': + """Initialize a AppInstance object from a json dictionary.""" + args = {} + if (app_name := _dict.get('app_name')) is not None: + args['app_name'] = app_name + else: + raise ValueError('Required property \'app_name\' not present in AppInstance JSON') + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (restarts := _dict.get('restarts')) is not None: + args['restarts'] = restarts + if (revision_name := _dict.get('revision_name')) is not None: + args['revision_name'] = revision_name + else: + raise ValueError('Required property \'revision_name\' not present in AppInstance JSON') + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + else: + raise ValueError('Required property \'scale_cpu_limit\' not present in AppInstance JSON') + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + else: + raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in AppInstance JSON') + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + else: + raise ValueError('Required property \'scale_memory_limit\' not present in AppInstance JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + if (system_container := _dict.get('system_container')) is not None: + args['system_container'] = ContainerStatus.from_dict(system_container) + if (user_container := _dict.get('user_container')) is not None: + args['user_container'] = ContainerStatus.from_dict(user_container) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppInstance object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'app_name') and self.app_name is not None: + _dict['app_name'] = self.app_name + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'name') and getattr(self, 'name') is not None: + _dict['name'] = getattr(self, 'name') + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'restarts') and getattr(self, 'restarts') is not None: + _dict['restarts'] = getattr(self, 'restarts') + if hasattr(self, 'revision_name') and self.revision_name is not None: + _dict['revision_name'] = self.revision_name + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + if hasattr(self, 'system_container') and self.system_container is not None: + if isinstance(self.system_container, dict): + _dict['system_container'] = self.system_container + else: + _dict['system_container'] = self.system_container.to_dict() + if hasattr(self, 'user_container') and self.user_container is not None: + if isinstance(self.user_container, dict): + _dict['user_container'] = self.user_container + else: + _dict['user_container'] = self.user_container.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppInstance object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppInstance') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppInstance') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the app instance. + """ + + APP_INSTANCE_V2 = 'app_instance_v2' + + class StatusEnum(str, Enum): + """ + The current status of the instance. + """ + + PENDING = 'pending' + RUNNING = 'running' + SUCCEEDED = 'succeeded' + FAILED = 'failed' + + +class AppInstanceList: + """ + Contains a list of app instances and pagination information. + + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param List[AppInstance] instances: List of all app instances. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + instances: List['AppInstance'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a AppInstanceList object. + + :param List[AppInstance] instances: List of all app instances. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.first = first + self.instances = instances + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppInstanceList': + """Initialize a AppInstanceList object from a json dictionary.""" + args = {} + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (instances := _dict.get('instances')) is not None: + args['instances'] = [AppInstance.from_dict(v) for v in instances] + else: + raise ValueError('Required property \'instances\' not present in AppInstanceList JSON') + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in AppInstanceList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppInstanceList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'instances') and self.instances is not None: + instances_list = [] + for v in self.instances: + if isinstance(v, dict): + instances_list.append(v) + else: + instances_list.append(v.to_dict()) + _dict['instances'] = instances_list + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppInstanceList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppInstanceList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppInstanceList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AppList: + """ + Contains a list of apps and pagination information. + + :param List[App] apps: List of all apps. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + apps: List['App'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a AppList object. + + :param List[App] apps: List of all apps. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.apps = apps + self.first = first + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppList': + """Initialize a AppList object from a json dictionary.""" + args = {} + if (apps := _dict.get('apps')) is not None: + args['apps'] = [App.from_dict(v) for v in apps] + else: + raise ValueError('Required property \'apps\' not present in AppList JSON') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in AppList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'apps') and self.apps is not None: + apps_list = [] + for v in self.apps: + if isinstance(v, dict): + apps_list.append(v) + else: + apps_list.append(v.to_dict()) + _dict['apps'] = apps_list + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AppPatch: + """ + App is the request model for app update operations. + + :param int image_port: (optional) Optional port the app listens on. While the + app will always be exposed via port `443` for end users, this port is used to + connect to the port that is exposed by the container image. + :param str image_reference: (optional) The name of the image that is used for + this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. + If `TAG` is not specified, the default is `latest`. If the image reference + points to a registry that requires authentication, make sure to also specify the + property `image_secret`. + :param str image_secret: (optional) Optional name of the image registry access + secret. The image registry access secret is used to authenticate with a private + registry when you download the container image. If the image reference points to + a registry that requires authentication, the app will be created but cannot + reach the ready status, until this property is provided, too. + :param str managed_domain_mappings: (optional) Optional value controlling which + of the system managed domain mappings will be setup for the application. Valid + values are 'local_public', 'local_private' and 'local'. Visibility can only be + 'local_private' if the project supports application private visibility. + :param ProbePrototype probe_liveness: (optional) Request model for probes. + :param ProbePrototype probe_readiness: (optional) Request model for probes. + :param List[str] run_arguments: (optional) Optional arguments for the app that + are passed to start the container. If not specified an empty string array will + be applied and the arguments specified by the container image, will be used to + start the container. + :param int run_as_user: (optional) Optional user ID (UID) to run the app. + :param List[str] run_commands: (optional) Optional commands for the app that are + passed to start the container. If not specified an empty string array will be + applied and the command specified by the container image, will be used to start + the container. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional references + to config maps, secrets or literal values. + :param str run_service_account: (optional) Optional name of the service account. + For built-in service accounts, you can use the shortened names `manager` , + `none`, `reader`, and `writer`. + :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional mounts + of config maps or a secrets. In case this is provided, existing + `run_volume_mounts` will be overwritten. + :param int scale_concurrency: (optional) Optional maximum number of requests + that can be processed concurrently per instance. + :param int scale_concurrency_target: (optional) Optional threshold of concurrent + requests per instance at which one or more additional instances are created. Use + this value to scale up instances based on concurrent number of requests. This + option defaults to the value of the `scale_concurrency` option, if not + specified. + :param str scale_cpu_limit: (optional) Optional number of CPU set for the + instance of the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds that + delays the scale-down behavior for an app instance. + :param str scale_ephemeral_storage_limit: (optional) Optional amount of + ephemeral storage to set for the instance of the app. The amount specified as + ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units + for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_initial_instances: (optional) Optional initial number of + instances that are created upon app creation or app update. + :param int scale_max_instances: (optional) Optional maximum number of instances + for this app. If you set this value to `0`, this property does not set a upper + scaling limit. However, the app scaling is still limited by the project quota + for instances. See [Limits and quotas for Code + Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). + :param str scale_memory_limit: (optional) Optional amount of memory set for the + instance of the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_min_instances: (optional) Optional minimum number of instances + for this app. If you set this value to `0`, the app will scale down to zero, if + not hit by any request for some time. + :param int scale_request_timeout: (optional) Optional amount of time in seconds + that is allowed for a running app to respond to a request. + """ + + def __init__( + self, + *, + image_port: Optional[int] = None, + image_reference: Optional[str] = None, + image_secret: Optional[str] = None, + managed_domain_mappings: Optional[str] = None, + probe_liveness: Optional['ProbePrototype'] = None, + probe_readiness: Optional['ProbePrototype'] = None, + run_arguments: Optional[List[str]] = None, + run_as_user: Optional[int] = None, + run_commands: Optional[List[str]] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + run_service_account: Optional[str] = None, + run_volume_mounts: Optional[List['VolumeMountPrototype']] = None, + scale_concurrency: Optional[int] = None, + scale_concurrency_target: Optional[int] = None, + scale_cpu_limit: Optional[str] = None, + scale_down_delay: Optional[int] = None, + scale_ephemeral_storage_limit: Optional[str] = None, + scale_initial_instances: Optional[int] = None, + scale_max_instances: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + scale_min_instances: Optional[int] = None, + scale_request_timeout: Optional[int] = None, + ) -> None: + """ + Initialize a AppPatch object. + + :param int image_port: (optional) Optional port the app listens on. While + the app will always be exposed via port `443` for end users, this port is + used to connect to the port that is exposed by the container image. + :param str image_reference: (optional) The name of the image that is used + for this app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where + `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the + default is `docker.io`. If `TAG` is not specified, the default is `latest`. + If the image reference points to a registry that requires authentication, + make sure to also specify the property `image_secret`. + :param str image_secret: (optional) Optional name of the image registry + access secret. The image registry access secret is used to authenticate + with a private registry when you download the container image. If the image + reference points to a registry that requires authentication, the app will + be created but cannot reach the ready status, until this property is + provided, too. + :param str managed_domain_mappings: (optional) Optional value controlling + which of the system managed domain mappings will be setup for the + application. Valid values are 'local_public', 'local_private' and 'local'. + Visibility can only be 'local_private' if the project supports application + private visibility. + :param ProbePrototype probe_liveness: (optional) Request model for probes. + :param ProbePrototype probe_readiness: (optional) Request model for probes. + :param List[str] run_arguments: (optional) Optional arguments for the app + that are passed to start the container. If not specified an empty string + array will be applied and the arguments specified by the container image, + will be used to start the container. + :param int run_as_user: (optional) Optional user ID (UID) to run the app. + :param List[str] run_commands: (optional) Optional commands for the app + that are passed to start the container. If not specified an empty string + array will be applied and the command specified by the container image, + will be used to start the container. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional + references to config maps, secrets or literal values. + :param str run_service_account: (optional) Optional name of the service + account. For built-in service accounts, you can use the shortened names + `manager` , `none`, `reader`, and `writer`. + :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional + mounts of config maps or a secrets. In case this is provided, existing + `run_volume_mounts` will be overwritten. + :param int scale_concurrency: (optional) Optional maximum number of + requests that can be processed concurrently per instance. + :param int scale_concurrency_target: (optional) Optional threshold of + concurrent requests per instance at which one or more additional instances + are created. Use this value to scale up instances based on concurrent + number of requests. This option defaults to the value of the + `scale_concurrency` option, if not specified. + :param str scale_cpu_limit: (optional) Optional number of CPU set for the + instance of the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds + that delays the scale-down behavior for an app instance. + :param str scale_ephemeral_storage_limit: (optional) Optional amount of + ephemeral storage to set for the instance of the app. The amount specified + as ephemeral storage, must not exceed the amount of `scale_memory_limit`. + The units for specifying ephemeral storage are Megabyte (M) or Gigabyte + (G), whereas G and M are the shorthand expressions for GB and MB. For more + information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_initial_instances: (optional) Optional initial number of + instances that are created upon app creation or app update. + :param int scale_max_instances: (optional) Optional maximum number of + instances for this app. If you set this value to `0`, this property does + not set a upper scaling limit. However, the app scaling is still limited by + the project quota for instances. See [Limits and quotas for Code + Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). + :param str scale_memory_limit: (optional) Optional amount of memory set for + the instance of the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_min_instances: (optional) Optional minimum number of + instances for this app. If you set this value to `0`, the app will scale + down to zero, if not hit by any request for some time. + :param int scale_request_timeout: (optional) Optional amount of time in + seconds that is allowed for a running app to respond to a request. + """ + self.image_port = image_port + self.image_reference = image_reference + self.image_secret = image_secret + self.managed_domain_mappings = managed_domain_mappings + self.probe_liveness = probe_liveness + self.probe_readiness = probe_readiness + self.run_arguments = run_arguments + self.run_as_user = run_as_user + self.run_commands = run_commands + self.run_env_variables = run_env_variables + self.run_service_account = run_service_account + self.run_volume_mounts = run_volume_mounts + self.scale_concurrency = scale_concurrency + self.scale_concurrency_target = scale_concurrency_target + self.scale_cpu_limit = scale_cpu_limit + self.scale_down_delay = scale_down_delay + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_initial_instances = scale_initial_instances + self.scale_max_instances = scale_max_instances + self.scale_memory_limit = scale_memory_limit + self.scale_min_instances = scale_min_instances + self.scale_request_timeout = scale_request_timeout + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppPatch': + """Initialize a AppPatch object from a json dictionary.""" + args = {} + if (image_port := _dict.get('image_port')) is not None: + args['image_port'] = image_port + if (image_reference := _dict.get('image_reference')) is not None: + args['image_reference'] = image_reference + if (image_secret := _dict.get('image_secret')) is not None: + args['image_secret'] = image_secret + if (managed_domain_mappings := _dict.get('managed_domain_mappings')) is not None: + args['managed_domain_mappings'] = managed_domain_mappings + if (probe_liveness := _dict.get('probe_liveness')) is not None: + args['probe_liveness'] = ProbePrototype.from_dict(probe_liveness) + if (probe_readiness := _dict.get('probe_readiness')) is not None: + args['probe_readiness'] = ProbePrototype.from_dict(probe_readiness) + if (run_arguments := _dict.get('run_arguments')) is not None: + args['run_arguments'] = run_arguments + if (run_as_user := _dict.get('run_as_user')) is not None: + args['run_as_user'] = run_as_user + if (run_commands := _dict.get('run_commands')) is not None: + args['run_commands'] = run_commands + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVarPrototype.from_dict(v) for v in run_env_variables] + if (run_service_account := _dict.get('run_service_account')) is not None: + args['run_service_account'] = run_service_account + if (run_volume_mounts := _dict.get('run_volume_mounts')) is not None: + args['run_volume_mounts'] = [VolumeMountPrototype.from_dict(v) for v in run_volume_mounts] + if (scale_concurrency := _dict.get('scale_concurrency')) is not None: + args['scale_concurrency'] = scale_concurrency + if (scale_concurrency_target := _dict.get('scale_concurrency_target')) is not None: + args['scale_concurrency_target'] = scale_concurrency_target + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + if (scale_down_delay := _dict.get('scale_down_delay')) is not None: + args['scale_down_delay'] = scale_down_delay + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + if (scale_initial_instances := _dict.get('scale_initial_instances')) is not None: + args['scale_initial_instances'] = scale_initial_instances + if (scale_max_instances := _dict.get('scale_max_instances')) is not None: + args['scale_max_instances'] = scale_max_instances + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + if (scale_min_instances := _dict.get('scale_min_instances')) is not None: + args['scale_min_instances'] = scale_min_instances + if (scale_request_timeout := _dict.get('scale_request_timeout')) is not None: + args['scale_request_timeout'] = scale_request_timeout + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppPatch object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'image_port') and self.image_port is not None: + _dict['image_port'] = self.image_port + if hasattr(self, 'image_reference') and self.image_reference is not None: + _dict['image_reference'] = self.image_reference + if hasattr(self, 'image_secret') and self.image_secret is not None: + _dict['image_secret'] = self.image_secret + if hasattr(self, 'managed_domain_mappings') and self.managed_domain_mappings is not None: + _dict['managed_domain_mappings'] = self.managed_domain_mappings + if hasattr(self, 'probe_liveness') and self.probe_liveness is not None: + if isinstance(self.probe_liveness, dict): + _dict['probe_liveness'] = self.probe_liveness + else: + _dict['probe_liveness'] = self.probe_liveness.to_dict() + if hasattr(self, 'probe_readiness') and self.probe_readiness is not None: + if isinstance(self.probe_readiness, dict): + _dict['probe_readiness'] = self.probe_readiness + else: + _dict['probe_readiness'] = self.probe_readiness.to_dict() + if hasattr(self, 'run_arguments') and self.run_arguments is not None: + _dict['run_arguments'] = self.run_arguments + if hasattr(self, 'run_as_user') and self.run_as_user is not None: + _dict['run_as_user'] = self.run_as_user + if hasattr(self, 'run_commands') and self.run_commands is not None: + _dict['run_commands'] = self.run_commands + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: + if isinstance(v, dict): + run_env_variables_list.append(v) + else: + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'run_service_account') and self.run_service_account is not None: + _dict['run_service_account'] = self.run_service_account + if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: + run_volume_mounts_list = [] + for v in self.run_volume_mounts: + if isinstance(v, dict): + run_volume_mounts_list.append(v) + else: + run_volume_mounts_list.append(v.to_dict()) + _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: + _dict['scale_concurrency'] = self.scale_concurrency + if hasattr(self, 'scale_concurrency_target') and self.scale_concurrency_target is not None: + _dict['scale_concurrency_target'] = self.scale_concurrency_target + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_down_delay') and self.scale_down_delay is not None: + _dict['scale_down_delay'] = self.scale_down_delay + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_initial_instances') and self.scale_initial_instances is not None: + _dict['scale_initial_instances'] = self.scale_initial_instances + if hasattr(self, 'scale_max_instances') and self.scale_max_instances is not None: + _dict['scale_max_instances'] = self.scale_max_instances + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'scale_min_instances') and self.scale_min_instances is not None: + _dict['scale_min_instances'] = self.scale_min_instances + if hasattr(self, 'scale_request_timeout') and self.scale_request_timeout is not None: + _dict['scale_request_timeout'] = self.scale_request_timeout + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppPatch object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppPatch') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppPatch') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ManagedDomainMappingsEnum(str, Enum): + """ + Optional value controlling which of the system managed domain mappings will be + setup for the application. Valid values are 'local_public', 'local_private' and + 'local'. Visibility can only be 'local_private' if the project supports + application private visibility. + """ + + LOCAL = 'local' + LOCAL_PRIVATE = 'local_private' + LOCAL_PUBLIC = 'local_public' + + class RunServiceAccountEnum(str, Enum): + """ + Optional name of the service account. For built-in service accounts, you can use + the shortened names `manager` , `none`, `reader`, and `writer`. + """ + + DEFAULT = 'default' + MANAGER = 'manager' + READER = 'reader' + WRITER = 'writer' + NONE = 'none' + + +class AppRevision: + """ + AppRevision is the response model for app revision resources. + + :param str app_name: (optional) Name of the associated app. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine and + are exposed as environment variables in the application. + :param str created_at: (optional) The timestamp when the resource was created. + :param str href: (optional) When you provision a new revision, a URL is created + identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param int image_port: (optional) Optional port the app listens on. While the + app will always be exposed via port `443` for end users, this port is used to + connect to the port that is exposed by the container image. + :param str image_reference: The name of the image that is used for this app. The + format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are + optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` + is not specified, the default is `latest`. If the image reference points to a + registry that requires authentication, make sure to also specify the property + `image_secret`. + :param str image_secret: (optional) Optional name of the image registry access + secret. The image registry access secret is used to authenticate with a private + registry when you download the container image. If the image reference points to + a registry that requires authentication, the app will be created but cannot reach the ready status, until this property is provided, too. - :attr str managed_domain_mappings: Optional value controlling which of the - system managed domain mappings will be setup for the application. Valid values - are 'local_public', 'local_private' and 'local'. Visibility can only be - 'local_private' if the project supports application private visibility. - :attr str name: The name of the app. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the app. - :attr List[str] run_arguments: Optional arguments for the app that are passed to - start the container. If not specified an empty string array will be applied and - the arguments specified by the container image, will be used to start the + :param str name: (optional) The name of the app revision. + :param Probe probe_liveness: (optional) Response model for probes. + :param Probe probe_readiness: (optional) Response model for probes. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the app revision. + :param List[str] run_arguments: Optional arguments for the app that are passed + to start the container. If not specified an empty string array will be applied + and the arguments specified by the container image, will be used to start the container. - :attr int run_as_user: (optional) Optional user ID (UID) to run the app (e.g., - `1001`). - :attr List[str] run_commands: Optional commands for the app that are passed to + :param int run_as_user: (optional) Optional user ID (UID) to run the app. + :param List[str] run_commands: Optional commands for the app that are passed to start the container. If not specified an empty string array will be applied and the command specified by the container image, will be used to start the container. - :attr List[EnvVar] run_env_variables: References to config maps, secrets or a - literal values, which are exposed as environment variables in the application. - :attr str run_service_account: (optional) Optional name of the service account. + :param List[EnvVar] run_env_variables: References to config maps, secrets or + literal values, which are defined by the app owner and are exposed as + environment variables in the application. + :param str run_service_account: (optional) Optional name of the service account. For built-in service accounts, you can use the shortened names `manager` , `none`, `reader`, and `writer`. - :attr List[VolumeMount] run_volume_mounts: Mounts of config maps or secrets. - :attr int scale_concurrency: (optional) Optional maximum number of requests that - can be processed concurrently per instance. - :attr int scale_concurrency_target: (optional) Optional threshold of concurrent + :param List[VolumeMount] run_volume_mounts: Mounts of config maps or secrets. + :param int scale_concurrency: (optional) Optional maximum number of requests + that can be processed concurrently per instance. + :param int scale_concurrency_target: (optional) Optional threshold of concurrent requests per instance at which one or more additional instances are created. Use this value to scale up instances based on concurrent number of requests. This option defaults to the value of the `scale_concurrency` option, if not specified. - :attr str scale_cpu_limit: Optional number of CPU set for the instance of the + :param str scale_cpu_limit: Optional number of CPU set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :attr str scale_ephemeral_storage_limit: Optional amount of ephemeral storage to - set for the instance of the app. The amount specified as ephemeral storage, must - not exceed the amount of `scale_memory_limit`. The units for specifying + :param int scale_down_delay: (optional) Optional amount of time in seconds that + delays the scale-down behavior for an app instance. + :param str scale_ephemeral_storage_limit: Optional amount of ephemeral storage + to set for the instance of the app. The amount specified as ephemeral storage, + must not exceed the amount of `scale_memory_limit`. The units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_initial_instances: (optional) Optional initial number of + :param int scale_initial_instances: (optional) Optional initial number of instances that are created upon app creation or app update. - :attr int scale_max_instances: Optional maximum number of instances for this + :param int scale_max_instances: Optional maximum number of instances for this app. If you set this value to `0`, this property does not set a upper scaling limit. However, the app scaling is still limited by the project quota for instances. See [Limits and quotas for Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). - :attr str scale_memory_limit: Optional amount of memory set for the instance of + :param str scale_memory_limit: Optional amount of memory set for the instance of the app. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_min_instances: Optional minimum number of instances for this + :param int scale_min_instances: Optional minimum number of instances for this app. If you set this value to `0`, the app will scale down to zero, if not hit by any request for some time. - :attr int scale_request_timeout: Optional amount of time in seconds that is + :param int scale_request_timeout: Optional amount of time in seconds that is allowed for a running app to respond to a request. - :attr str status: (optional) The current status of the app. - :attr AppStatus status_details: (optional) The detailed status of the - application. + :param str status: (optional) The current status of the app revision. + :param AppRevisionStatus status_details: (optional) The detailed status of the + application revision. + """ + + def __init__( + self, + image_reference: str, + run_arguments: List[str], + run_commands: List[str], + run_env_variables: List['EnvVar'], + run_volume_mounts: List['VolumeMount'], + scale_cpu_limit: str, + scale_ephemeral_storage_limit: str, + scale_max_instances: int, + scale_memory_limit: str, + scale_min_instances: int, + scale_request_timeout: int, + *, + app_name: Optional[str] = None, + computed_env_variables: Optional[List['EnvVar']] = None, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + image_port: Optional[int] = None, + image_secret: Optional[str] = None, + name: Optional[str] = None, + probe_liveness: Optional['Probe'] = None, + probe_readiness: Optional['Probe'] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + run_as_user: Optional[int] = None, + run_service_account: Optional[str] = None, + scale_concurrency: Optional[int] = None, + scale_concurrency_target: Optional[int] = None, + scale_down_delay: Optional[int] = None, + scale_initial_instances: Optional[int] = None, + status: Optional[str] = None, + status_details: Optional['AppRevisionStatus'] = None, + ) -> None: + """ + Initialize a AppRevision object. + + :param str image_reference: The name of the image that is used for this + app. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + `TAG` are optional. If `REGISTRY` is not specified, the default is + `docker.io`. If `TAG` is not specified, the default is `latest`. If the + image reference points to a registry that requires authentication, make + sure to also specify the property `image_secret`. + :param List[str] run_arguments: Optional arguments for the app that are + passed to start the container. If not specified an empty string array will + be applied and the arguments specified by the container image, will be used + to start the container. + :param List[str] run_commands: Optional commands for the app that are + passed to start the container. If not specified an empty string array will + be applied and the command specified by the container image, will be used + to start the container. + :param List[EnvVar] run_env_variables: References to config maps, secrets + or literal values, which are defined by the app owner and are exposed as + environment variables in the application. + :param List[VolumeMount] run_volume_mounts: Mounts of config maps or + secrets. + :param str scale_cpu_limit: Optional number of CPU set for the instance of + the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: Optional amount of ephemeral + storage to set for the instance of the app. The amount specified as + ephemeral storage, must not exceed the amount of `scale_memory_limit`. The + units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), + whereas G and M are the shorthand expressions for GB and MB. For more + information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_instances: Optional maximum number of instances for + this app. If you set this value to `0`, this property does not set a upper + scaling limit. However, the app scaling is still limited by the project + quota for instances. See [Limits and quotas for Code + Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). + :param str scale_memory_limit: Optional amount of memory set for the + instance of the app. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_min_instances: Optional minimum number of instances for + this app. If you set this value to `0`, the app will scale down to zero, if + not hit by any request for some time. + :param int scale_request_timeout: Optional amount of time in seconds that + is allowed for a running app to respond to a request. + :param str app_name: (optional) Name of the associated app. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine + and are exposed as environment variables in the application. + :param int image_port: (optional) Optional port the app listens on. While + the app will always be exposed via port `443` for end users, this port is + used to connect to the port that is exposed by the container image. + :param str image_secret: (optional) Optional name of the image registry + access secret. The image registry access secret is used to authenticate + with a private registry when you download the container image. If the image + reference points to a registry that requires authentication, the app will + be created but cannot reach the ready status, until this property is + provided, too. + :param Probe probe_liveness: (optional) Response model for probes. + :param Probe probe_readiness: (optional) Response model for probes. + :param int run_as_user: (optional) Optional user ID (UID) to run the app. + :param str run_service_account: (optional) Optional name of the service + account. For built-in service accounts, you can use the shortened names + `manager` , `none`, `reader`, and `writer`. + :param int scale_concurrency: (optional) Optional maximum number of + requests that can be processed concurrently per instance. + :param int scale_concurrency_target: (optional) Optional threshold of + concurrent requests per instance at which one or more additional instances + are created. Use this value to scale up instances based on concurrent + number of requests. This option defaults to the value of the + `scale_concurrency` option, if not specified. + :param int scale_down_delay: (optional) Optional amount of time in seconds + that delays the scale-down behavior for an app instance. + :param int scale_initial_instances: (optional) Optional initial number of + instances that are created upon app creation or app update. + :param AppRevisionStatus status_details: (optional) The detailed status of + the application revision. + """ + self.app_name = app_name + self.computed_env_variables = computed_env_variables + self.created_at = created_at + self.href = href + self.id = id + self.image_port = image_port + self.image_reference = image_reference + self.image_secret = image_secret + self.name = name + self.probe_liveness = probe_liveness + self.probe_readiness = probe_readiness + self.project_id = project_id + self.region = region + self.resource_type = resource_type + self.run_arguments = run_arguments + self.run_as_user = run_as_user + self.run_commands = run_commands + self.run_env_variables = run_env_variables + self.run_service_account = run_service_account + self.run_volume_mounts = run_volume_mounts + self.scale_concurrency = scale_concurrency + self.scale_concurrency_target = scale_concurrency_target + self.scale_cpu_limit = scale_cpu_limit + self.scale_down_delay = scale_down_delay + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_initial_instances = scale_initial_instances + self.scale_max_instances = scale_max_instances + self.scale_memory_limit = scale_memory_limit + self.scale_min_instances = scale_min_instances + self.scale_request_timeout = scale_request_timeout + self.status = status + self.status_details = status_details + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppRevision': + """Initialize a AppRevision object from a json dictionary.""" + args = {} + if (app_name := _dict.get('app_name')) is not None: + args['app_name'] = app_name + if (computed_env_variables := _dict.get('computed_env_variables')) is not None: + args['computed_env_variables'] = [EnvVar.from_dict(v) for v in computed_env_variables] + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (image_port := _dict.get('image_port')) is not None: + args['image_port'] = image_port + if (image_reference := _dict.get('image_reference')) is not None: + args['image_reference'] = image_reference + else: + raise ValueError('Required property \'image_reference\' not present in AppRevision JSON') + if (image_secret := _dict.get('image_secret')) is not None: + args['image_secret'] = image_secret + if (name := _dict.get('name')) is not None: + args['name'] = name + if (probe_liveness := _dict.get('probe_liveness')) is not None: + args['probe_liveness'] = Probe.from_dict(probe_liveness) + if (probe_readiness := _dict.get('probe_readiness')) is not None: + args['probe_readiness'] = Probe.from_dict(probe_readiness) + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (run_arguments := _dict.get('run_arguments')) is not None: + args['run_arguments'] = run_arguments + else: + raise ValueError('Required property \'run_arguments\' not present in AppRevision JSON') + if (run_as_user := _dict.get('run_as_user')) is not None: + args['run_as_user'] = run_as_user + if (run_commands := _dict.get('run_commands')) is not None: + args['run_commands'] = run_commands + else: + raise ValueError('Required property \'run_commands\' not present in AppRevision JSON') + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVar.from_dict(v) for v in run_env_variables] + else: + raise ValueError('Required property \'run_env_variables\' not present in AppRevision JSON') + if (run_service_account := _dict.get('run_service_account')) is not None: + args['run_service_account'] = run_service_account + if (run_volume_mounts := _dict.get('run_volume_mounts')) is not None: + args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in run_volume_mounts] + else: + raise ValueError('Required property \'run_volume_mounts\' not present in AppRevision JSON') + if (scale_concurrency := _dict.get('scale_concurrency')) is not None: + args['scale_concurrency'] = scale_concurrency + if (scale_concurrency_target := _dict.get('scale_concurrency_target')) is not None: + args['scale_concurrency_target'] = scale_concurrency_target + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + else: + raise ValueError('Required property \'scale_cpu_limit\' not present in AppRevision JSON') + if (scale_down_delay := _dict.get('scale_down_delay')) is not None: + args['scale_down_delay'] = scale_down_delay + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + else: + raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in AppRevision JSON') + if (scale_initial_instances := _dict.get('scale_initial_instances')) is not None: + args['scale_initial_instances'] = scale_initial_instances + if (scale_max_instances := _dict.get('scale_max_instances')) is not None: + args['scale_max_instances'] = scale_max_instances + else: + raise ValueError('Required property \'scale_max_instances\' not present in AppRevision JSON') + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + else: + raise ValueError('Required property \'scale_memory_limit\' not present in AppRevision JSON') + if (scale_min_instances := _dict.get('scale_min_instances')) is not None: + args['scale_min_instances'] = scale_min_instances + else: + raise ValueError('Required property \'scale_min_instances\' not present in AppRevision JSON') + if (scale_request_timeout := _dict.get('scale_request_timeout')) is not None: + args['scale_request_timeout'] = scale_request_timeout + else: + raise ValueError('Required property \'scale_request_timeout\' not present in AppRevision JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = AppRevisionStatus.from_dict(status_details) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppRevision object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'app_name') and self.app_name is not None: + _dict['app_name'] = self.app_name + if hasattr(self, 'computed_env_variables') and self.computed_env_variables is not None: + computed_env_variables_list = [] + for v in self.computed_env_variables: + if isinstance(v, dict): + computed_env_variables_list.append(v) + else: + computed_env_variables_list.append(v.to_dict()) + _dict['computed_env_variables'] = computed_env_variables_list + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'image_port') and self.image_port is not None: + _dict['image_port'] = self.image_port + if hasattr(self, 'image_reference') and self.image_reference is not None: + _dict['image_reference'] = self.image_reference + if hasattr(self, 'image_secret') and self.image_secret is not None: + _dict['image_secret'] = self.image_secret + if hasattr(self, 'name') and getattr(self, 'name') is not None: + _dict['name'] = getattr(self, 'name') + if hasattr(self, 'probe_liveness') and self.probe_liveness is not None: + if isinstance(self.probe_liveness, dict): + _dict['probe_liveness'] = self.probe_liveness + else: + _dict['probe_liveness'] = self.probe_liveness.to_dict() + if hasattr(self, 'probe_readiness') and self.probe_readiness is not None: + if isinstance(self.probe_readiness, dict): + _dict['probe_readiness'] = self.probe_readiness + else: + _dict['probe_readiness'] = self.probe_readiness.to_dict() + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'run_arguments') and self.run_arguments is not None: + _dict['run_arguments'] = self.run_arguments + if hasattr(self, 'run_as_user') and self.run_as_user is not None: + _dict['run_as_user'] = self.run_as_user + if hasattr(self, 'run_commands') and self.run_commands is not None: + _dict['run_commands'] = self.run_commands + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: + if isinstance(v, dict): + run_env_variables_list.append(v) + else: + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'run_service_account') and self.run_service_account is not None: + _dict['run_service_account'] = self.run_service_account + if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: + run_volume_mounts_list = [] + for v in self.run_volume_mounts: + if isinstance(v, dict): + run_volume_mounts_list.append(v) + else: + run_volume_mounts_list.append(v.to_dict()) + _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: + _dict['scale_concurrency'] = self.scale_concurrency + if hasattr(self, 'scale_concurrency_target') and self.scale_concurrency_target is not None: + _dict['scale_concurrency_target'] = self.scale_concurrency_target + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_down_delay') and self.scale_down_delay is not None: + _dict['scale_down_delay'] = self.scale_down_delay + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_initial_instances') and self.scale_initial_instances is not None: + _dict['scale_initial_instances'] = self.scale_initial_instances + if hasattr(self, 'scale_max_instances') and self.scale_max_instances is not None: + _dict['scale_max_instances'] = self.scale_max_instances + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'scale_min_instances') and self.scale_min_instances is not None: + _dict['scale_min_instances'] = self.scale_min_instances + if hasattr(self, 'scale_request_timeout') and self.scale_request_timeout is not None: + _dict['scale_request_timeout'] = self.scale_request_timeout + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + if hasattr(self, 'status_details') and self.status_details is not None: + if isinstance(self.status_details, dict): + _dict['status_details'] = self.status_details + else: + _dict['status_details'] = self.status_details.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppRevision object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppRevision') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppRevision') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the app revision. + """ + + APP_REVISION_V2 = 'app_revision_v2' + + class RunServiceAccountEnum(str, Enum): + """ + Optional name of the service account. For built-in service accounts, you can use + the shortened names `manager` , `none`, `reader`, and `writer`. + """ + + DEFAULT = 'default' + MANAGER = 'manager' + READER = 'reader' + WRITER = 'writer' + NONE = 'none' + + class StatusEnum(str, Enum): + """ + The current status of the app revision. + """ + + READY = 'ready' + LOADING = 'loading' + WARNING = 'warning' + FAILED = 'failed' + + +class AppRevisionList: + """ + Contains a list of app revisions and pagination information. + + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + :param List[AppRevision] revisions: List of all app revisions. + """ + + def __init__( + self, + limit: int, + revisions: List['AppRevision'], + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a AppRevisionList object. + + :param int limit: Maximum number of resources per page. + :param List[AppRevision] revisions: List of all app revisions. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.first = first + self.limit = limit + self.next = next + self.revisions = revisions + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppRevisionList': + """Initialize a AppRevisionList object from a json dictionary.""" + args = {} + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in AppRevisionList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + if (revisions := _dict.get('revisions')) is not None: + args['revisions'] = [AppRevision.from_dict(v) for v in revisions] + else: + raise ValueError('Required property \'revisions\' not present in AppRevisionList JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppRevisionList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'revisions') and self.revisions is not None: + revisions_list = [] + for v in self.revisions: + if isinstance(v, dict): + revisions_list.append(v) + else: + revisions_list.append(v.to_dict()) + _dict['revisions'] = revisions_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppRevisionList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppRevisionList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppRevisionList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AppRevisionStatus: + """ + The detailed status of the application revision. + + :param int actual_instances: (optional) The number of running instances of the + revision. + :param str reason: (optional) Optional information to provide more context in + case of a 'failed' or 'warning' status. + """ + + def __init__( + self, + *, + actual_instances: Optional[int] = None, + reason: Optional[str] = None, + ) -> None: + """ + Initialize a AppRevisionStatus object. + + """ + self.actual_instances = actual_instances + self.reason = reason + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppRevisionStatus': + """Initialize a AppRevisionStatus object from a json dictionary.""" + args = {} + if (actual_instances := _dict.get('actual_instances')) is not None: + args['actual_instances'] = actual_instances + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppRevisionStatus object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'actual_instances') and getattr(self, 'actual_instances') is not None: + _dict['actual_instances'] = getattr(self, 'actual_instances') + if hasattr(self, 'reason') and getattr(self, 'reason') is not None: + _dict['reason'] = getattr(self, 'reason') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppRevisionStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppRevisionStatus') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppRevisionStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ReasonEnum(str, Enum): + """ + Optional information to provide more context in case of a 'failed' or 'warning' + status. + """ + + READY = 'ready' + WAITING = 'waiting' + DEPLOYING = 'deploying' + DEPLOYING_WAITING_FOR_RESOURCES = 'deploying_waiting_for_resources' + INITIAL_SCALE_NEVER_ACHIEVED = 'initial_scale_never_achieved' + FETCH_IMAGE_FAILED_UNKNOWN_MANIFEST = 'fetch_image_failed_unknown_manifest' + FETCH_IMAGE_FAILED_UNKNOWN_REPOSITORY = 'fetch_image_failed_unknown_repository' + FETCH_IMAGE_FAILED_REGISTRY_NOT_FOUND = 'fetch_image_failed_registry_not_found' + FETCH_IMAGE_FAILED_MISSING_PULL_SECRET = 'fetch_image_failed_missing_pull_secret' + FETCH_IMAGE_FAILED_WRONG_PULL_CREDENTIALS = 'fetch_image_failed_wrong_pull_credentials' + FETCH_IMAGE_FAILED_MISSING_PULL_CREDENTIALS = 'fetch_image_failed_missing_pull_credentials' + CONTAINER_FAILED_EXIT_CODE_0 = 'container_failed_exit_code_0' + CONTAINER_FAILED_EXIT_CODE_1 = 'container_failed_exit_code_1' + CONTAINER_FAILED_EXIT_CODE_139 = 'container_failed_exit_code_139' + CONTAINER_FAILED_EXIT_CODE_24 = 'container_failed_exit_code_24' + IMAGE_PULL_BACK_OFF = 'image_pull_back_off' + INVALID_TAR_HEADER_IMAGE_PULL_ERR = 'invalid_tar_header_image_pull_err' + + +class AppStatus: + """ + The detailed status of the application. + + :param str latest_created_revision: (optional) Latest app revision that has been + created. + :param str latest_ready_revision: (optional) Latest app revision that reached a + ready state. + :param str reason: (optional) Optional information to provide more context in + case of a 'failed' or 'warning' status. + """ + + def __init__( + self, + *, + latest_created_revision: Optional[str] = None, + latest_ready_revision: Optional[str] = None, + reason: Optional[str] = None, + ) -> None: + """ + Initialize a AppStatus object. + + """ + self.latest_created_revision = latest_created_revision + self.latest_ready_revision = latest_ready_revision + self.reason = reason + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AppStatus': + """Initialize a AppStatus object from a json dictionary.""" + args = {} + if (latest_created_revision := _dict.get('latest_created_revision')) is not None: + args['latest_created_revision'] = latest_created_revision + if (latest_ready_revision := _dict.get('latest_ready_revision')) is not None: + args['latest_ready_revision'] = latest_ready_revision + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AppStatus object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'latest_created_revision') and getattr(self, 'latest_created_revision') is not None: + _dict['latest_created_revision'] = getattr(self, 'latest_created_revision') + if hasattr(self, 'latest_ready_revision') and getattr(self, 'latest_ready_revision') is not None: + _dict['latest_ready_revision'] = getattr(self, 'latest_ready_revision') + if hasattr(self, 'reason') and getattr(self, 'reason') is not None: + _dict['reason'] = getattr(self, 'reason') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AppStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AppStatus') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AppStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ReasonEnum(str, Enum): + """ + Optional information to provide more context in case of a 'failed' or 'warning' + status. + """ + + READY = 'ready' + DEPLOYING = 'deploying' + WAITING_FOR_RESOURCES = 'waiting_for_resources' + NO_REVISION_READY = 'no_revision_ready' + READY_BUT_LATEST_REVISION_FAILED = 'ready_but_latest_revision_failed' + + +class Binding: + """ + Describes the model of a binding. + + :param ComponentRef component: A reference to another component. + :param str href: (optional) When you provision a new binding, a URL is created + identifying the location of the instance. + :param str id: (optional) The ID of the binding. + :param str prefix: The value that is set as a prefix in the component that is + bound. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str resource_type: (optional) The type of the binding. + :param str secret_name: The service access secret that is bound to a component. + :param str status: (optional) The current status of the binding. + """ + + def __init__( + self, + component: 'ComponentRef', + prefix: str, + secret_name: str, + *, + href: Optional[str] = None, + id: Optional[str] = None, + project_id: Optional[str] = None, + resource_type: Optional[str] = None, + status: Optional[str] = None, + ) -> None: + """ + Initialize a Binding object. + + :param ComponentRef component: A reference to another component. + :param str prefix: The value that is set as a prefix in the component that + is bound. + :param str secret_name: The service access secret that is bound to a + component. + """ + self.component = component + self.href = href + self.id = id + self.prefix = prefix + self.project_id = project_id + self.resource_type = resource_type + self.secret_name = secret_name + self.status = status + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Binding': + """Initialize a Binding object from a json dictionary.""" + args = {} + if (component := _dict.get('component')) is not None: + args['component'] = ComponentRef.from_dict(component) + else: + raise ValueError('Required property \'component\' not present in Binding JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (prefix := _dict.get('prefix')) is not None: + args['prefix'] = prefix + else: + raise ValueError('Required property \'prefix\' not present in Binding JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (secret_name := _dict.get('secret_name')) is not None: + args['secret_name'] = secret_name + else: + raise ValueError('Required property \'secret_name\' not present in Binding JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Binding object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'component') and self.component is not None: + if isinstance(self.component, dict): + _dict['component'] = self.component + else: + _dict['component'] = self.component.to_dict() + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'prefix') and self.prefix is not None: + _dict['prefix'] = self.prefix + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'secret_name') and self.secret_name is not None: + _dict['secret_name'] = self.secret_name + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this Binding object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Binding') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'Binding') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the binding. + """ + + BINDING_V2 = 'binding_v2' + + +class BindingList: + """ + Contains a list of bindings and pagination information. + + :param List[Binding] bindings: List of all bindings. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + bindings: List['Binding'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a BindingList object. + + :param List[Binding] bindings: List of all bindings. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.bindings = bindings + self.first = first + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BindingList': + """Initialize a BindingList object from a json dictionary.""" + args = {} + if (bindings := _dict.get('bindings')) is not None: + args['bindings'] = [Binding.from_dict(v) for v in bindings] + else: + raise ValueError('Required property \'bindings\' not present in BindingList JSON') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in BindingList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BindingList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'bindings') and self.bindings is not None: + bindings_list = [] + for v in self.bindings: + if isinstance(v, dict): + bindings_list.append(v) + else: + bindings_list.append(v.to_dict()) + _dict['bindings'] = bindings_list + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BindingList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BindingList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BindingList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Build: + """ + Response model for build definitions. + + :param str created_at: (optional) The timestamp when the resource was created. + :param str entity_tag: The version of the build instance, which is used to + achieve optimistic locking. + :param str href: (optional) When you provision a new build, a URL is created + identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str name: (optional) The name of the build. + :param str output_image: The name of the image. + :param str output_secret: The secret that is required to access the image + registry. Make sure that the secret is granted with push permissions towards the + specified container registry namespace. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the build. + :param str source_context_dir: (optional) Optional directory in the repository + that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` and + uses the HEAD of default branch if not specified. If the `source_type` value is + `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access the + repository source. This field is optional if the `source_type` is `git`. + Additionally, if the `source_url` points to a repository that requires + authentication, the build will be created but cannot access any source code, + until this property is provided, too. If the `source_type` value is `local`, + this field must be omitted. + :param str source_type: Specifies the type of source to determine if your build + source is in a repository or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This field is + required if the `source_type` is `git`. If the `source_type` value is `local`, + this field must be omitted. If the repository is publicly available you can + provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the + repository requires authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to + a secret of format `ssh_auth`. + :param str status: (optional) The current status of the build. + :param BuildStatus status_details: (optional) The detailed status of the build. + :param str strategy_size: Optional size for the build, which determines the + amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`, + `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the specification + file that is used for build strategies for building an image. + :param str strategy_type: The strategy to use for building the image. + :param int timeout: (optional) The maximum amount of time, in seconds, that can + pass before the build must succeed or fail. + """ + + def __init__( + self, + entity_tag: str, + output_image: str, + output_secret: str, + source_type: str, + strategy_size: str, + strategy_type: str, + *, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + source_context_dir: Optional[str] = None, + source_revision: Optional[str] = None, + source_secret: Optional[str] = None, + source_url: Optional[str] = None, + status: Optional[str] = None, + status_details: Optional['BuildStatus'] = None, + strategy_spec_file: Optional[str] = None, + timeout: Optional[int] = None, + ) -> None: + """ + Initialize a Build object. + + :param str entity_tag: The version of the build instance, which is used to + achieve optimistic locking. + :param str output_image: The name of the image. + :param str output_secret: The secret that is required to access the image + registry. Make sure that the secret is granted with push permissions + towards the specified container registry namespace. + :param str source_type: Specifies the type of source to determine if your + build source is in a repository or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str strategy_size: Optional size for the build, which determines the + amount of resources used. Build sizes are `small`, `medium`, `large`, + `xlarge`, `xxlarge`. + :param str strategy_type: The strategy to use for building the image. + :param str name: (optional) The name of the build. + :param str source_context_dir: (optional) Optional directory in the + repository that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` + and uses the HEAD of default branch if not specified. If the `source_type` + value is `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access + the repository source. This field is optional if the `source_type` is + `git`. Additionally, if the `source_url` points to a repository that + requires authentication, the build will be created but cannot access any + source code, until this property is provided, too. If the `source_type` + value is `local`, this field must be omitted. + :param str source_url: (optional) The URL of the code repository. This + field is required if the `source_type` is `git`. If the `source_type` value + is `local`, this field must be omitted. If the repository is publicly + available you can provide a 'https' URL like + `https://github.com/IBM/CodeEngine`. If the repository requires + authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that + points to a secret of format `ssh_auth`. + :param BuildStatus status_details: (optional) The detailed status of the + build. + :param str strategy_spec_file: (optional) Optional path to the + specification file that is used for build strategies for building an image. + :param int timeout: (optional) The maximum amount of time, in seconds, that + can pass before the build must succeed or fail. + """ + self.created_at = created_at + self.entity_tag = entity_tag + self.href = href + self.id = id + self.name = name + self.output_image = output_image + self.output_secret = output_secret + self.project_id = project_id + self.region = region + self.resource_type = resource_type + self.source_context_dir = source_context_dir + self.source_revision = source_revision + self.source_secret = source_secret + self.source_type = source_type + self.source_url = source_url + self.status = status + self.status_details = status_details + self.strategy_size = strategy_size + self.strategy_spec_file = strategy_spec_file + self.strategy_type = strategy_type + self.timeout = timeout + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Build': + """Initialize a Build object from a json dictionary.""" + args = {} + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag + else: + raise ValueError('Required property \'entity_tag\' not present in Build JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (output_image := _dict.get('output_image')) is not None: + args['output_image'] = output_image + else: + raise ValueError('Required property \'output_image\' not present in Build JSON') + if (output_secret := _dict.get('output_secret')) is not None: + args['output_secret'] = output_secret + else: + raise ValueError('Required property \'output_secret\' not present in Build JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (source_context_dir := _dict.get('source_context_dir')) is not None: + args['source_context_dir'] = source_context_dir + if (source_revision := _dict.get('source_revision')) is not None: + args['source_revision'] = source_revision + if (source_secret := _dict.get('source_secret')) is not None: + args['source_secret'] = source_secret + if (source_type := _dict.get('source_type')) is not None: + args['source_type'] = source_type + else: + raise ValueError('Required property \'source_type\' not present in Build JSON') + if (source_url := _dict.get('source_url')) is not None: + args['source_url'] = source_url + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = BuildStatus.from_dict(status_details) + if (strategy_size := _dict.get('strategy_size')) is not None: + args['strategy_size'] = strategy_size + else: + raise ValueError('Required property \'strategy_size\' not present in Build JSON') + if (strategy_spec_file := _dict.get('strategy_spec_file')) is not None: + args['strategy_spec_file'] = strategy_spec_file + if (strategy_type := _dict.get('strategy_type')) is not None: + args['strategy_type'] = strategy_type + else: + raise ValueError('Required property \'strategy_type\' not present in Build JSON') + if (timeout := _dict.get('timeout')) is not None: + args['timeout'] = timeout + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Build object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'entity_tag') and self.entity_tag is not None: + _dict['entity_tag'] = self.entity_tag + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'output_image') and self.output_image is not None: + _dict['output_image'] = self.output_image + if hasattr(self, 'output_secret') and self.output_secret is not None: + _dict['output_secret'] = self.output_secret + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'source_context_dir') and self.source_context_dir is not None: + _dict['source_context_dir'] = self.source_context_dir + if hasattr(self, 'source_revision') and self.source_revision is not None: + _dict['source_revision'] = self.source_revision + if hasattr(self, 'source_secret') and self.source_secret is not None: + _dict['source_secret'] = self.source_secret + if hasattr(self, 'source_type') and self.source_type is not None: + _dict['source_type'] = self.source_type + if hasattr(self, 'source_url') and self.source_url is not None: + _dict['source_url'] = self.source_url + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + if hasattr(self, 'status_details') and self.status_details is not None: + if isinstance(self.status_details, dict): + _dict['status_details'] = self.status_details + else: + _dict['status_details'] = self.status_details.to_dict() + if hasattr(self, 'strategy_size') and self.strategy_size is not None: + _dict['strategy_size'] = self.strategy_size + if hasattr(self, 'strategy_spec_file') and self.strategy_spec_file is not None: + _dict['strategy_spec_file'] = self.strategy_spec_file + if hasattr(self, 'strategy_type') and self.strategy_type is not None: + _dict['strategy_type'] = self.strategy_type + if hasattr(self, 'timeout') and self.timeout is not None: + _dict['timeout'] = self.timeout + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this Build object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Build') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'Build') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the build. + """ + + BUILD_V2 = 'build_v2' + + class SourceTypeEnum(str, Enum): + """ + Specifies the type of source to determine if your build source is in a repository + or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + """ + + LOCAL = 'local' + GIT = 'git' + + class StatusEnum(str, Enum): + """ + The current status of the build. + """ + + READY = 'ready' + FAILED = 'failed' + + +class BuildList: + """ + Contains a list of builds and pagination information. + + :param List[Build] builds: List of all builds. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + builds: List['Build'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a BuildList object. + + :param List[Build] builds: List of all builds. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.builds = builds + self.first = first + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BuildList': + """Initialize a BuildList object from a json dictionary.""" + args = {} + if (builds := _dict.get('builds')) is not None: + args['builds'] = [Build.from_dict(v) for v in builds] + else: + raise ValueError('Required property \'builds\' not present in BuildList JSON') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in BuildList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BuildList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'builds') and self.builds is not None: + builds_list = [] + for v in self.builds: + if isinstance(v, dict): + builds_list.append(v) + else: + builds_list.append(v.to_dict()) + _dict['builds'] = builds_list + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BuildList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BuildList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BuildList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class BuildPatch: + """ + Patch a build object. + + :param str output_image: (optional) The name of the image. + :param str output_secret: (optional) The secret that is required to access the + image registry. Make sure that the secret is granted with push permissions + towards the specified container registry namespace. + :param str source_context_dir: (optional) Optional directory in the repository + that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` and + uses the HEAD of default branch if not specified. If the `source_type` value is + `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access the + repository source. This field is optional if the `source_type` is `git`. + Additionally, if the `source_url` points to a repository that requires + authentication, the build will be created but cannot access any source code, + until this property is provided, too. If the `source_type` value is `local`, + this field must be omitted. + :param str source_type: (optional) Specifies the type of source to determine if + your build source is in a repository or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This field is + required if the `source_type` is `git`. If the `source_type` value is `local`, + this field must be omitted. If the repository is publicly available you can + provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the + repository requires authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to + a secret of format `ssh_auth`. + :param str strategy_size: (optional) Optional size for the build, which + determines the amount of resources used. Build sizes are `small`, `medium`, + `large`, `xlarge`, `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the specification + file that is used for build strategies for building an image. + :param str strategy_type: (optional) The strategy to use for building the image. + :param int timeout: (optional) The maximum amount of time, in seconds, that can + pass before the build must succeed or fail. + """ + + def __init__( + self, + *, + output_image: Optional[str] = None, + output_secret: Optional[str] = None, + source_context_dir: Optional[str] = None, + source_revision: Optional[str] = None, + source_secret: Optional[str] = None, + source_type: Optional[str] = None, + source_url: Optional[str] = None, + strategy_size: Optional[str] = None, + strategy_spec_file: Optional[str] = None, + strategy_type: Optional[str] = None, + timeout: Optional[int] = None, + ) -> None: + """ + Initialize a BuildPatch object. + + :param str output_image: (optional) The name of the image. + :param str output_secret: (optional) The secret that is required to access + the image registry. Make sure that the secret is granted with push + permissions towards the specified container registry namespace. + :param str source_context_dir: (optional) Optional directory in the + repository that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` + and uses the HEAD of default branch if not specified. If the `source_type` + value is `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access + the repository source. This field is optional if the `source_type` is + `git`. Additionally, if the `source_url` points to a repository that + requires authentication, the build will be created but cannot access any + source code, until this property is provided, too. If the `source_type` + value is `local`, this field must be omitted. + :param str source_type: (optional) Specifies the type of source to + determine if your build source is in a repository or based on local source + code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This + field is required if the `source_type` is `git`. If the `source_type` value + is `local`, this field must be omitted. If the repository is publicly + available you can provide a 'https' URL like + `https://github.com/IBM/CodeEngine`. If the repository requires + authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that + points to a secret of format `ssh_auth`. + :param str strategy_size: (optional) Optional size for the build, which + determines the amount of resources used. Build sizes are `small`, `medium`, + `large`, `xlarge`, `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the + specification file that is used for build strategies for building an image. + :param str strategy_type: (optional) The strategy to use for building the + image. + :param int timeout: (optional) The maximum amount of time, in seconds, that + can pass before the build must succeed or fail. + """ + self.output_image = output_image + self.output_secret = output_secret + self.source_context_dir = source_context_dir + self.source_revision = source_revision + self.source_secret = source_secret + self.source_type = source_type + self.source_url = source_url + self.strategy_size = strategy_size + self.strategy_spec_file = strategy_spec_file + self.strategy_type = strategy_type + self.timeout = timeout + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BuildPatch': + """Initialize a BuildPatch object from a json dictionary.""" + args = {} + if (output_image := _dict.get('output_image')) is not None: + args['output_image'] = output_image + if (output_secret := _dict.get('output_secret')) is not None: + args['output_secret'] = output_secret + if (source_context_dir := _dict.get('source_context_dir')) is not None: + args['source_context_dir'] = source_context_dir + if (source_revision := _dict.get('source_revision')) is not None: + args['source_revision'] = source_revision + if (source_secret := _dict.get('source_secret')) is not None: + args['source_secret'] = source_secret + if (source_type := _dict.get('source_type')) is not None: + args['source_type'] = source_type + if (source_url := _dict.get('source_url')) is not None: + args['source_url'] = source_url + if (strategy_size := _dict.get('strategy_size')) is not None: + args['strategy_size'] = strategy_size + if (strategy_spec_file := _dict.get('strategy_spec_file')) is not None: + args['strategy_spec_file'] = strategy_spec_file + if (strategy_type := _dict.get('strategy_type')) is not None: + args['strategy_type'] = strategy_type + if (timeout := _dict.get('timeout')) is not None: + args['timeout'] = timeout + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BuildPatch object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'output_image') and self.output_image is not None: + _dict['output_image'] = self.output_image + if hasattr(self, 'output_secret') and self.output_secret is not None: + _dict['output_secret'] = self.output_secret + if hasattr(self, 'source_context_dir') and self.source_context_dir is not None: + _dict['source_context_dir'] = self.source_context_dir + if hasattr(self, 'source_revision') and self.source_revision is not None: + _dict['source_revision'] = self.source_revision + if hasattr(self, 'source_secret') and self.source_secret is not None: + _dict['source_secret'] = self.source_secret + if hasattr(self, 'source_type') and self.source_type is not None: + _dict['source_type'] = self.source_type + if hasattr(self, 'source_url') and self.source_url is not None: + _dict['source_url'] = self.source_url + if hasattr(self, 'strategy_size') and self.strategy_size is not None: + _dict['strategy_size'] = self.strategy_size + if hasattr(self, 'strategy_spec_file') and self.strategy_spec_file is not None: + _dict['strategy_spec_file'] = self.strategy_spec_file + if hasattr(self, 'strategy_type') and self.strategy_type is not None: + _dict['strategy_type'] = self.strategy_type + if hasattr(self, 'timeout') and self.timeout is not None: + _dict['timeout'] = self.timeout + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BuildPatch object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BuildPatch') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BuildPatch') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class SourceTypeEnum(str, Enum): + """ + Specifies the type of source to determine if your build source is in a repository + or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + """ + + LOCAL = 'local' + GIT = 'git' + + +class BuildRun: + """ + Response model for build run objects. + + :param str build_name: Optional name of the build on which this build run is + based on. If specified, the build run will inherit the configuration of the + referenced build. If not specified, make sure to specify at least the fields + `strategy_type`, `source_url`, `output_image` and `output_secret` to describe + the build run. + :param str created_at: (optional) The timestamp when the resource was created. + :param str href: (optional) When you trigger a new build run, a URL is created + identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str name: The name of the build run. + :param str output_image: (optional) The name of the image. + :param str output_secret: (optional) The secret that is required to access the + image registry. Make sure that the secret is granted with push permissions + towards the specified container registry namespace. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the build run. + :param str service_account: (optional) Optional service account, which is used + for resource control.” or “Optional service account that is used for resource + control. + :param str source_context_dir: (optional) Optional directory in the repository + that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` and + uses the HEAD of default branch if not specified. If the `source_type` value is + `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access the + repository source. This field is optional if the `source_type` is `git`. + Additionally, if the `source_url` points to a repository that requires + authentication, the build will be created but cannot access any source code, + until this property is provided, too. If the `source_type` value is `local`, + this field must be omitted. + :param str source_type: (optional) Specifies the type of source to determine if + your build source is in a repository or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This field is + required if the `source_type` is `git`. If the `source_type` value is `local`, + this field must be omitted. If the repository is publicly available you can + provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the + repository requires authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to + a secret of format `ssh_auth`. + :param str status: (optional) The current status of the build run. + :param BuildRunStatus status_details: (optional) Current status condition of a + build run. + :param str strategy_size: (optional) Optional size for the build, which + determines the amount of resources used. Build sizes are `small`, `medium`, + `large`, `xlarge`, `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the specification + file that is used for build strategies for building an image. + :param str strategy_type: (optional) The strategy to use for building the image. + :param int timeout: (optional) The maximum amount of time, in seconds, that can + pass before the build must succeed or fail. + """ + + def __init__( + self, + build_name: str, + name: str, + *, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + output_image: Optional[str] = None, + output_secret: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + service_account: Optional[str] = None, + source_context_dir: Optional[str] = None, + source_revision: Optional[str] = None, + source_secret: Optional[str] = None, + source_type: Optional[str] = None, + source_url: Optional[str] = None, + status: Optional[str] = None, + status_details: Optional['BuildRunStatus'] = None, + strategy_size: Optional[str] = None, + strategy_spec_file: Optional[str] = None, + strategy_type: Optional[str] = None, + timeout: Optional[int] = None, + ) -> None: + """ + Initialize a BuildRun object. + + :param str build_name: Optional name of the build on which this build run + is based on. If specified, the build run will inherit the configuration of + the referenced build. If not specified, make sure to specify at least the + fields `strategy_type`, `source_url`, `output_image` and `output_secret` to + describe the build run. + :param str name: The name of the build run. + :param str output_image: (optional) The name of the image. + :param str output_secret: (optional) The secret that is required to access + the image registry. Make sure that the secret is granted with push + permissions towards the specified container registry namespace. + :param str service_account: (optional) Optional service account, which is + used for resource control.” or “Optional service account that is used for + resource control. + :param str source_context_dir: (optional) Optional directory in the + repository that contains the buildpacks file or the Dockerfile. + :param str source_revision: (optional) Commit, tag, or branch in the source + repository to pull. This field is optional if the `source_type` is `git` + and uses the HEAD of default branch if not specified. If the `source_type` + value is `local`, this field must be omitted. + :param str source_secret: (optional) Name of the secret that is used access + the repository source. This field is optional if the `source_type` is + `git`. Additionally, if the `source_url` points to a repository that + requires authentication, the build will be created but cannot access any + source code, until this property is provided, too. If the `source_type` + value is `local`, this field must be omitted. + :param str source_type: (optional) Specifies the type of source to + determine if your build source is in a repository or based on local source + code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + :param str source_url: (optional) The URL of the code repository. This + field is required if the `source_type` is `git`. If the `source_type` value + is `local`, this field must be omitted. If the repository is publicly + available you can provide a 'https' URL like + `https://github.com/IBM/CodeEngine`. If the repository requires + authentication, you need to provide a 'ssh' URL like + `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that + points to a secret of format `ssh_auth`. + :param BuildRunStatus status_details: (optional) Current status condition + of a build run. + :param str strategy_size: (optional) Optional size for the build, which + determines the amount of resources used. Build sizes are `small`, `medium`, + `large`, `xlarge`, `xxlarge`. + :param str strategy_spec_file: (optional) Optional path to the + specification file that is used for build strategies for building an image. + :param str strategy_type: (optional) The strategy to use for building the + image. + :param int timeout: (optional) The maximum amount of time, in seconds, that + can pass before the build must succeed or fail. + """ + self.build_name = build_name + self.created_at = created_at + self.href = href + self.id = id + self.name = name + self.output_image = output_image + self.output_secret = output_secret + self.project_id = project_id + self.region = region + self.resource_type = resource_type + self.service_account = service_account + self.source_context_dir = source_context_dir + self.source_revision = source_revision + self.source_secret = source_secret + self.source_type = source_type + self.source_url = source_url + self.status = status + self.status_details = status_details + self.strategy_size = strategy_size + self.strategy_spec_file = strategy_spec_file + self.strategy_type = strategy_type + self.timeout = timeout + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BuildRun': + """Initialize a BuildRun object from a json dictionary.""" + args = {} + if (build_name := _dict.get('build_name')) is not None: + args['build_name'] = build_name + else: + raise ValueError('Required property \'build_name\' not present in BuildRun JSON') + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in BuildRun JSON') + if (output_image := _dict.get('output_image')) is not None: + args['output_image'] = output_image + if (output_secret := _dict.get('output_secret')) is not None: + args['output_secret'] = output_secret + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (service_account := _dict.get('service_account')) is not None: + args['service_account'] = service_account + if (source_context_dir := _dict.get('source_context_dir')) is not None: + args['source_context_dir'] = source_context_dir + if (source_revision := _dict.get('source_revision')) is not None: + args['source_revision'] = source_revision + if (source_secret := _dict.get('source_secret')) is not None: + args['source_secret'] = source_secret + if (source_type := _dict.get('source_type')) is not None: + args['source_type'] = source_type + if (source_url := _dict.get('source_url')) is not None: + args['source_url'] = source_url + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = BuildRunStatus.from_dict(status_details) + if (strategy_size := _dict.get('strategy_size')) is not None: + args['strategy_size'] = strategy_size + if (strategy_spec_file := _dict.get('strategy_spec_file')) is not None: + args['strategy_spec_file'] = strategy_spec_file + if (strategy_type := _dict.get('strategy_type')) is not None: + args['strategy_type'] = strategy_type + if (timeout := _dict.get('timeout')) is not None: + args['timeout'] = timeout + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BuildRun object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'build_name') and self.build_name is not None: + _dict['build_name'] = self.build_name + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'output_image') and self.output_image is not None: + _dict['output_image'] = self.output_image + if hasattr(self, 'output_secret') and self.output_secret is not None: + _dict['output_secret'] = self.output_secret + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'service_account') and self.service_account is not None: + _dict['service_account'] = self.service_account + if hasattr(self, 'source_context_dir') and self.source_context_dir is not None: + _dict['source_context_dir'] = self.source_context_dir + if hasattr(self, 'source_revision') and self.source_revision is not None: + _dict['source_revision'] = self.source_revision + if hasattr(self, 'source_secret') and self.source_secret is not None: + _dict['source_secret'] = self.source_secret + if hasattr(self, 'source_type') and self.source_type is not None: + _dict['source_type'] = self.source_type + if hasattr(self, 'source_url') and self.source_url is not None: + _dict['source_url'] = self.source_url + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + if hasattr(self, 'status_details') and self.status_details is not None: + if isinstance(self.status_details, dict): + _dict['status_details'] = self.status_details + else: + _dict['status_details'] = self.status_details.to_dict() + if hasattr(self, 'strategy_size') and self.strategy_size is not None: + _dict['strategy_size'] = self.strategy_size + if hasattr(self, 'strategy_spec_file') and self.strategy_spec_file is not None: + _dict['strategy_spec_file'] = self.strategy_spec_file + if hasattr(self, 'strategy_type') and self.strategy_type is not None: + _dict['strategy_type'] = self.strategy_type + if hasattr(self, 'timeout') and self.timeout is not None: + _dict['timeout'] = self.timeout + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BuildRun object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BuildRun') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BuildRun') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the build run. + """ + + BUILD_RUN_V2 = 'build_run_v2' + + class ServiceAccountEnum(str, Enum): + """ + Optional service account, which is used for resource control.” or “Optional + service account that is used for resource control. + """ + + DEFAULT = 'default' + MANAGER = 'manager' + READER = 'reader' + WRITER = 'writer' + NONE = 'none' + + class SourceTypeEnum(str, Enum): + """ + Specifies the type of source to determine if your build source is in a repository + or based on local source code. + * local - For builds from local source code. + * git - For builds from git version controlled source code. + """ + + LOCAL = 'local' + GIT = 'git' + + class StatusEnum(str, Enum): + """ + The current status of the build run. + """ + + SUCCEEDED = 'succeeded' + RUNNING = 'running' + PENDING = 'pending' + FAILED = 'failed' + + +class BuildRunList: + """ + Contains a list of build runs and pagination information. + + :param List[BuildRun] build_runs: List of all build runs. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + build_runs: List['BuildRun'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a BuildRunList object. + + :param List[BuildRun] build_runs: List of all build runs. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.build_runs = build_runs + self.first = first + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BuildRunList': + """Initialize a BuildRunList object from a json dictionary.""" + args = {} + if (build_runs := _dict.get('build_runs')) is not None: + args['build_runs'] = [BuildRun.from_dict(v) for v in build_runs] + else: + raise ValueError('Required property \'build_runs\' not present in BuildRunList JSON') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in BuildRunList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BuildRunList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'build_runs') and self.build_runs is not None: + build_runs_list = [] + for v in self.build_runs: + if isinstance(v, dict): + build_runs_list.append(v) + else: + build_runs_list.append(v.to_dict()) + _dict['build_runs'] = build_runs_list + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BuildRunList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BuildRunList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BuildRunList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class BuildRunStatus: + """ + Current status condition of a build run. + + :param str completion_time: (optional) Time the build run completed. + :param str output_digest: (optional) Describes the time the build run completed. + :param str reason: (optional) Optional information to provide more context in + case of a 'failed' or 'warning' status. + :param str start_time: (optional) Time the build run started. + """ + + def __init__( + self, + *, + completion_time: Optional[str] = None, + output_digest: Optional[str] = None, + reason: Optional[str] = None, + start_time: Optional[str] = None, + ) -> None: + """ + Initialize a BuildRunStatus object. + + """ + self.completion_time = completion_time + self.output_digest = output_digest + self.reason = reason + self.start_time = start_time + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BuildRunStatus': + """Initialize a BuildRunStatus object from a json dictionary.""" + args = {} + if (completion_time := _dict.get('completion_time')) is not None: + args['completion_time'] = completion_time + if (output_digest := _dict.get('output_digest')) is not None: + args['output_digest'] = output_digest + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason + if (start_time := _dict.get('start_time')) is not None: + args['start_time'] = start_time + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BuildRunStatus object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'completion_time') and getattr(self, 'completion_time') is not None: + _dict['completion_time'] = getattr(self, 'completion_time') + if hasattr(self, 'output_digest') and getattr(self, 'output_digest') is not None: + _dict['output_digest'] = getattr(self, 'output_digest') + if hasattr(self, 'reason') and getattr(self, 'reason') is not None: + _dict['reason'] = getattr(self, 'reason') + if hasattr(self, 'start_time') and getattr(self, 'start_time') is not None: + _dict['start_time'] = getattr(self, 'start_time') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BuildRunStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BuildRunStatus') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BuildRunStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ReasonEnum(str, Enum): + """ + Optional information to provide more context in case of a 'failed' or 'warning' + status. + """ + + SUCCEEDED = 'succeeded' + RUNNING = 'running' + PENDING = 'pending' + FAILED_TO_EXECUTE_BUILD_RUN = 'failed_to_execute_build_run' + EXCEEDED_EPHEMERAL_STORAGE = 'exceeded_ephemeral_storage' + MISSING_REGISTRY_ACCESS = 'missing_registry_access' + MISSING_CODE_REPO_ACCESS = 'missing_code_repo_access' + MISSING_SECRETS = 'missing_secrets' + UNKNOWN_STRATEGY = 'unknown_strategy' + INVALID_BUILD_CONFIGURATION = 'invalid_build_configuration' + POD_EVICTED_BECAUSE_OF_STORAGE_QUOTA_EXCEEDS = 'pod_evicted_because_of_storage_quota_exceeds' + POD_EVICTED = 'pod_evicted' + MISSING_TASK_RUN = 'missing_task_run' + TASK_RUN_GENERATION_FAILED = 'task_run_generation_failed' + BUILD_NOT_FOUND = 'build_not_found' + TIMEOUT = 'timeout' + FAILED = 'failed' + + +class BuildStatus: + """ + The detailed status of the build. + + :param str reason: (optional) Optional information to provide more context in + case of a 'failed' or 'warning' status. + """ + + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: + """ + Initialize a BuildStatus object. + + """ + self.reason = reason + + @classmethod + def from_dict(cls, _dict: Dict) -> 'BuildStatus': + """Initialize a BuildStatus object from a json dictionary.""" + args = {} + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a BuildStatus object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'reason') and getattr(self, 'reason') is not None: + _dict['reason'] = getattr(self, 'reason') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this BuildStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'BuildStatus') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'BuildStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ReasonEnum(str, Enum): + """ + Optional information to provide more context in case of a 'failed' or 'warning' + status. + """ + + REGISTERED = 'registered' + STRATEGY_NOT_FOUND = 'strategy_not_found' + CLUSTER_BUILD_STRATEGY_NOT_FOUND = 'cluster_build_strategy_not_found' + SET_OWNER_REFERENCE_FAILED = 'set_owner_reference_failed' + SPEC_SOURCE_SECRET_NOT_FOUND = 'spec_source_secret_not_found' + SPEC_OUTPUT_SECRET_REF_NOT_FOUND = 'spec_output_secret_ref_not_found' + SPEC_RUNTIME_SECRET_REF_NOT_FOUND = 'spec_runtime_secret_ref_not_found' + MULTIPLE_SECRET_REF_NOT_FOUND = 'multiple_secret_ref_not_found' + RUNTIME_PATHS_CAN_NOT_BE_EMPTY = 'runtime_paths_can_not_be_empty' + REMOTE_REPOSITORY_UNREACHABLE = 'remote_repository_unreachable' + FAILED = 'failed' + + +class ComponentRef: + """ + A reference to another component. + + :param str name: The name of the referenced component. + :param str resource_type: The type of the referenced resource. + """ + + def __init__( + self, + name: str, + resource_type: str, + ) -> None: + """ + Initialize a ComponentRef object. + + :param str name: The name of the referenced component. + :param str resource_type: The type of the referenced resource. + """ + self.name = name + self.resource_type = resource_type + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ComponentRef': + """Initialize a ComponentRef object from a json dictionary.""" + args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in ComponentRef JSON') + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + else: + raise ValueError('Required property \'resource_type\' not present in ComponentRef JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ComponentRef object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'resource_type') and self.resource_type is not None: + _dict['resource_type'] = self.resource_type + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ComponentRef object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ComponentRef') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ComponentRef') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ConfigMap: + """ + Describes the model of a configmap. + + :param str created_at: (optional) The timestamp when the resource was created. + :param dict data: (optional) The key-value pair for the config map. Values must + be specified in `KEY=VALUE` format. + :param str entity_tag: The version of the config map instance, which is used to + achieve optimistic locking. + :param str href: (optional) When you provision a new config map, a URL is + created identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str name: The name of the config map. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the config map. + """ + + def __init__( + self, + entity_tag: str, + name: str, + *, + created_at: Optional[str] = None, + data: Optional[dict] = None, + href: Optional[str] = None, + id: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + ) -> None: + """ + Initialize a ConfigMap object. + + :param str entity_tag: The version of the config map instance, which is + used to achieve optimistic locking. + :param str name: The name of the config map. + :param dict data: (optional) The key-value pair for the config map. Values + must be specified in `KEY=VALUE` format. + """ + self.created_at = created_at + self.data = data + self.entity_tag = entity_tag + self.href = href + self.id = id + self.name = name + self.project_id = project_id + self.region = region + self.resource_type = resource_type + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ConfigMap': + """Initialize a ConfigMap object from a json dictionary.""" + args = {} + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (data := _dict.get('data')) is not None: + args['data'] = data + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag + else: + raise ValueError('Required property \'entity_tag\' not present in ConfigMap JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in ConfigMap JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ConfigMap object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'data') and self.data is not None: + _dict['data'] = self.data + if hasattr(self, 'entity_tag') and self.entity_tag is not None: + _dict['entity_tag'] = self.entity_tag + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ConfigMap object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ConfigMap') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ConfigMap') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the config map. + """ + + CONFIG_MAP_V2 = 'config_map_v2' + + +class ConfigMapList: + """ + Contains a list of config maps and pagination information. + + :param List[ConfigMap] config_maps: List of all config maps. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + config_maps: List['ConfigMap'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a ConfigMapList object. + + :param List[ConfigMap] config_maps: List of all config maps. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.config_maps = config_maps + self.first = first + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ConfigMapList': + """Initialize a ConfigMapList object from a json dictionary.""" + args = {} + if (config_maps := _dict.get('config_maps')) is not None: + args['config_maps'] = [ConfigMap.from_dict(v) for v in config_maps] + else: + raise ValueError('Required property \'config_maps\' not present in ConfigMapList JSON') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in ConfigMapList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ConfigMapList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'config_maps') and self.config_maps is not None: + config_maps_list = [] + for v in self.config_maps: + if isinstance(v, dict): + config_maps_list.append(v) + else: + config_maps_list.append(v.to_dict()) + _dict['config_maps'] = config_maps_list + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ConfigMapList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ConfigMapList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ConfigMapList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ContainerStatus: + """ + The status of a container. + + :param ContainerStatusDetails current_state: (optional) Details of the observed + container status. + :param ContainerStatusDetails last_observed_state: (optional) Details of the + observed container status. + """ + + def __init__( + self, + *, + current_state: Optional['ContainerStatusDetails'] = None, + last_observed_state: Optional['ContainerStatusDetails'] = None, + ) -> None: + """ + Initialize a ContainerStatus object. + + :param ContainerStatusDetails current_state: (optional) Details of the + observed container status. + :param ContainerStatusDetails last_observed_state: (optional) Details of + the observed container status. + """ + self.current_state = current_state + self.last_observed_state = last_observed_state + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ContainerStatus': + """Initialize a ContainerStatus object from a json dictionary.""" + args = {} + if (current_state := _dict.get('current_state')) is not None: + args['current_state'] = ContainerStatusDetails.from_dict(current_state) + if (last_observed_state := _dict.get('last_observed_state')) is not None: + args['last_observed_state'] = ContainerStatusDetails.from_dict(last_observed_state) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ContainerStatus object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'current_state') and self.current_state is not None: + if isinstance(self.current_state, dict): + _dict['current_state'] = self.current_state + else: + _dict['current_state'] = self.current_state.to_dict() + if hasattr(self, 'last_observed_state') and self.last_observed_state is not None: + if isinstance(self.last_observed_state, dict): + _dict['last_observed_state'] = self.last_observed_state + else: + _dict['last_observed_state'] = self.last_observed_state.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ContainerStatus object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ContainerStatus') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ContainerStatus') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ContainerStatusDetails: + """ + Details of the observed container status. + + :param str completed_at: (optional) The time the container terminated. Only + populated in an observed failure state. + :param str container_status: (optional) The status of the container. + :param int exit_code: (optional) The exit code of the last termination of the + container. Only populated in an observed failure state. + :param str reason: (optional) The reason the container is not yet running or has + failed. Only populated in non-running states. + :param str started_at: (optional) The time the container started. + """ + + def __init__( + self, + *, + completed_at: Optional[str] = None, + container_status: Optional[str] = None, + exit_code: Optional[int] = None, + reason: Optional[str] = None, + started_at: Optional[str] = None, + ) -> None: + """ + Initialize a ContainerStatusDetails object. + + """ + self.completed_at = completed_at + self.container_status = container_status + self.exit_code = exit_code + self.reason = reason + self.started_at = started_at + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ContainerStatusDetails': + """Initialize a ContainerStatusDetails object from a json dictionary.""" + args = {} + if (completed_at := _dict.get('completed_at')) is not None: + args['completed_at'] = completed_at + if (container_status := _dict.get('container_status')) is not None: + args['container_status'] = container_status + if (exit_code := _dict.get('exit_code')) is not None: + args['exit_code'] = exit_code + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason + if (started_at := _dict.get('started_at')) is not None: + args['started_at'] = started_at + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ContainerStatusDetails object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'completed_at') and getattr(self, 'completed_at') is not None: + _dict['completed_at'] = getattr(self, 'completed_at') + if hasattr(self, 'container_status') and getattr(self, 'container_status') is not None: + _dict['container_status'] = getattr(self, 'container_status') + if hasattr(self, 'exit_code') and getattr(self, 'exit_code') is not None: + _dict['exit_code'] = getattr(self, 'exit_code') + if hasattr(self, 'reason') and getattr(self, 'reason') is not None: + _dict['reason'] = getattr(self, 'reason') + if hasattr(self, 'started_at') and getattr(self, 'started_at') is not None: + _dict['started_at'] = getattr(self, 'started_at') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ContainerStatusDetails object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ContainerStatusDetails') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ContainerStatusDetails') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ReasonEnum(str, Enum): + """ + The reason the container is not yet running or has failed. Only populated in + non-running states. + """ + + READY = 'ready' + WAITING = 'waiting' + DEPLOYING = 'deploying' + DEPLOYING_WAITING_FOR_RESOURCES = 'deploying_waiting_for_resources' + INITIAL_SCALE_NEVER_ACHIEVED = 'initial_scale_never_achieved' + FETCH_IMAGE_FAILED_UNKNOWN_MANIFEST = 'fetch_image_failed_unknown_manifest' + FETCH_IMAGE_FAILED_UNKNOWN_REPOSITORY = 'fetch_image_failed_unknown_repository' + FETCH_IMAGE_FAILED_REGISTRY_NOT_FOUND = 'fetch_image_failed_registry_not_found' + FETCH_IMAGE_FAILED_MISSING_PULL_SECRET = 'fetch_image_failed_missing_pull_secret' + FETCH_IMAGE_FAILED_WRONG_PULL_CREDENTIALS = 'fetch_image_failed_wrong_pull_credentials' + FETCH_IMAGE_FAILED_MISSING_PULL_CREDENTIALS = 'fetch_image_failed_missing_pull_credentials' + CONTAINER_FAILED_EXIT_CODE_0 = 'container_failed_exit_code_0' + CONTAINER_FAILED_EXIT_CODE_1 = 'container_failed_exit_code_1' + CONTAINER_FAILED_EXIT_CODE_139 = 'container_failed_exit_code_139' + CONTAINER_FAILED_EXIT_CODE_24 = 'container_failed_exit_code_24' + IMAGE_PULL_BACK_OFF = 'image_pull_back_off' + INVALID_TAR_HEADER_IMAGE_PULL_ERR = 'invalid_tar_header_image_pull_err' + + +class DomainMapping: + """ + Response model for domain mapping definitions. + + :param str cname_target: (optional) The value of the CNAME record that must be + configured in the DNS settings of the domain, to route traffic properly to the + target Code Engine region. + :param ComponentRef component: A reference to another component. + :param str created_at: (optional) The timestamp when the resource was created. + :param str entity_tag: The version of the domain mapping instance, which is used + to achieve optimistic locking. + :param str href: (optional) When you provision a new domain mapping, a URL is + created identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str name: The name of the domain mapping. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the Code Engine resource. + :param str status: (optional) The current status of the domain mapping. + :param DomainMappingStatus status_details: (optional) The detailed status of the + domain mapping. + :param str tls_secret: The name of the TLS secret that includes the certificate + and private key of this domain mapping. + :param bool user_managed: (optional) Specifies whether the domain mapping is + managed by the user or by Code Engine. + :param str visibility: (optional) Specifies whether the domain mapping is + reachable through the public internet, or private IBM network, or only through + other components within the same Code Engine project. """ def __init__( self, + component: 'ComponentRef', entity_tag: str, - image_reference: str, - managed_domain_mappings: str, name: str, - run_arguments: List[str], - run_commands: List[str], - run_env_variables: List['EnvVar'], - run_volume_mounts: List['VolumeMount'], - scale_cpu_limit: str, - scale_ephemeral_storage_limit: str, - scale_max_instances: int, - scale_memory_limit: str, - scale_min_instances: int, - scale_request_timeout: int, + tls_secret: str, *, - created_at: str = None, - endpoint: str = None, - endpoint_internal: str = None, - href: str = None, - id: str = None, - image_port: int = None, - image_secret: str = None, - project_id: str = None, - resource_type: str = None, - run_as_user: int = None, - run_service_account: str = None, - scale_concurrency: int = None, - scale_concurrency_target: int = None, - scale_initial_instances: int = None, - status: str = None, - status_details: 'AppStatus' = None, + cname_target: Optional[str] = None, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + status: Optional[str] = None, + status_details: Optional['DomainMappingStatus'] = None, + user_managed: Optional[bool] = None, + visibility: Optional[str] = None, ) -> None: """ - Initialize a App object. + Initialize a DomainMapping object. - :param str entity_tag: The version of the app instance, which is used to - achieve optimistic locking. - :param str image_reference: The name of the image that is used for this - job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and - `TAG` are optional. If `REGISTRY` is not specified, the default is - `docker.io`. If `TAG` is not specified, the default is `latest`. If the - image reference points to a registry that requires authentication, make - sure to also specify the property `image_secret`. - :param str managed_domain_mappings: Optional value controlling which of the - system managed domain mappings will be setup for the application. Valid - values are 'local_public', 'local_private' and 'local'. Visibility can only - be 'local_private' if the project supports application private visibility. - :param str name: The name of the app. - :param List[str] run_arguments: Optional arguments for the app that are - passed to start the container. If not specified an empty string array will - be applied and the arguments specified by the container image, will be used - to start the container. - :param List[str] run_commands: Optional commands for the app that are - passed to start the container. If not specified an empty string array will - be applied and the command specified by the container image, will be used - to start the container. - :param List[EnvVar] run_env_variables: References to config maps, secrets - or a literal values, which are exposed as environment variables in the - application. - :param List[VolumeMount] run_volume_mounts: Mounts of config maps or - secrets. - :param str scale_cpu_limit: Optional number of CPU set for the instance of - the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :param str scale_ephemeral_storage_limit: Optional amount of ephemeral - storage to set for the instance of the app. The amount specified as - ephemeral storage, must not exceed the amount of `scale_memory_limit`. The - units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), - whereas G and M are the shorthand expressions for GB and MB. For more - information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_max_instances: Optional maximum number of instances for - this app. If you set this value to `0`, this property does not set a upper - scaling limit. However, the app scaling is still limited by the project - quota for instances. See [Limits and quotas for Code - Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). - :param str scale_memory_limit: Optional amount of memory set for the - instance of the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G - and M are the shorthand expressions for GB and MB. For more information see - [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_min_instances: Optional minimum number of instances for - this app. If you set this value to `0`, the app will scale down to zero, if - not hit by any request for some time. - :param int scale_request_timeout: Optional amount of time in seconds that - is allowed for a running app to respond to a request. - :param int image_port: (optional) Optional port the app listens on. While - the app will always be exposed via port `443` for end users, this port is - used to connect to the port that is exposed by the container image. - :param str image_secret: (optional) Optional name of the image registry - access secret. The image registry access secret is used to authenticate - with a private registry when you download the container image. If the image - reference points to a registry that requires authentication, the app will - be created but cannot reach the ready status, until this property is - provided, too. - :param int run_as_user: (optional) Optional user ID (UID) to run the app - (e.g., `1001`). - :param str run_service_account: (optional) Optional name of the service - account. For built-in service accounts, you can use the shortened names - `manager` , `none`, `reader`, and `writer`. - :param int scale_concurrency: (optional) Optional maximum number of - requests that can be processed concurrently per instance. - :param int scale_concurrency_target: (optional) Optional threshold of - concurrent requests per instance at which one or more additional instances - are created. Use this value to scale up instances based on concurrent - number of requests. This option defaults to the value of the - `scale_concurrency` option, if not specified. - :param int scale_initial_instances: (optional) Optional initial number of - instances that are created upon app creation or app update. - :param AppStatus status_details: (optional) The detailed status of the - application. - """ + :param ComponentRef component: A reference to another component. + :param str entity_tag: The version of the domain mapping instance, which is + used to achieve optimistic locking. + :param str name: The name of the domain mapping. + :param str tls_secret: The name of the TLS secret that includes the + certificate and private key of this domain mapping. + :param DomainMappingStatus status_details: (optional) The detailed status + of the domain mapping. + """ + self.cname_target = cname_target + self.component = component self.created_at = created_at - self.endpoint = endpoint - self.endpoint_internal = endpoint_internal self.entity_tag = entity_tag self.href = href self.id = id - self.image_port = image_port - self.image_reference = image_reference - self.image_secret = image_secret - self.managed_domain_mappings = managed_domain_mappings self.name = name self.project_id = project_id + self.region = region self.resource_type = resource_type - self.run_arguments = run_arguments - self.run_as_user = run_as_user - self.run_commands = run_commands - self.run_env_variables = run_env_variables - self.run_service_account = run_service_account - self.run_volume_mounts = run_volume_mounts - self.scale_concurrency = scale_concurrency - self.scale_concurrency_target = scale_concurrency_target - self.scale_cpu_limit = scale_cpu_limit - self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit - self.scale_initial_instances = scale_initial_instances - self.scale_max_instances = scale_max_instances - self.scale_memory_limit = scale_memory_limit - self.scale_min_instances = scale_min_instances - self.scale_request_timeout = scale_request_timeout self.status = status self.status_details = status_details + self.tls_secret = tls_secret + self.user_managed = user_managed + self.visibility = visibility - @classmethod - def from_dict(cls, _dict: Dict) -> 'App': - """Initialize a App object from a json dictionary.""" + @classmethod + def from_dict(cls, _dict: Dict) -> 'DomainMapping': + """Initialize a DomainMapping object from a json dictionary.""" args = {} - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'endpoint' in _dict: - args['endpoint'] = _dict.get('endpoint') - if 'endpoint_internal' in _dict: - args['endpoint_internal'] = _dict.get('endpoint_internal') - if 'entity_tag' in _dict: - args['entity_tag'] = _dict.get('entity_tag') - else: - raise ValueError('Required property \'entity_tag\' not present in App JSON') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'image_port' in _dict: - args['image_port'] = _dict.get('image_port') - if 'image_reference' in _dict: - args['image_reference'] = _dict.get('image_reference') - else: - raise ValueError('Required property \'image_reference\' not present in App JSON') - if 'image_secret' in _dict: - args['image_secret'] = _dict.get('image_secret') - if 'managed_domain_mappings' in _dict: - args['managed_domain_mappings'] = _dict.get('managed_domain_mappings') - else: - raise ValueError('Required property \'managed_domain_mappings\' not present in App JSON') - if 'name' in _dict: - args['name'] = _dict.get('name') - else: - raise ValueError('Required property \'name\' not present in App JSON') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'run_arguments' in _dict: - args['run_arguments'] = _dict.get('run_arguments') - else: - raise ValueError('Required property \'run_arguments\' not present in App JSON') - if 'run_as_user' in _dict: - args['run_as_user'] = _dict.get('run_as_user') - if 'run_commands' in _dict: - args['run_commands'] = _dict.get('run_commands') - else: - raise ValueError('Required property \'run_commands\' not present in App JSON') - if 'run_env_variables' in _dict: - args['run_env_variables'] = [EnvVar.from_dict(v) for v in _dict.get('run_env_variables')] - else: - raise ValueError('Required property \'run_env_variables\' not present in App JSON') - if 'run_service_account' in _dict: - args['run_service_account'] = _dict.get('run_service_account') - if 'run_volume_mounts' in _dict: - args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in _dict.get('run_volume_mounts')] - else: - raise ValueError('Required property \'run_volume_mounts\' not present in App JSON') - if 'scale_concurrency' in _dict: - args['scale_concurrency'] = _dict.get('scale_concurrency') - if 'scale_concurrency_target' in _dict: - args['scale_concurrency_target'] = _dict.get('scale_concurrency_target') - if 'scale_cpu_limit' in _dict: - args['scale_cpu_limit'] = _dict.get('scale_cpu_limit') - else: - raise ValueError('Required property \'scale_cpu_limit\' not present in App JSON') - if 'scale_ephemeral_storage_limit' in _dict: - args['scale_ephemeral_storage_limit'] = _dict.get('scale_ephemeral_storage_limit') - else: - raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in App JSON') - if 'scale_initial_instances' in _dict: - args['scale_initial_instances'] = _dict.get('scale_initial_instances') - if 'scale_max_instances' in _dict: - args['scale_max_instances'] = _dict.get('scale_max_instances') + if (cname_target := _dict.get('cname_target')) is not None: + args['cname_target'] = cname_target + if (component := _dict.get('component')) is not None: + args['component'] = ComponentRef.from_dict(component) else: - raise ValueError('Required property \'scale_max_instances\' not present in App JSON') - if 'scale_memory_limit' in _dict: - args['scale_memory_limit'] = _dict.get('scale_memory_limit') + raise ValueError('Required property \'component\' not present in DomainMapping JSON') + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag else: - raise ValueError('Required property \'scale_memory_limit\' not present in App JSON') - if 'scale_min_instances' in _dict: - args['scale_min_instances'] = _dict.get('scale_min_instances') + raise ValueError('Required property \'entity_tag\' not present in DomainMapping JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'scale_min_instances\' not present in App JSON') - if 'scale_request_timeout' in _dict: - args['scale_request_timeout'] = _dict.get('scale_request_timeout') + raise ValueError('Required property \'name\' not present in DomainMapping JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = DomainMappingStatus.from_dict(status_details) + if (tls_secret := _dict.get('tls_secret')) is not None: + args['tls_secret'] = tls_secret else: - raise ValueError('Required property \'scale_request_timeout\' not present in App JSON') - if 'status' in _dict: - args['status'] = _dict.get('status') - if 'status_details' in _dict: - args['status_details'] = AppStatus.from_dict(_dict.get('status_details')) + raise ValueError('Required property \'tls_secret\' not present in DomainMapping JSON') + if (user_managed := _dict.get('user_managed')) is not None: + args['user_managed'] = user_managed + if (visibility := _dict.get('visibility')) is not None: + args['visibility'] = visibility return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a App object from a json dictionary.""" + """Initialize a DomainMapping object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'cname_target') and getattr(self, 'cname_target') is not None: + _dict['cname_target'] = getattr(self, 'cname_target') + if hasattr(self, 'component') and self.component is not None: + if isinstance(self.component, dict): + _dict['component'] = self.component + else: + _dict['component'] = self.component.to_dict() if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: _dict['created_at'] = getattr(self, 'created_at') - if hasattr(self, 'endpoint') and getattr(self, 'endpoint') is not None: - _dict['endpoint'] = getattr(self, 'endpoint') - if hasattr(self, 'endpoint_internal') and getattr(self, 'endpoint_internal') is not None: - _dict['endpoint_internal'] = getattr(self, 'endpoint_internal') if hasattr(self, 'entity_tag') and self.entity_tag is not None: _dict['entity_tag'] = self.entity_tag if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'image_port') and self.image_port is not None: - _dict['image_port'] = self.image_port - if hasattr(self, 'image_reference') and self.image_reference is not None: - _dict['image_reference'] = self.image_reference - if hasattr(self, 'image_secret') and self.image_secret is not None: - _dict['image_secret'] = self.image_secret - if hasattr(self, 'managed_domain_mappings') and self.managed_domain_mappings is not None: - _dict['managed_domain_mappings'] = self.managed_domain_mappings if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'run_arguments') and self.run_arguments is not None: - _dict['run_arguments'] = self.run_arguments - if hasattr(self, 'run_as_user') and self.run_as_user is not None: - _dict['run_as_user'] = self.run_as_user - if hasattr(self, 'run_commands') and self.run_commands is not None: - _dict['run_commands'] = self.run_commands - if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: - run_env_variables_list = [] - for v in self.run_env_variables: - if isinstance(v, dict): - run_env_variables_list.append(v) - else: - run_env_variables_list.append(v.to_dict()) - _dict['run_env_variables'] = run_env_variables_list - if hasattr(self, 'run_service_account') and self.run_service_account is not None: - _dict['run_service_account'] = self.run_service_account - if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: - run_volume_mounts_list = [] - for v in self.run_volume_mounts: - if isinstance(v, dict): - run_volume_mounts_list.append(v) - else: - run_volume_mounts_list.append(v.to_dict()) - _dict['run_volume_mounts'] = run_volume_mounts_list - if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: - _dict['scale_concurrency'] = self.scale_concurrency - if hasattr(self, 'scale_concurrency_target') and self.scale_concurrency_target is not None: - _dict['scale_concurrency_target'] = self.scale_concurrency_target - if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: - _dict['scale_cpu_limit'] = self.scale_cpu_limit - if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: - _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit - if hasattr(self, 'scale_initial_instances') and self.scale_initial_instances is not None: - _dict['scale_initial_instances'] = self.scale_initial_instances - if hasattr(self, 'scale_max_instances') and self.scale_max_instances is not None: - _dict['scale_max_instances'] = self.scale_max_instances - if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: - _dict['scale_memory_limit'] = self.scale_memory_limit - if hasattr(self, 'scale_min_instances') and self.scale_min_instances is not None: - _dict['scale_min_instances'] = self.scale_min_instances - if hasattr(self, 'scale_request_timeout') and self.scale_request_timeout is not None: - _dict['scale_request_timeout'] = self.scale_request_timeout if hasattr(self, 'status') and getattr(self, 'status') is not None: _dict['status'] = getattr(self, 'status') if hasattr(self, 'status_details') and self.status_details is not None: @@ -2774,6 +8221,12 @@ def to_dict(self) -> Dict: _dict['status_details'] = self.status_details else: _dict['status_details'] = self.status_details.to_dict() + if hasattr(self, 'tls_secret') and self.tls_secret is not None: + _dict['tls_secret'] = self.tls_secret + if hasattr(self, 'user_managed') and getattr(self, 'user_managed') is not None: + _dict['user_managed'] = getattr(self, 'user_managed') + if hasattr(self, 'visibility') and getattr(self, 'visibility') is not None: + _dict['visibility'] = getattr(self, 'visibility') return _dict def _to_dict(self): @@ -2781,137 +8234,373 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this App object.""" + """Return a `str` version of this DomainMapping object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DomainMapping') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'DomainMapping') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ResourceTypeEnum(str, Enum): + """ + The type of the Code Engine resource. + """ + + DOMAIN_MAPPING_V2 = 'domain_mapping_v2' + + class StatusEnum(str, Enum): + """ + The current status of the domain mapping. + """ + + READY = 'ready' + FAILED = 'failed' + DEPLOYING = 'deploying' + + class VisibilityEnum(str, Enum): + """ + Specifies whether the domain mapping is reachable through the public internet, or + private IBM network, or only through other components within the same Code Engine + project. + """ + + CUSTOM = 'custom' + PRIVATE = 'private' + PROJECT = 'project' + PUBLIC = 'public' + + +class DomainMappingList: + """ + Contains a list of domain mappings and pagination information. + + :param List[DomainMapping] domain_mappings: List of all domain mappings. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + """ + + def __init__( + self, + domain_mappings: List['DomainMapping'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a DomainMappingList object. + + :param List[DomainMapping] domain_mappings: List of all domain mappings. + :param int limit: Maximum number of resources per page. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.domain_mappings = domain_mappings + self.first = first + self.limit = limit + self.next = next + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DomainMappingList': + """Initialize a DomainMappingList object from a json dictionary.""" + args = {} + if (domain_mappings := _dict.get('domain_mappings')) is not None: + args['domain_mappings'] = [DomainMapping.from_dict(v) for v in domain_mappings] + else: + raise ValueError('Required property \'domain_mappings\' not present in DomainMappingList JSON') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in DomainMappingList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DomainMappingList object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'domain_mappings') and self.domain_mappings is not None: + domain_mappings_list = [] + for v in self.domain_mappings: + if isinstance(v, dict): + domain_mappings_list.append(v) + else: + domain_mappings_list.append(v.to_dict()) + _dict['domain_mappings'] = domain_mappings_list + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this DomainMappingList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DomainMappingList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'DomainMappingList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DomainMappingPatch: + """ + Patch a domain mappings object. + + :param ComponentRef component: (optional) A reference to another component. + :param str tls_secret: (optional) The name of the TLS secret that includes the + certificate and private key of this domain mapping. + """ + + def __init__( + self, + *, + component: Optional['ComponentRef'] = None, + tls_secret: Optional[str] = None, + ) -> None: + """ + Initialize a DomainMappingPatch object. + + :param ComponentRef component: (optional) A reference to another component. + :param str tls_secret: (optional) The name of the TLS secret that includes + the certificate and private key of this domain mapping. + """ + self.component = component + self.tls_secret = tls_secret + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DomainMappingPatch': + """Initialize a DomainMappingPatch object from a json dictionary.""" + args = {} + if (component := _dict.get('component')) is not None: + args['component'] = ComponentRef.from_dict(component) + if (tls_secret := _dict.get('tls_secret')) is not None: + args['tls_secret'] = tls_secret + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DomainMappingPatch object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'component') and self.component is not None: + if isinstance(self.component, dict): + _dict['component'] = self.component + else: + _dict['component'] = self.component.to_dict() + if hasattr(self, 'tls_secret') and self.tls_secret is not None: + _dict['tls_secret'] = self.tls_secret + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this DomainMappingPatch object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DomainMappingPatch') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'DomainMappingPatch') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DomainMappingStatus: + """ + The detailed status of the domain mapping. + + :param str reason: (optional) Optional information to provide more context in + case of a 'failed' or 'warning' status. + """ + + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: + """ + Initialize a DomainMappingStatus object. + + """ + self.reason = reason + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DomainMappingStatus': + """Initialize a DomainMappingStatus object from a json dictionary.""" + args = {} + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DomainMappingStatus object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'reason') and getattr(self, 'reason') is not None: + _dict['reason'] = getattr(self, 'reason') + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this DomainMappingStatus object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'App') -> bool: + def __eq__(self, other: 'DomainMappingStatus') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'App') -> bool: + def __ne__(self, other: 'DomainMappingStatus') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ManagedDomainMappingsEnum(str, Enum): - """ - Optional value controlling which of the system managed domain mappings will be - setup for the application. Valid values are 'local_public', 'local_private' and - 'local'. Visibility can only be 'local_private' if the project supports - application private visibility. - """ - - LOCAL = 'local' - LOCAL_PRIVATE = 'local_private' - LOCAL_PUBLIC = 'local_public' - - class ResourceTypeEnum(str, Enum): - """ - The type of the app. - """ - - APP_V2 = 'app_v2' - - class RunServiceAccountEnum(str, Enum): - """ - Optional name of the service account. For built-in service accounts, you can use - the shortened names `manager` , `none`, `reader`, and `writer`. - """ - - DEFAULT = 'default' - MANAGER = 'manager' - READER = 'reader' - WRITER = 'writer' - NONE = 'none' - - class StatusEnum(str, Enum): + class ReasonEnum(str, Enum): """ - The current status of the app. + Optional information to provide more context in case of a 'failed' or 'warning' + status. """ READY = 'ready' + DOMAIN_ALREADY_CLAIMED = 'domain_already_claimed' + APP_REF_FAILED = 'app_ref_failed' + FAILED_RECONCILE_INGRESS = 'failed_reconcile_ingress' DEPLOYING = 'deploying' FAILED = 'failed' - WARNING = 'warning' -class AppList: +class EnvVar: """ - Contains a list of apps and pagination information. + Response model for environment variables. - :attr List[App] apps: List of all apps. - :attr ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve - the next page of a result list. + :param str key: (optional) The key to reference as environment variable. + :param str name: (optional) The name of the environment variable. + :param str prefix: (optional) A prefix that can be added to all keys of a full + secret or config map reference. + :param str reference: (optional) The name of the secret or config map. + :param str type: Specify the type of the environment variable. + :param str value: (optional) The literal value of the environment variable. """ def __init__( - self, apps: List['App'], limit: int, *, first: 'ListFirstMetadata' = None, next: 'ListNextMetadata' = None + self, + type: str, + *, + key: Optional[str] = None, + name: Optional[str] = None, + prefix: Optional[str] = None, + reference: Optional[str] = None, + value: Optional[str] = None, ) -> None: """ - Initialize a AppList object. + Initialize a EnvVar object. - :param List[App] apps: List of all apps. - :param int limit: Maximum number of resources per page. - :param ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :param ListNextMetadata next: (optional) Describes properties needed to - retrieve the next page of a result list. + :param str type: Specify the type of the environment variable. + :param str key: (optional) The key to reference as environment variable. + :param str name: (optional) The name of the environment variable. + :param str prefix: (optional) A prefix that can be added to all keys of a + full secret or config map reference. + :param str reference: (optional) The name of the secret or config map. + :param str value: (optional) The literal value of the environment variable. """ - self.apps = apps - self.first = first - self.limit = limit - self.next = next + self.key = key + self.name = name + self.prefix = prefix + self.reference = reference + self.type = type + self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'AppList': - """Initialize a AppList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'EnvVar': + """Initialize a EnvVar object from a json dictionary.""" args = {} - if 'apps' in _dict: - args['apps'] = [App.from_dict(v) for v in _dict.get('apps')] - else: - raise ValueError('Required property \'apps\' not present in AppList JSON') - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') + if (key := _dict.get('key')) is not None: + args['key'] = key + if (name := _dict.get('name')) is not None: + args['name'] = name + if (prefix := _dict.get('prefix')) is not None: + args['prefix'] = prefix + if (reference := _dict.get('reference')) is not None: + args['reference'] = reference + if (type := _dict.get('type')) is not None: + args['type'] = type else: - raise ValueError('Required property \'limit\' not present in AppList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) + raise ValueError('Required property \'type\' not present in EnvVar JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AppList object from a json dictionary.""" + """Initialize a EnvVar object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'apps') and self.apps is not None: - apps_list = [] - for v in self.apps: - if isinstance(v, dict): - apps_list.append(v) - else: - apps_list.append(v.to_dict()) - _dict['apps'] = apps_list - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() + if hasattr(self, 'key') and self.key is not None: + _dict['key'] = self.key + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'prefix') and self.prefix is not None: + _dict['prefix'] = self.prefix + if hasattr(self, 'reference') and self.reference is not None: + _dict['reference'] = self.reference + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value return _dict def _to_dict(self): @@ -2919,320 +8608,110 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AppList object.""" + """Return a `str` version of this EnvVar object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AppList') -> bool: + def __eq__(self, other: 'EnvVar') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AppList') -> bool: + def __ne__(self, other: 'EnvVar') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TypeEnum(str, Enum): + """ + Specify the type of the environment variable. + """ -class AppPatch: + LITERAL = 'literal' + CONFIG_MAP_FULL_REFERENCE = 'config_map_full_reference' + SECRET_FULL_REFERENCE = 'secret_full_reference' + CONFIG_MAP_KEY_REFERENCE = 'config_map_key_reference' + SECRET_KEY_REFERENCE = 'secret_key_reference' + + +class EnvVarPrototype: """ - App is the request model for app update operations. + Prototype model for environment variables. - :attr int image_port: (optional) Optional port the app listens on. While the app - will always be exposed via port `443` for end users, this port is used to - connect to the port that is exposed by the container image. - :attr str image_reference: (optional) The name of the image that is used for - this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and - `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. - If `TAG` is not specified, the default is `latest`. If the image reference - points to a registry that requires authentication, make sure to also specify the - property `image_secret`. - :attr str image_secret: (optional) Optional name of the image registry access - secret. The image registry access secret is used to authenticate with a private - registry when you download the container image. If the image reference points to - a registry that requires authentication, the app will be created but cannot - reach the ready status, until this property is provided, too. - :attr str managed_domain_mappings: (optional) Optional value controlling which - of the system managed domain mappings will be setup for the application. Valid - values are 'local_public', 'local_private' and 'local'. Visibility can only be - 'local_private' if the project supports application private visibility. - :attr List[str] run_arguments: (optional) Optional arguments for the app that - are passed to start the container. If not specified an empty string array will - be applied and the arguments specified by the container image, will be used to - start the container. - :attr int run_as_user: (optional) Optional user ID (UID) to run the app (e.g., - `1001`). - :attr List[str] run_commands: (optional) Optional commands for the app that are - passed to start the container. If not specified an empty string array will be - applied and the command specified by the container image, will be used to start - the container. - :attr List[EnvVarPrototype] run_env_variables: (optional) Optional references to - config maps, secrets or a literal values. - :attr str run_service_account: (optional) Optional name of the service account. - For built-in service accounts, you can use the shortened names `manager` , - `none`, `reader`, and `writer`. - :attr List[VolumeMountPrototype] run_volume_mounts: (optional) Optional mounts - of config maps or a secrets. In case this is provided, existing - `run_volume_mounts` will be overwritten. - :attr int scale_concurrency: (optional) Optional maximum number of requests that - can be processed concurrently per instance. - :attr int scale_concurrency_target: (optional) Optional threshold of concurrent - requests per instance at which one or more additional instances are created. Use - this value to scale up instances based on concurrent number of requests. This - option defaults to the value of the `scale_concurrency` option, if not - specified. - :attr str scale_cpu_limit: (optional) Optional number of CPU set for the - instance of the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :attr str scale_ephemeral_storage_limit: (optional) Optional amount of ephemeral - storage to set for the instance of the app. The amount specified as ephemeral - storage, must not exceed the amount of `scale_memory_limit`. The units for - specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M - are the shorthand expressions for GB and MB. For more information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_initial_instances: (optional) Optional initial number of - instances that are created upon app creation or app update. - :attr int scale_max_instances: (optional) Optional maximum number of instances - for this app. If you set this value to `0`, this property does not set a upper - scaling limit. However, the app scaling is still limited by the project quota - for instances. See [Limits and quotas for Code - Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). - :attr str scale_memory_limit: (optional) Optional amount of memory set for the - instance of the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and - M are the shorthand expressions for GB and MB. For more information see [Units - of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_min_instances: (optional) Optional minimum number of instances - for this app. If you set this value to `0`, the app will scale down to zero, if - not hit by any request for some time. - :attr int scale_request_timeout: (optional) Optional amount of time in seconds - that is allowed for a running app to respond to a request. + :param str key: (optional) The key to reference as environment variable. + :param str name: (optional) The name of the environment variable. + :param str prefix: (optional) A prefix that can be added to all keys of a full + secret or config map reference. + :param str reference: (optional) The name of the secret or config map. + :param str type: (optional) Specify the type of the environment variable. + :param str value: (optional) The literal value of the environment variable. """ def __init__( self, *, - image_port: int = None, - image_reference: str = None, - image_secret: str = None, - managed_domain_mappings: str = None, - run_arguments: List[str] = None, - run_as_user: int = None, - run_commands: List[str] = None, - run_env_variables: List['EnvVarPrototype'] = None, - run_service_account: str = None, - run_volume_mounts: List['VolumeMountPrototype'] = None, - scale_concurrency: int = None, - scale_concurrency_target: int = None, - scale_cpu_limit: str = None, - scale_ephemeral_storage_limit: str = None, - scale_initial_instances: int = None, - scale_max_instances: int = None, - scale_memory_limit: str = None, - scale_min_instances: int = None, - scale_request_timeout: int = None, + key: Optional[str] = None, + name: Optional[str] = None, + prefix: Optional[str] = None, + reference: Optional[str] = None, + type: Optional[str] = None, + value: Optional[str] = None, ) -> None: """ - Initialize a AppPatch object. + Initialize a EnvVarPrototype object. - :param int image_port: (optional) Optional port the app listens on. While - the app will always be exposed via port `443` for end users, this port is - used to connect to the port that is exposed by the container image. - :param str image_reference: (optional) The name of the image that is used - for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where - `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the - default is `docker.io`. If `TAG` is not specified, the default is `latest`. - If the image reference points to a registry that requires authentication, - make sure to also specify the property `image_secret`. - :param str image_secret: (optional) Optional name of the image registry - access secret. The image registry access secret is used to authenticate - with a private registry when you download the container image. If the image - reference points to a registry that requires authentication, the app will - be created but cannot reach the ready status, until this property is - provided, too. - :param str managed_domain_mappings: (optional) Optional value controlling - which of the system managed domain mappings will be setup for the - application. Valid values are 'local_public', 'local_private' and 'local'. - Visibility can only be 'local_private' if the project supports application - private visibility. - :param List[str] run_arguments: (optional) Optional arguments for the app - that are passed to start the container. If not specified an empty string - array will be applied and the arguments specified by the container image, - will be used to start the container. - :param int run_as_user: (optional) Optional user ID (UID) to run the app - (e.g., `1001`). - :param List[str] run_commands: (optional) Optional commands for the app - that are passed to start the container. If not specified an empty string - array will be applied and the command specified by the container image, - will be used to start the container. - :param List[EnvVarPrototype] run_env_variables: (optional) Optional - references to config maps, secrets or a literal values. - :param str run_service_account: (optional) Optional name of the service - account. For built-in service accounts, you can use the shortened names - `manager` , `none`, `reader`, and `writer`. - :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional - mounts of config maps or a secrets. In case this is provided, existing - `run_volume_mounts` will be overwritten. - :param int scale_concurrency: (optional) Optional maximum number of - requests that can be processed concurrently per instance. - :param int scale_concurrency_target: (optional) Optional threshold of - concurrent requests per instance at which one or more additional instances - are created. Use this value to scale up instances based on concurrent - number of requests. This option defaults to the value of the - `scale_concurrency` option, if not specified. - :param str scale_cpu_limit: (optional) Optional number of CPU set for the - instance of the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :param str scale_ephemeral_storage_limit: (optional) Optional amount of - ephemeral storage to set for the instance of the app. The amount specified - as ephemeral storage, must not exceed the amount of `scale_memory_limit`. - The units for specifying ephemeral storage are Megabyte (M) or Gigabyte - (G), whereas G and M are the shorthand expressions for GB and MB. For more - information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_initial_instances: (optional) Optional initial number of - instances that are created upon app creation or app update. - :param int scale_max_instances: (optional) Optional maximum number of - instances for this app. If you set this value to `0`, this property does - not set a upper scaling limit. However, the app scaling is still limited by - the project quota for instances. See [Limits and quotas for Code - Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). - :param str scale_memory_limit: (optional) Optional amount of memory set for - the instance of the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G - and M are the shorthand expressions for GB and MB. For more information see - [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_min_instances: (optional) Optional minimum number of - instances for this app. If you set this value to `0`, the app will scale - down to zero, if not hit by any request for some time. - :param int scale_request_timeout: (optional) Optional amount of time in - seconds that is allowed for a running app to respond to a request. + :param str key: (optional) The key to reference as environment variable. + :param str name: (optional) The name of the environment variable. + :param str prefix: (optional) A prefix that can be added to all keys of a + full secret or config map reference. + :param str reference: (optional) The name of the secret or config map. + :param str type: (optional) Specify the type of the environment variable. + :param str value: (optional) The literal value of the environment variable. """ - self.image_port = image_port - self.image_reference = image_reference - self.image_secret = image_secret - self.managed_domain_mappings = managed_domain_mappings - self.run_arguments = run_arguments - self.run_as_user = run_as_user - self.run_commands = run_commands - self.run_env_variables = run_env_variables - self.run_service_account = run_service_account - self.run_volume_mounts = run_volume_mounts - self.scale_concurrency = scale_concurrency - self.scale_concurrency_target = scale_concurrency_target - self.scale_cpu_limit = scale_cpu_limit - self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit - self.scale_initial_instances = scale_initial_instances - self.scale_max_instances = scale_max_instances - self.scale_memory_limit = scale_memory_limit - self.scale_min_instances = scale_min_instances - self.scale_request_timeout = scale_request_timeout + self.key = key + self.name = name + self.prefix = prefix + self.reference = reference + self.type = type + self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'AppPatch': - """Initialize a AppPatch object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'EnvVarPrototype': + """Initialize a EnvVarPrototype object from a json dictionary.""" args = {} - if 'image_port' in _dict: - args['image_port'] = _dict.get('image_port') - if 'image_reference' in _dict: - args['image_reference'] = _dict.get('image_reference') - if 'image_secret' in _dict: - args['image_secret'] = _dict.get('image_secret') - if 'managed_domain_mappings' in _dict: - args['managed_domain_mappings'] = _dict.get('managed_domain_mappings') - if 'run_arguments' in _dict: - args['run_arguments'] = _dict.get('run_arguments') - if 'run_as_user' in _dict: - args['run_as_user'] = _dict.get('run_as_user') - if 'run_commands' in _dict: - args['run_commands'] = _dict.get('run_commands') - if 'run_env_variables' in _dict: - args['run_env_variables'] = [EnvVarPrototype.from_dict(v) for v in _dict.get('run_env_variables')] - if 'run_service_account' in _dict: - args['run_service_account'] = _dict.get('run_service_account') - if 'run_volume_mounts' in _dict: - args['run_volume_mounts'] = [VolumeMountPrototype.from_dict(v) for v in _dict.get('run_volume_mounts')] - if 'scale_concurrency' in _dict: - args['scale_concurrency'] = _dict.get('scale_concurrency') - if 'scale_concurrency_target' in _dict: - args['scale_concurrency_target'] = _dict.get('scale_concurrency_target') - if 'scale_cpu_limit' in _dict: - args['scale_cpu_limit'] = _dict.get('scale_cpu_limit') - if 'scale_ephemeral_storage_limit' in _dict: - args['scale_ephemeral_storage_limit'] = _dict.get('scale_ephemeral_storage_limit') - if 'scale_initial_instances' in _dict: - args['scale_initial_instances'] = _dict.get('scale_initial_instances') - if 'scale_max_instances' in _dict: - args['scale_max_instances'] = _dict.get('scale_max_instances') - if 'scale_memory_limit' in _dict: - args['scale_memory_limit'] = _dict.get('scale_memory_limit') - if 'scale_min_instances' in _dict: - args['scale_min_instances'] = _dict.get('scale_min_instances') - if 'scale_request_timeout' in _dict: - args['scale_request_timeout'] = _dict.get('scale_request_timeout') + if (key := _dict.get('key')) is not None: + args['key'] = key + if (name := _dict.get('name')) is not None: + args['name'] = name + if (prefix := _dict.get('prefix')) is not None: + args['prefix'] = prefix + if (reference := _dict.get('reference')) is not None: + args['reference'] = reference + if (type := _dict.get('type')) is not None: + args['type'] = type + if (value := _dict.get('value')) is not None: + args['value'] = value return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AppPatch object from a json dictionary.""" + """Initialize a EnvVarPrototype object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'image_port') and self.image_port is not None: - _dict['image_port'] = self.image_port - if hasattr(self, 'image_reference') and self.image_reference is not None: - _dict['image_reference'] = self.image_reference - if hasattr(self, 'image_secret') and self.image_secret is not None: - _dict['image_secret'] = self.image_secret - if hasattr(self, 'managed_domain_mappings') and self.managed_domain_mappings is not None: - _dict['managed_domain_mappings'] = self.managed_domain_mappings - if hasattr(self, 'run_arguments') and self.run_arguments is not None: - _dict['run_arguments'] = self.run_arguments - if hasattr(self, 'run_as_user') and self.run_as_user is not None: - _dict['run_as_user'] = self.run_as_user - if hasattr(self, 'run_commands') and self.run_commands is not None: - _dict['run_commands'] = self.run_commands - if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: - run_env_variables_list = [] - for v in self.run_env_variables: - if isinstance(v, dict): - run_env_variables_list.append(v) - else: - run_env_variables_list.append(v.to_dict()) - _dict['run_env_variables'] = run_env_variables_list - if hasattr(self, 'run_service_account') and self.run_service_account is not None: - _dict['run_service_account'] = self.run_service_account - if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: - run_volume_mounts_list = [] - for v in self.run_volume_mounts: - if isinstance(v, dict): - run_volume_mounts_list.append(v) - else: - run_volume_mounts_list.append(v.to_dict()) - _dict['run_volume_mounts'] = run_volume_mounts_list - if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: - _dict['scale_concurrency'] = self.scale_concurrency - if hasattr(self, 'scale_concurrency_target') and self.scale_concurrency_target is not None: - _dict['scale_concurrency_target'] = self.scale_concurrency_target - if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: - _dict['scale_cpu_limit'] = self.scale_cpu_limit - if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: - _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit - if hasattr(self, 'scale_initial_instances') and self.scale_initial_instances is not None: - _dict['scale_initial_instances'] = self.scale_initial_instances - if hasattr(self, 'scale_max_instances') and self.scale_max_instances is not None: - _dict['scale_max_instances'] = self.scale_max_instances - if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: - _dict['scale_memory_limit'] = self.scale_memory_limit - if hasattr(self, 'scale_min_instances') and self.scale_min_instances is not None: - _dict['scale_min_instances'] = self.scale_min_instances - if hasattr(self, 'scale_request_timeout') and self.scale_request_timeout is not None: - _dict['scale_request_timeout'] = self.scale_request_timeout + if hasattr(self, 'key') and self.key is not None: + _dict['key'] = self.key + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'prefix') and self.prefix is not None: + _dict['prefix'] = self.prefix + if hasattr(self, 'reference') and self.reference is not None: + _dict['reference'] = self.reference + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value return _dict def _to_dict(self): @@ -3240,378 +8719,324 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AppPatch object.""" + """Return a `str` version of this EnvVarPrototype object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AppPatch') -> bool: + def __eq__(self, other: 'EnvVarPrototype') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AppPatch') -> bool: + def __ne__(self, other: 'EnvVarPrototype') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ManagedDomainMappingsEnum(str, Enum): - """ - Optional value controlling which of the system managed domain mappings will be - setup for the application. Valid values are 'local_public', 'local_private' and - 'local'. Visibility can only be 'local_private' if the project supports - application private visibility. - """ - - LOCAL = 'local' - LOCAL_PRIVATE = 'local_private' - LOCAL_PUBLIC = 'local_public' - - class RunServiceAccountEnum(str, Enum): + class TypeEnum(str, Enum): """ - Optional name of the service account. For built-in service accounts, you can use - the shortened names `manager` , `none`, `reader`, and `writer`. + Specify the type of the environment variable. """ - DEFAULT = 'default' - MANAGER = 'manager' - READER = 'reader' - WRITER = 'writer' - NONE = 'none' + LITERAL = 'literal' + CONFIG_MAP_FULL_REFERENCE = 'config_map_full_reference' + SECRET_FULL_REFERENCE = 'secret_full_reference' + CONFIG_MAP_KEY_REFERENCE = 'config_map_key_reference' + SECRET_KEY_REFERENCE = 'secret_key_reference' -class AppRevision: +class Function: """ - AppRevision is the response model for app revision resources. - - :attr str app_name: (optional) Name of the associated app. - :attr str created_at: (optional) The date when the resource was created. - :attr str href: (optional) When you provision a new revision, a URL is created - identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr int image_port: (optional) Optional port the app listens on. While the app - will always be exposed via port `443` for end users, this port is used to - connect to the port that is exposed by the container image. - :attr str image_reference: The name of the image that is used for this job. The - format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are - optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` - is not specified, the default is `latest`. If the image reference points to a - registry that requires authentication, make sure to also specify the property - `image_secret`. - :attr str image_secret: (optional) Optional name of the image registry access - secret. The image registry access secret is used to authenticate with a private - registry when you download the container image. If the image reference points to - a registry that requires authentication, the app will be created but cannot - reach the ready status, until this property is provided, too. - :attr str name: (optional) The name of the app revison. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the app revision. - :attr List[str] run_arguments: Optional arguments for the app that are passed to - start the container. If not specified an empty string array will be applied and - the arguments specified by the container image, will be used to start the - container. - :attr int run_as_user: (optional) Optional user ID (UID) to run the app (e.g., - `1001`). - :attr List[str] run_commands: Optional commands for the app that are passed to - start the container. If not specified an empty string array will be applied and - the command specified by the container image, will be used to start the - container. - :attr List[EnvVar] run_env_variables: References to config maps, secrets or a - literal values, which are exposed as environment variables in the application. - :attr str run_service_account: (optional) Optional name of the service account. - For built-in service accounts, you can use the shortened names `manager` , - `none`, `reader`, and `writer`. - :attr List[VolumeMount] run_volume_mounts: Mounts of config maps or secrets. - :attr int scale_concurrency: (optional) Optional maximum number of requests that - can be processed concurrently per instance. - :attr int scale_concurrency_target: (optional) Optional threshold of concurrent - requests per instance at which one or more additional instances are created. Use - this value to scale up instances based on concurrent number of requests. This - option defaults to the value of the `scale_concurrency` option, if not - specified. - :attr str scale_cpu_limit: Optional number of CPU set for the instance of the - app. For valid values see [Supported memory and CPU + Function is the response model for function resources. + + :param bool code_binary: Specifies whether the code is binary or not. Defaults + to false when `code_reference` is set to a data URL. When `code_reference` is + set to a code bundle URL, this field is always true. + :param str code_main: (optional) Specifies the name of the function that should + be invoked. + :param str code_reference: Specifies either a reference to a code bundle or the + source code itself. To specify the source code, use the data URL scheme and + include the source code as base64 encoded. The data URL scheme is defined in + [RFC 2397](https://tools.ietf.org/html/rfc2397). + :param str code_secret: (optional) The name of the secret that is used to access + the specified `code_reference`. The secret is used to authenticate with a + non-public endpoint that is specified as`code_reference`. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine and + are exposed as environment variables in the function. + :param str created_at: (optional) The timestamp when the resource was created. + :param str endpoint: (optional) URL to invoke the function. + :param str endpoint_internal: (optional) URL to function that is only visible + within the project. + :param str entity_tag: The version of the function instance, which is used to + achieve optimistic locking. + :param str href: (optional) When you provision a new function, a relative URL + path is created identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str managed_domain_mappings: Optional value controlling which of the + system managed domain mappings will be setup for the function. Valid values are + 'local_public', 'local_private' and 'local'. Visibility can only be + 'local_private' if the project supports function private visibility. + :param str name: The name of the function. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the function. + :param List[EnvVar] run_env_variables: References to config maps, secrets or + literal values, which are defined by the function owner and are exposed as + environment variables in the function. + :param str runtime: The managed runtime used to execute the injected code. + :param int scale_concurrency: Number of parallel requests handled by a single + instance, supported only by Node.js, default is `1`. + :param str scale_cpu_limit: Optional amount of CPU set for the instance of the + function. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :attr str scale_ephemeral_storage_limit: Optional amount of ephemeral storage to - set for the instance of the app. The amount specified as ephemeral storage, must - not exceed the amount of `scale_memory_limit`. The units for specifying - ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the - shorthand expressions for GB and MB. For more information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_initial_instances: (optional) Optional initial number of - instances that are created upon app creation or app update. - :attr int scale_max_instances: Optional maximum number of instances for this - app. If you set this value to `0`, this property does not set a upper scaling - limit. However, the app scaling is still limited by the project quota for - instances. See [Limits and quotas for Code - Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). - :attr str scale_memory_limit: Optional amount of memory set for the instance of - the app. For valid values see [Supported memory and CPU + :param int scale_down_delay: Optional amount of time in seconds that delays the + scale down behavior for a function. + :param int scale_max_execution_time: Timeout in secs after which the function is + terminated. + :param str scale_memory_limit: Optional amount of memory set for the instance of + the function. For valid values see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and M are the shorthand expressions for GB and MB. For more information see [Units of measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_min_instances: Optional minimum number of instances for this - app. If you set this value to `0`, the app will scale down to zero, if not hit - by any request for some time. - :attr int scale_request_timeout: Optional amount of time in seconds that is - allowed for a running app to respond to a request. - :attr str status: (optional) The current status of the app revision. - :attr AppRevisionStatus status_details: (optional) The detailed status of the - application revision. + :param str status: (optional) The current status of the function. + :param FunctionStatus status_details: The detailed status of the function. """ def __init__( self, - image_reference: str, - run_arguments: List[str], - run_commands: List[str], + code_binary: bool, + code_reference: str, + entity_tag: str, + managed_domain_mappings: str, + name: str, run_env_variables: List['EnvVar'], - run_volume_mounts: List['VolumeMount'], + runtime: str, + scale_concurrency: int, scale_cpu_limit: str, - scale_ephemeral_storage_limit: str, - scale_max_instances: int, + scale_down_delay: int, + scale_max_execution_time: int, scale_memory_limit: str, - scale_min_instances: int, - scale_request_timeout: int, + status_details: 'FunctionStatus', *, - app_name: str = None, - created_at: str = None, - href: str = None, - id: str = None, - image_port: int = None, - image_secret: str = None, - name: str = None, - project_id: str = None, - resource_type: str = None, - run_as_user: int = None, - run_service_account: str = None, - scale_concurrency: int = None, - scale_concurrency_target: int = None, - scale_initial_instances: int = None, - status: str = None, - status_details: 'AppRevisionStatus' = None, + code_main: Optional[str] = None, + code_secret: Optional[str] = None, + computed_env_variables: Optional[List['EnvVar']] = None, + created_at: Optional[str] = None, + endpoint: Optional[str] = None, + endpoint_internal: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + status: Optional[str] = None, ) -> None: """ - Initialize a AppRevision object. - - :param str image_reference: The name of the image that is used for this - job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and - `TAG` are optional. If `REGISTRY` is not specified, the default is - `docker.io`. If `TAG` is not specified, the default is `latest`. If the - image reference points to a registry that requires authentication, make - sure to also specify the property `image_secret`. - :param List[str] run_arguments: Optional arguments for the app that are - passed to start the container. If not specified an empty string array will - be applied and the arguments specified by the container image, will be used - to start the container. - :param List[str] run_commands: Optional commands for the app that are - passed to start the container. If not specified an empty string array will - be applied and the command specified by the container image, will be used - to start the container. + Initialize a Function object. + + :param bool code_binary: Specifies whether the code is binary or not. + Defaults to false when `code_reference` is set to a data URL. When + `code_reference` is set to a code bundle URL, this field is always true. + :param str code_reference: Specifies either a reference to a code bundle or + the source code itself. To specify the source code, use the data URL scheme + and include the source code as base64 encoded. The data URL scheme is + defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). + :param str entity_tag: The version of the function instance, which is used + to achieve optimistic locking. + :param str managed_domain_mappings: Optional value controlling which of the + system managed domain mappings will be setup for the function. Valid values + are 'local_public', 'local_private' and 'local'. Visibility can only be + 'local_private' if the project supports function private visibility. + :param str name: The name of the function. :param List[EnvVar] run_env_variables: References to config maps, secrets - or a literal values, which are exposed as environment variables in the - application. - :param List[VolumeMount] run_volume_mounts: Mounts of config maps or - secrets. - :param str scale_cpu_limit: Optional number of CPU set for the instance of - the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :param str scale_ephemeral_storage_limit: Optional amount of ephemeral - storage to set for the instance of the app. The amount specified as - ephemeral storage, must not exceed the amount of `scale_memory_limit`. The - units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), - whereas G and M are the shorthand expressions for GB and MB. For more - information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_max_instances: Optional maximum number of instances for - this app. If you set this value to `0`, this property does not set a upper - scaling limit. However, the app scaling is still limited by the project - quota for instances. See [Limits and quotas for Code - Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits). - :param str scale_memory_limit: Optional amount of memory set for the - instance of the app. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G - and M are the shorthand expressions for GB and MB. For more information see - [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_min_instances: Optional minimum number of instances for - this app. If you set this value to `0`, the app will scale down to zero, if - not hit by any request for some time. - :param int scale_request_timeout: Optional amount of time in seconds that - is allowed for a running app to respond to a request. - :param str app_name: (optional) Name of the associated app. - :param int image_port: (optional) Optional port the app listens on. While - the app will always be exposed via port `443` for end users, this port is - used to connect to the port that is exposed by the container image. - :param str image_secret: (optional) Optional name of the image registry - access secret. The image registry access secret is used to authenticate - with a private registry when you download the container image. If the image - reference points to a registry that requires authentication, the app will - be created but cannot reach the ready status, until this property is - provided, too. - :param int run_as_user: (optional) Optional user ID (UID) to run the app - (e.g., `1001`). - :param str run_service_account: (optional) Optional name of the service - account. For built-in service accounts, you can use the shortened names - `manager` , `none`, `reader`, and `writer`. - :param int scale_concurrency: (optional) Optional maximum number of - requests that can be processed concurrently per instance. - :param int scale_concurrency_target: (optional) Optional threshold of - concurrent requests per instance at which one or more additional instances - are created. Use this value to scale up instances based on concurrent - number of requests. This option defaults to the value of the - `scale_concurrency` option, if not specified. - :param int scale_initial_instances: (optional) Optional initial number of - instances that are created upon app creation or app update. - :param AppRevisionStatus status_details: (optional) The detailed status of - the application revision. - """ - self.app_name = app_name + or literal values, which are defined by the function owner and are exposed + as environment variables in the function. + :param str runtime: The managed runtime used to execute the injected code. + :param int scale_concurrency: Number of parallel requests handled by a + single instance, supported only by Node.js, default is `1`. + :param str scale_cpu_limit: Optional amount of CPU set for the instance of + the function. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: Optional amount of time in seconds that delays + the scale down behavior for a function. + :param int scale_max_execution_time: Timeout in secs after which the + function is terminated. + :param str scale_memory_limit: Optional amount of memory set for the + instance of the function. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param FunctionStatus status_details: The detailed status of the function. + :param str code_main: (optional) Specifies the name of the function that + should be invoked. + :param str code_secret: (optional) The name of the secret that is used to + access the specified `code_reference`. The secret is used to authenticate + with a non-public endpoint that is specified as`code_reference`. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine + and are exposed as environment variables in the function. + """ + self.code_binary = code_binary + self.code_main = code_main + self.code_reference = code_reference + self.code_secret = code_secret + self.computed_env_variables = computed_env_variables self.created_at = created_at + self.endpoint = endpoint + self.endpoint_internal = endpoint_internal + self.entity_tag = entity_tag self.href = href self.id = id - self.image_port = image_port - self.image_reference = image_reference - self.image_secret = image_secret + self.managed_domain_mappings = managed_domain_mappings self.name = name self.project_id = project_id + self.region = region self.resource_type = resource_type - self.run_arguments = run_arguments - self.run_as_user = run_as_user - self.run_commands = run_commands self.run_env_variables = run_env_variables - self.run_service_account = run_service_account - self.run_volume_mounts = run_volume_mounts + self.runtime = runtime self.scale_concurrency = scale_concurrency - self.scale_concurrency_target = scale_concurrency_target self.scale_cpu_limit = scale_cpu_limit - self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit - self.scale_initial_instances = scale_initial_instances - self.scale_max_instances = scale_max_instances + self.scale_down_delay = scale_down_delay + self.scale_max_execution_time = scale_max_execution_time self.scale_memory_limit = scale_memory_limit - self.scale_min_instances = scale_min_instances - self.scale_request_timeout = scale_request_timeout self.status = status self.status_details = status_details @classmethod - def from_dict(cls, _dict: Dict) -> 'AppRevision': - """Initialize a AppRevision object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Function': + """Initialize a Function object from a json dictionary.""" args = {} - if 'app_name' in _dict: - args['app_name'] = _dict.get('app_name') - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'image_port' in _dict: - args['image_port'] = _dict.get('image_port') - if 'image_reference' in _dict: - args['image_reference'] = _dict.get('image_reference') + if (code_binary := _dict.get('code_binary')) is not None: + args['code_binary'] = code_binary else: - raise ValueError('Required property \'image_reference\' not present in AppRevision JSON') - if 'image_secret' in _dict: - args['image_secret'] = _dict.get('image_secret') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'run_arguments' in _dict: - args['run_arguments'] = _dict.get('run_arguments') + raise ValueError('Required property \'code_binary\' not present in Function JSON') + if (code_main := _dict.get('code_main')) is not None: + args['code_main'] = code_main + if (code_reference := _dict.get('code_reference')) is not None: + args['code_reference'] = code_reference else: - raise ValueError('Required property \'run_arguments\' not present in AppRevision JSON') - if 'run_as_user' in _dict: - args['run_as_user'] = _dict.get('run_as_user') - if 'run_commands' in _dict: - args['run_commands'] = _dict.get('run_commands') + raise ValueError('Required property \'code_reference\' not present in Function JSON') + if (code_secret := _dict.get('code_secret')) is not None: + args['code_secret'] = code_secret + if (computed_env_variables := _dict.get('computed_env_variables')) is not None: + args['computed_env_variables'] = [EnvVar.from_dict(v) for v in computed_env_variables] + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (endpoint := _dict.get('endpoint')) is not None: + args['endpoint'] = endpoint + if (endpoint_internal := _dict.get('endpoint_internal')) is not None: + args['endpoint_internal'] = endpoint_internal + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag else: - raise ValueError('Required property \'run_commands\' not present in AppRevision JSON') - if 'run_env_variables' in _dict: - args['run_env_variables'] = [EnvVar.from_dict(v) for v in _dict.get('run_env_variables')] + raise ValueError('Required property \'entity_tag\' not present in Function JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (managed_domain_mappings := _dict.get('managed_domain_mappings')) is not None: + args['managed_domain_mappings'] = managed_domain_mappings else: - raise ValueError('Required property \'run_env_variables\' not present in AppRevision JSON') - if 'run_service_account' in _dict: - args['run_service_account'] = _dict.get('run_service_account') - if 'run_volume_mounts' in _dict: - args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in _dict.get('run_volume_mounts')] + raise ValueError('Required property \'managed_domain_mappings\' not present in Function JSON') + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'run_volume_mounts\' not present in AppRevision JSON') - if 'scale_concurrency' in _dict: - args['scale_concurrency'] = _dict.get('scale_concurrency') - if 'scale_concurrency_target' in _dict: - args['scale_concurrency_target'] = _dict.get('scale_concurrency_target') - if 'scale_cpu_limit' in _dict: - args['scale_cpu_limit'] = _dict.get('scale_cpu_limit') + raise ValueError('Required property \'name\' not present in Function JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVar.from_dict(v) for v in run_env_variables] else: - raise ValueError('Required property \'scale_cpu_limit\' not present in AppRevision JSON') - if 'scale_ephemeral_storage_limit' in _dict: - args['scale_ephemeral_storage_limit'] = _dict.get('scale_ephemeral_storage_limit') + raise ValueError('Required property \'run_env_variables\' not present in Function JSON') + if (runtime := _dict.get('runtime')) is not None: + args['runtime'] = runtime else: - raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in AppRevision JSON') - if 'scale_initial_instances' in _dict: - args['scale_initial_instances'] = _dict.get('scale_initial_instances') - if 'scale_max_instances' in _dict: - args['scale_max_instances'] = _dict.get('scale_max_instances') + raise ValueError('Required property \'runtime\' not present in Function JSON') + if (scale_concurrency := _dict.get('scale_concurrency')) is not None: + args['scale_concurrency'] = scale_concurrency else: - raise ValueError('Required property \'scale_max_instances\' not present in AppRevision JSON') - if 'scale_memory_limit' in _dict: - args['scale_memory_limit'] = _dict.get('scale_memory_limit') + raise ValueError('Required property \'scale_concurrency\' not present in Function JSON') + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit else: - raise ValueError('Required property \'scale_memory_limit\' not present in AppRevision JSON') - if 'scale_min_instances' in _dict: - args['scale_min_instances'] = _dict.get('scale_min_instances') + raise ValueError('Required property \'scale_cpu_limit\' not present in Function JSON') + if (scale_down_delay := _dict.get('scale_down_delay')) is not None: + args['scale_down_delay'] = scale_down_delay else: - raise ValueError('Required property \'scale_min_instances\' not present in AppRevision JSON') - if 'scale_request_timeout' in _dict: - args['scale_request_timeout'] = _dict.get('scale_request_timeout') + raise ValueError('Required property \'scale_down_delay\' not present in Function JSON') + if (scale_max_execution_time := _dict.get('scale_max_execution_time')) is not None: + args['scale_max_execution_time'] = scale_max_execution_time else: - raise ValueError('Required property \'scale_request_timeout\' not present in AppRevision JSON') - if 'status' in _dict: - args['status'] = _dict.get('status') - if 'status_details' in _dict: - args['status_details'] = AppRevisionStatus.from_dict(_dict.get('status_details')) + raise ValueError('Required property \'scale_max_execution_time\' not present in Function JSON') + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + else: + raise ValueError('Required property \'scale_memory_limit\' not present in Function JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = FunctionStatus.from_dict(status_details) + else: + raise ValueError('Required property \'status_details\' not present in Function JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AppRevision object from a json dictionary.""" + """Initialize a Function object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'app_name') and self.app_name is not None: - _dict['app_name'] = self.app_name + if hasattr(self, 'code_binary') and self.code_binary is not None: + _dict['code_binary'] = self.code_binary + if hasattr(self, 'code_main') and self.code_main is not None: + _dict['code_main'] = self.code_main + if hasattr(self, 'code_reference') and self.code_reference is not None: + _dict['code_reference'] = self.code_reference + if hasattr(self, 'code_secret') and self.code_secret is not None: + _dict['code_secret'] = self.code_secret + if hasattr(self, 'computed_env_variables') and self.computed_env_variables is not None: + computed_env_variables_list = [] + for v in self.computed_env_variables: + if isinstance(v, dict): + computed_env_variables_list.append(v) + else: + computed_env_variables_list.append(v.to_dict()) + _dict['computed_env_variables'] = computed_env_variables_list if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'endpoint') and getattr(self, 'endpoint') is not None: + _dict['endpoint'] = getattr(self, 'endpoint') + if hasattr(self, 'endpoint_internal') and getattr(self, 'endpoint_internal') is not None: + _dict['endpoint_internal'] = getattr(self, 'endpoint_internal') + if hasattr(self, 'entity_tag') and self.entity_tag is not None: + _dict['entity_tag'] = self.entity_tag if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'image_port') and self.image_port is not None: - _dict['image_port'] = self.image_port - if hasattr(self, 'image_reference') and self.image_reference is not None: - _dict['image_reference'] = self.image_reference - if hasattr(self, 'image_secret') and self.image_secret is not None: - _dict['image_secret'] = self.image_secret - if hasattr(self, 'name') and getattr(self, 'name') is not None: - _dict['name'] = getattr(self, 'name') + if hasattr(self, 'managed_domain_mappings') and self.managed_domain_mappings is not None: + _dict['managed_domain_mappings'] = self.managed_domain_mappings + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'run_arguments') and self.run_arguments is not None: - _dict['run_arguments'] = self.run_arguments - if hasattr(self, 'run_as_user') and self.run_as_user is not None: - _dict['run_as_user'] = self.run_as_user - if hasattr(self, 'run_commands') and self.run_commands is not None: - _dict['run_commands'] = self.run_commands if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: run_env_variables_list = [] for v in self.run_env_variables: @@ -3620,34 +9045,18 @@ def to_dict(self) -> Dict: else: run_env_variables_list.append(v.to_dict()) _dict['run_env_variables'] = run_env_variables_list - if hasattr(self, 'run_service_account') and self.run_service_account is not None: - _dict['run_service_account'] = self.run_service_account - if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: - run_volume_mounts_list = [] - for v in self.run_volume_mounts: - if isinstance(v, dict): - run_volume_mounts_list.append(v) - else: - run_volume_mounts_list.append(v.to_dict()) - _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'runtime') and self.runtime is not None: + _dict['runtime'] = self.runtime if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: _dict['scale_concurrency'] = self.scale_concurrency - if hasattr(self, 'scale_concurrency_target') and self.scale_concurrency_target is not None: - _dict['scale_concurrency_target'] = self.scale_concurrency_target if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: _dict['scale_cpu_limit'] = self.scale_cpu_limit - if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: - _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit - if hasattr(self, 'scale_initial_instances') and self.scale_initial_instances is not None: - _dict['scale_initial_instances'] = self.scale_initial_instances - if hasattr(self, 'scale_max_instances') and self.scale_max_instances is not None: - _dict['scale_max_instances'] = self.scale_max_instances + if hasattr(self, 'scale_down_delay') and self.scale_down_delay is not None: + _dict['scale_down_delay'] = self.scale_down_delay + if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: + _dict['scale_max_execution_time'] = self.scale_max_execution_time if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: _dict['scale_memory_limit'] = self.scale_memory_limit - if hasattr(self, 'scale_min_instances') and self.scale_min_instances is not None: - _dict['scale_min_instances'] = self.scale_min_instances - if hasattr(self, 'scale_request_timeout') and self.scale_request_timeout is not None: - _dict['scale_request_timeout'] = self.scale_request_timeout if hasattr(self, 'status') and getattr(self, 'status') is not None: _dict['status'] = getattr(self, 'status') if hasattr(self, 'status_details') and self.status_details is not None: @@ -3662,105 +9071,105 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AppRevision object.""" + """Return a `str` version of this Function object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AppRevision') -> bool: + def __eq__(self, other: 'Function') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AppRevision') -> bool: + def __ne__(self, other: 'Function') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ResourceTypeEnum(str, Enum): + class ManagedDomainMappingsEnum(str, Enum): """ - The type of the app revision. + Optional value controlling which of the system managed domain mappings will be + setup for the function. Valid values are 'local_public', 'local_private' and + 'local'. Visibility can only be 'local_private' if the project supports function + private visibility. """ - APP_REVISION_V2 = 'app_revision_v2' + LOCAL = 'local' + LOCAL_PRIVATE = 'local_private' + LOCAL_PUBLIC = 'local_public' - class RunServiceAccountEnum(str, Enum): + class ResourceTypeEnum(str, Enum): """ - Optional name of the service account. For built-in service accounts, you can use - the shortened names `manager` , `none`, `reader`, and `writer`. + The type of the function. """ - DEFAULT = 'default' - MANAGER = 'manager' - READER = 'reader' - WRITER = 'writer' - NONE = 'none' + FUNCTION_V2 = 'function_v2' class StatusEnum(str, Enum): """ - The current status of the app revision. + The current status of the function. """ + OFFLINE = 'offline' + DEPLOYING = 'deploying' READY = 'ready' - LOADING = 'loading' - WARNING = 'warning' FAILED = 'failed' -class AppRevisionList: +class FunctionList: """ - Contains a list of app revisions and pagination information. + Contains a list of functions and pagination information. - :attr ListFirstMetadata first: (optional) Describes properties needed to + :param ListFirstMetadata first: (optional) Describes properties needed to retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve + :param List[Function] functions: List of all functions. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve the next page of a result list. - :attr List[AppRevision] revisions: List of all app revisions. """ def __init__( self, + functions: List['Function'], limit: int, - revisions: List['AppRevision'], *, - first: 'ListFirstMetadata' = None, - next: 'ListNextMetadata' = None, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, ) -> None: """ - Initialize a AppRevisionList object. + Initialize a FunctionList object. + :param List[Function] functions: List of all functions. :param int limit: Maximum number of resources per page. - :param List[AppRevision] revisions: List of all app revisions. :param ListFirstMetadata first: (optional) Describes properties needed to retrieve the first page of a result list. :param ListNextMetadata next: (optional) Describes properties needed to retrieve the next page of a result list. """ self.first = first + self.functions = functions self.limit = limit self.next = next - self.revisions = revisions @classmethod - def from_dict(cls, _dict: Dict) -> 'AppRevisionList': - """Initialize a AppRevisionList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'FunctionList': + """Initialize a FunctionList object from a json dictionary.""" args = {} - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (functions := _dict.get('functions')) is not None: + args['functions'] = [Function.from_dict(v) for v in functions] else: - raise ValueError('Required property \'limit\' not present in AppRevisionList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) - if 'revisions' in _dict: - args['revisions'] = [AppRevision.from_dict(v) for v in _dict.get('revisions')] + raise ValueError('Required property \'functions\' not present in FunctionList JSON') + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit else: - raise ValueError('Required property \'revisions\' not present in AppRevisionList JSON') + raise ValueError('Required property \'limit\' not present in FunctionList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AppRevisionList object from a json dictionary.""" + """Initialize a FunctionList object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -3771,6 +9180,14 @@ def to_dict(self) -> Dict: _dict['first'] = self.first else: _dict['first'] = self.first.to_dict() + if hasattr(self, 'functions') and self.functions is not None: + functions_list = [] + for v in self.functions: + if isinstance(v, dict): + functions_list.append(v) + else: + functions_list.append(v.to_dict()) + _dict['functions'] = functions_list if hasattr(self, 'limit') and self.limit is not None: _dict['limit'] = self.limit if hasattr(self, 'next') and self.next is not None: @@ -3778,14 +9195,313 @@ def to_dict(self) -> Dict: _dict['next'] = self.next else: _dict['next'] = self.next.to_dict() - if hasattr(self, 'revisions') and self.revisions is not None: - revisions_list = [] - for v in self.revisions: + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this FunctionList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FunctionList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'FunctionList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class FunctionPatch: + """ + Request model for function update operations. + + :param bool code_binary: (optional) Specifies whether the code is binary or not. + Defaults to false when `code_reference` is set to a data URL. When + `code_reference` is set to a code bundle URL, this field is always true. + :param str code_main: (optional) Specifies the name of the function that should + be invoked. + :param str code_reference: (optional) Specifies either a reference to a code + bundle or the source code itself. To specify the source code, use the data URL + scheme and include the source code as base64 encoded. The data URL scheme is + defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). + :param str code_secret: (optional) The name of the secret that is used to access + the specified `code_reference`. The secret is used to authenticate with a + non-public endpoint that is specified as`code_reference`. + :param str managed_domain_mappings: (optional) Optional value controlling which + of the system managed domain mappings will be setup for the function. Valid + values are 'local_public', 'local_private' and 'local'. Visibility can only be + 'local_private' if the project supports function private visibility. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional references + to config maps, secrets or literal values. + :param str runtime: (optional) The managed runtime used to execute the injected + code. + :param int scale_concurrency: (optional) Number of parallel requests handled by + a single instance, supported only by Node.js, default is `1`. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the function. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds that + delays the scale down behavior for a function. + :param int scale_max_execution_time: (optional) Timeout in secs after which the + function is terminated. + :param str scale_memory_limit: (optional) Optional amount of memory set for the + instance of the function. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + """ + + def __init__( + self, + *, + code_binary: Optional[bool] = None, + code_main: Optional[str] = None, + code_reference: Optional[str] = None, + code_secret: Optional[str] = None, + managed_domain_mappings: Optional[str] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + runtime: Optional[str] = None, + scale_concurrency: Optional[int] = None, + scale_cpu_limit: Optional[str] = None, + scale_down_delay: Optional[int] = None, + scale_max_execution_time: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + ) -> None: + """ + Initialize a FunctionPatch object. + + :param bool code_binary: (optional) Specifies whether the code is binary or + not. Defaults to false when `code_reference` is set to a data URL. When + `code_reference` is set to a code bundle URL, this field is always true. + :param str code_main: (optional) Specifies the name of the function that + should be invoked. + :param str code_reference: (optional) Specifies either a reference to a + code bundle or the source code itself. To specify the source code, use the + data URL scheme and include the source code as base64 encoded. The data URL + scheme is defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). + :param str code_secret: (optional) The name of the secret that is used to + access the specified `code_reference`. The secret is used to authenticate + with a non-public endpoint that is specified as`code_reference`. + :param str managed_domain_mappings: (optional) Optional value controlling + which of the system managed domain mappings will be setup for the function. + Valid values are 'local_public', 'local_private' and 'local'. Visibility + can only be 'local_private' if the project supports function private + visibility. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional + references to config maps, secrets or literal values. + :param str runtime: (optional) The managed runtime used to execute the + injected code. + :param int scale_concurrency: (optional) Number of parallel requests + handled by a single instance, supported only by Node.js, default is `1`. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the function. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param int scale_down_delay: (optional) Optional amount of time in seconds + that delays the scale down behavior for a function. + :param int scale_max_execution_time: (optional) Timeout in secs after which + the function is terminated. + :param str scale_memory_limit: (optional) Optional amount of memory set for + the instance of the function. For valid values see [Supported memory and + CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + """ + self.code_binary = code_binary + self.code_main = code_main + self.code_reference = code_reference + self.code_secret = code_secret + self.managed_domain_mappings = managed_domain_mappings + self.run_env_variables = run_env_variables + self.runtime = runtime + self.scale_concurrency = scale_concurrency + self.scale_cpu_limit = scale_cpu_limit + self.scale_down_delay = scale_down_delay + self.scale_max_execution_time = scale_max_execution_time + self.scale_memory_limit = scale_memory_limit + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FunctionPatch': + """Initialize a FunctionPatch object from a json dictionary.""" + args = {} + if (code_binary := _dict.get('code_binary')) is not None: + args['code_binary'] = code_binary + if (code_main := _dict.get('code_main')) is not None: + args['code_main'] = code_main + if (code_reference := _dict.get('code_reference')) is not None: + args['code_reference'] = code_reference + if (code_secret := _dict.get('code_secret')) is not None: + args['code_secret'] = code_secret + if (managed_domain_mappings := _dict.get('managed_domain_mappings')) is not None: + args['managed_domain_mappings'] = managed_domain_mappings + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVarPrototype.from_dict(v) for v in run_env_variables] + if (runtime := _dict.get('runtime')) is not None: + args['runtime'] = runtime + if (scale_concurrency := _dict.get('scale_concurrency')) is not None: + args['scale_concurrency'] = scale_concurrency + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + if (scale_down_delay := _dict.get('scale_down_delay')) is not None: + args['scale_down_delay'] = scale_down_delay + if (scale_max_execution_time := _dict.get('scale_max_execution_time')) is not None: + args['scale_max_execution_time'] = scale_max_execution_time + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FunctionPatch object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'code_binary') and self.code_binary is not None: + _dict['code_binary'] = self.code_binary + if hasattr(self, 'code_main') and self.code_main is not None: + _dict['code_main'] = self.code_main + if hasattr(self, 'code_reference') and self.code_reference is not None: + _dict['code_reference'] = self.code_reference + if hasattr(self, 'code_secret') and self.code_secret is not None: + _dict['code_secret'] = self.code_secret + if hasattr(self, 'managed_domain_mappings') and self.managed_domain_mappings is not None: + _dict['managed_domain_mappings'] = self.managed_domain_mappings + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: if isinstance(v, dict): - revisions_list.append(v) + run_env_variables_list.append(v) else: - revisions_list.append(v.to_dict()) - _dict['revisions'] = revisions_list + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'runtime') and self.runtime is not None: + _dict['runtime'] = self.runtime + if hasattr(self, 'scale_concurrency') and self.scale_concurrency is not None: + _dict['scale_concurrency'] = self.scale_concurrency + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_down_delay') and self.scale_down_delay is not None: + _dict['scale_down_delay'] = self.scale_down_delay + if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: + _dict['scale_max_execution_time'] = self.scale_max_execution_time + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this FunctionPatch object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'FunctionPatch') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'FunctionPatch') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class ManagedDomainMappingsEnum(str, Enum): + """ + Optional value controlling which of the system managed domain mappings will be + setup for the function. Valid values are 'local_public', 'local_private' and + 'local'. Visibility can only be 'local_private' if the project supports function + private visibility. + """ + + LOCAL = 'local' + LOCAL_PRIVATE = 'local_private' + LOCAL_PUBLIC = 'local_public' + + +class FunctionRuntime: + """ + Response model for Function runtime objects. + + :param bool default: (optional) Whether the function runtime is the default for + the code bundle family. + :param bool deprecated: (optional) Whether the function runtime is deprecated. + :param str family: (optional) The code bundle family of the function runtime. + :param str id: (optional) The ID of the function runtime. + :param str name: (optional) The name of the function runtime. + :param bool optimized: (optional) Whether the function runtime is optimized. + """ + + def __init__( + self, + *, + default: Optional[bool] = None, + deprecated: Optional[bool] = None, + family: Optional[str] = None, + id: Optional[str] = None, + name: Optional[str] = None, + optimized: Optional[bool] = None, + ) -> None: + """ + Initialize a FunctionRuntime object. + + """ + self.default = default + self.deprecated = deprecated + self.family = family + self.id = id + self.name = name + self.optimized = optimized + + @classmethod + def from_dict(cls, _dict: Dict) -> 'FunctionRuntime': + """Initialize a FunctionRuntime object from a json dictionary.""" + args = {} + if (default := _dict.get('default')) is not None: + args['default'] = default + if (deprecated := _dict.get('deprecated')) is not None: + args['deprecated'] = deprecated + if (family := _dict.get('family')) is not None: + args['family'] = family + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (optimized := _dict.get('optimized')) is not None: + args['optimized'] = optimized + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a FunctionRuntime object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'default') and getattr(self, 'default') is not None: + _dict['default'] = getattr(self, 'default') + if hasattr(self, 'deprecated') and getattr(self, 'deprecated') is not None: + _dict['deprecated'] = getattr(self, 'deprecated') + if hasattr(self, 'family') and getattr(self, 'family') is not None: + _dict['family'] = getattr(self, 'family') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'name') and getattr(self, 'name') is not None: + _dict['name'] = getattr(self, 'name') + if hasattr(self, 'optimized') and getattr(self, 'optimized') is not None: + _dict['optimized'] = getattr(self, 'optimized') return _dict def _to_dict(self): @@ -3793,60 +9509,65 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AppRevisionList object.""" + """Return a `str` version of this FunctionRuntime object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AppRevisionList') -> bool: + def __eq__(self, other: 'FunctionRuntime') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AppRevisionList') -> bool: + def __ne__(self, other: 'FunctionRuntime') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AppRevisionStatus: +class FunctionRuntimeList: """ - The detailed status of the application revision. + Contains a list of Function runtimes. - :attr int actual_instances: (optional) The number of running instances of the - revision. - :attr str reason: (optional) Optional information to provide more context in - case of a 'failed' or 'warning' status. + :param List[FunctionRuntime] function_runtimes: (optional) List of all Function + runtimes. """ - def __init__(self, *, actual_instances: int = None, reason: str = None) -> None: + def __init__( + self, + *, + function_runtimes: Optional[List['FunctionRuntime']] = None, + ) -> None: """ - Initialize a AppRevisionStatus object. + Initialize a FunctionRuntimeList object. + :param List[FunctionRuntime] function_runtimes: (optional) List of all + Function runtimes. """ - self.actual_instances = actual_instances - self.reason = reason + self.function_runtimes = function_runtimes @classmethod - def from_dict(cls, _dict: Dict) -> 'AppRevisionStatus': - """Initialize a AppRevisionStatus object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'FunctionRuntimeList': + """Initialize a FunctionRuntimeList object from a json dictionary.""" args = {} - if 'actual_instances' in _dict: - args['actual_instances'] = _dict.get('actual_instances') - if 'reason' in _dict: - args['reason'] = _dict.get('reason') + if (function_runtimes := _dict.get('function_runtimes')) is not None: + args['function_runtimes'] = [FunctionRuntime.from_dict(v) for v in function_runtimes] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AppRevisionStatus object from a json dictionary.""" + """Initialize a FunctionRuntimeList object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'actual_instances') and getattr(self, 'actual_instances') is not None: - _dict['actual_instances'] = getattr(self, 'actual_instances') - if hasattr(self, 'reason') and getattr(self, 'reason') is not None: - _dict['reason'] = getattr(self, 'reason') + if hasattr(self, 'function_runtimes') and self.function_runtimes is not None: + function_runtimes_list = [] + for v in self.function_runtimes: + if isinstance(v, dict): + function_runtimes_list.append(v) + else: + function_runtimes_list.append(v.to_dict()) + _dict['function_runtimes'] = function_runtimes_list return _dict def _to_dict(self): @@ -3854,91 +9575,55 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AppRevisionStatus object.""" + """Return a `str` version of this FunctionRuntimeList object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AppRevisionStatus') -> bool: + def __eq__(self, other: 'FunctionRuntimeList') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AppRevisionStatus') -> bool: + def __ne__(self, other: 'FunctionRuntimeList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ReasonEnum(str, Enum): - """ - Optional information to provide more context in case of a 'failed' or 'warning' - status. - """ - - READY = 'ready' - WAITING = 'waiting' - DEPLOYING = 'deploying' - DEPLOYING_WAITING_FOR_RESOURCES = 'deploying_waiting_for_resources' - INITIAL_SCALE_NEVER_ACHIEVED = 'initial_scale_never_achieved' - FETCH_IMAGE_FAILED_UNKNOWN_MANIFEST = 'fetch_image_failed_unknown_manifest' - FETCH_IMAGE_FAILED_UNKNOWN_REPOSITORY = 'fetch_image_failed_unknown_repository' - FETCH_IMAGE_FAILED_REGISTRY_NOT_FOUND = 'fetch_image_failed_registry_not_found' - FETCH_IMAGE_FAILED_MISSING_PULL_SECRET = 'fetch_image_failed_missing_pull_secret' - FETCH_IMAGE_FAILED_WRONG_PULL_CREDENTIALS = 'fetch_image_failed_wrong_pull_credentials' - FETCH_IMAGE_FAILED_MISSING_PULL_CREDENTIALS = 'fetch_image_failed_missing_pull_credentials' - CONTAINER_FAILED_EXIT_CODE_0 = 'container_failed_exit_code_0' - CONTAINER_FAILED_EXIT_CODE_1 = 'container_failed_exit_code_1' - CONTAINER_FAILED_EXIT_CODE_139 = 'container_failed_exit_code_139' - CONTAINER_FAILED_EXIT_CODE_24 = 'container_failed_exit_code_24' - IMAGE_PULL_BACK_OFF = 'image_pull_back_off' - INVALID_TAR_HEADER_IMAGE_PULL_ERR = 'invalid_tar_header_image_pull_err' - -class AppStatus: +class FunctionStatus: """ - The detailed status of the application. + The detailed status of the function. - :attr str latest_created_revision: (optional) Latest app revision that has been - created. - :attr str latest_ready_revision: (optional) Latest app revision that reached a - ready state. - :attr str reason: (optional) Optional information to provide more context in - case of a 'failed' or 'warning' status. + :param str reason: (optional) Provides additional information about the status + of the function. """ def __init__( - self, *, latest_created_revision: str = None, latest_ready_revision: str = None, reason: str = None + self, + *, + reason: Optional[str] = None, ) -> None: """ - Initialize a AppStatus object. + Initialize a FunctionStatus object. """ - self.latest_created_revision = latest_created_revision - self.latest_ready_revision = latest_ready_revision self.reason = reason @classmethod - def from_dict(cls, _dict: Dict) -> 'AppStatus': - """Initialize a AppStatus object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'FunctionStatus': + """Initialize a FunctionStatus object from a json dictionary.""" args = {} - if 'latest_created_revision' in _dict: - args['latest_created_revision'] = _dict.get('latest_created_revision') - if 'latest_ready_revision' in _dict: - args['latest_ready_revision'] = _dict.get('latest_ready_revision') - if 'reason' in _dict: - args['reason'] = _dict.get('reason') + if (reason := _dict.get('reason')) is not None: + args['reason'] = reason return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AppStatus object from a json dictionary.""" + """Initialize a FunctionStatus object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'latest_created_revision') and getattr(self, 'latest_created_revision') is not None: - _dict['latest_created_revision'] = getattr(self, 'latest_created_revision') - if hasattr(self, 'latest_ready_revision') and getattr(self, 'latest_ready_revision') is not None: - _dict['latest_ready_revision'] = getattr(self, 'latest_ready_revision') if hasattr(self, 'reason') and getattr(self, 'reason') is not None: _dict['reason'] = getattr(self, 'reason') return _dict @@ -3948,242 +9633,355 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AppStatus object.""" + """Return a `str` version of this FunctionStatus object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AppStatus') -> bool: + def __eq__(self, other: 'FunctionStatus') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AppStatus') -> bool: + def __ne__(self, other: 'FunctionStatus') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class ReasonEnum(str, Enum): """ - Optional information to provide more context in case of a 'failed' or 'warning' - status. + Provides additional information about the status of the function. """ - READY = 'ready' + OFFLINE = 'offline' + DEPLOYING_CONFIGURING_ROUTES = 'deploying_configuring_routes' + READY_UPDATE_IN_PROGRESS = 'ready_update_in_progress' DEPLOYING = 'deploying' - WAITING_FOR_RESOURCES = 'waiting_for_resources' - NO_REVISION_READY = 'no_revision_ready' - READY_BUT_LATEST_REVISION_FAILED = 'ready_but_latest_revision_failed' + READY_LAST_UPDATE_FAILED = 'ready_last_update_failed' + READY = 'ready' + UNKNOWN_REASON = 'unknown_reason' + NO_CODE_BUNDLE = 'no_code_bundle' -class Build: +class Job: """ - Response model for build definitions. + Job is the response model for job resources. - :attr str created_at: (optional) The date when the resource was created. - :attr str entity_tag: The version of the build instance, which is used to - achieve optimistic locking. - :attr str href: (optional) When you provision a new build, a URL is created + :param str build: (optional) Reference to a build that is associated with the + job. + :param str build_run: (optional) Reference to a build run that is associated + with the job. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine and + are exposed as environment variables in the job run. + :param str created_at: (optional) The timestamp when the resource was created. + :param str entity_tag: The version of the job instance, which is used to achieve + optimistic locking. + :param str href: (optional) When you provision a new job, a URL is created identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr str name: (optional) The name of the build. - :attr str output_image: The name of the image. - :attr str output_secret: The secret that is required to access the image - registry. Make sure that the secret is granted with push permissions towards the - specified container registry namespace. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the build. - :attr str source_context_dir: (optional) Option directory in the repository that - contains the buildpacks file or the Dockerfile. - :attr str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` and - uses the HEAD of default branch if not specified. If the `source_type` value is - `local`, this field must be omitted. - :attr str source_secret: (optional) Name of the secret that is used access the - repository source. This field is optional if the `source_type` is `git`. - Additionally, if the `source_url` points to a repository that requires - authentication, the build will be created but cannot access any source code, - until this property is provided, too. If the `source_type` value is `local`, - this field must be omitted. - :attr str source_type: Specifies the type of source to determine if your build - source is in a repository or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :attr str source_url: The URL of the code repository. This field is required if - the `source_type` is `git`. If the `source_type` value is `local`, this field - must be omitted. If the repository is publicly available you can provide a - 'https' URL like `https://github.com/IBM/CodeEngine`. If the repository requires - authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to - a secret of format `ssh_auth`. - :attr str status: (optional) The current status of the build. - :attr BuildStatus status_details: (optional) The detailed status of the build. - :attr str strategy_size: Optional size for the build, which determines the - amount of resources used. Build sizes are `small`, `medium`, `large`, `xlarge`. - :attr str strategy_spec_file: (optional) Optional path to the specification file - that is used for build strategies for building an image. - :attr str strategy_type: The strategy to use for building the image. - :attr int timeout: (optional) The maximum amount of time, in seconds, that can - pass before the build must succeed or fail. + :param str id: (optional) The identifier of the resource. + :param str image_reference: The name of the image that is used for this job. The + format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are + optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` + is not specified, the default is `latest`. If the image reference points to a + registry that requires authentication, make sure to also specify the property + `image_secret`. + :param str image_secret: (optional) The name of the image registry access + secret. The image registry access secret is used to authenticate with a private + registry when you download the container image. If the image reference points to + a registry that requires authentication, the job / job runs will be created but + submitted job runs will fail, until this property is provided, too. This + property must not be set on a job run, which references a job template. + :param str name: The name of the job. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the job. + :param List[str] run_arguments: Set arguments for the job that are passed to + start job run containers. If not specified an empty string array will be applied + and the arguments specified by the container image, will be used to start the + container. + :param int run_as_user: (optional) The user ID (UID) to run the job. + :param List[str] run_commands: Set commands for the job that are passed to start + job run containers. If not specified an empty string array will be applied and + the command specified by the container image, will be used to start the + container. + :param List[EnvVar] run_env_variables: References to config maps, secrets or + literal values, which are defined by the function owner and are exposed as + environment variables in the job run. + :param str run_mode: The mode for runs of the job. Valid values are `task` and + `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties + apply. In `daemon` mode, since there is no timeout and failed instances are + restarted indefinitely, the `max_execution_time` and `retry_limit` properties + are not allowed. + :param str run_service_account: (optional) The name of the service account. For + built-in service accounts, you can use the shortened names `manager`, `none`, + `reader`, and `writer`. This property must not be set on a job run, which + references a job template. + :param List[VolumeMount] run_volume_mounts: Optional mounts of config maps or + secrets. + :param str scale_array_spec: Define a custom set of array indices as a + comma-separated list containing single values and hyphen-separated ranges, such + as 5,12-14,23,27. Each instance gets its array index value from the environment + variable JOB_INDEX. The number of unique array indices that you specify with + this parameter determines the number of job instances to run. + :param str scale_cpu_limit: Optional amount of CPU set for the instance of the + job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: Optional amount of ephemeral storage + to set for the instance of the job. The amount specified as ephemeral storage, + must not exceed the amount of `scale_memory_limit`. The units for specifying + ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the + shorthand expressions for GB and MB. For more information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_execution_time: (optional) The maximum execution time in + seconds for runs of the job. This property can only be specified if `run_mode` + is `task`. + :param str scale_memory_limit: Optional amount of memory set for the instance of + the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_retry_limit: (optional) The number of times to rerun an + instance of the job before the job is marked as failed. This property can only + be specified if `run_mode` is `task`. """ def __init__( self, entity_tag: str, - output_image: str, - output_secret: str, - source_type: str, - source_url: str, - strategy_size: str, - strategy_type: str, + image_reference: str, + name: str, + run_arguments: List[str], + run_commands: List[str], + run_env_variables: List['EnvVar'], + run_mode: str, + run_volume_mounts: List['VolumeMount'], + scale_array_spec: str, + scale_cpu_limit: str, + scale_ephemeral_storage_limit: str, + scale_memory_limit: str, *, - created_at: str = None, - href: str = None, - id: str = None, - name: str = None, - project_id: str = None, - resource_type: str = None, - source_context_dir: str = None, - source_revision: str = None, - source_secret: str = None, - status: str = None, - status_details: 'BuildStatus' = None, - strategy_spec_file: str = None, - timeout: int = None, + build: Optional[str] = None, + build_run: Optional[str] = None, + computed_env_variables: Optional[List['EnvVar']] = None, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + image_secret: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + run_as_user: Optional[int] = None, + run_service_account: Optional[str] = None, + scale_max_execution_time: Optional[int] = None, + scale_retry_limit: Optional[int] = None, ) -> None: """ - Initialize a Build object. + Initialize a Job object. - :param str entity_tag: The version of the build instance, which is used to + :param str entity_tag: The version of the job instance, which is used to achieve optimistic locking. - :param str output_image: The name of the image. - :param str output_secret: The secret that is required to access the image - registry. Make sure that the secret is granted with push permissions - towards the specified container registry namespace. - :param str source_type: Specifies the type of source to determine if your - build source is in a repository or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :param str source_url: The URL of the code repository. This field is - required if the `source_type` is `git`. If the `source_type` value is - `local`, this field must be omitted. If the repository is publicly - available you can provide a 'https' URL like - `https://github.com/IBM/CodeEngine`. If the repository requires - authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that - points to a secret of format `ssh_auth`. - :param str strategy_size: Optional size for the build, which determines the - amount of resources used. Build sizes are `small`, `medium`, `large`, - `xlarge`. - :param str strategy_type: The strategy to use for building the image. - :param str name: (optional) The name of the build. - :param str source_context_dir: (optional) Option directory in the - repository that contains the buildpacks file or the Dockerfile. - :param str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` - and uses the HEAD of default branch if not specified. If the `source_type` - value is `local`, this field must be omitted. - :param str source_secret: (optional) Name of the secret that is used access - the repository source. This field is optional if the `source_type` is - `git`. Additionally, if the `source_url` points to a repository that - requires authentication, the build will be created but cannot access any - source code, until this property is provided, too. If the `source_type` - value is `local`, this field must be omitted. - :param BuildStatus status_details: (optional) The detailed status of the - build. - :param str strategy_spec_file: (optional) Optional path to the - specification file that is used for build strategies for building an image. - :param int timeout: (optional) The maximum amount of time, in seconds, that - can pass before the build must succeed or fail. + :param str image_reference: The name of the image that is used for this + job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + `TAG` are optional. If `REGISTRY` is not specified, the default is + `docker.io`. If `TAG` is not specified, the default is `latest`. If the + image reference points to a registry that requires authentication, make + sure to also specify the property `image_secret`. + :param str name: The name of the job. + :param List[str] run_arguments: Set arguments for the job that are passed + to start job run containers. If not specified an empty string array will be + applied and the arguments specified by the container image, will be used to + start the container. + :param List[str] run_commands: Set commands for the job that are passed to + start job run containers. If not specified an empty string array will be + applied and the command specified by the container image, will be used to + start the container. + :param List[EnvVar] run_env_variables: References to config maps, secrets + or literal values, which are defined by the function owner and are exposed + as environment variables in the job run. + :param str run_mode: The mode for runs of the job. Valid values are `task` + and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` + properties apply. In `daemon` mode, since there is no timeout and failed + instances are restarted indefinitely, the `max_execution_time` and + `retry_limit` properties are not allowed. + :param List[VolumeMount] run_volume_mounts: Optional mounts of config maps + or secrets. + :param str scale_array_spec: Define a custom set of array indices as a + comma-separated list containing single values and hyphen-separated ranges, + such as 5,12-14,23,27. Each instance gets its array index value from the + environment variable JOB_INDEX. The number of unique array indices that you + specify with this parameter determines the number of job instances to run. + :param str scale_cpu_limit: Optional amount of CPU set for the instance of + the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: Optional amount of ephemeral + storage to set for the instance of the job. The amount specified as + ephemeral storage, must not exceed the amount of `scale_memory_limit`. The + units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), + whereas G and M are the shorthand expressions for GB and MB. For more + information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param str scale_memory_limit: Optional amount of memory set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine + and are exposed as environment variables in the job run. + :param str image_secret: (optional) The name of the image registry access + secret. The image registry access secret is used to authenticate with a + private registry when you download the container image. If the image + reference points to a registry that requires authentication, the job / job + runs will be created but submitted job runs will fail, until this property + is provided, too. This property must not be set on a job run, which + references a job template. + :param int run_as_user: (optional) The user ID (UID) to run the job. + :param str run_service_account: (optional) The name of the service account. + For built-in service accounts, you can use the shortened names `manager`, + `none`, `reader`, and `writer`. This property must not be set on a job run, + which references a job template. + :param int scale_max_execution_time: (optional) The maximum execution time + in seconds for runs of the job. This property can only be specified if + `run_mode` is `task`. + :param int scale_retry_limit: (optional) The number of times to rerun an + instance of the job before the job is marked as failed. This property can + only be specified if `run_mode` is `task`. """ + self.build = build + self.build_run = build_run + self.computed_env_variables = computed_env_variables self.created_at = created_at self.entity_tag = entity_tag self.href = href self.id = id + self.image_reference = image_reference + self.image_secret = image_secret self.name = name - self.output_image = output_image - self.output_secret = output_secret self.project_id = project_id + self.region = region self.resource_type = resource_type - self.source_context_dir = source_context_dir - self.source_revision = source_revision - self.source_secret = source_secret - self.source_type = source_type - self.source_url = source_url - self.status = status - self.status_details = status_details - self.strategy_size = strategy_size - self.strategy_spec_file = strategy_spec_file - self.strategy_type = strategy_type - self.timeout = timeout + self.run_arguments = run_arguments + self.run_as_user = run_as_user + self.run_commands = run_commands + self.run_env_variables = run_env_variables + self.run_mode = run_mode + self.run_service_account = run_service_account + self.run_volume_mounts = run_volume_mounts + self.scale_array_spec = scale_array_spec + self.scale_cpu_limit = scale_cpu_limit + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_max_execution_time = scale_max_execution_time + self.scale_memory_limit = scale_memory_limit + self.scale_retry_limit = scale_retry_limit @classmethod - def from_dict(cls, _dict: Dict) -> 'Build': - """Initialize a Build object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Job': + """Initialize a Job object from a json dictionary.""" args = {} - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'entity_tag' in _dict: - args['entity_tag'] = _dict.get('entity_tag') + if (build := _dict.get('build')) is not None: + args['build'] = build + if (build_run := _dict.get('build_run')) is not None: + args['build_run'] = build_run + if (computed_env_variables := _dict.get('computed_env_variables')) is not None: + args['computed_env_variables'] = [EnvVar.from_dict(v) for v in computed_env_variables] + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag else: - raise ValueError('Required property \'entity_tag\' not present in Build JSON') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'output_image' in _dict: - args['output_image'] = _dict.get('output_image') + raise ValueError('Required property \'entity_tag\' not present in Job JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (image_reference := _dict.get('image_reference')) is not None: + args['image_reference'] = image_reference else: - raise ValueError('Required property \'output_image\' not present in Build JSON') - if 'output_secret' in _dict: - args['output_secret'] = _dict.get('output_secret') + raise ValueError('Required property \'image_reference\' not present in Job JSON') + if (image_secret := _dict.get('image_secret')) is not None: + args['image_secret'] = image_secret + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'output_secret\' not present in Build JSON') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'source_context_dir' in _dict: - args['source_context_dir'] = _dict.get('source_context_dir') - if 'source_revision' in _dict: - args['source_revision'] = _dict.get('source_revision') - if 'source_secret' in _dict: - args['source_secret'] = _dict.get('source_secret') - if 'source_type' in _dict: - args['source_type'] = _dict.get('source_type') + raise ValueError('Required property \'name\' not present in Job JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (run_arguments := _dict.get('run_arguments')) is not None: + args['run_arguments'] = run_arguments else: - raise ValueError('Required property \'source_type\' not present in Build JSON') - if 'source_url' in _dict: - args['source_url'] = _dict.get('source_url') + raise ValueError('Required property \'run_arguments\' not present in Job JSON') + if (run_as_user := _dict.get('run_as_user')) is not None: + args['run_as_user'] = run_as_user + if (run_commands := _dict.get('run_commands')) is not None: + args['run_commands'] = run_commands else: - raise ValueError('Required property \'source_url\' not present in Build JSON') - if 'status' in _dict: - args['status'] = _dict.get('status') - if 'status_details' in _dict: - args['status_details'] = BuildStatus.from_dict(_dict.get('status_details')) - if 'strategy_size' in _dict: - args['strategy_size'] = _dict.get('strategy_size') + raise ValueError('Required property \'run_commands\' not present in Job JSON') + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVar.from_dict(v) for v in run_env_variables] else: - raise ValueError('Required property \'strategy_size\' not present in Build JSON') - if 'strategy_spec_file' in _dict: - args['strategy_spec_file'] = _dict.get('strategy_spec_file') - if 'strategy_type' in _dict: - args['strategy_type'] = _dict.get('strategy_type') + raise ValueError('Required property \'run_env_variables\' not present in Job JSON') + if (run_mode := _dict.get('run_mode')) is not None: + args['run_mode'] = run_mode else: - raise ValueError('Required property \'strategy_type\' not present in Build JSON') - if 'timeout' in _dict: - args['timeout'] = _dict.get('timeout') + raise ValueError('Required property \'run_mode\' not present in Job JSON') + if (run_service_account := _dict.get('run_service_account')) is not None: + args['run_service_account'] = run_service_account + if (run_volume_mounts := _dict.get('run_volume_mounts')) is not None: + args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in run_volume_mounts] + else: + raise ValueError('Required property \'run_volume_mounts\' not present in Job JSON') + if (scale_array_spec := _dict.get('scale_array_spec')) is not None: + args['scale_array_spec'] = scale_array_spec + else: + raise ValueError('Required property \'scale_array_spec\' not present in Job JSON') + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + else: + raise ValueError('Required property \'scale_cpu_limit\' not present in Job JSON') + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + else: + raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in Job JSON') + if (scale_max_execution_time := _dict.get('scale_max_execution_time')) is not None: + args['scale_max_execution_time'] = scale_max_execution_time + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + else: + raise ValueError('Required property \'scale_memory_limit\' not present in Job JSON') + if (scale_retry_limit := _dict.get('scale_retry_limit')) is not None: + args['scale_retry_limit'] = scale_retry_limit return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Build object from a json dictionary.""" + """Initialize a Job object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'build') and getattr(self, 'build') is not None: + _dict['build'] = getattr(self, 'build') + if hasattr(self, 'build_run') and getattr(self, 'build_run') is not None: + _dict['build_run'] = getattr(self, 'build_run') + if hasattr(self, 'computed_env_variables') and self.computed_env_variables is not None: + computed_env_variables_list = [] + for v in self.computed_env_variables: + if isinstance(v, dict): + computed_env_variables_list.append(v) + else: + computed_env_variables_list.append(v.to_dict()) + _dict['computed_env_variables'] = computed_env_variables_list if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: _dict['created_at'] = getattr(self, 'created_at') if hasattr(self, 'entity_tag') and self.entity_tag is not None: @@ -4192,41 +9990,56 @@ def to_dict(self) -> Dict: _dict['href'] = getattr(self, 'href') if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') + if hasattr(self, 'image_reference') and self.image_reference is not None: + _dict['image_reference'] = self.image_reference + if hasattr(self, 'image_secret') and self.image_secret is not None: + _dict['image_secret'] = self.image_secret if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name - if hasattr(self, 'output_image') and self.output_image is not None: - _dict['output_image'] = self.output_image - if hasattr(self, 'output_secret') and self.output_secret is not None: - _dict['output_secret'] = self.output_secret if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'source_context_dir') and self.source_context_dir is not None: - _dict['source_context_dir'] = self.source_context_dir - if hasattr(self, 'source_revision') and self.source_revision is not None: - _dict['source_revision'] = self.source_revision - if hasattr(self, 'source_secret') and self.source_secret is not None: - _dict['source_secret'] = self.source_secret - if hasattr(self, 'source_type') and self.source_type is not None: - _dict['source_type'] = self.source_type - if hasattr(self, 'source_url') and self.source_url is not None: - _dict['source_url'] = self.source_url - if hasattr(self, 'status') and getattr(self, 'status') is not None: - _dict['status'] = getattr(self, 'status') - if hasattr(self, 'status_details') and self.status_details is not None: - if isinstance(self.status_details, dict): - _dict['status_details'] = self.status_details - else: - _dict['status_details'] = self.status_details.to_dict() - if hasattr(self, 'strategy_size') and self.strategy_size is not None: - _dict['strategy_size'] = self.strategy_size - if hasattr(self, 'strategy_spec_file') and self.strategy_spec_file is not None: - _dict['strategy_spec_file'] = self.strategy_spec_file - if hasattr(self, 'strategy_type') and self.strategy_type is not None: - _dict['strategy_type'] = self.strategy_type - if hasattr(self, 'timeout') and self.timeout is not None: - _dict['timeout'] = self.timeout + if hasattr(self, 'run_arguments') and self.run_arguments is not None: + _dict['run_arguments'] = self.run_arguments + if hasattr(self, 'run_as_user') and self.run_as_user is not None: + _dict['run_as_user'] = self.run_as_user + if hasattr(self, 'run_commands') and self.run_commands is not None: + _dict['run_commands'] = self.run_commands + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: + if isinstance(v, dict): + run_env_variables_list.append(v) + else: + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'run_mode') and self.run_mode is not None: + _dict['run_mode'] = self.run_mode + if hasattr(self, 'run_service_account') and self.run_service_account is not None: + _dict['run_service_account'] = self.run_service_account + if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: + run_volume_mounts_list = [] + for v in self.run_volume_mounts: + if isinstance(v, dict): + run_volume_mounts_list.append(v) + else: + run_volume_mounts_list.append(v.to_dict()) + _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'scale_array_spec') and self.scale_array_spec is not None: + _dict['scale_array_spec'] = self.scale_array_spec + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: + _dict['scale_max_execution_time'] = self.scale_max_execution_time + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'scale_retry_limit') and self.scale_retry_limit is not None: + _dict['scale_retry_limit'] = self.scale_retry_limit return _dict def _to_dict(self): @@ -4234,115 +10047,125 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Build object.""" + """Return a `str` version of this Job object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Build') -> bool: + def __eq__(self, other: 'Job') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Build') -> bool: + def __ne__(self, other: 'Job') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class ResourceTypeEnum(str, Enum): """ - The type of the build. + The type of the job. """ - BUILD_V2 = 'build_v2' + JOB_V2 = 'job_v2' - class SourceTypeEnum(str, Enum): + class RunModeEnum(str, Enum): """ - Specifies the type of source to determine if your build source is in a repository - or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. + The mode for runs of the job. Valid values are `task` and `daemon`. In `task` + mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` + mode, since there is no timeout and failed instances are restarted indefinitely, + the `max_execution_time` and `retry_limit` properties are not allowed. """ - LOCAL = 'local' - GIT = 'git' + TASK = 'task' + DAEMON = 'daemon' - class StatusEnum(str, Enum): + class RunServiceAccountEnum(str, Enum): """ - The current status of the build. + The name of the service account. For built-in service accounts, you can use the + shortened names `manager`, `none`, `reader`, and `writer`. This property must not + be set on a job run, which references a job template. """ - READY = 'ready' - FAILED = 'failed' + DEFAULT = 'default' + MANAGER = 'manager' + READER = 'reader' + WRITER = 'writer' + NONE = 'none' -class BuildList: +class JobList: """ - Contains a list of builds and pagination information. + Contains a list of jobs and pagination information. - :attr List[Build] builds: List of all builds. - :attr ListFirstMetadata first: (optional) Describes properties needed to + :param ListFirstMetadata first: (optional) Describes properties needed to retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve + :param List[Job] jobs: List of all jobs. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve the next page of a result list. """ def __init__( - self, builds: List['Build'], limit: int, *, first: 'ListFirstMetadata' = None, next: 'ListNextMetadata' = None + self, + jobs: List['Job'], + limit: int, + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, ) -> None: """ - Initialize a BuildList object. + Initialize a JobList object. - :param List[Build] builds: List of all builds. + :param List[Job] jobs: List of all jobs. :param int limit: Maximum number of resources per page. :param ListFirstMetadata first: (optional) Describes properties needed to retrieve the first page of a result list. :param ListNextMetadata next: (optional) Describes properties needed to retrieve the next page of a result list. """ - self.builds = builds self.first = first + self.jobs = jobs self.limit = limit self.next = next @classmethod - def from_dict(cls, _dict: Dict) -> 'BuildList': - """Initialize a BuildList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'JobList': + """Initialize a JobList object from a json dictionary.""" args = {} - if 'builds' in _dict: - args['builds'] = [Build.from_dict(v) for v in _dict.get('builds')] + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (jobs := _dict.get('jobs')) is not None: + args['jobs'] = [Job.from_dict(v) for v in jobs] else: - raise ValueError('Required property \'builds\' not present in BuildList JSON') - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') + raise ValueError('Required property \'jobs\' not present in JobList JSON') + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit else: - raise ValueError('Required property \'limit\' not present in BuildList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) + raise ValueError('Required property \'limit\' not present in JobList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a BuildList object from a json dictionary.""" + """Initialize a JobList object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'builds') and self.builds is not None: - builds_list = [] - for v in self.builds: - if isinstance(v, dict): - builds_list.append(v) - else: - builds_list.append(v.to_dict()) - _dict['builds'] = builds_list if hasattr(self, 'first') and self.first is not None: if isinstance(self.first, dict): _dict['first'] = self.first else: _dict['first'] = self.first.to_dict() + if hasattr(self, 'jobs') and self.jobs is not None: + jobs_list = [] + for v in self.jobs: + if isinstance(v, dict): + jobs_list.append(v) + else: + jobs_list.append(v.to_dict()) + _dict['jobs'] = jobs_list if hasattr(self, 'limit') and self.limit is not None: _dict['limit'] = self.limit if hasattr(self, 'next') and self.next is not None: @@ -4357,188 +10180,279 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this BuildList object.""" + """Return a `str` version of this JobList object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'BuildList') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ - - def __ne__(self, other: 'BuildList') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - - -class BuildPatch: - """ - Patch a build object. - - :attr str output_image: (optional) The name of the image. - :attr str output_secret: (optional) The secret that is required to access the - image registry. Make sure that the secret is granted with push permissions - towards the specified container registry namespace. - :attr str source_context_dir: (optional) Option directory in the repository that - contains the buildpacks file or the Dockerfile. - :attr str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` and - uses the HEAD of default branch if not specified. If the `source_type` value is - `local`, this field must be omitted. - :attr str source_secret: (optional) Name of the secret that is used access the - repository source. This field is optional if the `source_type` is `git`. - Additionally, if the `source_url` points to a repository that requires - authentication, the build will be created but cannot access any source code, - until this property is provided, too. If the `source_type` value is `local`, - this field must be omitted. - :attr str source_type: (optional) Specifies the type of source to determine if - your build source is in a repository or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :attr str source_url: (optional) The URL of the code repository. This field is - required if the `source_type` is `git`. If the `source_type` value is `local`, - this field must be omitted. If the repository is publicly available you can - provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the - repository requires authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to - a secret of format `ssh_auth`. - :attr str strategy_size: (optional) Optional size for the build, which - determines the amount of resources used. Build sizes are `small`, `medium`, - `large`, `xlarge`. - :attr str strategy_spec_file: (optional) Optional path to the specification file - that is used for build strategies for building an image. - :attr str strategy_type: (optional) The strategy to use for building the image. - :attr int timeout: (optional) The maximum amount of time, in seconds, that can - pass before the build must succeed or fail. + def __eq__(self, other: 'JobList') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'JobList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class JobPatch: + """ + Request model for job update operations. + + :param str image_reference: (optional) The name of the image that is used for + this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. + If `TAG` is not specified, the default is `latest`. If the image reference + points to a registry that requires authentication, make sure to also specify the + property `image_secret`. + :param str image_secret: (optional) The name of the image registry access + secret. The image registry access secret is used to authenticate with a private + registry when you download the container image. If the image reference points to + a registry that requires authentication, the job / job runs will be created but + submitted job runs will fail, until this property is provided, too. This + property must not be set on a job run, which references a job template. + :param List[str] run_arguments: (optional) Set arguments for the job that are + passed to start job run containers. If not specified an empty string array will + be applied and the arguments specified by the container image, will be used to + start the container. + :param int run_as_user: (optional) The user ID (UID) to run the job. + :param List[str] run_commands: (optional) Set commands for the job that are + passed to start job run containers. If not specified an empty string array will + be applied and the command specified by the container image, will be used to + start the container. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional references + to config maps, secrets or literal values. + :param str run_mode: (optional) The mode for runs of the job. Valid values are + `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` + properties apply. In `daemon` mode, since there is no timeout and failed + instances are restarted indefinitely, the `max_execution_time` and `retry_limit` + properties are not allowed. + :param str run_service_account: (optional) The name of the service account. For + built-in service accounts, you can use the shortened names `manager`, `none`, + `reader`, and `writer`. This property must not be set on a job run, which + references a job template. + :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional mounts + of config maps or a secrets. In case this is provided, existing + `run_volume_mounts` will be overwritten. + :param str scale_array_spec: (optional) Define a custom set of array indices as + a comma-separated list containing single values and hyphen-separated ranges, + such as 5,12-14,23,27. Each instance gets its array index value from the + environment variable JOB_INDEX. The number of unique array indices that you + specify with this parameter determines the number of job instances to run. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: (optional) Optional amount of + ephemeral storage to set for the instance of the job. The amount specified as + ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units + for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_execution_time: (optional) The maximum execution time in + seconds for runs of the job. This property can only be specified if `run_mode` + is `task`. + :param str scale_memory_limit: (optional) Optional amount of memory set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_retry_limit: (optional) The number of times to rerun an + instance of the job before the job is marked as failed. This property can only + be specified if `run_mode` is `task`. """ def __init__( self, *, - output_image: str = None, - output_secret: str = None, - source_context_dir: str = None, - source_revision: str = None, - source_secret: str = None, - source_type: str = None, - source_url: str = None, - strategy_size: str = None, - strategy_spec_file: str = None, - strategy_type: str = None, - timeout: int = None, + image_reference: Optional[str] = None, + image_secret: Optional[str] = None, + run_arguments: Optional[List[str]] = None, + run_as_user: Optional[int] = None, + run_commands: Optional[List[str]] = None, + run_env_variables: Optional[List['EnvVarPrototype']] = None, + run_mode: Optional[str] = None, + run_service_account: Optional[str] = None, + run_volume_mounts: Optional[List['VolumeMountPrototype']] = None, + scale_array_spec: Optional[str] = None, + scale_cpu_limit: Optional[str] = None, + scale_ephemeral_storage_limit: Optional[str] = None, + scale_max_execution_time: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + scale_retry_limit: Optional[int] = None, ) -> None: """ - Initialize a BuildPatch object. + Initialize a JobPatch object. - :param str output_image: (optional) The name of the image. - :param str output_secret: (optional) The secret that is required to access - the image registry. Make sure that the secret is granted with push - permissions towards the specified container registry namespace. - :param str source_context_dir: (optional) Option directory in the - repository that contains the buildpacks file or the Dockerfile. - :param str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` - and uses the HEAD of default branch if not specified. If the `source_type` - value is `local`, this field must be omitted. - :param str source_secret: (optional) Name of the secret that is used access - the repository source. This field is optional if the `source_type` is - `git`. Additionally, if the `source_url` points to a repository that - requires authentication, the build will be created but cannot access any - source code, until this property is provided, too. If the `source_type` - value is `local`, this field must be omitted. - :param str source_type: (optional) Specifies the type of source to - determine if your build source is in a repository or based on local source - code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :param str source_url: (optional) The URL of the code repository. This - field is required if the `source_type` is `git`. If the `source_type` value - is `local`, this field must be omitted. If the repository is publicly - available you can provide a 'https' URL like - `https://github.com/IBM/CodeEngine`. If the repository requires - authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that - points to a secret of format `ssh_auth`. - :param str strategy_size: (optional) Optional size for the build, which - determines the amount of resources used. Build sizes are `small`, `medium`, - `large`, `xlarge`. - :param str strategy_spec_file: (optional) Optional path to the - specification file that is used for build strategies for building an image. - :param str strategy_type: (optional) The strategy to use for building the - image. - :param int timeout: (optional) The maximum amount of time, in seconds, that - can pass before the build must succeed or fail. + :param str image_reference: (optional) The name of the image that is used + for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where + `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the + default is `docker.io`. If `TAG` is not specified, the default is `latest`. + If the image reference points to a registry that requires authentication, + make sure to also specify the property `image_secret`. + :param str image_secret: (optional) The name of the image registry access + secret. The image registry access secret is used to authenticate with a + private registry when you download the container image. If the image + reference points to a registry that requires authentication, the job / job + runs will be created but submitted job runs will fail, until this property + is provided, too. This property must not be set on a job run, which + references a job template. + :param List[str] run_arguments: (optional) Set arguments for the job that + are passed to start job run containers. If not specified an empty string + array will be applied and the arguments specified by the container image, + will be used to start the container. + :param int run_as_user: (optional) The user ID (UID) to run the job. + :param List[str] run_commands: (optional) Set commands for the job that are + passed to start job run containers. If not specified an empty string array + will be applied and the command specified by the container image, will be + used to start the container. + :param List[EnvVarPrototype] run_env_variables: (optional) Optional + references to config maps, secrets or literal values. + :param str run_mode: (optional) The mode for runs of the job. Valid values + are `task` and `daemon`. In `task` mode, the `max_execution_time` and + `retry_limit` properties apply. In `daemon` mode, since there is no timeout + and failed instances are restarted indefinitely, the `max_execution_time` + and `retry_limit` properties are not allowed. + :param str run_service_account: (optional) The name of the service account. + For built-in service accounts, you can use the shortened names `manager`, + `none`, `reader`, and `writer`. This property must not be set on a job run, + which references a job template. + :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional + mounts of config maps or a secrets. In case this is provided, existing + `run_volume_mounts` will be overwritten. + :param str scale_array_spec: (optional) Define a custom set of array + indices as a comma-separated list containing single values and + hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its + array index value from the environment variable JOB_INDEX. The number of + unique array indices that you specify with this parameter determines the + number of job instances to run. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: (optional) Optional amount of + ephemeral storage to set for the instance of the job. The amount specified + as ephemeral storage, must not exceed the amount of `scale_memory_limit`. + The units for specifying ephemeral storage are Megabyte (M) or Gigabyte + (G), whereas G and M are the shorthand expressions for GB and MB. For more + information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_execution_time: (optional) The maximum execution time + in seconds for runs of the job. This property can only be specified if + `run_mode` is `task`. + :param str scale_memory_limit: (optional) Optional amount of memory set for + the instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_retry_limit: (optional) The number of times to rerun an + instance of the job before the job is marked as failed. This property can + only be specified if `run_mode` is `task`. """ - self.output_image = output_image - self.output_secret = output_secret - self.source_context_dir = source_context_dir - self.source_revision = source_revision - self.source_secret = source_secret - self.source_type = source_type - self.source_url = source_url - self.strategy_size = strategy_size - self.strategy_spec_file = strategy_spec_file - self.strategy_type = strategy_type - self.timeout = timeout + self.image_reference = image_reference + self.image_secret = image_secret + self.run_arguments = run_arguments + self.run_as_user = run_as_user + self.run_commands = run_commands + self.run_env_variables = run_env_variables + self.run_mode = run_mode + self.run_service_account = run_service_account + self.run_volume_mounts = run_volume_mounts + self.scale_array_spec = scale_array_spec + self.scale_cpu_limit = scale_cpu_limit + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_max_execution_time = scale_max_execution_time + self.scale_memory_limit = scale_memory_limit + self.scale_retry_limit = scale_retry_limit @classmethod - def from_dict(cls, _dict: Dict) -> 'BuildPatch': - """Initialize a BuildPatch object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'JobPatch': + """Initialize a JobPatch object from a json dictionary.""" args = {} - if 'output_image' in _dict: - args['output_image'] = _dict.get('output_image') - if 'output_secret' in _dict: - args['output_secret'] = _dict.get('output_secret') - if 'source_context_dir' in _dict: - args['source_context_dir'] = _dict.get('source_context_dir') - if 'source_revision' in _dict: - args['source_revision'] = _dict.get('source_revision') - if 'source_secret' in _dict: - args['source_secret'] = _dict.get('source_secret') - if 'source_type' in _dict: - args['source_type'] = _dict.get('source_type') - if 'source_url' in _dict: - args['source_url'] = _dict.get('source_url') - if 'strategy_size' in _dict: - args['strategy_size'] = _dict.get('strategy_size') - if 'strategy_spec_file' in _dict: - args['strategy_spec_file'] = _dict.get('strategy_spec_file') - if 'strategy_type' in _dict: - args['strategy_type'] = _dict.get('strategy_type') - if 'timeout' in _dict: - args['timeout'] = _dict.get('timeout') + if (image_reference := _dict.get('image_reference')) is not None: + args['image_reference'] = image_reference + if (image_secret := _dict.get('image_secret')) is not None: + args['image_secret'] = image_secret + if (run_arguments := _dict.get('run_arguments')) is not None: + args['run_arguments'] = run_arguments + if (run_as_user := _dict.get('run_as_user')) is not None: + args['run_as_user'] = run_as_user + if (run_commands := _dict.get('run_commands')) is not None: + args['run_commands'] = run_commands + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVarPrototype.from_dict(v) for v in run_env_variables] + if (run_mode := _dict.get('run_mode')) is not None: + args['run_mode'] = run_mode + if (run_service_account := _dict.get('run_service_account')) is not None: + args['run_service_account'] = run_service_account + if (run_volume_mounts := _dict.get('run_volume_mounts')) is not None: + args['run_volume_mounts'] = [VolumeMountPrototype.from_dict(v) for v in run_volume_mounts] + if (scale_array_spec := _dict.get('scale_array_spec')) is not None: + args['scale_array_spec'] = scale_array_spec + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + if (scale_max_execution_time := _dict.get('scale_max_execution_time')) is not None: + args['scale_max_execution_time'] = scale_max_execution_time + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + if (scale_retry_limit := _dict.get('scale_retry_limit')) is not None: + args['scale_retry_limit'] = scale_retry_limit return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a BuildPatch object from a json dictionary.""" + """Initialize a JobPatch object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'output_image') and self.output_image is not None: - _dict['output_image'] = self.output_image - if hasattr(self, 'output_secret') and self.output_secret is not None: - _dict['output_secret'] = self.output_secret - if hasattr(self, 'source_context_dir') and self.source_context_dir is not None: - _dict['source_context_dir'] = self.source_context_dir - if hasattr(self, 'source_revision') and self.source_revision is not None: - _dict['source_revision'] = self.source_revision - if hasattr(self, 'source_secret') and self.source_secret is not None: - _dict['source_secret'] = self.source_secret - if hasattr(self, 'source_type') and self.source_type is not None: - _dict['source_type'] = self.source_type - if hasattr(self, 'source_url') and self.source_url is not None: - _dict['source_url'] = self.source_url - if hasattr(self, 'strategy_size') and self.strategy_size is not None: - _dict['strategy_size'] = self.strategy_size - if hasattr(self, 'strategy_spec_file') and self.strategy_spec_file is not None: - _dict['strategy_spec_file'] = self.strategy_spec_file - if hasattr(self, 'strategy_type') and self.strategy_type is not None: - _dict['strategy_type'] = self.strategy_type - if hasattr(self, 'timeout') and self.timeout is not None: - _dict['timeout'] = self.timeout + if hasattr(self, 'image_reference') and self.image_reference is not None: + _dict['image_reference'] = self.image_reference + if hasattr(self, 'image_secret') and self.image_secret is not None: + _dict['image_secret'] = self.image_secret + if hasattr(self, 'run_arguments') and self.run_arguments is not None: + _dict['run_arguments'] = self.run_arguments + if hasattr(self, 'run_as_user') and self.run_as_user is not None: + _dict['run_as_user'] = self.run_as_user + if hasattr(self, 'run_commands') and self.run_commands is not None: + _dict['run_commands'] = self.run_commands + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: + if isinstance(v, dict): + run_env_variables_list.append(v) + else: + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'run_mode') and self.run_mode is not None: + _dict['run_mode'] = self.run_mode + if hasattr(self, 'run_service_account') and self.run_service_account is not None: + _dict['run_service_account'] = self.run_service_account + if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: + run_volume_mounts_list = [] + for v in self.run_volume_mounts: + if isinstance(v, dict): + run_volume_mounts_list.append(v) + else: + run_volume_mounts_list.append(v.to_dict()) + _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'scale_array_spec') and self.scale_array_spec is not None: + _dict['scale_array_spec'] = self.scale_array_spec + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: + _dict['scale_max_execution_time'] = self.scale_max_execution_time + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'scale_retry_limit') and self.scale_retry_limit is not None: + _dict['scale_retry_limit'] = self.scale_retry_limit return _dict def _to_dict(self): @@ -4546,279 +10460,418 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this BuildPatch object.""" + """Return a `str` version of this JobPatch object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'BuildPatch') -> bool: + def __eq__(self, other: 'JobPatch') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'BuildPatch') -> bool: + def __ne__(self, other: 'JobPatch') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class SourceTypeEnum(str, Enum): + class RunModeEnum(str, Enum): + """ + The mode for runs of the job. Valid values are `task` and `daemon`. In `task` + mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` + mode, since there is no timeout and failed instances are restarted indefinitely, + the `max_execution_time` and `retry_limit` properties are not allowed. + """ + + TASK = 'task' + DAEMON = 'daemon' + + class RunServiceAccountEnum(str, Enum): """ - Specifies the type of source to determine if your build source is in a repository - or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. + The name of the service account. For built-in service accounts, you can use the + shortened names `manager`, `none`, `reader`, and `writer`. This property must not + be set on a job run, which references a job template. """ - LOCAL = 'local' - GIT = 'git' + DEFAULT = 'default' + MANAGER = 'manager' + READER = 'reader' + WRITER = 'writer' + NONE = 'none' -class BuildRun: +class JobRun: """ - Response model for build run objects. + Response model for job run resources. - :attr str build_name: Optional name of the build on which this build run is - based on. If specified, the build run will inherit the configuration of the - referenced build. If not specified, make sure to specify at least the fields - `strategy_type`, `source_url`, `output_image` and `output_secret` to describe - the build run. - :attr str created_at: (optional) The date when the resource was created. - :attr str href: (optional) When you trigger a new build run, a URL is created + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine and + are exposed as environment variables in the job run. + :param str created_at: (optional) The timestamp when the resource was created. + :param str href: (optional) When you provision a new job run, a URL is created identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr str name: The name of the build run. - :attr str output_image: (optional) The name of the image. - :attr str output_secret: (optional) The secret that is required to access the - image registry. Make sure that the secret is granted with push permissions - towards the specified container registry namespace. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the build run. - :attr str service_account: (optional) Optional service account which is used for - resource control. - :attr str source_context_dir: (optional) Option directory in the repository that - contains the buildpacks file or the Dockerfile. - :attr str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` and - uses the HEAD of default branch if not specified. If the `source_type` value is - `local`, this field must be omitted. - :attr str source_secret: (optional) Name of the secret that is used access the - repository source. This field is optional if the `source_type` is `git`. - Additionally, if the `source_url` points to a repository that requires - authentication, the build will be created but cannot access any source code, - until this property is provided, too. If the `source_type` value is `local`, - this field must be omitted. - :attr str source_type: (optional) Specifies the type of source to determine if - your build source is in a repository or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :attr str source_url: (optional) The URL of the code repository. This field is - required if the `source_type` is `git`. If the `source_type` value is `local`, - this field must be omitted. If the repository is publicly available you can - provide a 'https' URL like `https://github.com/IBM/CodeEngine`. If the - repository requires authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that points to - a secret of format `ssh_auth`. - :attr str status: (optional) The current status of the build run. - :attr BuildRunStatus status_details: (optional) Current status condition of a - build run. - :attr str strategy_size: (optional) Optional size for the build, which - determines the amount of resources used. Build sizes are `small`, `medium`, - `large`, `xlarge`. - :attr str strategy_spec_file: (optional) Optional path to the specification file - that is used for build strategies for building an image. - :attr str strategy_type: (optional) The strategy to use for building the image. - :attr int timeout: (optional) The maximum amount of time, in seconds, that can - pass before the build must succeed or fail. + :param str id: (optional) The identifier of the resource. + :param str image_reference: (optional) The name of the image that is used for + this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and + `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. + If `TAG` is not specified, the default is `latest`. If the image reference + points to a registry that requires authentication, make sure to also specify the + property `image_secret`. + :param str image_secret: (optional) The name of the image registry access + secret. The image registry access secret is used to authenticate with a private + registry when you download the container image. If the image reference points to + a registry that requires authentication, the job / job runs will be created but + submitted job runs will fail, until this property is provided, too. This + property must not be set on a job run, which references a job template. + :param str job_name: (optional) Optional name of the job reference of this job + run. If specified, the job run will inherit the configuration of the referenced + job. + :param str name: (optional) The name of the job run. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the job run. + :param List[str] run_arguments: Set arguments for the job that are passed to + start job run containers. If not specified an empty string array will be applied + and the arguments specified by the container image, will be used to start the + container. + :param int run_as_user: (optional) The user ID (UID) to run the job. + :param List[str] run_commands: Set commands for the job that are passed to start + job run containers. If not specified an empty string array will be applied and + the command specified by the container image, will be used to start the + container. + :param List[EnvVar] run_env_variables: References to config maps, secrets or + literal values, which are defined by the function owner and are exposed as + environment variables in the job run. + :param str run_mode: (optional) The mode for runs of the job. Valid values are + `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` + properties apply. In `daemon` mode, since there is no timeout and failed + instances are restarted indefinitely, the `max_execution_time` and `retry_limit` + properties are not allowed. + :param str run_service_account: (optional) The name of the service account. For + built-in service accounts, you can use the shortened names `manager`, `none`, + `reader`, and `writer`. This property must not be set on a job run, which + references a job template. + :param List[VolumeMount] run_volume_mounts: Optional mounts of config maps or + secrets. + :param int scale_array_size_variable_override: (optional) Optional value to + override the JOB_ARRAY_SIZE environment variable for a job run. + :param str scale_array_spec: (optional) Define a custom set of array indices as + a comma-separated list containing single values and hyphen-separated ranges, + such as 5,12-14,23,27. Each instance gets its array index value from the + environment variable JOB_INDEX. The number of unique array indices that you + specify with this parameter determines the number of job instances to run. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: (optional) Optional amount of + ephemeral storage to set for the instance of the job. The amount specified as + ephemeral storage, must not exceed the amount of `scale_memory_limit`. The units + for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_execution_time: (optional) The maximum execution time in + seconds for runs of the job. This property can only be specified if `run_mode` + is `task`. + :param str scale_memory_limit: (optional) Optional amount of memory set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and + M are the shorthand expressions for GB and MB. For more information see [Units + of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_retry_limit: (optional) The number of times to rerun an + instance of the job before the job is marked as failed. This property can only + be specified if `run_mode` is `task`. + :param str status: (optional) The current status of the job run. + :param JobRunStatus status_details: (optional) The detailed status of the job + run. """ def __init__( self, - build_name: str, - name: str, + run_arguments: List[str], + run_commands: List[str], + run_env_variables: List['EnvVar'], + run_volume_mounts: List['VolumeMount'], *, - created_at: str = None, - href: str = None, - id: str = None, - output_image: str = None, - output_secret: str = None, - project_id: str = None, - resource_type: str = None, - service_account: str = None, - source_context_dir: str = None, - source_revision: str = None, - source_secret: str = None, - source_type: str = None, - source_url: str = None, - status: str = None, - status_details: 'BuildRunStatus' = None, - strategy_size: str = None, - strategy_spec_file: str = None, - strategy_type: str = None, - timeout: int = None, + computed_env_variables: Optional[List['EnvVar']] = None, + created_at: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + image_reference: Optional[str] = None, + image_secret: Optional[str] = None, + job_name: Optional[str] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + run_as_user: Optional[int] = None, + run_mode: Optional[str] = None, + run_service_account: Optional[str] = None, + scale_array_size_variable_override: Optional[int] = None, + scale_array_spec: Optional[str] = None, + scale_cpu_limit: Optional[str] = None, + scale_ephemeral_storage_limit: Optional[str] = None, + scale_max_execution_time: Optional[int] = None, + scale_memory_limit: Optional[str] = None, + scale_retry_limit: Optional[int] = None, + status: Optional[str] = None, + status_details: Optional['JobRunStatus'] = None, ) -> None: """ - Initialize a BuildRun object. + Initialize a JobRun object. - :param str build_name: Optional name of the build on which this build run - is based on. If specified, the build run will inherit the configuration of - the referenced build. If not specified, make sure to specify at least the - fields `strategy_type`, `source_url`, `output_image` and `output_secret` to - describe the build run. - :param str name: The name of the build run. - :param str output_image: (optional) The name of the image. - :param str output_secret: (optional) The secret that is required to access - the image registry. Make sure that the secret is granted with push - permissions towards the specified container registry namespace. - :param str service_account: (optional) Optional service account which is - used for resource control. - :param str source_context_dir: (optional) Option directory in the - repository that contains the buildpacks file or the Dockerfile. - :param str source_revision: (optional) Commit, tag, or branch in the source - repository to pull. This field is optional if the `source_type` is `git` - and uses the HEAD of default branch if not specified. If the `source_type` - value is `local`, this field must be omitted. - :param str source_secret: (optional) Name of the secret that is used access - the repository source. This field is optional if the `source_type` is - `git`. Additionally, if the `source_url` points to a repository that - requires authentication, the build will be created but cannot access any - source code, until this property is provided, too. If the `source_type` - value is `local`, this field must be omitted. - :param str source_type: (optional) Specifies the type of source to - determine if your build source is in a repository or based on local source - code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - :param str source_url: (optional) The URL of the code repository. This - field is required if the `source_type` is `git`. If the `source_type` value - is `local`, this field must be omitted. If the repository is publicly - available you can provide a 'https' URL like - `https://github.com/IBM/CodeEngine`. If the repository requires - authentication, you need to provide a 'ssh' URL like - `git@github.com:IBM/CodeEngine.git` along with a `source_secret` that - points to a secret of format `ssh_auth`. - :param BuildRunStatus status_details: (optional) Current status condition - of a build run. - :param str strategy_size: (optional) Optional size for the build, which - determines the amount of resources used. Build sizes are `small`, `medium`, - `large`, `xlarge`. - :param str strategy_spec_file: (optional) Optional path to the - specification file that is used for build strategies for building an image. - :param str strategy_type: (optional) The strategy to use for building the - image. - :param int timeout: (optional) The maximum amount of time, in seconds, that - can pass before the build must succeed or fail. + :param List[str] run_arguments: Set arguments for the job that are passed + to start job run containers. If not specified an empty string array will be + applied and the arguments specified by the container image, will be used to + start the container. + :param List[str] run_commands: Set commands for the job that are passed to + start job run containers. If not specified an empty string array will be + applied and the command specified by the container image, will be used to + start the container. + :param List[EnvVar] run_env_variables: References to config maps, secrets + or literal values, which are defined by the function owner and are exposed + as environment variables in the job run. + :param List[VolumeMount] run_volume_mounts: Optional mounts of config maps + or secrets. + :param List[EnvVar] computed_env_variables: (optional) References to config + maps, secrets or literal values, which are defined and set by Code Engine + and are exposed as environment variables in the job run. + :param str image_reference: (optional) The name of the image that is used + for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where + `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the + default is `docker.io`. If `TAG` is not specified, the default is `latest`. + If the image reference points to a registry that requires authentication, + make sure to also specify the property `image_secret`. + :param str image_secret: (optional) The name of the image registry access + secret. The image registry access secret is used to authenticate with a + private registry when you download the container image. If the image + reference points to a registry that requires authentication, the job / job + runs will be created but submitted job runs will fail, until this property + is provided, too. This property must not be set on a job run, which + references a job template. + :param str job_name: (optional) Optional name of the job reference of this + job run. If specified, the job run will inherit the configuration of the + referenced job. + :param str name: (optional) The name of the job run. + :param int run_as_user: (optional) The user ID (UID) to run the job. + :param str run_mode: (optional) The mode for runs of the job. Valid values + are `task` and `daemon`. In `task` mode, the `max_execution_time` and + `retry_limit` properties apply. In `daemon` mode, since there is no timeout + and failed instances are restarted indefinitely, the `max_execution_time` + and `retry_limit` properties are not allowed. + :param str run_service_account: (optional) The name of the service account. + For built-in service accounts, you can use the shortened names `manager`, + `none`, `reader`, and `writer`. This property must not be set on a job run, + which references a job template. + :param int scale_array_size_variable_override: (optional) Optional value to + override the JOB_ARRAY_SIZE environment variable for a job run. + :param str scale_array_spec: (optional) Define a custom set of array + indices as a comma-separated list containing single values and + hyphen-separated ranges, such as 5,12-14,23,27. Each instance gets its + array index value from the environment variable JOB_INDEX. The number of + unique array indices that you specify with this parameter determines the + number of job instances to run. + :param str scale_cpu_limit: (optional) Optional amount of CPU set for the + instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + :param str scale_ephemeral_storage_limit: (optional) Optional amount of + ephemeral storage to set for the instance of the job. The amount specified + as ephemeral storage, must not exceed the amount of `scale_memory_limit`. + The units for specifying ephemeral storage are Megabyte (M) or Gigabyte + (G), whereas G and M are the shorthand expressions for GB and MB. For more + information see [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_max_execution_time: (optional) The maximum execution time + in seconds for runs of the job. This property can only be specified if + `run_mode` is `task`. + :param str scale_memory_limit: (optional) Optional amount of memory set for + the instance of the job. For valid values see [Supported memory and CPU + combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). + The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G + and M are the shorthand expressions for GB and MB. For more information see + [Units of + measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). + :param int scale_retry_limit: (optional) The number of times to rerun an + instance of the job before the job is marked as failed. This property can + only be specified if `run_mode` is `task`. + :param JobRunStatus status_details: (optional) The detailed status of the + job run. """ - self.build_name = build_name + self.computed_env_variables = computed_env_variables self.created_at = created_at self.href = href self.id = id + self.image_reference = image_reference + self.image_secret = image_secret + self.job_name = job_name self.name = name - self.output_image = output_image - self.output_secret = output_secret self.project_id = project_id + self.region = region self.resource_type = resource_type - self.service_account = service_account - self.source_context_dir = source_context_dir - self.source_revision = source_revision - self.source_secret = source_secret - self.source_type = source_type - self.source_url = source_url + self.run_arguments = run_arguments + self.run_as_user = run_as_user + self.run_commands = run_commands + self.run_env_variables = run_env_variables + self.run_mode = run_mode + self.run_service_account = run_service_account + self.run_volume_mounts = run_volume_mounts + self.scale_array_size_variable_override = scale_array_size_variable_override + self.scale_array_spec = scale_array_spec + self.scale_cpu_limit = scale_cpu_limit + self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit + self.scale_max_execution_time = scale_max_execution_time + self.scale_memory_limit = scale_memory_limit + self.scale_retry_limit = scale_retry_limit self.status = status self.status_details = status_details - self.strategy_size = strategy_size - self.strategy_spec_file = strategy_spec_file - self.strategy_type = strategy_type - self.timeout = timeout @classmethod - def from_dict(cls, _dict: Dict) -> 'BuildRun': - """Initialize a BuildRun object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'JobRun': + """Initialize a JobRun object from a json dictionary.""" args = {} - if 'build_name' in _dict: - args['build_name'] = _dict.get('build_name') + if (computed_env_variables := _dict.get('computed_env_variables')) is not None: + args['computed_env_variables'] = [EnvVar.from_dict(v) for v in computed_env_variables] + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (image_reference := _dict.get('image_reference')) is not None: + args['image_reference'] = image_reference + if (image_secret := _dict.get('image_secret')) is not None: + args['image_secret'] = image_secret + if (job_name := _dict.get('job_name')) is not None: + args['job_name'] = job_name + if (name := _dict.get('name')) is not None: + args['name'] = name + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (run_arguments := _dict.get('run_arguments')) is not None: + args['run_arguments'] = run_arguments else: - raise ValueError('Required property \'build_name\' not present in BuildRun JSON') - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'name' in _dict: - args['name'] = _dict.get('name') + raise ValueError('Required property \'run_arguments\' not present in JobRun JSON') + if (run_as_user := _dict.get('run_as_user')) is not None: + args['run_as_user'] = run_as_user + if (run_commands := _dict.get('run_commands')) is not None: + args['run_commands'] = run_commands else: - raise ValueError('Required property \'name\' not present in BuildRun JSON') - if 'output_image' in _dict: - args['output_image'] = _dict.get('output_image') - if 'output_secret' in _dict: - args['output_secret'] = _dict.get('output_secret') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'service_account' in _dict: - args['service_account'] = _dict.get('service_account') - if 'source_context_dir' in _dict: - args['source_context_dir'] = _dict.get('source_context_dir') - if 'source_revision' in _dict: - args['source_revision'] = _dict.get('source_revision') - if 'source_secret' in _dict: - args['source_secret'] = _dict.get('source_secret') - if 'source_type' in _dict: - args['source_type'] = _dict.get('source_type') - if 'source_url' in _dict: - args['source_url'] = _dict.get('source_url') - if 'status' in _dict: - args['status'] = _dict.get('status') - if 'status_details' in _dict: - args['status_details'] = BuildRunStatus.from_dict(_dict.get('status_details')) - if 'strategy_size' in _dict: - args['strategy_size'] = _dict.get('strategy_size') - if 'strategy_spec_file' in _dict: - args['strategy_spec_file'] = _dict.get('strategy_spec_file') - if 'strategy_type' in _dict: - args['strategy_type'] = _dict.get('strategy_type') - if 'timeout' in _dict: - args['timeout'] = _dict.get('timeout') + raise ValueError('Required property \'run_commands\' not present in JobRun JSON') + if (run_env_variables := _dict.get('run_env_variables')) is not None: + args['run_env_variables'] = [EnvVar.from_dict(v) for v in run_env_variables] + else: + raise ValueError('Required property \'run_env_variables\' not present in JobRun JSON') + if (run_mode := _dict.get('run_mode')) is not None: + args['run_mode'] = run_mode + if (run_service_account := _dict.get('run_service_account')) is not None: + args['run_service_account'] = run_service_account + if (run_volume_mounts := _dict.get('run_volume_mounts')) is not None: + args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in run_volume_mounts] + else: + raise ValueError('Required property \'run_volume_mounts\' not present in JobRun JSON') + if (scale_array_size_variable_override := _dict.get('scale_array_size_variable_override')) is not None: + args['scale_array_size_variable_override'] = scale_array_size_variable_override + if (scale_array_spec := _dict.get('scale_array_spec')) is not None: + args['scale_array_spec'] = scale_array_spec + if (scale_cpu_limit := _dict.get('scale_cpu_limit')) is not None: + args['scale_cpu_limit'] = scale_cpu_limit + if (scale_ephemeral_storage_limit := _dict.get('scale_ephemeral_storage_limit')) is not None: + args['scale_ephemeral_storage_limit'] = scale_ephemeral_storage_limit + if (scale_max_execution_time := _dict.get('scale_max_execution_time')) is not None: + args['scale_max_execution_time'] = scale_max_execution_time + if (scale_memory_limit := _dict.get('scale_memory_limit')) is not None: + args['scale_memory_limit'] = scale_memory_limit + if (scale_retry_limit := _dict.get('scale_retry_limit')) is not None: + args['scale_retry_limit'] = scale_retry_limit + if (status := _dict.get('status')) is not None: + args['status'] = status + if (status_details := _dict.get('status_details')) is not None: + args['status_details'] = JobRunStatus.from_dict(status_details) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a BuildRun object from a json dictionary.""" + """Initialize a JobRun object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'build_name') and self.build_name is not None: - _dict['build_name'] = self.build_name + if hasattr(self, 'computed_env_variables') and self.computed_env_variables is not None: + computed_env_variables_list = [] + for v in self.computed_env_variables: + if isinstance(v, dict): + computed_env_variables_list.append(v) + else: + computed_env_variables_list.append(v.to_dict()) + _dict['computed_env_variables'] = computed_env_variables_list if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: _dict['created_at'] = getattr(self, 'created_at') if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') + if hasattr(self, 'image_reference') and self.image_reference is not None: + _dict['image_reference'] = self.image_reference + if hasattr(self, 'image_secret') and self.image_secret is not None: + _dict['image_secret'] = self.image_secret + if hasattr(self, 'job_name') and self.job_name is not None: + _dict['job_name'] = self.job_name if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name - if hasattr(self, 'output_image') and self.output_image is not None: - _dict['output_image'] = self.output_image - if hasattr(self, 'output_secret') and self.output_secret is not None: - _dict['output_secret'] = self.output_secret if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'service_account') and self.service_account is not None: - _dict['service_account'] = self.service_account - if hasattr(self, 'source_context_dir') and self.source_context_dir is not None: - _dict['source_context_dir'] = self.source_context_dir - if hasattr(self, 'source_revision') and self.source_revision is not None: - _dict['source_revision'] = self.source_revision - if hasattr(self, 'source_secret') and self.source_secret is not None: - _dict['source_secret'] = self.source_secret - if hasattr(self, 'source_type') and self.source_type is not None: - _dict['source_type'] = self.source_type - if hasattr(self, 'source_url') and self.source_url is not None: - _dict['source_url'] = self.source_url + if hasattr(self, 'run_arguments') and self.run_arguments is not None: + _dict['run_arguments'] = self.run_arguments + if hasattr(self, 'run_as_user') and self.run_as_user is not None: + _dict['run_as_user'] = self.run_as_user + if hasattr(self, 'run_commands') and self.run_commands is not None: + _dict['run_commands'] = self.run_commands + if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: + run_env_variables_list = [] + for v in self.run_env_variables: + if isinstance(v, dict): + run_env_variables_list.append(v) + else: + run_env_variables_list.append(v.to_dict()) + _dict['run_env_variables'] = run_env_variables_list + if hasattr(self, 'run_mode') and self.run_mode is not None: + _dict['run_mode'] = self.run_mode + if hasattr(self, 'run_service_account') and self.run_service_account is not None: + _dict['run_service_account'] = self.run_service_account + if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: + run_volume_mounts_list = [] + for v in self.run_volume_mounts: + if isinstance(v, dict): + run_volume_mounts_list.append(v) + else: + run_volume_mounts_list.append(v.to_dict()) + _dict['run_volume_mounts'] = run_volume_mounts_list + if hasattr(self, 'scale_array_size_variable_override') and self.scale_array_size_variable_override is not None: + _dict['scale_array_size_variable_override'] = self.scale_array_size_variable_override + if hasattr(self, 'scale_array_spec') and self.scale_array_spec is not None: + _dict['scale_array_spec'] = self.scale_array_spec + if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: + _dict['scale_cpu_limit'] = self.scale_cpu_limit + if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: + _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit + if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: + _dict['scale_max_execution_time'] = self.scale_max_execution_time + if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: + _dict['scale_memory_limit'] = self.scale_memory_limit + if hasattr(self, 'scale_retry_limit') and self.scale_retry_limit is not None: + _dict['scale_retry_limit'] = self.scale_retry_limit if hasattr(self, 'status') and getattr(self, 'status') is not None: _dict['status'] = getattr(self, 'status') if hasattr(self, 'status_details') and self.status_details is not None: @@ -4826,14 +10879,6 @@ def to_dict(self) -> Dict: _dict['status_details'] = self.status_details else: _dict['status_details'] = self.status_details.to_dict() - if hasattr(self, 'strategy_size') and self.strategy_size is not None: - _dict['strategy_size'] = self.strategy_size - if hasattr(self, 'strategy_spec_file') and self.strategy_spec_file is not None: - _dict['strategy_spec_file'] = self.strategy_spec_file - if hasattr(self, 'strategy_type') and self.strategy_type is not None: - _dict['strategy_type'] = self.strategy_type - if hasattr(self, 'timeout') and self.timeout is not None: - _dict['timeout'] = self.timeout return _dict def _to_dict(self): @@ -4841,29 +10886,42 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this BuildRun object.""" + """Return a `str` version of this JobRun object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'BuildRun') -> bool: + def __eq__(self, other: 'JobRun') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'BuildRun') -> bool: + def __ne__(self, other: 'JobRun') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class ResourceTypeEnum(str, Enum): """ - The type of the build run. + The type of the job run. """ - BUILD_RUN_V2 = 'build_run_v2' + JOB_RUN_V2 = 'job_run_v2' - class ServiceAccountEnum(str, Enum): + class RunModeEnum(str, Enum): + """ + The mode for runs of the job. Valid values are `task` and `daemon`. In `task` + mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` + mode, since there is no timeout and failed instances are restarted indefinitely, + the `max_execution_time` and `retry_limit` properties are not allowed. + """ + + TASK = 'task' + DAEMON = 'daemon' + + class RunServiceAccountEnum(str, Enum): """ - Optional service account which is used for resource control. + The name of the service account. For built-in service accounts, you can use the + shortened names `manager`, `none`, `reader`, and `writer`. This property must not + be set on a job run, which references a job template. """ DEFAULT = 'default' @@ -4872,102 +10930,91 @@ class ServiceAccountEnum(str, Enum): WRITER = 'writer' NONE = 'none' - class SourceTypeEnum(str, Enum): - """ - Specifies the type of source to determine if your build source is in a repository - or based on local source code. - * local - For builds from local source code. - * git - For builds from git version controlled source code. - """ - - LOCAL = 'local' - GIT = 'git' - class StatusEnum(str, Enum): """ - The current status of the build run. + The current status of the job run. """ - SUCCEEDED = 'succeeded' + FAILED = 'failed' + COMPLETED = 'completed' RUNNING = 'running' PENDING = 'pending' - FAILED = 'failed' -class BuildRunList: +class JobRunList: """ - Contains a list of build runs and pagination information. + Contains a list of job runs and pagination information. - :attr List[BuildRun] build_runs: List of all build runs. - :attr ListFirstMetadata first: (optional) Describes properties needed to + :param ListFirstMetadata first: (optional) Describes properties needed to retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve + :param List[JobRun] job_runs: List of all jobs. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve the next page of a result list. """ def __init__( self, - build_runs: List['BuildRun'], + job_runs: List['JobRun'], limit: int, *, - first: 'ListFirstMetadata' = None, - next: 'ListNextMetadata' = None, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, ) -> None: """ - Initialize a BuildRunList object. + Initialize a JobRunList object. - :param List[BuildRun] build_runs: List of all build runs. + :param List[JobRun] job_runs: List of all jobs. :param int limit: Maximum number of resources per page. :param ListFirstMetadata first: (optional) Describes properties needed to retrieve the first page of a result list. :param ListNextMetadata next: (optional) Describes properties needed to retrieve the next page of a result list. """ - self.build_runs = build_runs self.first = first + self.job_runs = job_runs self.limit = limit self.next = next @classmethod - def from_dict(cls, _dict: Dict) -> 'BuildRunList': - """Initialize a BuildRunList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'JobRunList': + """Initialize a JobRunList object from a json dictionary.""" args = {} - if 'build_runs' in _dict: - args['build_runs'] = [BuildRun.from_dict(v) for v in _dict.get('build_runs')] + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (job_runs := _dict.get('job_runs')) is not None: + args['job_runs'] = [JobRun.from_dict(v) for v in job_runs] else: - raise ValueError('Required property \'build_runs\' not present in BuildRunList JSON') - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') + raise ValueError('Required property \'job_runs\' not present in JobRunList JSON') + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit else: - raise ValueError('Required property \'limit\' not present in BuildRunList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) + raise ValueError('Required property \'limit\' not present in JobRunList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a BuildRunList object from a json dictionary.""" + """Initialize a JobRunList object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'build_runs') and self.build_runs is not None: - build_runs_list = [] - for v in self.build_runs: - if isinstance(v, dict): - build_runs_list.append(v) - else: - build_runs_list.append(v.to_dict()) - _dict['build_runs'] = build_runs_list if hasattr(self, 'first') and self.first is not None: if isinstance(self.first, dict): _dict['first'] = self.first else: _dict['first'] = self.first.to_dict() + if hasattr(self, 'job_runs') and self.job_runs is not None: + job_runs_list = [] + for v in self.job_runs: + if isinstance(v, dict): + job_runs_list.append(v) + else: + job_runs_list.append(v.to_dict()) + _dict['job_runs'] = job_runs_list if hasattr(self, 'limit') and self.limit is not None: _dict['limit'] = self.limit if hasattr(self, 'next') and self.next is not None: @@ -4982,60 +11029,104 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this BuildRunList object.""" + """Return a `str` version of this JobRunList object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'BuildRunList') -> bool: + def __eq__(self, other: 'JobRunList') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'BuildRunList') -> bool: + def __ne__(self, other: 'JobRunList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class BuildRunStatus: +class JobRunStatus: """ - Current status condition of a build run. + The detailed status of the job run. - :attr str completion_time: (optional) Time the build run completed. - :attr str output_digest: (optional) Describes the time the build run completed. - :attr str reason: (optional) Optional information to provide more context in - case of a 'failed' or 'warning' status. - :attr str start_time: (optional) Time the build run started. + :param str completion_time: (optional) Time the job run completed. + :param int failed: (optional) Number of failed job run instances. + :param str failed_indices: (optional) List of job run indices that failed. + :param int pending: (optional) Number of pending job run instances. + :param str pending_indices: (optional) List of job run indices that are pending. + :param int requested: (optional) Number of requested job run instances. + :param int running: (optional) Number of running job run instances. + :param str running_indices: (optional) List of job run indices that are running. + :param str start_time: (optional) Time the job run started. + :param int succeeded: (optional) Number of succeeded job run instances. + :param str succeeded_indices: (optional) List of job run indices that succeeded. + :param int unknown: (optional) Number of job run instances with unknown state. """ def __init__( - self, *, completion_time: str = None, output_digest: str = None, reason: str = None, start_time: str = None + self, + *, + completion_time: Optional[str] = None, + failed: Optional[int] = None, + failed_indices: Optional[str] = None, + pending: Optional[int] = None, + pending_indices: Optional[str] = None, + requested: Optional[int] = None, + running: Optional[int] = None, + running_indices: Optional[str] = None, + start_time: Optional[str] = None, + succeeded: Optional[int] = None, + succeeded_indices: Optional[str] = None, + unknown: Optional[int] = None, ) -> None: """ - Initialize a BuildRunStatus object. + Initialize a JobRunStatus object. """ self.completion_time = completion_time - self.output_digest = output_digest - self.reason = reason + self.failed = failed + self.failed_indices = failed_indices + self.pending = pending + self.pending_indices = pending_indices + self.requested = requested + self.running = running + self.running_indices = running_indices self.start_time = start_time + self.succeeded = succeeded + self.succeeded_indices = succeeded_indices + self.unknown = unknown @classmethod - def from_dict(cls, _dict: Dict) -> 'BuildRunStatus': - """Initialize a BuildRunStatus object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'JobRunStatus': + """Initialize a JobRunStatus object from a json dictionary.""" args = {} - if 'completion_time' in _dict: - args['completion_time'] = _dict.get('completion_time') - if 'output_digest' in _dict: - args['output_digest'] = _dict.get('output_digest') - if 'reason' in _dict: - args['reason'] = _dict.get('reason') - if 'start_time' in _dict: - args['start_time'] = _dict.get('start_time') + if (completion_time := _dict.get('completion_time')) is not None: + args['completion_time'] = completion_time + if (failed := _dict.get('failed')) is not None: + args['failed'] = failed + if (failed_indices := _dict.get('failed_indices')) is not None: + args['failed_indices'] = failed_indices + if (pending := _dict.get('pending')) is not None: + args['pending'] = pending + if (pending_indices := _dict.get('pending_indices')) is not None: + args['pending_indices'] = pending_indices + if (requested := _dict.get('requested')) is not None: + args['requested'] = requested + if (running := _dict.get('running')) is not None: + args['running'] = running + if (running_indices := _dict.get('running_indices')) is not None: + args['running_indices'] = running_indices + if (start_time := _dict.get('start_time')) is not None: + args['start_time'] = start_time + if (succeeded := _dict.get('succeeded')) is not None: + args['succeeded'] = succeeded + if (succeeded_indices := _dict.get('succeeded_indices')) is not None: + args['succeeded_indices'] = succeeded_indices + if (unknown := _dict.get('unknown')) is not None: + args['unknown'] = unknown return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a BuildRunStatus object from a json dictionary.""" + """Initialize a JobRunStatus object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -5043,12 +11134,28 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'completion_time') and getattr(self, 'completion_time') is not None: _dict['completion_time'] = getattr(self, 'completion_time') - if hasattr(self, 'output_digest') and getattr(self, 'output_digest') is not None: - _dict['output_digest'] = getattr(self, 'output_digest') - if hasattr(self, 'reason') and getattr(self, 'reason') is not None: - _dict['reason'] = getattr(self, 'reason') + if hasattr(self, 'failed') and getattr(self, 'failed') is not None: + _dict['failed'] = getattr(self, 'failed') + if hasattr(self, 'failed_indices') and getattr(self, 'failed_indices') is not None: + _dict['failed_indices'] = getattr(self, 'failed_indices') + if hasattr(self, 'pending') and getattr(self, 'pending') is not None: + _dict['pending'] = getattr(self, 'pending') + if hasattr(self, 'pending_indices') and getattr(self, 'pending_indices') is not None: + _dict['pending_indices'] = getattr(self, 'pending_indices') + if hasattr(self, 'requested') and getattr(self, 'requested') is not None: + _dict['requested'] = getattr(self, 'requested') + if hasattr(self, 'running') and getattr(self, 'running') is not None: + _dict['running'] = getattr(self, 'running') + if hasattr(self, 'running_indices') and getattr(self, 'running_indices') is not None: + _dict['running_indices'] = getattr(self, 'running_indices') if hasattr(self, 'start_time') and getattr(self, 'start_time') is not None: _dict['start_time'] = getattr(self, 'start_time') + if hasattr(self, 'succeeded') and getattr(self, 'succeeded') is not None: + _dict['succeeded'] = getattr(self, 'succeeded') + if hasattr(self, 'succeeded_indices') and getattr(self, 'succeeded_indices') is not None: + _dict['succeeded_indices'] = getattr(self, 'succeeded_indices') + if hasattr(self, 'unknown') and getattr(self, 'unknown') is not None: + _dict['unknown'] = getattr(self, 'unknown') return _dict def _to_dict(self): @@ -5056,77 +11163,123 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this BuildRunStatus object.""" + """Return a `str` version of this JobRunStatus object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'BuildRunStatus') -> bool: + def __eq__(self, other: 'JobRunStatus') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'BuildRunStatus') -> bool: + def __ne__(self, other: 'JobRunStatus') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ReasonEnum(str, Enum): + +class ListFirstMetadata: + """ + Describes properties needed to retrieve the first page of a result list. + + :param str href: (optional) Href that points to the first page. + """ + + def __init__( + self, + *, + href: Optional[str] = None, + ) -> None: """ - Optional information to provide more context in case of a 'failed' or 'warning' - status. + Initialize a ListFirstMetadata object. + + :param str href: (optional) Href that points to the first page. """ + self.href = href - SUCCEEDED = 'succeeded' - RUNNING = 'running' - PENDING = 'pending' - FAILED_TO_EXECUTE_BUILD_RUN = 'failed_to_execute_build_run' - EXCEEDED_EPHEMERAL_STORAGE = 'exceeded_ephemeral_storage' - MISSING_REGISTRY_ACCESS = 'missing_registry_access' - MISSING_CODE_REPO_ACCESS = 'missing_code_repo_access' - MISSING_SECRETS = 'missing_secrets' - UNKNOWN_STRATEGY = 'unknown_strategy' - INVALID_BUILD_CONFIGURATION = 'invalid_build_configuration' - POD_EVICTED_BECAUSE_OF_STORAGE_QUOTA_EXCEEDS = 'pod_evicted_because_of_storage_quota_exceeds' - POD_EVICTED = 'pod_evicted' - MISSING_TASK_RUN = 'missing_task_run' - TASK_RUN_GENERATION_FAILED = 'task_run_generation_failed' - BUILD_NOT_FOUND = 'build_not_found' - TIMEOUT = 'timeout' - FAILED = 'failed' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListFirstMetadata': + """Initialize a ListFirstMetadata object from a json dictionary.""" + args = {} + if (href := _dict.get('href')) is not None: + args['href'] = href + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListFirstMetadata object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ListFirstMetadata object.""" + return json.dumps(self.to_dict(), indent=2) + def __eq__(self, other: 'ListFirstMetadata') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ -class BuildStatus: + def __ne__(self, other: 'ListFirstMetadata') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListNextMetadata: """ - The detailed status of the build. + Describes properties needed to retrieve the next page of a result list. - :attr str reason: (optional) Optional information to provide more context in - case of a 'failed' or 'warning' status. + :param str href: (optional) Href that points to the next page. + :param str start: (optional) Token. """ - def __init__(self, *, reason: str = None) -> None: + def __init__( + self, + *, + href: Optional[str] = None, + start: Optional[str] = None, + ) -> None: """ - Initialize a BuildStatus object. + Initialize a ListNextMetadata object. + :param str href: (optional) Href that points to the next page. + :param str start: (optional) Token. """ - self.reason = reason + self.href = href + self.start = start @classmethod - def from_dict(cls, _dict: Dict) -> 'BuildStatus': - """Initialize a BuildStatus object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ListNextMetadata': + """Initialize a ListNextMetadata object from a json dictionary.""" args = {} - if 'reason' in _dict: - args['reason'] = _dict.get('reason') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (start := _dict.get('start')) is not None: + args['start'] = start return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a BuildStatus object from a json dictionary.""" + """Initialize a ListNextMetadata object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'reason') and getattr(self, 'reason') is not None: - _dict['reason'] = getattr(self, 'reason') + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start return _dict def _to_dict(self): @@ -5134,136 +11287,95 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this BuildStatus object.""" + """Return a `str` version of this ListNextMetadata object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'BuildStatus') -> bool: + def __eq__(self, other: 'ListNextMetadata') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'BuildStatus') -> bool: + def __ne__(self, other: 'ListNextMetadata') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ReasonEnum(str, Enum): - """ - Optional information to provide more context in case of a 'failed' or 'warning' - status. - """ - - REGISTERED = 'registered' - STRATEGY_NOT_FOUND = 'strategy_not_found' - CLUSTER_BUILD_STRATEGY_NOT_FOUND = 'cluster_build_strategy_not_found' - SET_OWNER_REFERENCE_FAILED = 'set_owner_reference_failed' - SPEC_SOURCE_SECRET_NOT_FOUND = 'spec_source_secret_not_found' - SPEC_OUTPUT_SECRET_REF_NOT_FOUND = 'spec_output_secret_ref_not_found' - SPEC_RUNTIME_SECRET_REF_NOT_FOUND = 'spec_runtime_secret_ref_not_found' - MULTIPLE_SECRET_REF_NOT_FOUND = 'multiple_secret_ref_not_found' - RUNTIME_PATHS_CAN_NOT_BE_EMPTY = 'runtime_paths_can_not_be_empty' - REMOTE_REPOSITORY_UNREACHABLE = 'remote_repository_unreachable' - FAILED = 'failed' - -class ConfigMap: +class OperatorSecretProps: """ - Describes the model of a configmap. + Properties for the IBM Cloud Operator Secret. - :attr str created_at: (optional) The date when the resource was created. - :attr dict data: (optional) The key-value pair for the config map. Values must - be specified in `KEY=VALUE` format. - :attr str entity_tag: The version of the config map instance, which is used to - achieve optimistic locking. - :attr str href: (optional) When you provision a new config map, a URL is - created identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr str name: The name of the config map. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the config map. + :param str apikey_id: The ID of the apikey associated with the operator secret. + :param List[str] resource_group_ids: The list of resource groups (by ID) that + the operator secret can bind services in. + :param ServiceIDRef serviceid: A reference to a Service ID. + :param bool user_managed: Specifies whether the operator secret is user managed. """ def __init__( self, - entity_tag: str, - name: str, - *, - created_at: str = None, - data: dict = None, - href: str = None, - id: str = None, - project_id: str = None, - resource_type: str = None, + apikey_id: str, + resource_group_ids: List[str], + serviceid: 'ServiceIDRef', + user_managed: bool, ) -> None: """ - Initialize a ConfigMap object. + Initialize a OperatorSecretProps object. - :param str entity_tag: The version of the config map instance, which is - used to achieve optimistic locking. - :param str name: The name of the config map. - :param dict data: (optional) The key-value pair for the config map. Values - must be specified in `KEY=VALUE` format. + :param str apikey_id: The ID of the apikey associated with the operator + secret. + :param List[str] resource_group_ids: The list of resource groups (by ID) + that the operator secret can bind services in. + :param ServiceIDRef serviceid: A reference to a Service ID. + :param bool user_managed: Specifies whether the operator secret is user + managed. """ - self.created_at = created_at - self.data = data - self.entity_tag = entity_tag - self.href = href - self.id = id - self.name = name - self.project_id = project_id - self.resource_type = resource_type + self.apikey_id = apikey_id + self.resource_group_ids = resource_group_ids + self.serviceid = serviceid + self.user_managed = user_managed @classmethod - def from_dict(cls, _dict: Dict) -> 'ConfigMap': - """Initialize a ConfigMap object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'OperatorSecretProps': + """Initialize a OperatorSecretProps object from a json dictionary.""" args = {} - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'data' in _dict: - args['data'] = _dict.get('data') - if 'entity_tag' in _dict: - args['entity_tag'] = _dict.get('entity_tag') + if (apikey_id := _dict.get('apikey_id')) is not None: + args['apikey_id'] = apikey_id else: - raise ValueError('Required property \'entity_tag\' not present in ConfigMap JSON') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'name' in _dict: - args['name'] = _dict.get('name') + raise ValueError('Required property \'apikey_id\' not present in OperatorSecretProps JSON') + if (resource_group_ids := _dict.get('resource_group_ids')) is not None: + args['resource_group_ids'] = resource_group_ids else: - raise ValueError('Required property \'name\' not present in ConfigMap JSON') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') + raise ValueError('Required property \'resource_group_ids\' not present in OperatorSecretProps JSON') + if (serviceid := _dict.get('serviceid')) is not None: + args['serviceid'] = ServiceIDRef.from_dict(serviceid) + else: + raise ValueError('Required property \'serviceid\' not present in OperatorSecretProps JSON') + if (user_managed := _dict.get('user_managed')) is not None: + args['user_managed'] = user_managed + else: + raise ValueError('Required property \'user_managed\' not present in OperatorSecretProps JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ConfigMap object from a json dictionary.""" + """Initialize a OperatorSecretProps object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = getattr(self, 'created_at') - if hasattr(self, 'data') and self.data is not None: - _dict['data'] = self.data - if hasattr(self, 'entity_tag') and self.entity_tag is not None: - _dict['entity_tag'] = self.entity_tag - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: - _dict['project_id'] = getattr(self, 'project_id') - if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: - _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'apikey_id') and self.apikey_id is not None: + _dict['apikey_id'] = self.apikey_id + if hasattr(self, 'resource_group_ids') and self.resource_group_ids is not None: + _dict['resource_group_ids'] = self.resource_group_ids + if hasattr(self, 'serviceid') and self.serviceid is not None: + if isinstance(self.serviceid, dict): + _dict['serviceid'] = self.serviceid + else: + _dict['serviceid'] = self.serviceid.to_dict() + if hasattr(self, 'user_managed') and self.user_managed is not None: + _dict['user_managed'] = self.user_managed return _dict def _to_dict(self): @@ -5271,108 +11383,72 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ConfigMap object.""" + """Return a `str` version of this OperatorSecretProps object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ConfigMap') -> bool: + def __eq__(self, other: 'OperatorSecretProps') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ConfigMap') -> bool: + def __ne__(self, other: 'OperatorSecretProps') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ResourceTypeEnum(str, Enum): - """ - The type of the config map. - """ - CONFIG_MAP_V2 = 'config_map_v2' - - -class ConfigMapList: +class OperatorSecretPrototypeProps: """ - Contains a list of configmaps and pagination information. + Properties for the IBM Cloud Operator Secrets. - :attr List[ConfigMap] config_maps: List of all configmaps. - :attr ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve - the next page of a result list. + :param List[str] resource_group_ids: (optional) The list of resource groups (by + ID) that the operator secret can bind services in. + :param ServiceIDRefPrototype serviceid: (optional) A reference to the Service + ID. """ def __init__( self, - config_maps: List['ConfigMap'], - limit: int, *, - first: 'ListFirstMetadata' = None, - next: 'ListNextMetadata' = None, + resource_group_ids: Optional[List[str]] = None, + serviceid: Optional['ServiceIDRefPrototype'] = None, ) -> None: """ - Initialize a ConfigMapList object. + Initialize a OperatorSecretPrototypeProps object. - :param List[ConfigMap] config_maps: List of all configmaps. - :param int limit: Maximum number of resources per page. - :param ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :param ListNextMetadata next: (optional) Describes properties needed to - retrieve the next page of a result list. + :param List[str] resource_group_ids: (optional) The list of resource groups + (by ID) that the operator secret can bind services in. + :param ServiceIDRefPrototype serviceid: (optional) A reference to the + Service ID. """ - self.config_maps = config_maps - self.first = first - self.limit = limit - self.next = next + self.resource_group_ids = resource_group_ids + self.serviceid = serviceid @classmethod - def from_dict(cls, _dict: Dict) -> 'ConfigMapList': - """Initialize a ConfigMapList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'OperatorSecretPrototypeProps': + """Initialize a OperatorSecretPrototypeProps object from a json dictionary.""" args = {} - if 'config_maps' in _dict: - args['config_maps'] = [ConfigMap.from_dict(v) for v in _dict.get('config_maps')] - else: - raise ValueError('Required property \'config_maps\' not present in ConfigMapList JSON') - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in ConfigMapList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) + if (resource_group_ids := _dict.get('resource_group_ids')) is not None: + args['resource_group_ids'] = resource_group_ids + if (serviceid := _dict.get('serviceid')) is not None: + args['serviceid'] = ServiceIDRefPrototype.from_dict(serviceid) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ConfigMapList object from a json dictionary.""" + """Initialize a OperatorSecretPrototypeProps object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'config_maps') and self.config_maps is not None: - config_maps_list = [] - for v in self.config_maps: - if isinstance(v, dict): - config_maps_list.append(v) - else: - config_maps_list.append(v.to_dict()) - _dict['config_maps'] = config_maps_list - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next + if hasattr(self, 'resource_group_ids') and self.resource_group_ids is not None: + _dict['resource_group_ids'] = self.resource_group_ids + if hasattr(self, 'serviceid') and self.serviceid is not None: + if isinstance(self.serviceid, dict): + _dict['serviceid'] = self.serviceid else: - _dict['next'] = self.next.to_dict() + _dict['serviceid'] = self.serviceid.to_dict() return _dict def _to_dict(self): @@ -5380,101 +11456,117 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ConfigMapList object.""" + """Return a `str` version of this OperatorSecretPrototypeProps object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ConfigMapList') -> bool: + def __eq__(self, other: 'OperatorSecretPrototypeProps') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ConfigMapList') -> bool: + def __ne__(self, other: 'OperatorSecretPrototypeProps') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class EnvVar: +class Probe: """ - Response model for environment variables. - - :attr str key: (optional) The key to reference as environment variable. - :attr str name: (optional) The name of the environment variable. - :attr str prefix: (optional) A prefix that can be added to all keys of a full - secret or config map reference. - :attr str reference: (optional) The name of the secret or config map. - :attr str type: Specify the type of the environment variable. - :attr str value: (optional) The literal value of the environment variable. + Response model for probes. + + :param int failure_threshold: (optional) The number of consecutive, unsuccessful + checks for the probe to be considered failed. + :param int initial_delay: (optional) The amount of time in seconds to wait + before the first probe check is performed. + :param int interval: (optional) The amount of time in seconds between probe + checks. + :param str path: (optional) The path of the HTTP request to the resource. A path + is only supported for a probe with a `type` of `http`. + :param int port: (optional) The port on which to probe the resource. + :param int timeout: (optional) The amount of time in seconds that the probe + waits for a response from the application before it times out and fails. + :param str type: (optional) Specifies whether to use HTTP or TCP for the probe + checks. The default is TCP. """ def __init__( self, - type: str, *, - key: str = None, - name: str = None, - prefix: str = None, - reference: str = None, - value: str = None, + failure_threshold: Optional[int] = None, + initial_delay: Optional[int] = None, + interval: Optional[int] = None, + path: Optional[str] = None, + port: Optional[int] = None, + timeout: Optional[int] = None, + type: Optional[str] = None, ) -> None: """ - Initialize a EnvVar object. - - :param str type: Specify the type of the environment variable. - :param str key: (optional) The key to reference as environment variable. - :param str name: (optional) The name of the environment variable. - :param str prefix: (optional) A prefix that can be added to all keys of a - full secret or config map reference. - :param str reference: (optional) The name of the secret or config map. - :param str value: (optional) The literal value of the environment variable. - """ - self.key = key - self.name = name - self.prefix = prefix - self.reference = reference + Initialize a Probe object. + + :param int failure_threshold: (optional) The number of consecutive, + unsuccessful checks for the probe to be considered failed. + :param int initial_delay: (optional) The amount of time in seconds to wait + before the first probe check is performed. + :param int interval: (optional) The amount of time in seconds between probe + checks. + :param str path: (optional) The path of the HTTP request to the resource. A + path is only supported for a probe with a `type` of `http`. + :param int port: (optional) The port on which to probe the resource. + :param int timeout: (optional) The amount of time in seconds that the probe + waits for a response from the application before it times out and fails. + :param str type: (optional) Specifies whether to use HTTP or TCP for the + probe checks. The default is TCP. + """ + self.failure_threshold = failure_threshold + self.initial_delay = initial_delay + self.interval = interval + self.path = path + self.port = port + self.timeout = timeout self.type = type - self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'EnvVar': - """Initialize a EnvVar object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Probe': + """Initialize a Probe object from a json dictionary.""" args = {} - if 'key' in _dict: - args['key'] = _dict.get('key') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'prefix' in _dict: - args['prefix'] = _dict.get('prefix') - if 'reference' in _dict: - args['reference'] = _dict.get('reference') - if 'type' in _dict: - args['type'] = _dict.get('type') - else: - raise ValueError('Required property \'type\' not present in EnvVar JSON') - if 'value' in _dict: - args['value'] = _dict.get('value') + if (failure_threshold := _dict.get('failure_threshold')) is not None: + args['failure_threshold'] = failure_threshold + if (initial_delay := _dict.get('initial_delay')) is not None: + args['initial_delay'] = initial_delay + if (interval := _dict.get('interval')) is not None: + args['interval'] = interval + if (path := _dict.get('path')) is not None: + args['path'] = path + if (port := _dict.get('port')) is not None: + args['port'] = port + if (timeout := _dict.get('timeout')) is not None: + args['timeout'] = timeout + if (type := _dict.get('type')) is not None: + args['type'] = type return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a EnvVar object from a json dictionary.""" + """Initialize a Probe object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'key') and self.key is not None: - _dict['key'] = self.key - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'prefix') and self.prefix is not None: - _dict['prefix'] = self.prefix - if hasattr(self, 'reference') and self.reference is not None: - _dict['reference'] = self.reference + if hasattr(self, 'failure_threshold') and self.failure_threshold is not None: + _dict['failure_threshold'] = self.failure_threshold + if hasattr(self, 'initial_delay') and self.initial_delay is not None: + _dict['initial_delay'] = self.initial_delay + if hasattr(self, 'interval') and self.interval is not None: + _dict['interval'] = self.interval + if hasattr(self, 'path') and self.path is not None: + _dict['path'] = self.path + if hasattr(self, 'port') and self.port is not None: + _dict['port'] = self.port + if hasattr(self, 'timeout') and self.timeout is not None: + _dict['timeout'] = self.timeout if hasattr(self, 'type') and self.type is not None: _dict['type'] = self.type - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value return _dict def _to_dict(self): @@ -5482,110 +11574,125 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this EnvVar object.""" + """Return a `str` version of this Probe object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'EnvVar') -> bool: + def __eq__(self, other: 'Probe') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'EnvVar') -> bool: + def __ne__(self, other: 'Probe') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class TypeEnum(str, Enum): """ - Specify the type of the environment variable. + Specifies whether to use HTTP or TCP for the probe checks. The default is TCP. """ - LITERAL = 'literal' - CONFIG_MAP_FULL_REFERENCE = 'config_map_full_reference' - SECRET_FULL_REFERENCE = 'secret_full_reference' - CONFIG_MAP_KEY_REFERENCE = 'config_map_key_reference' - SECRET_KEY_REFERENCE = 'secret_key_reference' + TCP = 'tcp' + HTTP = 'http' -class EnvVarPrototype: +class ProbePrototype: """ - Prototype model for environment variables. - - :attr str key: (optional) The key to reference as environment variable. - :attr str name: (optional) The name of the environment variable. - :attr str prefix: (optional) A prefix that can be added to all keys of a full - secret or config map reference. - :attr str reference: (optional) The name of the secret or config map. - :attr str type: (optional) Specify the type of the environment variable. - :attr str value: (optional) The literal value of the environment variable. + Request model for probes. + + :param int failure_threshold: (optional) The number of consecutive, unsuccessful + checks for the probe to be considered failed. + :param int initial_delay: (optional) The amount of time in seconds to wait + before the first probe check is performed. + :param int interval: (optional) The amount of time in seconds between probe + checks. + :param str path: (optional) The path of the HTTP request to the resource. A path + is only supported for a probe with a `type` of `http`. + :param int port: (optional) The port on which to probe the resource. + :param int timeout: (optional) The amount of time in seconds that the probe + waits for a response from the application before it times out and fails. + :param str type: (optional) Specifies whether to use HTTP or TCP for the probe + checks. The default is TCP. """ def __init__( self, *, - key: str = None, - name: str = None, - prefix: str = None, - reference: str = None, - type: str = None, - value: str = None, + failure_threshold: Optional[int] = None, + initial_delay: Optional[int] = None, + interval: Optional[int] = None, + path: Optional[str] = None, + port: Optional[int] = None, + timeout: Optional[int] = None, + type: Optional[str] = None, ) -> None: """ - Initialize a EnvVarPrototype object. - - :param str key: (optional) The key to reference as environment variable. - :param str name: (optional) The name of the environment variable. - :param str prefix: (optional) A prefix that can be added to all keys of a - full secret or config map reference. - :param str reference: (optional) The name of the secret or config map. - :param str type: (optional) Specify the type of the environment variable. - :param str value: (optional) The literal value of the environment variable. - """ - self.key = key - self.name = name - self.prefix = prefix - self.reference = reference + Initialize a ProbePrototype object. + + :param int failure_threshold: (optional) The number of consecutive, + unsuccessful checks for the probe to be considered failed. + :param int initial_delay: (optional) The amount of time in seconds to wait + before the first probe check is performed. + :param int interval: (optional) The amount of time in seconds between probe + checks. + :param str path: (optional) The path of the HTTP request to the resource. A + path is only supported for a probe with a `type` of `http`. + :param int port: (optional) The port on which to probe the resource. + :param int timeout: (optional) The amount of time in seconds that the probe + waits for a response from the application before it times out and fails. + :param str type: (optional) Specifies whether to use HTTP or TCP for the + probe checks. The default is TCP. + """ + self.failure_threshold = failure_threshold + self.initial_delay = initial_delay + self.interval = interval + self.path = path + self.port = port + self.timeout = timeout self.type = type - self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'EnvVarPrototype': - """Initialize a EnvVarPrototype object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ProbePrototype': + """Initialize a ProbePrototype object from a json dictionary.""" args = {} - if 'key' in _dict: - args['key'] = _dict.get('key') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'prefix' in _dict: - args['prefix'] = _dict.get('prefix') - if 'reference' in _dict: - args['reference'] = _dict.get('reference') - if 'type' in _dict: - args['type'] = _dict.get('type') - if 'value' in _dict: - args['value'] = _dict.get('value') + if (failure_threshold := _dict.get('failure_threshold')) is not None: + args['failure_threshold'] = failure_threshold + if (initial_delay := _dict.get('initial_delay')) is not None: + args['initial_delay'] = initial_delay + if (interval := _dict.get('interval')) is not None: + args['interval'] = interval + if (path := _dict.get('path')) is not None: + args['path'] = path + if (port := _dict.get('port')) is not None: + args['port'] = port + if (timeout := _dict.get('timeout')) is not None: + args['timeout'] = timeout + if (type := _dict.get('type')) is not None: + args['type'] = type return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a EnvVarPrototype object from a json dictionary.""" + """Initialize a ProbePrototype object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'key') and self.key is not None: - _dict['key'] = self.key - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'prefix') and self.prefix is not None: - _dict['prefix'] = self.prefix - if hasattr(self, 'reference') and self.reference is not None: - _dict['reference'] = self.reference + if hasattr(self, 'failure_threshold') and self.failure_threshold is not None: + _dict['failure_threshold'] = self.failure_threshold + if hasattr(self, 'initial_delay') and self.initial_delay is not None: + _dict['initial_delay'] = self.initial_delay + if hasattr(self, 'interval') and self.interval is not None: + _dict['interval'] = self.interval + if hasattr(self, 'path') and self.path is not None: + _dict['path'] = self.path + if hasattr(self, 'port') and self.port is not None: + _dict['port'] = self.port + if hasattr(self, 'timeout') and self.timeout is not None: + _dict['timeout'] = self.timeout if hasattr(self, 'type') and self.type is not None: _dict['type'] = self.type - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value return _dict def _to_dict(self): @@ -5593,368 +11700,139 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this EnvVarPrototype object.""" + """Return a `str` version of this ProbePrototype object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'EnvVarPrototype') -> bool: + def __eq__(self, other: 'ProbePrototype') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'EnvVarPrototype') -> bool: + def __ne__(self, other: 'ProbePrototype') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class TypeEnum(str, Enum): """ - Specify the type of the environment variable. + Specifies whether to use HTTP or TCP for the probe checks. The default is TCP. """ - LITERAL = 'literal' - CONFIG_MAP_FULL_REFERENCE = 'config_map_full_reference' - SECRET_FULL_REFERENCE = 'secret_full_reference' - CONFIG_MAP_KEY_REFERENCE = 'config_map_key_reference' - SECRET_KEY_REFERENCE = 'secret_key_reference' + TCP = 'tcp' + HTTP = 'http' -class Job: +class Project: """ - Job is the response model for job resources. + Describes the model of a project. - :attr str created_at: (optional) The date when the resource was created. - :attr str entity_tag: The version of the job instance, which is used to achieve - optimistic locking. - :attr str href: (optional) When you provision a new job, a URL is created + :param str account_id: (optional) An alphanumeric value identifying the account + ID. + :param str created_at: (optional) The timestamp when the project was created. + :param str crn: (optional) The CRN of the project. + :param str href: (optional) When you provision a new resource, a URL is created identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr str image_reference: The name of the image that is used for this job. The - format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are - optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` - is not specified, the default is `latest`. If the image reference points to a - registry that requires authentication, make sure to also specify the property - `image_secret`. - :attr str image_secret: (optional) The name of the image registry access secret. - The image registry access secret is used to authenticate with a private registry - when you download the container image. If the image reference points to a - registry that requires authentication, the job / job runs will be created but - submitted job runs will fail, until this property is provided, too. This - property must not be set on a job run, which references a job template. - :attr str name: The name of the job. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the job. - :attr List[str] run_arguments: Set arguments for the job that are passed to - start job run containers. If not specified an empty string array will be applied - and the arguments specified by the container image, will be used to start the - container. - :attr int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). - :attr List[str] run_commands: Set commands for the job that are passed to start - job run containers. If not specified an empty string array will be applied and - the command specified by the container image, will be used to start the - container. - :attr List[EnvVar] run_env_variables: References to config maps, secrets or a - literal values, which are exposed as environment variables in the job run. - :attr str run_mode: The mode for runs of the job. Valid values are `task` and - `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` properties - apply. In `daemon` mode, since there is no timeout and failed instances are - restarted indefinitely, the `max_execution_time` and `retry_limit` properties - are not allowed. - :attr str run_service_account: (optional) The name of the service account. For - built-in service accounts, you can use the shortened names `manager`, `none`, - `reader`, and `writer`. This property must not be set on a job run, which - references a job template. - :attr List[VolumeMount] run_volume_mounts: Optional mounts of config maps or a - secrets. - :attr str scale_array_spec: Define a custom set of array indices as - comma-separated list containing single values and hyphen-separated ranges like - `5,12-14,23,27`. Each instance can pick up its array index via environment - variable `JOB_INDEX`. The number of unique array indices specified here - determines the number of job instances to run. - :attr str scale_cpu_limit: Optional amount of CPU set for the instance of the - job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :attr str scale_ephemeral_storage_limit: Optional amount of ephemeral storage to - set for the instance of the job. The amount specified as ephemeral storage, must - not exceed the amount of `scale_memory_limit`. The units for specifying - ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M are the - shorthand expressions for GB and MB. For more information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_max_execution_time: (optional) The maximum execution time in - seconds for runs of the job. This property can only be specified if `run_mode` - is `task`. - :attr str scale_memory_limit: Optional amount of memory set for the instance of - the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and - M are the shorthand expressions for GB and MB. For more information see [Units - of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_retry_limit: (optional) The number of times to rerun an instance - of the job before the job is marked as failed. This property can only be - specified if `run_mode` is `task`. + :param str id: (optional) The ID of the project. + :param str name: The name of the project. + :param str region: (optional) The region for your project deployment. Possible + values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', + 'us-east', 'us-south'. + :param str resource_group_id: The ID of the resource group. + :param str resource_type: (optional) The type of the project. + :param str status: (optional) The current state of the project. For example, + when the project is created and is ready for use, the status of the project is + active. """ def __init__( self, - entity_tag: str, - image_reference: str, name: str, - run_arguments: List[str], - run_commands: List[str], - run_env_variables: List['EnvVar'], - run_mode: str, - run_volume_mounts: List['VolumeMount'], - scale_array_spec: str, - scale_cpu_limit: str, - scale_ephemeral_storage_limit: str, - scale_memory_limit: str, + resource_group_id: str, *, - created_at: str = None, - href: str = None, - id: str = None, - image_secret: str = None, - project_id: str = None, - resource_type: str = None, - run_as_user: int = None, - run_service_account: str = None, - scale_max_execution_time: int = None, - scale_retry_limit: int = None, + account_id: Optional[str] = None, + created_at: Optional[str] = None, + crn: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + status: Optional[str] = None, ) -> None: """ - Initialize a Job object. + Initialize a Project object. - :param str entity_tag: The version of the job instance, which is used to - achieve optimistic locking. - :param str image_reference: The name of the image that is used for this - job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and - `TAG` are optional. If `REGISTRY` is not specified, the default is - `docker.io`. If `TAG` is not specified, the default is `latest`. If the - image reference points to a registry that requires authentication, make - sure to also specify the property `image_secret`. - :param str name: The name of the job. - :param List[str] run_arguments: Set arguments for the job that are passed - to start job run containers. If not specified an empty string array will be - applied and the arguments specified by the container image, will be used to - start the container. - :param List[str] run_commands: Set commands for the job that are passed to - start job run containers. If not specified an empty string array will be - applied and the command specified by the container image, will be used to - start the container. - :param List[EnvVar] run_env_variables: References to config maps, secrets - or a literal values, which are exposed as environment variables in the job - run. - :param str run_mode: The mode for runs of the job. Valid values are `task` - and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` - properties apply. In `daemon` mode, since there is no timeout and failed - instances are restarted indefinitely, the `max_execution_time` and - `retry_limit` properties are not allowed. - :param List[VolumeMount] run_volume_mounts: Optional mounts of config maps - or a secrets. - :param str scale_array_spec: Define a custom set of array indices as - comma-separated list containing single values and hyphen-separated ranges - like `5,12-14,23,27`. Each instance can pick up its array index via - environment variable `JOB_INDEX`. The number of unique array indices - specified here determines the number of job instances to run. - :param str scale_cpu_limit: Optional amount of CPU set for the instance of - the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :param str scale_ephemeral_storage_limit: Optional amount of ephemeral - storage to set for the instance of the job. The amount specified as - ephemeral storage, must not exceed the amount of `scale_memory_limit`. The - units for specifying ephemeral storage are Megabyte (M) or Gigabyte (G), - whereas G and M are the shorthand expressions for GB and MB. For more - information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param str scale_memory_limit: Optional amount of memory set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G - and M are the shorthand expressions for GB and MB. For more information see - [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param str image_secret: (optional) The name of the image registry access - secret. The image registry access secret is used to authenticate with a - private registry when you download the container image. If the image - reference points to a registry that requires authentication, the job / job - runs will be created but submitted job runs will fail, until this property - is provided, too. This property must not be set on a job run, which - references a job template. - :param int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). - :param str run_service_account: (optional) The name of the service account. - For built-in service accounts, you can use the shortened names `manager`, - `none`, `reader`, and `writer`. This property must not be set on a job run, - which references a job template. - :param int scale_max_execution_time: (optional) The maximum execution time - in seconds for runs of the job. This property can only be specified if - `run_mode` is `task`. - :param int scale_retry_limit: (optional) The number of times to rerun an - instance of the job before the job is marked as failed. This property can - only be specified if `run_mode` is `task`. + :param str name: The name of the project. + :param str resource_group_id: The ID of the resource group. """ + self.account_id = account_id self.created_at = created_at - self.entity_tag = entity_tag + self.crn = crn self.href = href self.id = id - self.image_reference = image_reference - self.image_secret = image_secret self.name = name - self.project_id = project_id + self.region = region + self.resource_group_id = resource_group_id self.resource_type = resource_type - self.run_arguments = run_arguments - self.run_as_user = run_as_user - self.run_commands = run_commands - self.run_env_variables = run_env_variables - self.run_mode = run_mode - self.run_service_account = run_service_account - self.run_volume_mounts = run_volume_mounts - self.scale_array_spec = scale_array_spec - self.scale_cpu_limit = scale_cpu_limit - self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit - self.scale_max_execution_time = scale_max_execution_time - self.scale_memory_limit = scale_memory_limit - self.scale_retry_limit = scale_retry_limit + self.status = status @classmethod - def from_dict(cls, _dict: Dict) -> 'Job': - """Initialize a Job object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Project': + """Initialize a Project object from a json dictionary.""" args = {} - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'entity_tag' in _dict: - args['entity_tag'] = _dict.get('entity_tag') - else: - raise ValueError('Required property \'entity_tag\' not present in Job JSON') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'image_reference' in _dict: - args['image_reference'] = _dict.get('image_reference') - else: - raise ValueError('Required property \'image_reference\' not present in Job JSON') - if 'image_secret' in _dict: - args['image_secret'] = _dict.get('image_secret') - if 'name' in _dict: - args['name'] = _dict.get('name') - else: - raise ValueError('Required property \'name\' not present in Job JSON') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'run_arguments' in _dict: - args['run_arguments'] = _dict.get('run_arguments') - else: - raise ValueError('Required property \'run_arguments\' not present in Job JSON') - if 'run_as_user' in _dict: - args['run_as_user'] = _dict.get('run_as_user') - if 'run_commands' in _dict: - args['run_commands'] = _dict.get('run_commands') - else: - raise ValueError('Required property \'run_commands\' not present in Job JSON') - if 'run_env_variables' in _dict: - args['run_env_variables'] = [EnvVar.from_dict(v) for v in _dict.get('run_env_variables')] - else: - raise ValueError('Required property \'run_env_variables\' not present in Job JSON') - if 'run_mode' in _dict: - args['run_mode'] = _dict.get('run_mode') - else: - raise ValueError('Required property \'run_mode\' not present in Job JSON') - if 'run_service_account' in _dict: - args['run_service_account'] = _dict.get('run_service_account') - if 'run_volume_mounts' in _dict: - args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in _dict.get('run_volume_mounts')] - else: - raise ValueError('Required property \'run_volume_mounts\' not present in Job JSON') - if 'scale_array_spec' in _dict: - args['scale_array_spec'] = _dict.get('scale_array_spec') - else: - raise ValueError('Required property \'scale_array_spec\' not present in Job JSON') - if 'scale_cpu_limit' in _dict: - args['scale_cpu_limit'] = _dict.get('scale_cpu_limit') - else: - raise ValueError('Required property \'scale_cpu_limit\' not present in Job JSON') - if 'scale_ephemeral_storage_limit' in _dict: - args['scale_ephemeral_storage_limit'] = _dict.get('scale_ephemeral_storage_limit') + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'scale_ephemeral_storage_limit\' not present in Job JSON') - if 'scale_max_execution_time' in _dict: - args['scale_max_execution_time'] = _dict.get('scale_max_execution_time') - if 'scale_memory_limit' in _dict: - args['scale_memory_limit'] = _dict.get('scale_memory_limit') + raise ValueError('Required property \'name\' not present in Project JSON') + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_group_id := _dict.get('resource_group_id')) is not None: + args['resource_group_id'] = resource_group_id else: - raise ValueError('Required property \'scale_memory_limit\' not present in Job JSON') - if 'scale_retry_limit' in _dict: - args['scale_retry_limit'] = _dict.get('scale_retry_limit') + raise ValueError('Required property \'resource_group_id\' not present in Project JSON') + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (status := _dict.get('status')) is not None: + args['status'] = status return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Job object from a json dictionary.""" + """Initialize a Project object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: + _dict['account_id'] = getattr(self, 'account_id') if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: _dict['created_at'] = getattr(self, 'created_at') - if hasattr(self, 'entity_tag') and self.entity_tag is not None: - _dict['entity_tag'] = self.entity_tag + if hasattr(self, 'crn') and getattr(self, 'crn') is not None: + _dict['crn'] = getattr(self, 'crn') if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'image_reference') and self.image_reference is not None: - _dict['image_reference'] = self.image_reference - if hasattr(self, 'image_secret') and self.image_secret is not None: - _dict['image_secret'] = self.image_secret if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name - if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: - _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_group_id') and self.resource_group_id is not None: + _dict['resource_group_id'] = self.resource_group_id if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'run_arguments') and self.run_arguments is not None: - _dict['run_arguments'] = self.run_arguments - if hasattr(self, 'run_as_user') and self.run_as_user is not None: - _dict['run_as_user'] = self.run_as_user - if hasattr(self, 'run_commands') and self.run_commands is not None: - _dict['run_commands'] = self.run_commands - if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: - run_env_variables_list = [] - for v in self.run_env_variables: - if isinstance(v, dict): - run_env_variables_list.append(v) - else: - run_env_variables_list.append(v.to_dict()) - _dict['run_env_variables'] = run_env_variables_list - if hasattr(self, 'run_mode') and self.run_mode is not None: - _dict['run_mode'] = self.run_mode - if hasattr(self, 'run_service_account') and self.run_service_account is not None: - _dict['run_service_account'] = self.run_service_account - if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: - run_volume_mounts_list = [] - for v in self.run_volume_mounts: - if isinstance(v, dict): - run_volume_mounts_list.append(v) - else: - run_volume_mounts_list.append(v.to_dict()) - _dict['run_volume_mounts'] = run_volume_mounts_list - if hasattr(self, 'scale_array_spec') and self.scale_array_spec is not None: - _dict['scale_array_spec'] = self.scale_array_spec - if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: - _dict['scale_cpu_limit'] = self.scale_cpu_limit - if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: - _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit - if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: - _dict['scale_max_execution_time'] = self.scale_max_execution_time - if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: - _dict['scale_memory_limit'] = self.scale_memory_limit - if hasattr(self, 'scale_retry_limit') and self.scale_retry_limit is not None: - _dict['scale_retry_limit'] = self.scale_retry_limit + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') return _dict def _to_dict(self): @@ -5962,127 +11840,92 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Job object.""" + """Return a `str` version of this Project object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Job') -> bool: + def __eq__(self, other: 'Project') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Job') -> bool: + def __ne__(self, other: 'Project') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class ResourceTypeEnum(str, Enum): """ - The type of the job. - """ - - JOB_V2 = 'job_v2' - - class RunModeEnum(str, Enum): - """ - The mode for runs of the job. Valid values are `task` and `daemon`. In `task` - mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` - mode, since there is no timeout and failed instances are restarted indefinitely, - the `max_execution_time` and `retry_limit` properties are not allowed. + The type of the project. """ - TASK = 'task' - DAEMON = 'daemon' + PROJECT_V2 = 'project_v2' - class RunServiceAccountEnum(str, Enum): - """ - The name of the service account. For built-in service accounts, you can use the - shortened names `manager`, `none`, `reader`, and `writer`. This property must not - be set on a job run, which references a job template. + class StatusEnum(str, Enum): """ - - DEFAULT = 'default' - MANAGER = 'manager' - READER = 'reader' - WRITER = 'writer' - NONE = 'none' + The current state of the project. For example, when the project is created and is + ready for use, the status of the project is active. + """ + + ACTIVE = 'active' + INACTIVE = 'inactive' + PENDING_REMOVAL = 'pending_removal' + HARD_DELETING = 'hard_deleting' + HARD_DELETION_FAILED = 'hard_deletion_failed' + HARD_DELETED = 'hard_deleted' + DELETING = 'deleting' + DELETION_FAILED = 'deletion_failed' + SOFT_DELETED = 'soft_deleted' + PREPARING = 'preparing' + CREATING = 'creating' + CREATION_FAILED = 'creation_failed' -class JobList: +class ProjectEgressIPAddresses: """ - Contains a list of jobs and pagination information. + Describes the model of egress IP addresses. - :attr ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :attr List[Job] jobs: List of all jobs. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve - the next page of a result list. + :param List[str] private: (optional) List of IBM private network IP addresses. + :param List[str] public: (optional) List of public IP addresses. """ def __init__( - self, jobs: List['Job'], limit: int, *, first: 'ListFirstMetadata' = None, next: 'ListNextMetadata' = None + self, + *, + private: Optional[List[str]] = None, + public: Optional[List[str]] = None, ) -> None: """ - Initialize a JobList object. + Initialize a ProjectEgressIPAddresses object. - :param List[Job] jobs: List of all jobs. - :param int limit: Maximum number of resources per page. - :param ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :param ListNextMetadata next: (optional) Describes properties needed to - retrieve the next page of a result list. + :param List[str] private: (optional) List of IBM private network IP + addresses. + :param List[str] public: (optional) List of public IP addresses. """ - self.first = first - self.jobs = jobs - self.limit = limit - self.next = next + self.private = private + self.public = public @classmethod - def from_dict(cls, _dict: Dict) -> 'JobList': - """Initialize a JobList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ProjectEgressIPAddresses': + """Initialize a ProjectEgressIPAddresses object from a json dictionary.""" args = {} - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'jobs' in _dict: - args['jobs'] = [Job.from_dict(v) for v in _dict.get('jobs')] - else: - raise ValueError('Required property \'jobs\' not present in JobList JSON') - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in JobList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) + if (private := _dict.get('private')) is not None: + args['private'] = private + if (public := _dict.get('public')) is not None: + args['public'] = public return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a JobList object from a json dictionary.""" + """Initialize a ProjectEgressIPAddresses object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'jobs') and self.jobs is not None: - jobs_list = [] - for v in self.jobs: - if isinstance(v, dict): - jobs_list.append(v) - else: - jobs_list.append(v.to_dict()) - _dict['jobs'] = jobs_list - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() + if hasattr(self, 'private') and self.private is not None: + _dict['private'] = self.private + if hasattr(self, 'public') and self.public is not None: + _dict['public'] = self.public return _dict def _to_dict(self): @@ -6090,279 +11933,101 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this JobList object.""" + """Return a `str` version of this ProjectEgressIPAddresses object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'JobList') -> bool: + def __eq__(self, other: 'ProjectEgressIPAddresses') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'JobList') -> bool: + def __ne__(self, other: 'ProjectEgressIPAddresses') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class JobPatch: +class ProjectList: """ - Request model for job update operations. + Contains a list of projects and pagination information. - :attr str image_reference: (optional) The name of the image that is used for - this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and - `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. - If `TAG` is not specified, the default is `latest`. If the image reference - points to a registry that requires authentication, make sure to also specify the - property `image_secret`. - :attr str image_secret: (optional) The name of the image registry access secret. - The image registry access secret is used to authenticate with a private registry - when you download the container image. If the image reference points to a - registry that requires authentication, the job / job runs will be created but - submitted job runs will fail, until this property is provided, too. This - property must not be set on a job run, which references a job template. - :attr List[str] run_arguments: (optional) Set arguments for the job that are - passed to start job run containers. If not specified an empty string array will - be applied and the arguments specified by the container image, will be used to - start the container. - :attr int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). - :attr List[str] run_commands: (optional) Set commands for the job that are - passed to start job run containers. If not specified an empty string array will - be applied and the command specified by the container image, will be used to - start the container. - :attr List[EnvVarPrototype] run_env_variables: (optional) Optional references to - config maps, secrets or a literal values. - :attr str run_mode: (optional) The mode for runs of the job. Valid values are - `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` - properties apply. In `daemon` mode, since there is no timeout and failed - instances are restarted indefinitely, the `max_execution_time` and `retry_limit` - properties are not allowed. - :attr str run_service_account: (optional) The name of the service account. For - built-in service accounts, you can use the shortened names `manager`, `none`, - `reader`, and `writer`. This property must not be set on a job run, which - references a job template. - :attr List[VolumeMountPrototype] run_volume_mounts: (optional) Optional mounts - of config maps or a secrets. In case this is provided, existing - `run_volume_mounts` will be overwritten. - :attr str scale_array_spec: (optional) Define a custom set of array indices as - comma-separated list containing single values and hyphen-separated ranges like - `5,12-14,23,27`. Each instance can pick up its array index via environment - variable `JOB_INDEX`. The number of unique array indices specified here - determines the number of job instances to run. - :attr str scale_cpu_limit: (optional) Optional amount of CPU set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :attr str scale_ephemeral_storage_limit: (optional) Optional amount of ephemeral - storage to set for the instance of the job. The amount specified as ephemeral - storage, must not exceed the amount of `scale_memory_limit`. The units for - specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M - are the shorthand expressions for GB and MB. For more information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_max_execution_time: (optional) The maximum execution time in - seconds for runs of the job. This property can only be specified if `run_mode` - is `task`. - :attr str scale_memory_limit: (optional) Optional amount of memory set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and - M are the shorthand expressions for GB and MB. For more information see [Units - of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_retry_limit: (optional) The number of times to rerun an instance - of the job before the job is marked as failed. This property can only be - specified if `run_mode` is `task`. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + :param List[Project] projects: List of projects. """ def __init__( self, + limit: int, + projects: List['Project'], *, - image_reference: str = None, - image_secret: str = None, - run_arguments: List[str] = None, - run_as_user: int = None, - run_commands: List[str] = None, - run_env_variables: List['EnvVarPrototype'] = None, - run_mode: str = None, - run_service_account: str = None, - run_volume_mounts: List['VolumeMountPrototype'] = None, - scale_array_spec: str = None, - scale_cpu_limit: str = None, - scale_ephemeral_storage_limit: str = None, - scale_max_execution_time: int = None, - scale_memory_limit: str = None, - scale_retry_limit: int = None, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, ) -> None: """ - Initialize a JobPatch object. + Initialize a ProjectList object. - :param str image_reference: (optional) The name of the image that is used - for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where - `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the - default is `docker.io`. If `TAG` is not specified, the default is `latest`. - If the image reference points to a registry that requires authentication, - make sure to also specify the property `image_secret`. - :param str image_secret: (optional) The name of the image registry access - secret. The image registry access secret is used to authenticate with a - private registry when you download the container image. If the image - reference points to a registry that requires authentication, the job / job - runs will be created but submitted job runs will fail, until this property - is provided, too. This property must not be set on a job run, which - references a job template. - :param List[str] run_arguments: (optional) Set arguments for the job that - are passed to start job run containers. If not specified an empty string - array will be applied and the arguments specified by the container image, - will be used to start the container. - :param int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). - :param List[str] run_commands: (optional) Set commands for the job that are - passed to start job run containers. If not specified an empty string array - will be applied and the command specified by the container image, will be - used to start the container. - :param List[EnvVarPrototype] run_env_variables: (optional) Optional - references to config maps, secrets or a literal values. - :param str run_mode: (optional) The mode for runs of the job. Valid values - are `task` and `daemon`. In `task` mode, the `max_execution_time` and - `retry_limit` properties apply. In `daemon` mode, since there is no timeout - and failed instances are restarted indefinitely, the `max_execution_time` - and `retry_limit` properties are not allowed. - :param str run_service_account: (optional) The name of the service account. - For built-in service accounts, you can use the shortened names `manager`, - `none`, `reader`, and `writer`. This property must not be set on a job run, - which references a job template. - :param List[VolumeMountPrototype] run_volume_mounts: (optional) Optional - mounts of config maps or a secrets. In case this is provided, existing - `run_volume_mounts` will be overwritten. - :param str scale_array_spec: (optional) Define a custom set of array - indices as comma-separated list containing single values and - hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its - array index via environment variable `JOB_INDEX`. The number of unique - array indices specified here determines the number of job instances to run. - :param str scale_cpu_limit: (optional) Optional amount of CPU set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :param str scale_ephemeral_storage_limit: (optional) Optional amount of - ephemeral storage to set for the instance of the job. The amount specified - as ephemeral storage, must not exceed the amount of `scale_memory_limit`. - The units for specifying ephemeral storage are Megabyte (M) or Gigabyte - (G), whereas G and M are the shorthand expressions for GB and MB. For more - information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_max_execution_time: (optional) The maximum execution time - in seconds for runs of the job. This property can only be specified if - `run_mode` is `task`. - :param str scale_memory_limit: (optional) Optional amount of memory set for - the instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G - and M are the shorthand expressions for GB and MB. For more information see - [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_retry_limit: (optional) The number of times to rerun an - instance of the job before the job is marked as failed. This property can - only be specified if `run_mode` is `task`. + :param int limit: Maximum number of resources per page. + :param List[Project] projects: List of projects. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. """ - self.image_reference = image_reference - self.image_secret = image_secret - self.run_arguments = run_arguments - self.run_as_user = run_as_user - self.run_commands = run_commands - self.run_env_variables = run_env_variables - self.run_mode = run_mode - self.run_service_account = run_service_account - self.run_volume_mounts = run_volume_mounts - self.scale_array_spec = scale_array_spec - self.scale_cpu_limit = scale_cpu_limit - self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit - self.scale_max_execution_time = scale_max_execution_time - self.scale_memory_limit = scale_memory_limit - self.scale_retry_limit = scale_retry_limit + self.first = first + self.limit = limit + self.next = next + self.projects = projects @classmethod - def from_dict(cls, _dict: Dict) -> 'JobPatch': - """Initialize a JobPatch object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ProjectList': + """Initialize a ProjectList object from a json dictionary.""" args = {} - if 'image_reference' in _dict: - args['image_reference'] = _dict.get('image_reference') - if 'image_secret' in _dict: - args['image_secret'] = _dict.get('image_secret') - if 'run_arguments' in _dict: - args['run_arguments'] = _dict.get('run_arguments') - if 'run_as_user' in _dict: - args['run_as_user'] = _dict.get('run_as_user') - if 'run_commands' in _dict: - args['run_commands'] = _dict.get('run_commands') - if 'run_env_variables' in _dict: - args['run_env_variables'] = [EnvVarPrototype.from_dict(v) for v in _dict.get('run_env_variables')] - if 'run_mode' in _dict: - args['run_mode'] = _dict.get('run_mode') - if 'run_service_account' in _dict: - args['run_service_account'] = _dict.get('run_service_account') - if 'run_volume_mounts' in _dict: - args['run_volume_mounts'] = [VolumeMountPrototype.from_dict(v) for v in _dict.get('run_volume_mounts')] - if 'scale_array_spec' in _dict: - args['scale_array_spec'] = _dict.get('scale_array_spec') - if 'scale_cpu_limit' in _dict: - args['scale_cpu_limit'] = _dict.get('scale_cpu_limit') - if 'scale_ephemeral_storage_limit' in _dict: - args['scale_ephemeral_storage_limit'] = _dict.get('scale_ephemeral_storage_limit') - if 'scale_max_execution_time' in _dict: - args['scale_max_execution_time'] = _dict.get('scale_max_execution_time') - if 'scale_memory_limit' in _dict: - args['scale_memory_limit'] = _dict.get('scale_memory_limit') - if 'scale_retry_limit' in _dict: - args['scale_retry_limit'] = _dict.get('scale_retry_limit') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in ProjectList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + if (projects := _dict.get('projects')) is not None: + args['projects'] = [Project.from_dict(v) for v in projects] + else: + raise ValueError('Required property \'projects\' not present in ProjectList JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a JobPatch object from a json dictionary.""" + """Initialize a ProjectList object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'image_reference') and self.image_reference is not None: - _dict['image_reference'] = self.image_reference - if hasattr(self, 'image_secret') and self.image_secret is not None: - _dict['image_secret'] = self.image_secret - if hasattr(self, 'run_arguments') and self.run_arguments is not None: - _dict['run_arguments'] = self.run_arguments - if hasattr(self, 'run_as_user') and self.run_as_user is not None: - _dict['run_as_user'] = self.run_as_user - if hasattr(self, 'run_commands') and self.run_commands is not None: - _dict['run_commands'] = self.run_commands - if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: - run_env_variables_list = [] - for v in self.run_env_variables: - if isinstance(v, dict): - run_env_variables_list.append(v) - else: - run_env_variables_list.append(v.to_dict()) - _dict['run_env_variables'] = run_env_variables_list - if hasattr(self, 'run_mode') and self.run_mode is not None: - _dict['run_mode'] = self.run_mode - if hasattr(self, 'run_service_account') and self.run_service_account is not None: - _dict['run_service_account'] = self.run_service_account - if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: - run_volume_mounts_list = [] - for v in self.run_volume_mounts: + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'projects') and self.projects is not None: + projects_list = [] + for v in self.projects: if isinstance(v, dict): - run_volume_mounts_list.append(v) + projects_list.append(v) else: - run_volume_mounts_list.append(v.to_dict()) - _dict['run_volume_mounts'] = run_volume_mounts_list - if hasattr(self, 'scale_array_spec') and self.scale_array_spec is not None: - _dict['scale_array_spec'] = self.scale_array_spec - if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: - _dict['scale_cpu_limit'] = self.scale_cpu_limit - if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: - _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit - if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: - _dict['scale_max_execution_time'] = self.scale_max_execution_time - if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: - _dict['scale_memory_limit'] = self.scale_memory_limit - if hasattr(self, 'scale_retry_limit') and self.scale_retry_limit is not None: - _dict['scale_retry_limit'] = self.scale_retry_limit + projects_list.append(v.to_dict()) + _dict['projects'] = projects_list return _dict def _to_dict(self): @@ -6370,387 +12035,81 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this JobPatch object.""" + """Return a `str` version of this ProjectList object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'JobPatch') -> bool: + def __eq__(self, other: 'ProjectList') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'JobPatch') -> bool: + def __ne__(self, other: 'ProjectList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class RunModeEnum(str, Enum): - """ - The mode for runs of the job. Valid values are `task` and `daemon`. In `task` - mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` - mode, since there is no timeout and failed instances are restarted indefinitely, - the `max_execution_time` and `retry_limit` properties are not allowed. - """ - - TASK = 'task' - DAEMON = 'daemon' - - class RunServiceAccountEnum(str, Enum): - """ - The name of the service account. For built-in service accounts, you can use the - shortened names `manager`, `none`, `reader`, and `writer`. This property must not - be set on a job run, which references a job template. - """ - - DEFAULT = 'default' - MANAGER = 'manager' - READER = 'reader' - WRITER = 'writer' - NONE = 'none' - -class JobRun: +class ProjectStatusDetails: """ - Response model for job run resources. + Describes the model of a project status details. - :attr str created_at: (optional) The date when the resource was created. - :attr str href: (optional) When you provision a new job run, a URL is created - identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr str image_reference: (optional) The name of the image that is used for - this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and - `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. - If `TAG` is not specified, the default is `latest`. If the image reference - points to a registry that requires authentication, make sure to also specify the - property `image_secret`. - :attr str image_secret: (optional) The name of the image registry access secret. - The image registry access secret is used to authenticate with a private registry - when you download the container image. If the image reference points to a - registry that requires authentication, the job / job runs will be created but - submitted job runs will fail, until this property is provided, too. This - property must not be set on a job run, which references a job template. - :attr str job_name: (optional) Optional name of the job reference of this job - run. If specified, the job run will inherit the configuration of the referenced - job. - :attr str name: (optional) The name of the job run. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the job run. - :attr List[str] run_arguments: Set arguments for the job that are passed to - start job run containers. If not specified an empty string array will be applied - and the arguments specified by the container image, will be used to start the - container. - :attr int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). - :attr List[str] run_commands: Set commands for the job that are passed to start - job run containers. If not specified an empty string array will be applied and - the command specified by the container image, will be used to start the - container. - :attr List[EnvVar] run_env_variables: References to config maps, secrets or a - literal values, which are exposed as environment variables in the job run. - :attr str run_mode: (optional) The mode for runs of the job. Valid values are - `task` and `daemon`. In `task` mode, the `max_execution_time` and `retry_limit` - properties apply. In `daemon` mode, since there is no timeout and failed - instances are restarted indefinitely, the `max_execution_time` and `retry_limit` - properties are not allowed. - :attr str run_service_account: (optional) The name of the service account. For - built-in service accounts, you can use the shortened names `manager`, `none`, - `reader`, and `writer`. This property must not be set on a job run, which - references a job template. - :attr List[VolumeMount] run_volume_mounts: Optional mounts of config maps or a - secrets. - :attr str scale_array_spec: (optional) Define a custom set of array indices as - comma-separated list containing single values and hyphen-separated ranges like - `5,12-14,23,27`. Each instance can pick up its array index via environment - variable `JOB_INDEX`. The number of unique array indices specified here - determines the number of job instances to run. - :attr str scale_cpu_limit: (optional) Optional amount of CPU set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :attr str scale_ephemeral_storage_limit: (optional) Optional amount of ephemeral - storage to set for the instance of the job. The amount specified as ephemeral - storage, must not exceed the amount of `scale_memory_limit`. The units for - specifying ephemeral storage are Megabyte (M) or Gigabyte (G), whereas G and M - are the shorthand expressions for GB and MB. For more information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_max_execution_time: (optional) The maximum execution time in - seconds for runs of the job. This property can only be specified if `run_mode` - is `task`. - :attr str scale_memory_limit: (optional) Optional amount of memory set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G and - M are the shorthand expressions for GB and MB. For more information see [Units - of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :attr int scale_retry_limit: (optional) The number of times to rerun an instance - of the job before the job is marked as failed. This property can only be - specified if `run_mode` is `task`. - :attr str status: (optional) The current status of the job run. - :attr JobRunStatus status_details: (optional) The detailed status of the job - run. + :param str domain: Status of the domain created for the project. + :param str project: Defines whether a project is enabled for management and + consumption. + :param bool vpe_not_enabled: (optional) Return true when project is not VPE + enabled. """ def __init__( self, - run_arguments: List[str], - run_commands: List[str], - run_env_variables: List['EnvVar'], - run_volume_mounts: List['VolumeMount'], + domain: str, + project: str, *, - created_at: str = None, - href: str = None, - id: str = None, - image_reference: str = None, - image_secret: str = None, - job_name: str = None, - name: str = None, - project_id: str = None, - resource_type: str = None, - run_as_user: int = None, - run_mode: str = None, - run_service_account: str = None, - scale_array_spec: str = None, - scale_cpu_limit: str = None, - scale_ephemeral_storage_limit: str = None, - scale_max_execution_time: int = None, - scale_memory_limit: str = None, - scale_retry_limit: int = None, - status: str = None, - status_details: 'JobRunStatus' = None, + vpe_not_enabled: Optional[bool] = None, ) -> None: """ - Initialize a JobRun object. + Initialize a ProjectStatusDetails object. - :param List[str] run_arguments: Set arguments for the job that are passed - to start job run containers. If not specified an empty string array will be - applied and the arguments specified by the container image, will be used to - start the container. - :param List[str] run_commands: Set commands for the job that are passed to - start job run containers. If not specified an empty string array will be - applied and the command specified by the container image, will be used to - start the container. - :param List[EnvVar] run_env_variables: References to config maps, secrets - or a literal values, which are exposed as environment variables in the job - run. - :param List[VolumeMount] run_volume_mounts: Optional mounts of config maps - or a secrets. - :param str image_reference: (optional) The name of the image that is used - for this job. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where - `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the - default is `docker.io`. If `TAG` is not specified, the default is `latest`. - If the image reference points to a registry that requires authentication, - make sure to also specify the property `image_secret`. - :param str image_secret: (optional) The name of the image registry access - secret. The image registry access secret is used to authenticate with a - private registry when you download the container image. If the image - reference points to a registry that requires authentication, the job / job - runs will be created but submitted job runs will fail, until this property - is provided, too. This property must not be set on a job run, which - references a job template. - :param str job_name: (optional) Optional name of the job reference of this - job run. If specified, the job run will inherit the configuration of the - referenced job. - :param str name: (optional) The name of the job run. - :param int run_as_user: (optional) The user ID (UID) to run the application - (e.g., 1001). - :param str run_mode: (optional) The mode for runs of the job. Valid values - are `task` and `daemon`. In `task` mode, the `max_execution_time` and - `retry_limit` properties apply. In `daemon` mode, since there is no timeout - and failed instances are restarted indefinitely, the `max_execution_time` - and `retry_limit` properties are not allowed. - :param str run_service_account: (optional) The name of the service account. - For built-in service accounts, you can use the shortened names `manager`, - `none`, `reader`, and `writer`. This property must not be set on a job run, - which references a job template. - :param str scale_array_spec: (optional) Define a custom set of array - indices as comma-separated list containing single values and - hyphen-separated ranges like `5,12-14,23,27`. Each instance can pick up its - array index via environment variable `JOB_INDEX`. The number of unique - array indices specified here determines the number of job instances to run. - :param str scale_cpu_limit: (optional) Optional amount of CPU set for the - instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - :param str scale_ephemeral_storage_limit: (optional) Optional amount of - ephemeral storage to set for the instance of the job. The amount specified - as ephemeral storage, must not exceed the amount of `scale_memory_limit`. - The units for specifying ephemeral storage are Megabyte (M) or Gigabyte - (G), whereas G and M are the shorthand expressions for GB and MB. For more - information see [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_max_execution_time: (optional) The maximum execution time - in seconds for runs of the job. This property can only be specified if - `run_mode` is `task`. - :param str scale_memory_limit: (optional) Optional amount of memory set for - the instance of the job. For valid values see [Supported memory and CPU - combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo). - The units for specifying memory are Megabyte (M) or Gigabyte (G), whereas G - and M are the shorthand expressions for GB and MB. For more information see - [Units of - measurement](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo#unit-measurements). - :param int scale_retry_limit: (optional) The number of times to rerun an - instance of the job before the job is marked as failed. This property can - only be specified if `run_mode` is `task`. - :param JobRunStatus status_details: (optional) The detailed status of the - job run. + :param str domain: Status of the domain created for the project. + :param str project: Defines whether a project is enabled for management and + consumption. + :param bool vpe_not_enabled: (optional) Return true when project is not VPE + enabled. """ - self.created_at = created_at - self.href = href - self.id = id - self.image_reference = image_reference - self.image_secret = image_secret - self.job_name = job_name - self.name = name - self.project_id = project_id - self.resource_type = resource_type - self.run_arguments = run_arguments - self.run_as_user = run_as_user - self.run_commands = run_commands - self.run_env_variables = run_env_variables - self.run_mode = run_mode - self.run_service_account = run_service_account - self.run_volume_mounts = run_volume_mounts - self.scale_array_spec = scale_array_spec - self.scale_cpu_limit = scale_cpu_limit - self.scale_ephemeral_storage_limit = scale_ephemeral_storage_limit - self.scale_max_execution_time = scale_max_execution_time - self.scale_memory_limit = scale_memory_limit - self.scale_retry_limit = scale_retry_limit - self.status = status - self.status_details = status_details + self.domain = domain + self.project = project + self.vpe_not_enabled = vpe_not_enabled @classmethod - def from_dict(cls, _dict: Dict) -> 'JobRun': - """Initialize a JobRun object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ProjectStatusDetails': + """Initialize a ProjectStatusDetails object from a json dictionary.""" args = {} - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'image_reference' in _dict: - args['image_reference'] = _dict.get('image_reference') - if 'image_secret' in _dict: - args['image_secret'] = _dict.get('image_secret') - if 'job_name' in _dict: - args['job_name'] = _dict.get('job_name') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'run_arguments' in _dict: - args['run_arguments'] = _dict.get('run_arguments') - else: - raise ValueError('Required property \'run_arguments\' not present in JobRun JSON') - if 'run_as_user' in _dict: - args['run_as_user'] = _dict.get('run_as_user') - if 'run_commands' in _dict: - args['run_commands'] = _dict.get('run_commands') - else: - raise ValueError('Required property \'run_commands\' not present in JobRun JSON') - if 'run_env_variables' in _dict: - args['run_env_variables'] = [EnvVar.from_dict(v) for v in _dict.get('run_env_variables')] + if (domain := _dict.get('domain')) is not None: + args['domain'] = domain else: - raise ValueError('Required property \'run_env_variables\' not present in JobRun JSON') - if 'run_mode' in _dict: - args['run_mode'] = _dict.get('run_mode') - if 'run_service_account' in _dict: - args['run_service_account'] = _dict.get('run_service_account') - if 'run_volume_mounts' in _dict: - args['run_volume_mounts'] = [VolumeMount.from_dict(v) for v in _dict.get('run_volume_mounts')] + raise ValueError('Required property \'domain\' not present in ProjectStatusDetails JSON') + if (project := _dict.get('project')) is not None: + args['project'] = project else: - raise ValueError('Required property \'run_volume_mounts\' not present in JobRun JSON') - if 'scale_array_spec' in _dict: - args['scale_array_spec'] = _dict.get('scale_array_spec') - if 'scale_cpu_limit' in _dict: - args['scale_cpu_limit'] = _dict.get('scale_cpu_limit') - if 'scale_ephemeral_storage_limit' in _dict: - args['scale_ephemeral_storage_limit'] = _dict.get('scale_ephemeral_storage_limit') - if 'scale_max_execution_time' in _dict: - args['scale_max_execution_time'] = _dict.get('scale_max_execution_time') - if 'scale_memory_limit' in _dict: - args['scale_memory_limit'] = _dict.get('scale_memory_limit') - if 'scale_retry_limit' in _dict: - args['scale_retry_limit'] = _dict.get('scale_retry_limit') - if 'status' in _dict: - args['status'] = _dict.get('status') - if 'status_details' in _dict: - args['status_details'] = JobRunStatus.from_dict(_dict.get('status_details')) + raise ValueError('Required property \'project\' not present in ProjectStatusDetails JSON') + if (vpe_not_enabled := _dict.get('vpe_not_enabled')) is not None: + args['vpe_not_enabled'] = vpe_not_enabled return cls(**args) - @classmethod - def _from_dict(cls, _dict): - """Initialize a JobRun object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = getattr(self, 'created_at') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'image_reference') and self.image_reference is not None: - _dict['image_reference'] = self.image_reference - if hasattr(self, 'image_secret') and self.image_secret is not None: - _dict['image_secret'] = self.image_secret - if hasattr(self, 'job_name') and self.job_name is not None: - _dict['job_name'] = self.job_name - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: - _dict['project_id'] = getattr(self, 'project_id') - if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: - _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'run_arguments') and self.run_arguments is not None: - _dict['run_arguments'] = self.run_arguments - if hasattr(self, 'run_as_user') and self.run_as_user is not None: - _dict['run_as_user'] = self.run_as_user - if hasattr(self, 'run_commands') and self.run_commands is not None: - _dict['run_commands'] = self.run_commands - if hasattr(self, 'run_env_variables') and self.run_env_variables is not None: - run_env_variables_list = [] - for v in self.run_env_variables: - if isinstance(v, dict): - run_env_variables_list.append(v) - else: - run_env_variables_list.append(v.to_dict()) - _dict['run_env_variables'] = run_env_variables_list - if hasattr(self, 'run_mode') and self.run_mode is not None: - _dict['run_mode'] = self.run_mode - if hasattr(self, 'run_service_account') and self.run_service_account is not None: - _dict['run_service_account'] = self.run_service_account - if hasattr(self, 'run_volume_mounts') and self.run_volume_mounts is not None: - run_volume_mounts_list = [] - for v in self.run_volume_mounts: - if isinstance(v, dict): - run_volume_mounts_list.append(v) - else: - run_volume_mounts_list.append(v.to_dict()) - _dict['run_volume_mounts'] = run_volume_mounts_list - if hasattr(self, 'scale_array_spec') and self.scale_array_spec is not None: - _dict['scale_array_spec'] = self.scale_array_spec - if hasattr(self, 'scale_cpu_limit') and self.scale_cpu_limit is not None: - _dict['scale_cpu_limit'] = self.scale_cpu_limit - if hasattr(self, 'scale_ephemeral_storage_limit') and self.scale_ephemeral_storage_limit is not None: - _dict['scale_ephemeral_storage_limit'] = self.scale_ephemeral_storage_limit - if hasattr(self, 'scale_max_execution_time') and self.scale_max_execution_time is not None: - _dict['scale_max_execution_time'] = self.scale_max_execution_time - if hasattr(self, 'scale_memory_limit') and self.scale_memory_limit is not None: - _dict['scale_memory_limit'] = self.scale_memory_limit - if hasattr(self, 'scale_retry_limit') and self.scale_retry_limit is not None: - _dict['scale_retry_limit'] = self.scale_retry_limit - if hasattr(self, 'status') and getattr(self, 'status') is not None: - _dict['status'] = getattr(self, 'status') - if hasattr(self, 'status_details') and self.status_details is not None: - if isinstance(self.status_details, dict): - _dict['status_details'] = self.status_details - else: - _dict['status_details'] = self.status_details.to_dict() + @classmethod + def _from_dict(cls, _dict): + """Initialize a ProjectStatusDetails object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'domain') and self.domain is not None: + _dict['domain'] = self.domain + if hasattr(self, 'project') and self.project is not None: + _dict['project'] = self.project + if hasattr(self, 'vpe_not_enabled') and self.vpe_not_enabled is not None: + _dict['vpe_not_enabled'] = self.vpe_not_enabled return _dict def _to_dict(self): @@ -6758,141 +12117,212 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this JobRun object.""" + """Return a `str` version of this ProjectStatusDetails object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'JobRun') -> bool: + def __eq__(self, other: 'ProjectStatusDetails') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'JobRun') -> bool: + def __ne__(self, other: 'ProjectStatusDetails') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ResourceTypeEnum(str, Enum): + class DomainEnum(str, Enum): """ - The type of the job run. + Status of the domain created for the project. """ - JOB_RUN_V2 = 'job_run_v2' + UNKNOWN = 'unknown' + READY = 'ready' - class RunModeEnum(str, Enum): + class ProjectEnum(str, Enum): """ - The mode for runs of the job. Valid values are `task` and `daemon`. In `task` - mode, the `max_execution_time` and `retry_limit` properties apply. In `daemon` - mode, since there is no timeout and failed instances are restarted indefinitely, - the `max_execution_time` and `retry_limit` properties are not allowed. + Defines whether a project is enabled for management and consumption. """ - TASK = 'task' - DAEMON = 'daemon' + ENABLED = 'enabled' + DISABLED = 'disabled' - class RunServiceAccountEnum(str, Enum): + +class ResourceKeyRef: + """ + The service credential associated with the secret. + + :param str id: (optional) ID of the service credential associated with the + secret. + :param str name: (optional) Name of the service credential associated with the + secret. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + ) -> None: """ - The name of the service account. For built-in service accounts, you can use the - shortened names `manager`, `none`, `reader`, and `writer`. This property must not - be set on a job run, which references a job template. + Initialize a ResourceKeyRef object. + + :param str id: (optional) ID of the service credential associated with the + secret. + :param str name: (optional) Name of the service credential associated with + the secret. """ + self.id = id + self.name = name - DEFAULT = 'default' - MANAGER = 'manager' - READER = 'reader' - WRITER = 'writer' - NONE = 'none' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ResourceKeyRef': + """Initialize a ResourceKeyRef object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + return cls(**args) - class StatusEnum(str, Enum): + @classmethod + def _from_dict(cls, _dict): + """Initialize a ResourceKeyRef object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ResourceKeyRef object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ResourceKeyRef') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ResourceKeyRef') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ResourceKeyRefPrototype: + """ + The service credential associated with the secret. + + :param str id: (optional) ID of the service credential associated with the + secret. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: """ - The current status of the job run. + Initialize a ResourceKeyRefPrototype object. + + :param str id: (optional) ID of the service credential associated with the + secret. """ + self.id = id - COMPLETED = 'completed' - RUNNING = 'running' - PENDING = 'pending' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ResourceKeyRefPrototype': + """Initialize a ResourceKeyRefPrototype object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + return cls(**args) + @classmethod + def _from_dict(cls, _dict): + """Initialize a ResourceKeyRefPrototype object from a json dictionary.""" + return cls.from_dict(_dict) -class JobRunList: + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ResourceKeyRefPrototype object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ResourceKeyRefPrototype') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ResourceKeyRefPrototype') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class RoleRef: """ - Contains a list of job runs and pagination information. + A reference to the Role and Role CRN for service binding. - :attr ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :attr List[JobRun] job_runs: List of all jobs. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve - the next page of a result list. + :param str crn: (optional) CRN of the IAM Role for this service access secret. + :param str name: (optional) Role of the service credential. """ def __init__( self, - job_runs: List['JobRun'], - limit: int, *, - first: 'ListFirstMetadata' = None, - next: 'ListNextMetadata' = None, + crn: Optional[str] = None, + name: Optional[str] = None, ) -> None: """ - Initialize a JobRunList object. + Initialize a RoleRef object. - :param List[JobRun] job_runs: List of all jobs. - :param int limit: Maximum number of resources per page. - :param ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :param ListNextMetadata next: (optional) Describes properties needed to - retrieve the next page of a result list. + :param str crn: (optional) CRN of the IAM Role for this service access + secret. + :param str name: (optional) Role of the service credential. """ - self.first = first - self.job_runs = job_runs - self.limit = limit - self.next = next + self.crn = crn + self.name = name @classmethod - def from_dict(cls, _dict: Dict) -> 'JobRunList': - """Initialize a JobRunList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleRef': + """Initialize a RoleRef object from a json dictionary.""" args = {} - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'job_runs' in _dict: - args['job_runs'] = [JobRun.from_dict(v) for v in _dict.get('job_runs')] - else: - raise ValueError('Required property \'job_runs\' not present in JobRunList JSON') - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in JobRunList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn + if (name := _dict.get('name')) is not None: + args['name'] = name return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a JobRunList object from a json dictionary.""" + """Initialize a RoleRef object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'job_runs') and self.job_runs is not None: - job_runs_list = [] - for v in self.job_runs: - if isinstance(v, dict): - job_runs_list.append(v) - else: - job_runs_list.append(v.to_dict()) - _dict['job_runs'] = job_runs_list - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() + if hasattr(self, 'crn') and self.crn is not None: + _dict['crn'] = self.crn + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name return _dict def _to_dict(self): @@ -6900,105 +12330,226 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this JobRunList object.""" + """Return a `str` version of this RoleRef object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'JobRunList') -> bool: + def __eq__(self, other: 'RoleRef') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'JobRunList') -> bool: + def __ne__(self, other: 'RoleRef') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class JobRunStatus: +class RoleRefPrototype: """ - The detailed status of the job run. + A reference to the Role and Role CRN for service binding. - :attr str completion_time: (optional) Time the job run completed. - :attr int failed: (optional) Number of failed job run instances. - :attr int pending: (optional) Number of pending job run instances. - :attr int requested: (optional) Number of requested job run instances. - :attr int running: (optional) Number of running job run instances. - :attr str start_time: (optional) Time the job run started. - :attr int succeeded: (optional) Number of succeeded job run instances. - :attr int unknown: (optional) Number of job run instances with unknown state. + :param str crn: (optional) CRN of the IAM Role for this service access secret. """ def __init__( self, *, - completion_time: str = None, - failed: int = None, - pending: int = None, - requested: int = None, - running: int = None, - start_time: str = None, - succeeded: int = None, - unknown: int = None, + crn: Optional[str] = None, ) -> None: """ - Initialize a JobRunStatus object. + Initialize a RoleRefPrototype object. + :param str crn: (optional) CRN of the IAM Role for this service access + secret. """ - self.completion_time = completion_time - self.failed = failed - self.pending = pending - self.requested = requested - self.running = running - self.start_time = start_time - self.succeeded = succeeded - self.unknown = unknown + self.crn = crn @classmethod - def from_dict(cls, _dict: Dict) -> 'JobRunStatus': - """Initialize a JobRunStatus object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleRefPrototype': + """Initialize a RoleRefPrototype object from a json dictionary.""" args = {} - if 'completion_time' in _dict: - args['completion_time'] = _dict.get('completion_time') - if 'failed' in _dict: - args['failed'] = _dict.get('failed') - if 'pending' in _dict: - args['pending'] = _dict.get('pending') - if 'requested' in _dict: - args['requested'] = _dict.get('requested') - if 'running' in _dict: - args['running'] = _dict.get('running') - if 'start_time' in _dict: - args['start_time'] = _dict.get('start_time') - if 'succeeded' in _dict: - args['succeeded'] = _dict.get('succeeded') - if 'unknown' in _dict: - args['unknown'] = _dict.get('unknown') + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a JobRunStatus object from a json dictionary.""" + """Initialize a RoleRefPrototype object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'completion_time') and getattr(self, 'completion_time') is not None: - _dict['completion_time'] = getattr(self, 'completion_time') - if hasattr(self, 'failed') and getattr(self, 'failed') is not None: - _dict['failed'] = getattr(self, 'failed') - if hasattr(self, 'pending') and getattr(self, 'pending') is not None: - _dict['pending'] = getattr(self, 'pending') - if hasattr(self, 'requested') and getattr(self, 'requested') is not None: - _dict['requested'] = getattr(self, 'requested') - if hasattr(self, 'running') and getattr(self, 'running') is not None: - _dict['running'] = getattr(self, 'running') - if hasattr(self, 'start_time') and getattr(self, 'start_time') is not None: - _dict['start_time'] = getattr(self, 'start_time') - if hasattr(self, 'succeeded') and getattr(self, 'succeeded') is not None: - _dict['succeeded'] = getattr(self, 'succeeded') - if hasattr(self, 'unknown') and getattr(self, 'unknown') is not None: - _dict['unknown'] = getattr(self, 'unknown') + if hasattr(self, 'crn') and self.crn is not None: + _dict['crn'] = self.crn + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this RoleRefPrototype object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'RoleRefPrototype') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'RoleRefPrototype') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Secret: + """ + Describes the model of a secret. + + :param str created_at: (optional) The timestamp when the resource was created. + :param dict data: (optional) Data container that allows to specify config + parameters and their values as a key-value map. Each key field must consist of + alphanumeric characters, `-`, `_` or `.` and must not exceed a max length of 253 + characters. Each value field can consists of any character and must not exceed a + max length of 1048576 characters. + :param str entity_tag: The version of the secret instance, which is used to + achieve optimistic locking. + :param str format: (optional) Specify the format of the secret. + :param str href: (optional) When you provision a new secret, a URL is created + identifying the location of the instance. + :param str id: (optional) The identifier of the resource. + :param str name: The name of the secret. + :param str project_id: (optional) The ID of the project in which the resource is + located. + :param str region: (optional) The region of the project the resource is located + in. Possible values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', + 'jp-tok', 'us-east', 'us-south'. + :param str resource_type: (optional) The type of the secret. + :param ServiceAccessSecretProps service_access: (optional) Properties for + Service Access Secrets. + :param OperatorSecretProps service_operator: (optional) Properties for the IBM + Cloud Operator Secret. + """ + + def __init__( + self, + entity_tag: str, + name: str, + *, + created_at: Optional[str] = None, + data: Optional[dict] = None, + format: Optional[str] = None, + href: Optional[str] = None, + id: Optional[str] = None, + project_id: Optional[str] = None, + region: Optional[str] = None, + resource_type: Optional[str] = None, + service_access: Optional['ServiceAccessSecretProps'] = None, + service_operator: Optional['OperatorSecretProps'] = None, + ) -> None: + """ + Initialize a Secret object. + + :param str entity_tag: The version of the secret instance, which is used to + achieve optimistic locking. + :param str name: The name of the secret. + :param dict data: (optional) Data container that allows to specify config + parameters and their values as a key-value map. Each key field must consist + of alphanumeric characters, `-`, `_` or `.` and must not exceed a max + length of 253 characters. Each value field can consists of any character + and must not exceed a max length of 1048576 characters. + :param str format: (optional) Specify the format of the secret. + :param ServiceAccessSecretProps service_access: (optional) Properties for + Service Access Secrets. + :param OperatorSecretProps service_operator: (optional) Properties for the + IBM Cloud Operator Secret. + """ + self.created_at = created_at + self.data = data + self.entity_tag = entity_tag + self.format = format + self.href = href + self.id = id + self.name = name + self.project_id = project_id + self.region = region + self.resource_type = resource_type + self.service_access = service_access + self.service_operator = service_operator + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Secret': + """Initialize a Secret object from a json dictionary.""" + args = {} + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = created_at + if (data := _dict.get('data')) is not None: + args['data'] = data + if (entity_tag := _dict.get('entity_tag')) is not None: + args['entity_tag'] = entity_tag + else: + raise ValueError('Required property \'entity_tag\' not present in Secret JSON') + if (format := _dict.get('format')) is not None: + args['format'] = format + if (href := _dict.get('href')) is not None: + args['href'] = href + if (id := _dict.get('id')) is not None: + args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in Secret JSON') + if (project_id := _dict.get('project_id')) is not None: + args['project_id'] = project_id + if (region := _dict.get('region')) is not None: + args['region'] = region + if (resource_type := _dict.get('resource_type')) is not None: + args['resource_type'] = resource_type + if (service_access := _dict.get('service_access')) is not None: + args['service_access'] = ServiceAccessSecretProps.from_dict(service_access) + if (service_operator := _dict.get('service_operator')) is not None: + args['service_operator'] = OperatorSecretProps.from_dict(service_operator) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Secret object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = getattr(self, 'created_at') + if hasattr(self, 'data') and self.data is not None: + _dict['data'] = self.data + if hasattr(self, 'entity_tag') and self.entity_tag is not None: + _dict['entity_tag'] = self.entity_tag + if hasattr(self, 'format') and self.format is not None: + _dict['format'] = self.format + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: + _dict['project_id'] = getattr(self, 'project_id') + if hasattr(self, 'region') and getattr(self, 'region') is not None: + _dict['region'] = getattr(self, 'region') + if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: + _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'service_access') and self.service_access is not None: + if isinstance(self.service_access, dict): + _dict['service_access'] = self.service_access + else: + _dict['service_access'] = self.service_access.to_dict() + if hasattr(self, 'service_operator') and self.service_operator is not None: + if isinstance(self.service_operator, dict): + _dict['service_operator'] = self.service_operator + else: + _dict['service_operator'] = self.service_operator.to_dict() return _dict def _to_dict(self): @@ -7006,53 +12557,149 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this JobRunStatus object.""" + """Return a `str` version of this Secret object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'JobRunStatus') -> bool: + def __eq__(self, other: 'Secret') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'JobRunStatus') -> bool: + def __ne__(self, other: 'Secret') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class FormatEnum(str, Enum): + """ + Specify the format of the secret. + """ -class ListFirstMetadata: + GENERIC = 'generic' + SSH_AUTH = 'ssh_auth' + BASIC_AUTH = 'basic_auth' + TLS = 'tls' + SERVICE_ACCESS = 'service_access' + REGISTRY = 'registry' + SERVICE_OPERATOR = 'service_operator' + OTHER = 'other' + + +class SecretData: """ - Describes properties needed to retrieve the first page of a result list. + Data container that allows to specify config parameters and their values as a + key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` + and must not exceed a max length of 253 characters. Each value field can consists of + any character and must not exceed a max length of 1048576 characters. + - :attr str href: (optional) Href that points to the first page. + This type supports additional properties of type str. """ - def __init__(self, *, href: str = None) -> None: + def __init__( + self, + **kwargs: Optional[str], + ) -> None: """ - Initialize a ListFirstMetadata object. + Initialize a SecretData object. - :param str href: (optional) Href that points to the first page. + :param str **kwargs: (optional) Additional properties of type str """ - self.href = href + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join( + [ + 'SecretDataGenericSecretData', + 'SecretDataBasicAuthSecretData', + 'SecretDataRegistrySecretData', + 'SecretDataSSHSecretData', + 'SecretDataTLSSecretData', + ] + ) + ) + raise Exception(msg) + + +class SecretList: + """ + List of secret resources. + + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param int limit: Maximum number of resources per page. + :param ListNextMetadata next: (optional) Describes properties needed to retrieve + the next page of a result list. + :param List[Secret] secrets: List of secrets. + """ + + def __init__( + self, + limit: int, + secrets: List['Secret'], + *, + first: Optional['ListFirstMetadata'] = None, + next: Optional['ListNextMetadata'] = None, + ) -> None: + """ + Initialize a SecretList object. + + :param int limit: Maximum number of resources per page. + :param List[Secret] secrets: List of secrets. + :param ListFirstMetadata first: (optional) Describes properties needed to + retrieve the first page of a result list. + :param ListNextMetadata next: (optional) Describes properties needed to + retrieve the next page of a result list. + """ + self.first = first + self.limit = limit + self.next = next + self.secrets = secrets @classmethod - def from_dict(cls, _dict: Dict) -> 'ListFirstMetadata': - """Initialize a ListFirstMetadata object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'SecretList': + """Initialize a SecretList object from a json dictionary.""" args = {} - if 'href' in _dict: - args['href'] = _dict.get('href') + if (first := _dict.get('first')) is not None: + args['first'] = ListFirstMetadata.from_dict(first) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + else: + raise ValueError('Required property \'limit\' not present in SecretList JSON') + if (next := _dict.get('next')) is not None: + args['next'] = ListNextMetadata.from_dict(next) + if (secrets := _dict.get('secrets')) is not None: + args['secrets'] = [Secret.from_dict(v) for v in secrets] + else: + raise ValueError('Required property \'secrets\' not present in SecretList JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ListFirstMetadata object from a json dictionary.""" + """Initialize a SecretList object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'href') and self.href is not None: - _dict['href'] = self.href + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'secrets') and self.secrets is not None: + secrets_list = [] + for v in self.secrets: + if isinstance(v, dict): + secrets_list.append(v) + else: + secrets_list.append(v.to_dict()) + _dict['secrets'] = secrets_list return _dict def _to_dict(self): @@ -7060,60 +12707,103 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ListFirstMetadata object.""" + """Return a `str` version of this SecretList object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ListFirstMetadata') -> bool: + def __eq__(self, other: 'SecretList') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ListFirstMetadata') -> bool: + def __ne__(self, other: 'SecretList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ListNextMetadata: +class ServiceAccessSecretProps: """ - Describes properties needed to retrieve the next page of a result list. - - :attr str href: (optional) Href that points to the next page. - :attr str start: (optional) Token. + Properties for Service Access Secrets. + + :param ResourceKeyRef resource_key: The service credential associated with the + secret. + :param RoleRef role: (optional) A reference to the Role and Role CRN for service + binding. + :param ServiceInstanceRef service_instance: The IBM Cloud service instance + associated with the secret. + :param ServiceIDRef serviceid: (optional) A reference to a Service ID. """ - def __init__(self, *, href: str = None, start: str = None) -> None: + def __init__( + self, + resource_key: 'ResourceKeyRef', + service_instance: 'ServiceInstanceRef', + *, + role: Optional['RoleRef'] = None, + serviceid: Optional['ServiceIDRef'] = None, + ) -> None: """ - Initialize a ListNextMetadata object. + Initialize a ServiceAccessSecretProps object. - :param str href: (optional) Href that points to the next page. - :param str start: (optional) Token. + :param ResourceKeyRef resource_key: The service credential associated with + the secret. + :param ServiceInstanceRef service_instance: The IBM Cloud service instance + associated with the secret. + :param RoleRef role: (optional) A reference to the Role and Role CRN for + service binding. + :param ServiceIDRef serviceid: (optional) A reference to a Service ID. """ - self.href = href - self.start = start + self.resource_key = resource_key + self.role = role + self.service_instance = service_instance + self.serviceid = serviceid @classmethod - def from_dict(cls, _dict: Dict) -> 'ListNextMetadata': - """Initialize a ListNextMetadata object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ServiceAccessSecretProps': + """Initialize a ServiceAccessSecretProps object from a json dictionary.""" args = {} - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'start' in _dict: - args['start'] = _dict.get('start') + if (resource_key := _dict.get('resource_key')) is not None: + args['resource_key'] = ResourceKeyRef.from_dict(resource_key) + else: + raise ValueError('Required property \'resource_key\' not present in ServiceAccessSecretProps JSON') + if (role := _dict.get('role')) is not None: + args['role'] = RoleRef.from_dict(role) + if (service_instance := _dict.get('service_instance')) is not None: + args['service_instance'] = ServiceInstanceRef.from_dict(service_instance) + else: + raise ValueError('Required property \'service_instance\' not present in ServiceAccessSecretProps JSON') + if (serviceid := _dict.get('serviceid')) is not None: + args['serviceid'] = ServiceIDRef.from_dict(serviceid) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ListNextMetadata object from a json dictionary.""" + """Initialize a ServiceAccessSecretProps object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'href') and self.href is not None: - _dict['href'] = self.href - if hasattr(self, 'start') and self.start is not None: - _dict['start'] = self.start + if hasattr(self, 'resource_key') and self.resource_key is not None: + if isinstance(self.resource_key, dict): + _dict['resource_key'] = self.resource_key + else: + _dict['resource_key'] = self.resource_key.to_dict() + if hasattr(self, 'role') and self.role is not None: + if isinstance(self.role, dict): + _dict['role'] = self.role + else: + _dict['role'] = self.role.to_dict() + if hasattr(self, 'service_instance') and self.service_instance is not None: + if isinstance(self.service_instance, dict): + _dict['service_instance'] = self.service_instance + else: + _dict['service_instance'] = self.service_instance.to_dict() + if hasattr(self, 'serviceid') and self.serviceid is not None: + if isinstance(self.serviceid, dict): + _dict['serviceid'] = self.serviceid + else: + _dict['serviceid'] = self.serviceid.to_dict() return _dict def _to_dict(self): @@ -7121,130 +12811,105 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ListNextMetadata object.""" + """Return a `str` version of this ServiceAccessSecretProps object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ListNextMetadata') -> bool: + def __eq__(self, other: 'ServiceAccessSecretProps') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ListNextMetadata') -> bool: + def __ne__(self, other: 'ServiceAccessSecretProps') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Project: +class ServiceAccessSecretPrototypeProps: """ - Describes the model of a project. - - :attr str account_id: (optional) An alphanumeric value identifying the account - ID. - :attr str created_at: (optional) The date when the project was created. - :attr str crn: (optional) The CRN of the project. - :attr str href: (optional) When you provision a new resource, a URL is created - identifying the location of the instance. - :attr str id: (optional) The ID of the project. - :attr str name: The name of the project. - :attr str region: (optional) The region for your project deployment. Possible - values: 'au-syd', 'br-sao', 'ca-tor', 'eu-de', 'eu-gb', 'jp-osa', 'jp-tok', - 'us-east', 'us-south'. - :attr str resource_group_id: The ID of the resource group. - :attr str resource_type: (optional) The type of the project. - :attr str status: (optional) The current state of the project. For example, if - the project is created and ready to get used, it will return active. + Properties for Service Access Secrets. + + :param ResourceKeyRefPrototype resource_key: The service credential associated + with the secret. + :param RoleRefPrototype role: (optional) A reference to the Role and Role CRN + for service binding. + :param ServiceInstanceRefPrototype service_instance: The IBM Cloud service + instance associated with the secret. + :param ServiceIDRef serviceid: (optional) A reference to a Service ID. """ def __init__( self, - name: str, - resource_group_id: str, + resource_key: 'ResourceKeyRefPrototype', + service_instance: 'ServiceInstanceRefPrototype', *, - account_id: str = None, - created_at: str = None, - crn: str = None, - href: str = None, - id: str = None, - region: str = None, - resource_type: str = None, - status: str = None, + role: Optional['RoleRefPrototype'] = None, + serviceid: Optional['ServiceIDRef'] = None, ) -> None: """ - Initialize a Project object. + Initialize a ServiceAccessSecretPrototypeProps object. - :param str name: The name of the project. - :param str resource_group_id: The ID of the resource group. + :param ResourceKeyRefPrototype resource_key: The service credential + associated with the secret. + :param ServiceInstanceRefPrototype service_instance: The IBM Cloud service + instance associated with the secret. + :param RoleRefPrototype role: (optional) A reference to the Role and Role + CRN for service binding. + :param ServiceIDRef serviceid: (optional) A reference to a Service ID. """ - self.account_id = account_id - self.created_at = created_at - self.crn = crn - self.href = href - self.id = id - self.name = name - self.region = region - self.resource_group_id = resource_group_id - self.resource_type = resource_type - self.status = status + self.resource_key = resource_key + self.role = role + self.service_instance = service_instance + self.serviceid = serviceid @classmethod - def from_dict(cls, _dict: Dict) -> 'Project': - """Initialize a Project object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ServiceAccessSecretPrototypeProps': + """Initialize a ServiceAccessSecretPrototypeProps object from a json dictionary.""" args = {} - if 'account_id' in _dict: - args['account_id'] = _dict.get('account_id') - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'crn' in _dict: - args['crn'] = _dict.get('crn') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'name' in _dict: - args['name'] = _dict.get('name') + if (resource_key := _dict.get('resource_key')) is not None: + args['resource_key'] = ResourceKeyRefPrototype.from_dict(resource_key) else: - raise ValueError('Required property \'name\' not present in Project JSON') - if 'region' in _dict: - args['region'] = _dict.get('region') - if 'resource_group_id' in _dict: - args['resource_group_id'] = _dict.get('resource_group_id') + raise ValueError('Required property \'resource_key\' not present in ServiceAccessSecretPrototypeProps JSON') + if (role := _dict.get('role')) is not None: + args['role'] = RoleRefPrototype.from_dict(role) + if (service_instance := _dict.get('service_instance')) is not None: + args['service_instance'] = ServiceInstanceRefPrototype.from_dict(service_instance) else: - raise ValueError('Required property \'resource_group_id\' not present in Project JSON') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') - if 'status' in _dict: - args['status'] = _dict.get('status') + raise ValueError( + 'Required property \'service_instance\' not present in ServiceAccessSecretPrototypeProps JSON' + ) + if (serviceid := _dict.get('serviceid')) is not None: + args['serviceid'] = ServiceIDRef.from_dict(serviceid) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Project object from a json dictionary.""" + """Initialize a ServiceAccessSecretPrototypeProps object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: - _dict['account_id'] = getattr(self, 'account_id') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = getattr(self, 'created_at') - if hasattr(self, 'crn') and getattr(self, 'crn') is not None: - _dict['crn'] = getattr(self, 'crn') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'region') and getattr(self, 'region') is not None: - _dict['region'] = getattr(self, 'region') - if hasattr(self, 'resource_group_id') and self.resource_group_id is not None: - _dict['resource_group_id'] = self.resource_group_id - if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: - _dict['resource_type'] = getattr(self, 'resource_type') - if hasattr(self, 'status') and getattr(self, 'status') is not None: - _dict['status'] = getattr(self, 'status') + if hasattr(self, 'resource_key') and self.resource_key is not None: + if isinstance(self.resource_key, dict): + _dict['resource_key'] = self.resource_key + else: + _dict['resource_key'] = self.resource_key.to_dict() + if hasattr(self, 'role') and self.role is not None: + if isinstance(self.role, dict): + _dict['role'] = self.role + else: + _dict['role'] = self.role.to_dict() + if hasattr(self, 'service_instance') and self.service_instance is not None: + if isinstance(self.service_instance, dict): + _dict['service_instance'] = self.service_instance + else: + _dict['service_instance'] = self.service_instance.to_dict() + if hasattr(self, 'serviceid') and self.serviceid is not None: + if isinstance(self.serviceid, dict): + _dict['serviceid'] = self.serviceid + else: + _dict['serviceid'] = self.serviceid.to_dict() return _dict def _to_dict(self): @@ -7252,87 +12917,65 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Project object.""" + """Return a `str` version of this ServiceAccessSecretPrototypeProps object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Project') -> bool: + def __eq__(self, other: 'ServiceAccessSecretPrototypeProps') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Project') -> bool: + def __ne__(self, other: 'ServiceAccessSecretPrototypeProps') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class ResourceTypeEnum(str, Enum): - """ - The type of the project. - """ - - PROJECT_V2 = 'project_v2' - - class StatusEnum(str, Enum): - """ - The current state of the project. For example, if the project is created and ready - to get used, it will return active. - """ - - ACTIVE = 'active' - INACTIVE = 'inactive' - PENDING_REMOVAL = 'pending_removal' - HARD_DELETING = 'hard_deleting' - HARD_DELETION_FAILED = 'hard_deletion_failed' - HARD_DELETED = 'hard_deleted' - DELETING = 'deleting' - DELETION_FAILED = 'deletion_failed' - SOFT_DELETED = 'soft_deleted' - PREPARING = 'preparing' - CREATING = 'creating' - CREATION_FAILED = 'creation_failed' - -class ProjectEgressIPAddresses: +class ServiceIDRef: """ - Describes the model of egress IP addresses. + A reference to a Service ID. - :attr List[str] private: (optional) List of IBM private network IP addresses. - :attr List[str] public: (optional) List of public IP addresses. + :param str crn: (optional) CRN value of a Service ID. + :param str id: (optional) The ID of the Service ID. """ - def __init__(self, *, private: List[str] = None, public: List[str] = None) -> None: + def __init__( + self, + *, + crn: Optional[str] = None, + id: Optional[str] = None, + ) -> None: """ - Initialize a ProjectEgressIPAddresses object. + Initialize a ServiceIDRef object. - :param List[str] private: (optional) List of IBM private network IP - addresses. - :param List[str] public: (optional) List of public IP addresses. + :param str crn: (optional) CRN value of a Service ID. + :param str id: (optional) The ID of the Service ID. """ - self.private = private - self.public = public + self.crn = crn + self.id = id @classmethod - def from_dict(cls, _dict: Dict) -> 'ProjectEgressIPAddresses': - """Initialize a ProjectEgressIPAddresses object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ServiceIDRef': + """Initialize a ServiceIDRef object from a json dictionary.""" args = {} - if 'private' in _dict: - args['private'] = _dict.get('private') - if 'public' in _dict: - args['public'] = _dict.get('public') + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn + if (id := _dict.get('id')) is not None: + args['id'] = id return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ProjectEgressIPAddresses object from a json dictionary.""" + """Initialize a ServiceIDRef object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'private') and self.private is not None: - _dict['private'] = self.private - if hasattr(self, 'public') and self.public is not None: - _dict['public'] = self.public + if hasattr(self, 'crn') and self.crn is not None: + _dict['crn'] = self.crn + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id return _dict def _to_dict(self): @@ -7340,101 +12983,57 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ProjectEgressIPAddresses object.""" + """Return a `str` version of this ServiceIDRef object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ProjectEgressIPAddresses') -> bool: + def __eq__(self, other: 'ServiceIDRef') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ProjectEgressIPAddresses') -> bool: + def __ne__(self, other: 'ServiceIDRef') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProjectList: +class ServiceIDRefPrototype: """ - Contains a list of projects and pagination information. + A reference to the Service ID. - :attr ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve - the next page of a result list. - :attr List[Project] projects: List of projects. + :param str id: (optional) The ID of the Service ID. """ def __init__( self, - limit: int, - projects: List['Project'], *, - first: 'ListFirstMetadata' = None, - next: 'ListNextMetadata' = None, + id: Optional[str] = None, ) -> None: """ - Initialize a ProjectList object. + Initialize a ServiceIDRefPrototype object. - :param int limit: Maximum number of resources per page. - :param List[Project] projects: List of projects. - :param ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :param ListNextMetadata next: (optional) Describes properties needed to - retrieve the next page of a result list. + :param str id: (optional) The ID of the Service ID. """ - self.first = first - self.limit = limit - self.next = next - self.projects = projects + self.id = id @classmethod - def from_dict(cls, _dict: Dict) -> 'ProjectList': - """Initialize a ProjectList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ServiceIDRefPrototype': + """Initialize a ServiceIDRefPrototype object from a json dictionary.""" args = {} - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in ProjectList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) - if 'projects' in _dict: - args['projects'] = [Project.from_dict(v) for v in _dict.get('projects')] - else: - raise ValueError('Required property \'projects\' not present in ProjectList JSON') + if (id := _dict.get('id')) is not None: + args['id'] = id return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ProjectList object from a json dictionary.""" + """Initialize a ServiceIDRefPrototype object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() - if hasattr(self, 'projects') and self.projects is not None: - projects_list = [] - for v in self.projects: - if isinstance(v, dict): - projects_list.append(v) - else: - projects_list.append(v.to_dict()) - _dict['projects'] = projects_list + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id return _dict def _to_dict(self): @@ -7442,132 +13041,69 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ProjectList object.""" + """Return a `str` version of this ServiceIDRefPrototype object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ProjectList') -> bool: + def __eq__(self, other: 'ServiceIDRefPrototype') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ProjectList') -> bool: + def __ne__(self, other: 'ServiceIDRefPrototype') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Secret: +class ServiceInstanceRef: """ - Describes the model of a secret. + The IBM Cloud service instance associated with the secret. - :attr str created_at: (optional) The date when the resource was created. - :attr dict data: (optional) Data container that allows to specify config - parameters and their values as a key-value map. Each key field must consist of - alphanumeric characters, `-`, `_` or `.` and must not be exceed a max length of - 253 characters. Each value field can consists of any character and must not be - exceed a max length of 1048576 characters. - :attr str entity_tag: The version of the secret instance, which is used to - achieve optimistic locking. - :attr str format: (optional) Specify the format of the secret. - :attr str href: (optional) When you provision a new secret, a URL is created - identifying the location of the instance. - :attr str id: (optional) The identifier of the resource. - :attr str name: The name of the secret. - :attr str project_id: (optional) The ID of the project the resource is located - in. - :attr str resource_type: (optional) The type of the secret. + :param str id: (optional) ID of the IBM Cloud service instance associated with + the secret. + :param str type: (optional) Type of IBM Cloud service associated with the + secret. """ def __init__( self, - entity_tag: str, - name: str, *, - created_at: str = None, - data: dict = None, - format: str = None, - href: str = None, - id: str = None, - project_id: str = None, - resource_type: str = None, + id: Optional[str] = None, + type: Optional[str] = None, ) -> None: """ - Initialize a Secret object. + Initialize a ServiceInstanceRef object. - :param str entity_tag: The version of the secret instance, which is used to - achieve optimistic locking. - :param str name: The name of the secret. - :param dict data: (optional) Data container that allows to specify config - parameters and their values as a key-value map. Each key field must consist - of alphanumeric characters, `-`, `_` or `.` and must not be exceed a max - length of 253 characters. Each value field can consists of any character - and must not be exceed a max length of 1048576 characters. - :param str format: (optional) Specify the format of the secret. + :param str id: (optional) ID of the IBM Cloud service instance associated + with the secret. + :param str type: (optional) Type of IBM Cloud service associated with the + secret. """ - self.created_at = created_at - self.data = data - self.entity_tag = entity_tag - self.format = format - self.href = href self.id = id - self.name = name - self.project_id = project_id - self.resource_type = resource_type + self.type = type @classmethod - def from_dict(cls, _dict: Dict) -> 'Secret': - """Initialize a Secret object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ServiceInstanceRef': + """Initialize a ServiceInstanceRef object from a json dictionary.""" args = {} - if 'created_at' in _dict: - args['created_at'] = _dict.get('created_at') - if 'data' in _dict: - args['data'] = _dict.get('data') - if 'entity_tag' in _dict: - args['entity_tag'] = _dict.get('entity_tag') - else: - raise ValueError('Required property \'entity_tag\' not present in Secret JSON') - if 'format' in _dict: - args['format'] = _dict.get('format') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'name' in _dict: - args['name'] = _dict.get('name') - else: - raise ValueError('Required property \'name\' not present in Secret JSON') - if 'project_id' in _dict: - args['project_id'] = _dict.get('project_id') - if 'resource_type' in _dict: - args['resource_type'] = _dict.get('resource_type') + if (id := _dict.get('id')) is not None: + args['id'] = id + if (type := _dict.get('type')) is not None: + args['type'] = type return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Secret object from a json dictionary.""" + """Initialize a ServiceInstanceRef object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = getattr(self, 'created_at') - if hasattr(self, 'data') and self.data is not None: - _dict['data'] = self.data - if hasattr(self, 'entity_tag') and self.entity_tag is not None: - _dict['entity_tag'] = self.entity_tag - if hasattr(self, 'format') and self.format is not None: - _dict['format'] = self.format - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'project_id') and getattr(self, 'project_id') is not None: - _dict['project_id'] = getattr(self, 'project_id') - if hasattr(self, 'resource_type') and getattr(self, 'resource_type') is not None: - _dict['resource_type'] = getattr(self, 'resource_type') + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type return _dict def _to_dict(self): @@ -7575,138 +13111,59 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Secret object.""" + """Return a `str` version of this ServiceInstanceRef object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Secret') -> bool: + def __eq__(self, other: 'ServiceInstanceRef') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Secret') -> bool: + def __ne__(self, other: 'ServiceInstanceRef') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class FormatEnum(str, Enum): - """ - Specify the format of the secret. - """ - - GENERIC = 'generic' - SSH_AUTH = 'ssh_auth' - BASIC_AUTH = 'basic_auth' - TLS = 'tls' - SERVICE_ACCESS = 'service_access' - REGISTRY = 'registry' - OTHER = 'other' - - -class SecretData: - """ - Data container that allows to specify config parameters and their values as a - key-value map. Each key field must consist of alphanumeric characters, `-`, `_` or `.` - and must not be exceed a max length of 253 characters. Each value field can consists - of any character and must not be exceed a max length of 1048576 characters. - - """ - - def __init__(self, **kwargs) -> None: - """ - Initialize a SecretData object. - - :param **kwargs: (optional) Any additional properties. - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join( - [ - 'SecretDataSSHSecretData', - 'SecretDataRegistrySecretData', - 'SecretDataTLSSecretData', - 'SecretDataGenericSecretData', - 'SecretDataBasicAuthSecretData', - ] - ) - ) - raise Exception(msg) - -class SecretList: +class ServiceInstanceRefPrototype: """ - List of secret resources. + The IBM Cloud service instance associated with the secret. - :attr ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :attr int limit: Maximum number of resources per page. - :attr ListNextMetadata next: (optional) Describes properties needed to retrieve - the next page of a result list. - :attr List[Secret] secrets: List of Secrets. + :param str id: (optional) ID of the IBM Cloud service instance associated with + the secret. """ def __init__( - self, limit: int, secrets: List['Secret'], *, first: 'ListFirstMetadata' = None, next: 'ListNextMetadata' = None + self, + *, + id: Optional[str] = None, ) -> None: """ - Initialize a SecretList object. + Initialize a ServiceInstanceRefPrototype object. - :param int limit: Maximum number of resources per page. - :param List[Secret] secrets: List of Secrets. - :param ListFirstMetadata first: (optional) Describes properties needed to - retrieve the first page of a result list. - :param ListNextMetadata next: (optional) Describes properties needed to - retrieve the next page of a result list. + :param str id: (optional) ID of the IBM Cloud service instance associated + with the secret. """ - self.first = first - self.limit = limit - self.next = next - self.secrets = secrets + self.id = id @classmethod - def from_dict(cls, _dict: Dict) -> 'SecretList': - """Initialize a SecretList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ServiceInstanceRefPrototype': + """Initialize a ServiceInstanceRefPrototype object from a json dictionary.""" args = {} - if 'first' in _dict: - args['first'] = ListFirstMetadata.from_dict(_dict.get('first')) - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in SecretList JSON') - if 'next' in _dict: - args['next'] = ListNextMetadata.from_dict(_dict.get('next')) - if 'secrets' in _dict: - args['secrets'] = [Secret.from_dict(v) for v in _dict.get('secrets')] - else: - raise ValueError('Required property \'secrets\' not present in SecretList JSON') + if (id := _dict.get('id')) is not None: + args['id'] = id return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a SecretList object from a json dictionary.""" + """Initialize a ServiceInstanceRefPrototype object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() - if hasattr(self, 'secrets') and self.secrets is not None: - secrets_list = [] - for v in self.secrets: - if isinstance(v, dict): - secrets_list.append(v) - else: - secrets_list.append(v.to_dict()) - _dict['secrets'] = secrets_list + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id return _dict def _to_dict(self): @@ -7714,16 +13171,16 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this SecretList object.""" + """Return a `str` version of this ServiceInstanceRefPrototype object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'SecretList') -> bool: + def __eq__(self, other: 'ServiceInstanceRefPrototype') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'SecretList') -> bool: + def __ne__(self, other: 'ServiceInstanceRefPrototype') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other @@ -7732,14 +13189,20 @@ class VolumeMount: """ Response model of a volume mount. - :attr str mount_path: The path that should be mounted. - :attr str name: The name of the mount. - :attr str reference: The name of the referenced secret or config map. - :attr str type: Specify the type of the volume mount. Allowed types are: + :param str mount_path: The path that should be mounted. + :param str name: The name of the mount. + :param str reference: The name of the referenced secret or config map. + :param str type: Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'. """ - def __init__(self, mount_path: str, name: str, reference: str, type: str) -> None: + def __init__( + self, + mount_path: str, + name: str, + reference: str, + type: str, + ) -> None: """ Initialize a VolumeMount object. @@ -7758,20 +13221,20 @@ def __init__(self, mount_path: str, name: str, reference: str, type: str) -> Non def from_dict(cls, _dict: Dict) -> 'VolumeMount': """Initialize a VolumeMount object from a json dictionary.""" args = {} - if 'mount_path' in _dict: - args['mount_path'] = _dict.get('mount_path') + if (mount_path := _dict.get('mount_path')) is not None: + args['mount_path'] = mount_path else: raise ValueError('Required property \'mount_path\' not present in VolumeMount JSON') - if 'name' in _dict: - args['name'] = _dict.get('name') + if (name := _dict.get('name')) is not None: + args['name'] = name else: raise ValueError('Required property \'name\' not present in VolumeMount JSON') - if 'reference' in _dict: - args['reference'] = _dict.get('reference') + if (reference := _dict.get('reference')) is not None: + args['reference'] = reference else: raise ValueError('Required property \'reference\' not present in VolumeMount JSON') - if 'type' in _dict: - args['type'] = _dict.get('type') + if (type := _dict.get('type')) is not None: + args['type'] = type else: raise ValueError('Required property \'type\' not present in VolumeMount JSON') return cls(**args) @@ -7825,16 +13288,23 @@ class VolumeMountPrototype: """ Prototype model of a volume mount. - :attr str mount_path: The path that should be mounted. - :attr str name: (optional) Optional name of the mount. If not set, it will be + :param str mount_path: The path that should be mounted. + :param str name: (optional) Optional name of the mount. If not set, it will be generated based on the `ref` and a random ID. In case the `ref` is longer than 58 characters, it will be cut off. - :attr str reference: The name of the referenced secret or config map. - :attr str type: Specify the type of the volume mount. Allowed types are: + :param str reference: The name of the referenced secret or config map. + :param str type: Specify the type of the volume mount. Allowed types are: 'config_map', 'secret'. """ - def __init__(self, mount_path: str, reference: str, type: str, *, name: str = None) -> None: + def __init__( + self, + mount_path: str, + reference: str, + type: str, + *, + name: Optional[str] = None, + ) -> None: """ Initialize a VolumeMountPrototype object. @@ -7855,18 +13325,18 @@ def __init__(self, mount_path: str, reference: str, type: str, *, name: str = No def from_dict(cls, _dict: Dict) -> 'VolumeMountPrototype': """Initialize a VolumeMountPrototype object from a json dictionary.""" args = {} - if 'mount_path' in _dict: - args['mount_path'] = _dict.get('mount_path') + if (mount_path := _dict.get('mount_path')) is not None: + args['mount_path'] = mount_path else: raise ValueError('Required property \'mount_path\' not present in VolumeMountPrototype JSON') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'reference' in _dict: - args['reference'] = _dict.get('reference') + if (name := _dict.get('name')) is not None: + args['name'] = name + if (reference := _dict.get('reference')) is not None: + args['reference'] = reference else: raise ValueError('Required property \'reference\' not present in VolumeMountPrototype JSON') - if 'type' in _dict: - args['type'] = _dict.get('type') + if (type := _dict.get('type')) is not None: + args['type'] = type else: raise ValueError('Required property \'type\' not present in VolumeMountPrototype JSON') return cls(**args) @@ -7920,40 +13390,56 @@ class SecretDataBasicAuthSecretData(SecretData): """ SecretDataBasicAuthSecretData. - :attr str username: Basic auth username. - :attr str password: Basic auth password. + :param str username: Basic auth username. + :param str password: Basic auth password. + + This type supports additional properties of type str. """ # The set of defined properties for the class _properties = frozenset(['username', 'password']) - def __init__(self, username: str, password: str, **kwargs) -> None: + def __init__( + self, + username: str, + password: str, + **kwargs: Optional[str], + ) -> None: """ Initialize a SecretDataBasicAuthSecretData object. :param str username: Basic auth username. :param str password: Basic auth password. - :param **kwargs: (optional) Any additional properties. + :param str **kwargs: (optional) Additional properties of type str """ # pylint: disable=super-init-not-called self.username = username self.password = password - for _key, _value in kwargs.items(): - setattr(self, _key, _value) + for k, v in kwargs.items(): + if k not in SecretDataBasicAuthSecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) @classmethod def from_dict(cls, _dict: Dict) -> 'SecretDataBasicAuthSecretData': """Initialize a SecretDataBasicAuthSecretData object from a json dictionary.""" args = {} - if 'username' in _dict: - args['username'] = _dict.get('username') + if (username := _dict.get('username')) is not None: + args['username'] = username else: raise ValueError('Required property \'username\' not present in SecretDataBasicAuthSecretData JSON') - if 'password' in _dict: - args['password'] = _dict.get('password') + if (password := _dict.get('password')) is not None: + args['password'] = password else: raise ValueError('Required property \'password\' not present in SecretDataBasicAuthSecretData JSON') - args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) + for k, v in _dict.items(): + if k not in cls._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + args[k] = v return cls(**args) @classmethod @@ -7968,8 +13454,8 @@ def to_dict(self) -> Dict: _dict['username'] = self.username if hasattr(self, 'password') and self.password is not None: _dict['password'] = self.password - for _key in [k for k in vars(self).keys() if k not in SecretDataBasicAuthSecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataBasicAuthSecretData._properties]: + _dict[k] = getattr(self, k) return _dict def _to_dict(self): @@ -7977,21 +13463,23 @@ def _to_dict(self): return self.to_dict() def get_properties(self) -> Dict: - """Return a dictionary of arbitrary properties from this instance of SecretDataBasicAuthSecretData""" + """Return the additional properties from this instance of SecretDataBasicAuthSecretData in the form of a dict.""" _dict = {} - - for _key in [k for k in vars(self).keys() if k not in SecretDataBasicAuthSecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataBasicAuthSecretData._properties]: + _dict[k] = getattr(self, k) return _dict def set_properties(self, _dict: dict): - """Set a dictionary of arbitrary properties to this instance of SecretDataBasicAuthSecretData""" - for _key in [k for k in vars(self).keys() if k not in SecretDataBasicAuthSecretData._properties]: - delattr(self, _key) - - for _key, _value in _dict.items(): - if _key not in SecretDataBasicAuthSecretData._properties: - setattr(self, _key, _value) + """Set a dictionary of additional properties in this instance of SecretDataBasicAuthSecretData""" + for k in [_k for _k in vars(self).keys() if _k not in SecretDataBasicAuthSecretData._properties]: + delattr(self, k) + for k, v in _dict.items(): + if k not in SecretDataBasicAuthSecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) def __str__(self) -> str: """Return a `str` version of this SecretDataBasicAuthSecretData object.""" @@ -8015,22 +13503,34 @@ class SecretDataGenericSecretData(SecretData): and must not be exceed a max length of 253 characters. Each value field can consists of any character and must not be exceed a max length of 1048576 characters. + + This type supports additional properties of type str. """ - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs: Optional[str], + ) -> None: """ Initialize a SecretDataGenericSecretData object. - :param **kwargs: (optional) Any additional properties. + :param str **kwargs: (optional) Additional properties of type str """ # pylint: disable=super-init-not-called - for _key, _value in kwargs.items(): - setattr(self, _key, _value) + for k, v in kwargs.items(): + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) @classmethod def from_dict(cls, _dict: Dict) -> 'SecretDataGenericSecretData': """Initialize a SecretDataGenericSecretData object from a json dictionary.""" - return cls(**_dict) + args = {} + for k, v in _dict.items(): + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + args[k] = v + return cls(**args) @classmethod def _from_dict(cls, _dict): @@ -8039,27 +13539,30 @@ def _from_dict(cls, _dict): def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" - return vars(self) + _dict = {} + for k in [_k for _k in vars(self).keys()]: + _dict[k] = getattr(self, k) + return _dict def _to_dict(self): """Return a json dictionary representing this model.""" return self.to_dict() def get_properties(self) -> Dict: - """Return a dictionary of arbitrary properties from this instance of SecretDataGenericSecretData""" + """Return the additional properties from this instance of SecretDataGenericSecretData in the form of a dict.""" _dict = {} - - for _key in [k for k in vars(self).keys()]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys()]: + _dict[k] = getattr(self, k) return _dict def set_properties(self, _dict: dict): - """Set a dictionary of arbitrary properties to this instance of SecretDataGenericSecretData""" - for _key in [k for k in vars(self).keys()]: - delattr(self, _key) - - for _key, _value in _dict.items(): - setattr(self, _key, _value) + """Set a dictionary of additional properties in this instance of SecretDataGenericSecretData""" + for k in [_k for _k in vars(self).keys()]: + delattr(self, k) + for k, v in _dict.items(): + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) def __str__(self) -> str: """Return a `str` version of this SecretDataGenericSecretData object.""" @@ -8080,54 +13583,71 @@ class SecretDataRegistrySecretData(SecretData): """ SecretDataRegistrySecretData. - :attr str username: Registry username. - :attr str password: Registry password. - :attr str server: Registry server. - :attr str email: Registry email address. + :param str username: Registry username. + :param str password: Registry password. + :param str server: Registry server. + :param str email: (optional) Registry email address. + + This type supports additional properties of type str. """ # The set of defined properties for the class _properties = frozenset(['username', 'password', 'server', 'email']) - def __init__(self, username: str, password: str, server: str, email: str, **kwargs) -> None: + def __init__( + self, + username: str, + password: str, + server: str, + *, + email: Optional[str] = None, + **kwargs: Optional[str], + ) -> None: """ Initialize a SecretDataRegistrySecretData object. :param str username: Registry username. :param str password: Registry password. :param str server: Registry server. - :param str email: Registry email address. - :param **kwargs: (optional) Any additional properties. + :param str email: (optional) Registry email address. + :param str **kwargs: (optional) Additional properties of type str """ # pylint: disable=super-init-not-called self.username = username self.password = password self.server = server self.email = email - for _key, _value in kwargs.items(): - setattr(self, _key, _value) + for k, v in kwargs.items(): + if k not in SecretDataRegistrySecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) @classmethod def from_dict(cls, _dict: Dict) -> 'SecretDataRegistrySecretData': """Initialize a SecretDataRegistrySecretData object from a json dictionary.""" args = {} - if 'username' in _dict: - args['username'] = _dict.get('username') + if (username := _dict.get('username')) is not None: + args['username'] = username else: raise ValueError('Required property \'username\' not present in SecretDataRegistrySecretData JSON') - if 'password' in _dict: - args['password'] = _dict.get('password') + if (password := _dict.get('password')) is not None: + args['password'] = password else: raise ValueError('Required property \'password\' not present in SecretDataRegistrySecretData JSON') - if 'server' in _dict: - args['server'] = _dict.get('server') + if (server := _dict.get('server')) is not None: + args['server'] = server else: raise ValueError('Required property \'server\' not present in SecretDataRegistrySecretData JSON') - if 'email' in _dict: - args['email'] = _dict.get('email') - else: - raise ValueError('Required property \'email\' not present in SecretDataRegistrySecretData JSON') - args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) + if (email := _dict.get('email')) is not None: + args['email'] = email + for k, v in _dict.items(): + if k not in cls._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + args[k] = v return cls(**args) @classmethod @@ -8146,8 +13666,8 @@ def to_dict(self) -> Dict: _dict['server'] = self.server if hasattr(self, 'email') and self.email is not None: _dict['email'] = self.email - for _key in [k for k in vars(self).keys() if k not in SecretDataRegistrySecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataRegistrySecretData._properties]: + _dict[k] = getattr(self, k) return _dict def _to_dict(self): @@ -8155,21 +13675,23 @@ def _to_dict(self): return self.to_dict() def get_properties(self) -> Dict: - """Return a dictionary of arbitrary properties from this instance of SecretDataRegistrySecretData""" + """Return the additional properties from this instance of SecretDataRegistrySecretData in the form of a dict.""" _dict = {} - - for _key in [k for k in vars(self).keys() if k not in SecretDataRegistrySecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataRegistrySecretData._properties]: + _dict[k] = getattr(self, k) return _dict def set_properties(self, _dict: dict): - """Set a dictionary of arbitrary properties to this instance of SecretDataRegistrySecretData""" - for _key in [k for k in vars(self).keys() if k not in SecretDataRegistrySecretData._properties]: - delattr(self, _key) - - for _key, _value in _dict.items(): - if _key not in SecretDataRegistrySecretData._properties: - setattr(self, _key, _value) + """Set a dictionary of additional properties in this instance of SecretDataRegistrySecretData""" + for k in [_k for _k in vars(self).keys() if _k not in SecretDataRegistrySecretData._properties]: + delattr(self, k) + for k, v in _dict.items(): + if k not in SecretDataRegistrySecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) def __str__(self) -> str: """Return a `str` version of this SecretDataRegistrySecretData object.""" @@ -8190,38 +13712,55 @@ class SecretDataSSHSecretData(SecretData): """ Secret Data field used by SSH secrets. - :attr str ssh_key: SSH key. - :attr str known_hosts: (optional) Known hosts. + :param str ssh_key: SSH key. + :param str known_hosts: (optional) Known hosts. + + This type supports additional properties of type str. """ # The set of defined properties for the class _properties = frozenset(['ssh_key', 'known_hosts']) - def __init__(self, ssh_key: str, *, known_hosts: str = None, **kwargs) -> None: + def __init__( + self, + ssh_key: str, + *, + known_hosts: Optional[str] = None, + **kwargs: Optional[str], + ) -> None: """ Initialize a SecretDataSSHSecretData object. :param str ssh_key: SSH key. :param str known_hosts: (optional) Known hosts. - :param **kwargs: (optional) Any additional properties. + :param str **kwargs: (optional) Additional properties of type str """ # pylint: disable=super-init-not-called self.ssh_key = ssh_key self.known_hosts = known_hosts - for _key, _value in kwargs.items(): - setattr(self, _key, _value) + for k, v in kwargs.items(): + if k not in SecretDataSSHSecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) @classmethod def from_dict(cls, _dict: Dict) -> 'SecretDataSSHSecretData': """Initialize a SecretDataSSHSecretData object from a json dictionary.""" args = {} - if 'ssh_key' in _dict: - args['ssh_key'] = _dict.get('ssh_key') + if (ssh_key := _dict.get('ssh_key')) is not None: + args['ssh_key'] = ssh_key else: raise ValueError('Required property \'ssh_key\' not present in SecretDataSSHSecretData JSON') - if 'known_hosts' in _dict: - args['known_hosts'] = _dict.get('known_hosts') - args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) + if (known_hosts := _dict.get('known_hosts')) is not None: + args['known_hosts'] = known_hosts + for k, v in _dict.items(): + if k not in cls._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + args[k] = v return cls(**args) @classmethod @@ -8236,8 +13775,8 @@ def to_dict(self) -> Dict: _dict['ssh_key'] = self.ssh_key if hasattr(self, 'known_hosts') and self.known_hosts is not None: _dict['known_hosts'] = self.known_hosts - for _key in [k for k in vars(self).keys() if k not in SecretDataSSHSecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataSSHSecretData._properties]: + _dict[k] = getattr(self, k) return _dict def _to_dict(self): @@ -8245,21 +13784,23 @@ def _to_dict(self): return self.to_dict() def get_properties(self) -> Dict: - """Return a dictionary of arbitrary properties from this instance of SecretDataSSHSecretData""" + """Return the additional properties from this instance of SecretDataSSHSecretData in the form of a dict.""" _dict = {} - - for _key in [k for k in vars(self).keys() if k not in SecretDataSSHSecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataSSHSecretData._properties]: + _dict[k] = getattr(self, k) return _dict def set_properties(self, _dict: dict): - """Set a dictionary of arbitrary properties to this instance of SecretDataSSHSecretData""" - for _key in [k for k in vars(self).keys() if k not in SecretDataSSHSecretData._properties]: - delattr(self, _key) - - for _key, _value in _dict.items(): - if _key not in SecretDataSSHSecretData._properties: - setattr(self, _key, _value) + """Set a dictionary of additional properties in this instance of SecretDataSSHSecretData""" + for k in [_k for _k in vars(self).keys() if _k not in SecretDataSSHSecretData._properties]: + delattr(self, k) + for k, v in _dict.items(): + if k not in SecretDataSSHSecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) def __str__(self) -> str: """Return a `str` version of this SecretDataSSHSecretData object.""" @@ -8280,40 +13821,56 @@ class SecretDataTLSSecretData(SecretData): """ SecretDataTLSSecretData. - :attr str tls_cert: The TLS certificate used in a TLS secret. - :attr str tls_key: The TLS key used in a TLS secret. + :param str tls_cert: The TLS certificate used in a TLS secret. + :param str tls_key: The TLS key used in a TLS secret. + + This type supports additional properties of type str. """ # The set of defined properties for the class _properties = frozenset(['tls_cert', 'tls_key']) - def __init__(self, tls_cert: str, tls_key: str, **kwargs) -> None: + def __init__( + self, + tls_cert: str, + tls_key: str, + **kwargs: Optional[str], + ) -> None: """ Initialize a SecretDataTLSSecretData object. :param str tls_cert: The TLS certificate used in a TLS secret. :param str tls_key: The TLS key used in a TLS secret. - :param **kwargs: (optional) Any additional properties. + :param str **kwargs: (optional) Additional properties of type str """ # pylint: disable=super-init-not-called self.tls_cert = tls_cert self.tls_key = tls_key - for _key, _value in kwargs.items(): - setattr(self, _key, _value) + for k, v in kwargs.items(): + if k not in SecretDataTLSSecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) @classmethod def from_dict(cls, _dict: Dict) -> 'SecretDataTLSSecretData': """Initialize a SecretDataTLSSecretData object from a json dictionary.""" args = {} - if 'tls_cert' in _dict: - args['tls_cert'] = _dict.get('tls_cert') + if (tls_cert := _dict.get('tls_cert')) is not None: + args['tls_cert'] = tls_cert else: raise ValueError('Required property \'tls_cert\' not present in SecretDataTLSSecretData JSON') - if 'tls_key' in _dict: - args['tls_key'] = _dict.get('tls_key') + if (tls_key := _dict.get('tls_key')) is not None: + args['tls_key'] = tls_key else: raise ValueError('Required property \'tls_key\' not present in SecretDataTLSSecretData JSON') - args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) + for k, v in _dict.items(): + if k not in cls._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + args[k] = v return cls(**args) @classmethod @@ -8328,8 +13885,8 @@ def to_dict(self) -> Dict: _dict['tls_cert'] = self.tls_cert if hasattr(self, 'tls_key') and self.tls_key is not None: _dict['tls_key'] = self.tls_key - for _key in [k for k in vars(self).keys() if k not in SecretDataTLSSecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataTLSSecretData._properties]: + _dict[k] = getattr(self, k) return _dict def _to_dict(self): @@ -8337,21 +13894,23 @@ def _to_dict(self): return self.to_dict() def get_properties(self) -> Dict: - """Return a dictionary of arbitrary properties from this instance of SecretDataTLSSecretData""" + """Return the additional properties from this instance of SecretDataTLSSecretData in the form of a dict.""" _dict = {} - - for _key in [k for k in vars(self).keys() if k not in SecretDataTLSSecretData._properties]: - _dict[_key] = getattr(self, _key) + for k in [_k for _k in vars(self).keys() if _k not in SecretDataTLSSecretData._properties]: + _dict[k] = getattr(self, k) return _dict def set_properties(self, _dict: dict): - """Set a dictionary of arbitrary properties to this instance of SecretDataTLSSecretData""" - for _key in [k for k in vars(self).keys() if k not in SecretDataTLSSecretData._properties]: - delattr(self, _key) - - for _key, _value in _dict.items(): - if _key not in SecretDataTLSSecretData._properties: - setattr(self, _key, _value) + """Set a dictionary of additional properties in this instance of SecretDataTLSSecretData""" + for k in [_k for _k in vars(self).keys() if _k not in SecretDataTLSSecretData._properties]: + delattr(self, k) + for k, v in _dict.items(): + if k not in SecretDataTLSSecretData._properties: + if not isinstance(v, str): + raise ValueError('Value for additional property {} must be of type str'.format(k)) + setattr(self, k, v) + else: + raise ValueError('Property {} cannot be specified as an additional property'.format(k)) def __str__(self) -> str: """Return a `str` version of this SecretDataTLSSecretData object.""" @@ -8577,6 +14136,78 @@ def get_all(self) -> List[dict]: return results +class AppInstancesPager: + """ + AppInstancesPager can be used to simplify the use of the "list_app_instances" method. + """ + + def __init__( + self, + *, + client: CodeEngineV2, + project_id: str, + app_name: str, + limit: int = None, + ) -> None: + """ + Initialize a AppInstancesPager object. + :param str project_id: The ID of the project. + :param str app_name: The name of your application. + :param int limit: (optional) Optional maximum number of apps per page. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._project_id = project_id + self._app_name = app_name + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of AppInstance. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_app_instances( + project_id=self._project_id, + app_name=self._app_name, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('instances') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of AppInstance. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + class JobsPager: """ JobsPager can be used to simplify the use of the "list_jobs" method. @@ -8661,8 +14292,8 @@ def __init__( """ Initialize a JobRunsPager object. :param str project_id: The ID of the project. - :param str job_name: (optional) Optional name of the job that should be - filtered for. + :param str job_name: (optional) Optional name of the job that you want to + use to filter. :param int limit: (optional) Optional maximum number of job runs per page. """ self._has_next = True @@ -8718,6 +14349,142 @@ def get_all(self) -> List[dict]: return results +class FunctionsPager: + """ + FunctionsPager can be used to simplify the use of the "list_functions" method. + """ + + def __init__( + self, + *, + client: CodeEngineV2, + project_id: str, + limit: int = None, + ) -> None: + """ + Initialize a FunctionsPager object. + :param str project_id: The ID of the project. + :param int limit: (optional) Optional maximum number of functions per page. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._project_id = project_id + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of Function. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_functions( + project_id=self._project_id, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('functions') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of Function. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class BindingsPager: + """ + BindingsPager can be used to simplify the use of the "list_bindings" method. + """ + + def __init__( + self, + *, + client: CodeEngineV2, + project_id: str, + limit: int = None, + ) -> None: + """ + Initialize a BindingsPager object. + :param str project_id: The ID of the project. + :param int limit: (optional) Optional maximum number of bindings per page. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._project_id = project_id + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of Binding. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_bindings( + project_id=self._project_id, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('bindings') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of Binding. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + class BuildsPager: """ BuildsPager can be used to simplify the use of the "list_builds" method. @@ -8860,6 +14627,75 @@ def get_all(self) -> List[dict]: return results +class DomainMappingsPager: + """ + DomainMappingsPager can be used to simplify the use of the "list_domain_mappings" method. + """ + + def __init__( + self, + *, + client: CodeEngineV2, + project_id: str, + limit: int = None, + ) -> None: + """ + Initialize a DomainMappingsPager object. + :param str project_id: The ID of the project. + :param int limit: (optional) Optional maximum number of domain mappings per + page. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._project_id = project_id + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of DomainMapping. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_domain_mappings( + project_id=self._project_id, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('domain_mappings') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of DomainMapping. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + class ConfigMapsPager: """ ConfigMapsPager can be used to simplify the use of the "list_config_maps" method. diff --git a/ibm_code_engine_sdk/version.py b/ibm_code_engine_sdk/version.py index b042a73..369f1df 100644 --- a/ibm_code_engine_sdk/version.py +++ b/ibm_code_engine_sdk/version.py @@ -17,4 +17,4 @@ """ Version of ibm_code_engine_sdk """ -__version__ = '3.1.0' +__version__ = '4.0.0' diff --git a/requirements-dev.txt b/requirements-dev.txt index 2965c09..68738a1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,8 @@ # test dependencies coverage>=4.5.4 -pylint>=2.6.0,<3.0.0 -pytest>=7.0.1,<8.0.0 -pytest-cov>=2.2.1,<3.0.0 +pylint>=3.3.1,<3.4.0 +pytest>=8.3.2,<8.4.0 +pytest-cov>=5.0.0,<5.1.0 pytest-rerunfailures>=3.1 responses>=0.12.1,<1.0.0 black>=22.10 diff --git a/requirements.txt b/requirements.txt index ac10b3e..5159c28 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ requests>=2.26.0,<3.0.0 -urllib3>=1.26.0,<2.0.0 +urllib3>=2.2.1,<2.3.0 python_dateutil>=2.5.3,<3.0.0 ibm_cloud_sdk_core>=3.16.0,<4.0.0 diff --git a/setup.py b/setup.py index fc8c805..632ce0e 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import sys import pkg_resources -__version__ = '3.1.0' +__version__ = '4.0.0' PACKAGE_NAME = 'ibm_code_engine_sdk' PACKAGE_DESC = 'Python SDK for IBM Cloud Code Engine' diff --git a/test/integration/prepare-integration-tests.sh b/test/integration/prepare-integration-tests.sh new file mode 100755 index 0000000..d0a4a75 --- /dev/null +++ b/test/integration/prepare-integration-tests.sh @@ -0,0 +1,14 @@ +# Create two new self-signed certificates using openssl +# The certs are used to verify TLS secret creations and updates +echo "Creating dummy certificates to verify TLS secrets ..." +openssl req -newkey ed25519 -nodes -keyout ./test/integration/domain.key -out ./test/integration/domain.csr -config ./test/integration/sample_cert.conf +openssl x509 -signkey test/integration/domain.key -in test/integration/domain.csr -req -days 365 -out test/integration/domain.crt +echo "Creating dummy certificates to verify TLS secrets [done]" +echo "" + +# Create two private EC keys using openssl +# The SSH keys are used to verify SSH secret creations and updates +echo "Creating dummy SSH keys to verify SSH secrets ..." +openssl ecparam -name prime256v1 -genkey -noout -out ./test/integration/sshkey.pem +echo "Creating dummy certificates to verify SSH secrets [done]" +echo "" \ No newline at end of file diff --git a/test/integration/sample_cert.conf b/test/integration/sample_cert.conf new file mode 100644 index 0000000..d46551c --- /dev/null +++ b/test/integration/sample_cert.conf @@ -0,0 +1,26 @@ +################################################## +# Licensed Materials - Property of IBM +# IBM Cloud Code Engine, 5900-AB0 +# © Copyright IBM Corp. 2020, 2022 +# US Government Users Restricted Rights - Use, duplication or +# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. +################################################## + +[req] +distinguished_name = req_distinguished_name +req_extensions = v3_req +prompt = no + +[req_distinguished_name] +C = DE +ST = Foo Lane +L = Berlin +O = Foo +OU = Bar +CN = some.foo.local + +[v3_req] +subjectAltName = @alt_names + +[alt_names] +DNS.1 = some.foo.local \ No newline at end of file diff --git a/test/integration/test_v2.py b/test/integration/test_v2.py index 3eea6dd..3b16988 100644 --- a/test/integration/test_v2.py +++ b/test/integration/test_v2.py @@ -886,11 +886,14 @@ def test_create_secret(self): @needscredentials def test_create_ssh_secret(self): + file = open("test/integration/sshkey.pem", "r") + sshKeyContent = file.read() + file.close() response = self.code_engine_service.create_secret( project_id=pytest.e2e_test_project_id, format='ssh_auth', name='my-ssh-secret', - data={'ssh_key': '-----BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----'}, + data={'ssh_key': sshKeyContent}, ) assert response.get_status_code() == 201 @@ -899,13 +902,24 @@ def test_create_ssh_secret(self): @needscredentials def test_create_tls_secret(self): + tlsKeyFilePath = self.config.get('TLS_KEY_FILE_PATH') + assert tlsKeyFilePath is not None + tlsCertFilePath = self.config.get('TLS_CERT_FILE_PATH') + assert tlsCertFilePath is not None + + tlsKeyFile = open(tlsKeyFilePath, "r") + tlsKeyContent = tlsKeyFile.read() + tlsKeyFile.close() + tlsCertFile = open(tlsCertFilePath, "r") + tlsCertContent = tlsCertFile.read() + tlsCertFile.close() response = self.code_engine_service.create_secret( project_id=pytest.e2e_test_project_id, format='tls', name='my-tls-secret', data={ - 'tls_key': '-----BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----', - 'tls_cert': '---BEGIN CERTIFICATE------END CERTIFICATE---', + 'tls_key': tlsKeyContent, + 'tls_cert': tlsCertContent, }, ) @@ -913,6 +927,76 @@ def test_create_tls_secret(self): secret = response.get_result() assert secret is not None + @needscredentials + def test_create_domain_mapping(self): + # store the domainMappingName in the pytest context to be able to share it across tests + pytest.e2e_test_domain_mapping_name = self.config.get('DOMAIN_MAPPING_NAME') + + component_ref_model = { + 'name': 'my-app', + 'resource_type': 'app_v2', + } + response = self.code_engine_service.create_domain_mapping( + project_id=pytest.e2e_test_project_id, + component=component_ref_model, + name=pytest.e2e_test_domain_mapping_name, + tls_secret='my-tls-secret', + ) + assert response.get_status_code() == 201 + domain_mapping = response.get_result() + assert domain_mapping is not None + + @needscredentials + def test_get_domain_mapping(self): + response = self.code_engine_service.get_domain_mapping( + project_id=pytest.e2e_test_project_id, + name=pytest.e2e_test_domain_mapping_name, + ) + assert response.get_status_code() == 200 + domain_mapping = response.get_result() + assert domain_mapping is not None + + @needscredentials + def test_create_app_2(self): + response = self.code_engine_service.create_app( + project_id=pytest.e2e_test_project_id, + image_reference='icr.io/codeengine/helloworld', + name='my-app-2', + ) + + assert response.get_status_code() == 201 + app = response.get_result() + assert app is not None + + @needscredentials + def test_update_domain_mapping(self): + component_ref_model = { + 'name': 'my-app-2', + 'resource_type': 'app_v2', + } + domain_mapping_patch_model = { + 'name': component_ref_model, + } + response = self.code_engine_service.update_domain_mapping( + project_id=pytest.e2e_test_project_id, + name=pytest.e2e_test_domain_mapping_name, + if_match='*', + domain_mapping=domain_mapping_patch_model, + ) + + assert response.get_status_code() == 200 + domain_mapping = response.get_result() + assert domain_mapping is not None + + @needscredentials + def test_delete_domain_mapping_example(self): + response = self.code_engine_service.delete_domain_mapping( + project_id=pytest.e2e_test_project_id, + name=pytest.e2e_test_domain_mapping_name, + ) + + assert response.get_status_code() == 202 + @needscredentials def test_create_basic_auth_secret(self): response = self.code_engine_service.create_secret( @@ -1010,11 +1094,14 @@ def test_replace_secret(self): @needscredentials def test_replace_ssh_secret(self): + file = open("test/integration/sshkey.pem", "r") + sshKeyContent = file.read() + file.close() response = self.code_engine_service.replace_secret( project_id=pytest.e2e_test_project_id, name='my-ssh-secret', if_match='*', - data={'ssh_key': '-----BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----'}, + data={'ssh_key': sshKeyContent}, format='ssh_auth', ) @@ -1024,13 +1111,19 @@ def test_replace_ssh_secret(self): @needscredentials def test_replace_tls_secret(self): + tlsKeyFile = open("test/integration/domain.key", "r") + tlsKeyContent = tlsKeyFile.read() + tlsKeyFile.close() + tlsCertFile = open("test/integration/domain.crt", "r") + tlsCertContent = tlsCertFile.read() + tlsCertFile.close() response = self.code_engine_service.replace_secret( project_id=pytest.e2e_test_project_id, name='my-tls-secret', if_match='*', data={ - 'tls_key': '-----BEGIN RSA PRIVATE KEY-----update-----END RSA PRIVATE KEY-----', - 'tls_cert': '---BEGIN CERTIFICATE---update---END CERTIFICATE---', + 'tls_key': tlsKeyContent, + 'tls_cert': tlsCertContent, }, format='tls', ) @@ -1067,6 +1160,74 @@ def test_replace_registry_secret(self): secret = response.get_result() assert secret is not None + @needscredentials + def test_create_function(self): + response = self.code_engine_service.create_function( + project_id=pytest.e2e_test_project_id, + code_reference='data:text/plain;base64,YXN5bmMgZnVuY3Rpb24gbWFpbihwYXJhbXMpIHsKICByZXR1cm4gewogICAgICBzdGF0dXNDb2RlOiAyMDAsCiAgICAgIGhlYWRlcnM6IHsgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyB9LAogICAgICBib2R5OiBwYXJhbXMgfTsKfQptb2R1bGUuZXhwb3J0cy5tYWluID0gbWFpbjs=', + name='my-function', + runtime='nodejs-20', + ) + + assert response.get_status_code() == 201 + function = response.get_result() + assert function is not None + + @needscredentials + def test_get_function(self): + response = self.code_engine_service.get_function( + project_id=pytest.e2e_test_project_id, + name='my-function', + ) + + assert response.get_status_code() == 200 + function = response.get_result() + assert function is not None + + @needscredentials + def test_update_function(self): + function_patch_model = { + 'ScaleMaxExecutionTime': 30, + } + response = self.code_engine_service.update_function( + project_id=pytest.e2e_test_project_id, + name='my-function', + if_match='*', + function=function_patch_model, + ) + + assert response.get_status_code() == 200 + function = response.get_result() + assert function is not None + + @needscredentials + def test_list_functions(self): + response = self.code_engine_service.list_functions( + project_id=pytest.e2e_test_project_id, + limit=100, + ) + + assert response.get_status_code() == 200 + function_list = response.get_result() + assert function_list is not None + + @needscredentials + def test_list_function_runtimes(self): + response = self.code_engine_service.list_function_runtimes() + + assert response.get_status_code() == 200 + function_runtime_list = response.get_result() + assert function_runtime_list is not None + + @needscredentials + def test_delete_function(self): + response = self.code_engine_service.delete_function( + project_id=pytest.e2e_test_project_id, + name='my-function', + ) + + assert response.get_status_code() == 202 + @needscredentials def test_delete_app_revision(self): response = self.code_engine_service.delete_app_revision( diff --git a/test/unit/test_code_engine_v2.py b/test/unit/test_code_engine_v2.py index 72a3a86..2b5e428 100644 --- a/test/unit/test_code_engine_v2.py +++ b/test/unit/test_code_engine_v2.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2023. +# (C) Copyright IBM Corp. 2024. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import urllib from ibm_code_engine_sdk.code_engine_v2 import * +version = '2024-09-24' _service = CodeEngineV2(authenticator=NoAuthAuthenticator()) @@ -42,23 +43,15 @@ def preprocess_url(operation_path: str): The returned request URL is used to register the mock response so it needs to match the request URL that is formed by the requests library. """ - # First, unquote the path since it might have some quoted/escaped characters in it - # due to how the generator inserts the operation paths into the unit test code. - operation_path = urllib.parse.unquote(operation_path) - # Next, quote the path using urllib so that we approximate what will - # happen during request processing. - operation_path = urllib.parse.quote(operation_path, safe='/') - - # Finally, form the request URL from the base URL and operation path. + # Form the request URL from the base URL and operation path. request_url = _base_url + operation_path # If the request url does NOT end with a /, then just return it as-is. # Otherwise, return a regular expression that matches one or more trailing /. - if re.fullmatch('.*/+', request_url) is None: + if not request_url.endswith('/'): return request_url - else: - return re.compile(request_url.rstrip('/') + '/+') + return re.compile(request_url.rstrip('/') + '/+') ############################################################################## @@ -108,14 +101,24 @@ def test_list_projects_all_params(self): # Set up mock url = preprocess_url('/projects') mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "projects": [{"account_id": "4329073d16d2f3663f74bfa955259139", "created_at": "2021-03-29T12:18:13.992359829Z", "crn": "crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "project-name", "region": "us-east", "resource_group_id": "5c49eabcf5e85881a37e2d100a33b3df", "resource_type": "project_v2", "status": "active"}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values limit = 100 start = 'testString' # Invoke method - response = _service.list_projects(limit=limit, start=start, headers={}) + response = _service.list_projects( + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -143,7 +146,13 @@ def test_list_projects_required_params(self): # Set up mock url = preprocess_url('/projects') mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "projects": [{"account_id": "4329073d16d2f3663f74bfa955259139", "created_at": "2021-03-29T12:18:13.992359829Z", "crn": "crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "project-name", "region": "us-east", "resource_group_id": "5c49eabcf5e85881a37e2d100a33b3df", "resource_type": "project_v2", "status": "active"}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Invoke method response = _service.list_projects() @@ -170,8 +179,20 @@ def test_list_projects_with_pager_get_next(self): url = preprocess_url('/projects') mock_response1 = '{"next":{"start":"1"},"projects":[{"account_id":"4329073d16d2f3663f74bfa955259139","created_at":"2021-03-29T12:18:13.992359829Z","crn":"crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b","id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"project-name","region":"us-east","resource_group_id":"5c49eabcf5e85881a37e2d100a33b3df","resource_type":"project_v2","status":"active"}],"total_count":2,"limit":1}' mock_response2 = '{"projects":[{"account_id":"4329073d16d2f3663f74bfa955259139","created_at":"2021-03-29T12:18:13.992359829Z","crn":"crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b","id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"project-name","region":"us-east","resource_group_id":"5c49eabcf5e85881a37e2d100a33b3df","resource_type":"project_v2","status":"active"}],"total_count":2,"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -194,8 +215,20 @@ def test_list_projects_with_pager_get_all(self): url = preprocess_url('/projects') mock_response1 = '{"next":{"start":"1"},"projects":[{"account_id":"4329073d16d2f3663f74bfa955259139","created_at":"2021-03-29T12:18:13.992359829Z","crn":"crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b","id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"project-name","region":"us-east","resource_group_id":"5c49eabcf5e85881a37e2d100a33b3df","resource_type":"project_v2","status":"active"}],"total_count":2,"limit":1}' mock_response2 = '{"projects":[{"account_id":"4329073d16d2f3663f74bfa955259139","created_at":"2021-03-29T12:18:13.992359829Z","crn":"crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b","id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"project-name","region":"us-east","resource_group_id":"5c49eabcf5e85881a37e2d100a33b3df","resource_type":"project_v2","status":"active"}],"total_count":2,"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = ProjectsPager( @@ -220,7 +253,13 @@ def test_create_project_all_params(self): # Set up mock url = preprocess_url('/projects') mock_response = '{"account_id": "4329073d16d2f3663f74bfa955259139", "created_at": "2021-03-29T12:18:13.992359829Z", "crn": "crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "project-name", "region": "us-east", "resource_group_id": "5c49eabcf5e85881a37e2d100a33b3df", "resource_type": "project_v2", "status": "active"}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) # Set up parameter values name = 'my-project' @@ -228,7 +267,12 @@ def test_create_project_all_params(self): tags = ['testString'] # Invoke method - response = _service.create_project(name, resource_group_id=resource_group_id, tags=tags, headers={}) + response = _service.create_project( + name, + resource_group_id=resource_group_id, + tags=tags, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -256,7 +300,13 @@ def test_create_project_value_error(self): # Set up mock url = preprocess_url('/projects') mock_response = '{"account_id": "4329073d16d2f3663f74bfa955259139", "created_at": "2021-03-29T12:18:13.992359829Z", "crn": "crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "project-name", "region": "us-east", "resource_group_id": "5c49eabcf5e85881a37e2d100a33b3df", "resource_type": "project_v2", "status": "active"}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) # Set up parameter values name = 'my-project' @@ -295,13 +345,22 @@ def test_get_project_all_params(self): # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005') mock_response = '{"account_id": "4329073d16d2f3663f74bfa955259139", "created_at": "2021-03-29T12:18:13.992359829Z", "crn": "crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "project-name", "region": "us-east", "resource_group_id": "5c49eabcf5e85881a37e2d100a33b3df", "resource_type": "project_v2", "status": "active"}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.get_project(id, headers={}) + response = _service.get_project( + id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -324,7 +383,13 @@ def test_get_project_value_error(self): # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005') mock_response = '{"account_id": "4329073d16d2f3663f74bfa955259139", "created_at": "2021-03-29T12:18:13.992359829Z", "crn": "crn:v1:bluemix:public:codeengine:eu-de:a/4329073d16d2f3663f74bfa955259139:4e49b3e0-27a8-48d2-a784-c7ee48bb863b::", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "project-name", "region": "us-east", "resource_group_id": "5c49eabcf5e85881a37e2d100a33b3df", "resource_type": "project_v2", "status": "active"}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -360,13 +425,20 @@ def test_delete_project_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.delete_project(id, headers={}) + response = _service.delete_project( + id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -388,7 +460,11 @@ def test_delete_project_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -425,13 +501,22 @@ def test_get_project_egress_ips_all_params(self): # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/egress_ips') mock_response = '{"private": ["private"], "public": ["public"]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.get_project_egress_ips(project_id, headers={}) + response = _service.get_project_egress_ips( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -454,7 +539,13 @@ def test_get_project_egress_ips_value_error(self): # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/egress_ips') mock_response = '{"private": ["private"], "public": ["public"]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -478,6 +569,87 @@ def test_get_project_egress_ips_value_error_with_retries(self): self.test_get_project_egress_ips_value_error() +class TestGetProjectStatusDetails: + """ + Test Class for get_project_status_details + """ + + @responses.activate + def test_get_project_status_details_all_params(self): + """ + get_project_status_details() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/status_details') + mock_response = '{"domain": "unknown", "project": "enabled", "vpe_not_enabled": false}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Invoke method + response = _service.get_project_status_details( + project_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_project_status_details_all_params_with_retries(self): + # Enable retries and run test_get_project_status_details_all_params. + _service.enable_retries() + self.test_get_project_status_details_all_params() + + # Disable retries and run test_get_project_status_details_all_params. + _service.disable_retries() + self.test_get_project_status_details_all_params() + + @responses.activate + def test_get_project_status_details_value_error(self): + """ + test_get_project_status_details_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/status_details') + mock_response = '{"domain": "unknown", "project": "enabled", "vpe_not_enabled": false}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_project_status_details(**req_copy) + + def test_get_project_status_details_value_error_with_retries(self): + # Enable retries and run test_get_project_status_details_value_error. + _service.enable_retries() + self.test_get_project_status_details_value_error() + + # Disable retries and run test_get_project_status_details_value_error. + _service.disable_retries() + self.test_get_project_status_details_value_error() + + # endregion ############################################################################## # End of Service: Projects @@ -529,8 +701,14 @@ def test_list_apps_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response = '{"apps": [{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"apps": [{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -538,7 +716,12 @@ def test_list_apps_all_params(self): start = 'testString' # Invoke method - response = _service.list_apps(project_id, limit=limit, start=start, headers={}) + response = _service.list_apps( + project_id, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -565,14 +748,23 @@ def test_list_apps_required_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response = '{"apps": [{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"apps": [{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_apps(project_id, headers={}) + response = _service.list_apps( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -594,8 +786,14 @@ def test_list_apps_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response = '{"apps": [{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"apps": [{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -625,10 +823,22 @@ def test_list_apps_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"apps":[{"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' - mock_response2 = '{"total_count":2,"limit":1,"apps":[{"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"apps":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"apps":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -650,10 +860,22 @@ def test_list_apps_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"apps":[{"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' - mock_response2 = '{"total_count":2,"limit":1,"apps":[{"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"apps":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"apps":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-app.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","managed_domain_mappings":"local_public","name":"my-app","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"latest_created_revision":"my-app-00001","latest_ready_revision":"my-app-00001","reason":"ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = AppsPager( @@ -678,8 +900,24 @@ def test_create_app_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ProbePrototype model + probe_prototype_model = {} + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -704,6 +942,8 @@ def test_create_app_all_params(self): image_port = 8080 image_secret = 'my-secret' managed_domain_mappings = 'local_public' + probe_liveness = probe_prototype_model + probe_readiness = probe_prototype_model run_arguments = ['testString'] run_as_user = 1001 run_commands = ['testString'] @@ -713,6 +953,7 @@ def test_create_app_all_params(self): scale_concurrency = 100 scale_concurrency_target = 80 scale_cpu_limit = '1' + scale_down_delay = 300 scale_ephemeral_storage_limit = '4G' scale_initial_instances = 1 scale_max_instances = 10 @@ -728,6 +969,8 @@ def test_create_app_all_params(self): image_port=image_port, image_secret=image_secret, managed_domain_mappings=managed_domain_mappings, + probe_liveness=probe_liveness, + probe_readiness=probe_readiness, run_arguments=run_arguments, run_as_user=run_as_user, run_commands=run_commands, @@ -737,6 +980,7 @@ def test_create_app_all_params(self): scale_concurrency=scale_concurrency, scale_concurrency_target=scale_concurrency_target, scale_cpu_limit=scale_cpu_limit, + scale_down_delay=scale_down_delay, scale_ephemeral_storage_limit=scale_ephemeral_storage_limit, scale_initial_instances=scale_initial_instances, scale_max_instances=scale_max_instances, @@ -756,6 +1000,8 @@ def test_create_app_all_params(self): assert req_body['image_port'] == 8080 assert req_body['image_secret'] == 'my-secret' assert req_body['managed_domain_mappings'] == 'local_public' + assert req_body['probe_liveness'] == probe_prototype_model + assert req_body['probe_readiness'] == probe_prototype_model assert req_body['run_arguments'] == ['testString'] assert req_body['run_as_user'] == 1001 assert req_body['run_commands'] == ['testString'] @@ -765,6 +1011,7 @@ def test_create_app_all_params(self): assert req_body['scale_concurrency'] == 100 assert req_body['scale_concurrency_target'] == 80 assert req_body['scale_cpu_limit'] == '1' + assert req_body['scale_down_delay'] == 300 assert req_body['scale_ephemeral_storage_limit'] == '4G' assert req_body['scale_initial_instances'] == 1 assert req_body['scale_max_instances'] == 10 @@ -781,6 +1028,141 @@ def test_create_app_all_params_with_retries(self): _service.disable_retries() self.test_create_app_all_params() + @responses.activate + def test_create_app_required_params(self): + """ + test_create_app_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ProbePrototype model + probe_prototype_model = {} + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a VolumeMountPrototype model + volume_mount_prototype_model = {} + volume_mount_prototype_model['mount_path'] = '/app' + volume_mount_prototype_model['name'] = 'codeengine-mount-b69u90' + volume_mount_prototype_model['reference'] = 'my-secret' + volume_mount_prototype_model['type'] = 'secret' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + image_reference = 'icr.io/codeengine/helloworld' + name = 'my-app' + image_port = 8080 + image_secret = 'my-secret' + managed_domain_mappings = 'local_public' + probe_liveness = probe_prototype_model + probe_readiness = probe_prototype_model + run_arguments = ['testString'] + run_as_user = 1001 + run_commands = ['testString'] + run_env_variables = [env_var_prototype_model] + run_service_account = 'default' + run_volume_mounts = [volume_mount_prototype_model] + scale_concurrency = 100 + scale_concurrency_target = 80 + scale_cpu_limit = '1' + scale_down_delay = 300 + scale_ephemeral_storage_limit = '4G' + scale_initial_instances = 1 + scale_max_instances = 10 + scale_memory_limit = '4G' + scale_min_instances = 1 + scale_request_timeout = 300 + + # Invoke method + response = _service.create_app( + project_id, + image_reference, + name, + image_port=image_port, + image_secret=image_secret, + managed_domain_mappings=managed_domain_mappings, + probe_liveness=probe_liveness, + probe_readiness=probe_readiness, + run_arguments=run_arguments, + run_as_user=run_as_user, + run_commands=run_commands, + run_env_variables=run_env_variables, + run_service_account=run_service_account, + run_volume_mounts=run_volume_mounts, + scale_concurrency=scale_concurrency, + scale_concurrency_target=scale_concurrency_target, + scale_cpu_limit=scale_cpu_limit, + scale_down_delay=scale_down_delay, + scale_ephemeral_storage_limit=scale_ephemeral_storage_limit, + scale_initial_instances=scale_initial_instances, + scale_max_instances=scale_max_instances, + scale_memory_limit=scale_memory_limit, + scale_min_instances=scale_min_instances, + scale_request_timeout=scale_request_timeout, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['image_reference'] == 'icr.io/codeengine/helloworld' + assert req_body['name'] == 'my-app' + assert req_body['image_port'] == 8080 + assert req_body['image_secret'] == 'my-secret' + assert req_body['managed_domain_mappings'] == 'local_public' + assert req_body['probe_liveness'] == probe_prototype_model + assert req_body['probe_readiness'] == probe_prototype_model + assert req_body['run_arguments'] == ['testString'] + assert req_body['run_as_user'] == 1001 + assert req_body['run_commands'] == ['testString'] + assert req_body['run_env_variables'] == [env_var_prototype_model] + assert req_body['run_service_account'] == 'default' + assert req_body['run_volume_mounts'] == [volume_mount_prototype_model] + assert req_body['scale_concurrency'] == 100 + assert req_body['scale_concurrency_target'] == 80 + assert req_body['scale_cpu_limit'] == '1' + assert req_body['scale_down_delay'] == 300 + assert req_body['scale_ephemeral_storage_limit'] == '4G' + assert req_body['scale_initial_instances'] == 1 + assert req_body['scale_max_instances'] == 10 + assert req_body['scale_memory_limit'] == '4G' + assert req_body['scale_min_instances'] == 1 + assert req_body['scale_request_timeout'] == 300 + + def test_create_app_required_params_with_retries(self): + # Enable retries and run test_create_app_required_params. + _service.enable_retries() + self.test_create_app_required_params() + + # Disable retries and run test_create_app_required_params. + _service.disable_retries() + self.test_create_app_required_params() + @responses.activate def test_create_app_value_error(self): """ @@ -788,8 +1170,24 @@ def test_create_app_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ProbePrototype model + probe_prototype_model = {} + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -814,6 +1212,8 @@ def test_create_app_value_error(self): image_port = 8080 image_secret = 'my-secret' managed_domain_mappings = 'local_public' + probe_liveness = probe_prototype_model + probe_readiness = probe_prototype_model run_arguments = ['testString'] run_as_user = 1001 run_commands = ['testString'] @@ -823,6 +1223,7 @@ def test_create_app_value_error(self): scale_concurrency = 100 scale_concurrency_target = 80 scale_cpu_limit = '1' + scale_down_delay = 300 scale_ephemeral_storage_limit = '4G' scale_initial_instances = 1 scale_max_instances = 10 @@ -863,15 +1264,25 @@ def test_get_app_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-app' # Invoke method - response = _service.get_app(project_id, name, headers={}) + response = _service.get_app( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -886,6 +1297,46 @@ def test_get_app_all_params_with_retries(self): _service.disable_retries() self.test_get_app_all_params() + @responses.activate + def test_get_app_required_params(self): + """ + test_get_app_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-app' + + # Invoke method + response = _service.get_app( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_app_required_params_with_retries(self): + # Enable retries and run test_get_app_required_params. + _service.enable_retries() + self.test_get_app_required_params() + + # Disable retries and run test_get_app_required_params. + _service.disable_retries() + self.test_get_app_required_params() + @responses.activate def test_get_app_value_error(self): """ @@ -893,8 +1344,14 @@ def test_get_app_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -932,14 +1389,22 @@ def test_delete_app_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-app' # Invoke method - response = _service.delete_app(project_id, name, headers={}) + response = _service.delete_app( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -954,6 +1419,43 @@ def test_delete_app_all_params_with_retries(self): _service.disable_retries() self.test_delete_app_all_params() + @responses.activate + def test_delete_app_required_params(self): + """ + test_delete_app_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-app' + + # Invoke method + response = _service.delete_app( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_app_required_params_with_retries(self): + # Enable retries and run test_delete_app_required_params. + _service.enable_retries() + self.test_delete_app_required_params() + + # Disable retries and run test_delete_app_required_params. + _service.disable_retries() + self.test_delete_app_required_params() + @responses.activate def test_delete_app_value_error(self): """ @@ -961,7 +1463,11 @@ def test_delete_app_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -999,8 +1505,24 @@ def test_update_app_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' - responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a ProbePrototype model + probe_prototype_model = {} + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -1024,6 +1546,8 @@ def test_update_app_all_params(self): app_patch_model['image_reference'] = 'icr.io/codeengine/helloworld' app_patch_model['image_secret'] = 'my-secret' app_patch_model['managed_domain_mappings'] = 'local_public' + app_patch_model['probe_liveness'] = probe_prototype_model + app_patch_model['probe_readiness'] = probe_prototype_model app_patch_model['run_arguments'] = ['testString'] app_patch_model['run_as_user'] = 1001 app_patch_model['run_commands'] = ['testString'] @@ -1033,6 +1557,7 @@ def test_update_app_all_params(self): app_patch_model['scale_concurrency'] = 100 app_patch_model['scale_concurrency_target'] = 80 app_patch_model['scale_cpu_limit'] = '1' + app_patch_model['scale_down_delay'] = 300 app_patch_model['scale_ephemeral_storage_limit'] = '4G' app_patch_model['scale_initial_instances'] = 1 app_patch_model['scale_max_instances'] = 10 @@ -1047,7 +1572,13 @@ def test_update_app_all_params(self): app = app_patch_model # Invoke method - response = _service.update_app(project_id, name, if_match, app, headers={}) + response = _service.update_app( + project_id, + name, + if_match, + app, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1065,6 +1596,104 @@ def test_update_app_all_params_with_retries(self): _service.disable_retries() self.test_update_app_all_params() + @responses.activate + def test_update_app_required_params(self): + """ + test_update_app_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a ProbePrototype model + probe_prototype_model = {} + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a VolumeMountPrototype model + volume_mount_prototype_model = {} + volume_mount_prototype_model['mount_path'] = '/app' + volume_mount_prototype_model['name'] = 'codeengine-mount-b69u90' + volume_mount_prototype_model['reference'] = 'my-secret' + volume_mount_prototype_model['type'] = 'secret' + + # Construct a dict representation of a AppPatch model + app_patch_model = {} + app_patch_model['image_port'] = 8080 + app_patch_model['image_reference'] = 'icr.io/codeengine/helloworld' + app_patch_model['image_secret'] = 'my-secret' + app_patch_model['managed_domain_mappings'] = 'local_public' + app_patch_model['probe_liveness'] = probe_prototype_model + app_patch_model['probe_readiness'] = probe_prototype_model + app_patch_model['run_arguments'] = ['testString'] + app_patch_model['run_as_user'] = 1001 + app_patch_model['run_commands'] = ['testString'] + app_patch_model['run_env_variables'] = [env_var_prototype_model] + app_patch_model['run_service_account'] = 'default' + app_patch_model['run_volume_mounts'] = [volume_mount_prototype_model] + app_patch_model['scale_concurrency'] = 100 + app_patch_model['scale_concurrency_target'] = 80 + app_patch_model['scale_cpu_limit'] = '1' + app_patch_model['scale_down_delay'] = 300 + app_patch_model['scale_ephemeral_storage_limit'] = '4G' + app_patch_model['scale_initial_instances'] = 1 + app_patch_model['scale_max_instances'] = 10 + app_patch_model['scale_memory_limit'] = '4G' + app_patch_model['scale_min_instances'] = 1 + app_patch_model['scale_request_timeout'] = 300 + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-app' + if_match = 'testString' + app = app_patch_model + + # Invoke method + response = _service.update_app( + project_id, + name, + if_match, + app, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == app + + def test_update_app_required_params_with_retries(self): + # Enable retries and run test_update_app_required_params. + _service.enable_retries() + self.test_update_app_required_params() + + # Disable retries and run test_update_app_required_params. + _service.disable_retries() + self.test_update_app_required_params() + @responses.activate def test_update_app_value_error(self): """ @@ -1072,8 +1701,24 @@ def test_update_app_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' - responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-app.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-app.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "managed_domain_mappings": "local_public", "name": "my-app", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"latest_created_revision": "my-app-00001", "latest_ready_revision": "my-app-00001", "reason": "ready"}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a ProbePrototype model + probe_prototype_model = {} + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -1097,6 +1742,8 @@ def test_update_app_value_error(self): app_patch_model['image_reference'] = 'icr.io/codeengine/helloworld' app_patch_model['image_secret'] = 'my-secret' app_patch_model['managed_domain_mappings'] = 'local_public' + app_patch_model['probe_liveness'] = probe_prototype_model + app_patch_model['probe_readiness'] = probe_prototype_model app_patch_model['run_arguments'] = ['testString'] app_patch_model['run_as_user'] = 1001 app_patch_model['run_commands'] = ['testString'] @@ -1106,6 +1753,7 @@ def test_update_app_value_error(self): app_patch_model['scale_concurrency'] = 100 app_patch_model['scale_concurrency_target'] = 80 app_patch_model['scale_cpu_limit'] = '1' + app_patch_model['scale_down_delay'] = 300 app_patch_model['scale_ephemeral_storage_limit'] = '4G' app_patch_model['scale_initial_instances'] = 1 app_patch_model['scale_max_instances'] = 10 @@ -1153,8 +1801,14 @@ def test_list_app_revisions_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions') - mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "revisions": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "revisions": [{"app_name": "my-app", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1163,7 +1817,13 @@ def test_list_app_revisions_all_params(self): start = 'testString' # Invoke method - response = _service.list_app_revisions(project_id, app_name, limit=limit, start=start, headers={}) + response = _service.list_app_revisions( + project_id, + app_name, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1190,15 +1850,25 @@ def test_list_app_revisions_required_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions') - mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "revisions": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "revisions": [{"app_name": "my-app", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' app_name = 'my-app' # Invoke method - response = _service.list_app_revisions(project_id, app_name, headers={}) + response = _service.list_app_revisions( + project_id, + app_name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1220,8 +1890,14 @@ def test_list_app_revisions_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions') - mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "revisions": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "revisions": [{"app_name": "my-app", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1253,10 +1929,22 @@ def test_list_app_revisions_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' - mock_response2 = '{"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -1279,10 +1967,22 @@ def test_list_app_revisions_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' - mock_response2 = '{"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"revisions":[{"app_name":"my-app","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_port":8080,"image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-app-00001","probe_liveness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"probe_readiness":{"failure_threshold":5,"initial_delay":5,"interval":5,"path":"path","port":8080,"timeout":300,"type":"tcp"},"project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_revision_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_concurrency":100,"scale_concurrency_target":80,"scale_cpu_limit":"1","scale_down_delay":300,"scale_ephemeral_storage_limit":"4G","scale_initial_instances":1,"scale_max_instances":10,"scale_memory_limit":"4G","scale_min_instances":1,"scale_request_timeout":300,"status":"ready","status_details":{"actual_instances":1,"reason":"ready"}}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = AppRevisionsPager( @@ -1308,8 +2008,14 @@ def test_get_app_revision_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions/my-app-00001') - mock_response = '{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"app_name": "my-app", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1317,7 +2023,12 @@ def test_get_app_revision_all_params(self): name = 'my-app-00001' # Invoke method - response = _service.get_app_revision(project_id, app_name, name, headers={}) + response = _service.get_app_revision( + project_id, + app_name, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1332,6 +2043,48 @@ def test_get_app_revision_all_params_with_retries(self): _service.disable_retries() self.test_get_app_revision_all_params() + @responses.activate + def test_get_app_revision_required_params(self): + """ + test_get_app_revision_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions/my-app-00001') + mock_response = '{"app_name": "my-app", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + app_name = 'my-app' + name = 'my-app-00001' + + # Invoke method + response = _service.get_app_revision( + project_id, + app_name, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_app_revision_required_params_with_retries(self): + # Enable retries and run test_get_app_revision_required_params. + _service.enable_retries() + self.test_get_app_revision_required_params() + + # Disable retries and run test_get_app_revision_required_params. + _service.disable_retries() + self.test_get_app_revision_required_params() + @responses.activate def test_get_app_revision_value_error(self): """ @@ -1339,8 +2092,14 @@ def test_get_app_revision_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions/my-app-00001') - mock_response = '{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"app_name": "my-app", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/revisions/my-app-00001", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_port": 8080, "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-app-00001", "probe_liveness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "probe_readiness": {"failure_threshold": 5, "initial_delay": 5, "interval": 5, "path": "path", "port": 8080, "timeout": 300, "type": "tcp"}, "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_revision_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_concurrency": 100, "scale_concurrency_target": 80, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_ephemeral_storage_limit": "4G", "scale_initial_instances": 1, "scale_max_instances": 10, "scale_memory_limit": "4G", "scale_min_instances": 1, "scale_request_timeout": 300, "status": "ready", "status_details": {"actual_instances": 1, "reason": "ready"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1380,7 +2139,11 @@ def test_delete_app_revision_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions/my-app-00001') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1388,7 +2151,12 @@ def test_delete_app_revision_all_params(self): name = 'my-app-00001' # Invoke method - response = _service.delete_app_revision(project_id, app_name, name, headers={}) + response = _service.delete_app_revision( + project_id, + app_name, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1410,7 +2178,11 @@ def test_delete_app_revision_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/revisions/my-app-00001') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1438,6 +2210,213 @@ def test_delete_app_revision_value_error_with_retries(self): self.test_delete_app_revision_value_error() +class TestListAppInstances: + """ + Test Class for list_app_instances + """ + + @responses.activate + def test_list_app_instances_all_params(self): + """ + list_app_instances() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances') + mock_response = '{"first": {"href": "href"}, "instances": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-app-00001-deployment-6c9b5cf966-wjs44", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_instance_v2", "restarts": 4, "revision_name": "my-app", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_memory_limit": "4G", "status": "pending", "system_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}, "user_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + app_name = 'my-app' + limit = 100 + start = 'testString' + + # Invoke method + response = _service.list_app_instances( + project_id, + app_name, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_app_instances_all_params_with_retries(self): + # Enable retries and run test_list_app_instances_all_params. + _service.enable_retries() + self.test_list_app_instances_all_params() + + # Disable retries and run test_list_app_instances_all_params. + _service.disable_retries() + self.test_list_app_instances_all_params() + + @responses.activate + def test_list_app_instances_required_params(self): + """ + test_list_app_instances_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances') + mock_response = '{"first": {"href": "href"}, "instances": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-app-00001-deployment-6c9b5cf966-wjs44", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_instance_v2", "restarts": 4, "revision_name": "my-app", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_memory_limit": "4G", "status": "pending", "system_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}, "user_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + app_name = 'my-app' + + # Invoke method + response = _service.list_app_instances( + project_id, + app_name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_app_instances_required_params_with_retries(self): + # Enable retries and run test_list_app_instances_required_params. + _service.enable_retries() + self.test_list_app_instances_required_params() + + # Disable retries and run test_list_app_instances_required_params. + _service.disable_retries() + self.test_list_app_instances_required_params() + + @responses.activate + def test_list_app_instances_value_error(self): + """ + test_list_app_instances_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances') + mock_response = '{"first": {"href": "href"}, "instances": [{"app_name": "my-app", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-app-00001-deployment-6c9b5cf966-wjs44", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "app_instance_v2", "restarts": 4, "revision_name": "my-app", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_memory_limit": "4G", "status": "pending", "system_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}, "user_container": {"current_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}, "last_observed_state": {"completed_at": "2022-09-22T17:40:00Z", "container_status": "container_status", "exit_code": 100, "reason": "ready", "started_at": "2022-09-22T17:34:00Z"}}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + app_name = 'my-app' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "app_name": app_name, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_app_instances(**req_copy) + + def test_list_app_instances_value_error_with_retries(self): + # Enable retries and run test_list_app_instances_value_error. + _service.enable_retries() + self.test_list_app_instances_value_error() + + # Disable retries and run test_list_app_instances_value_error. + _service.disable_retries() + self.test_list_app_instances_value_error() + + @responses.activate + def test_list_app_instances_with_pager_get_next(self): + """ + test_list_app_instances_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances') + mock_response1 = '{"next":{"start":"1"},"instances":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-app-00001-deployment-6c9b5cf966-wjs44","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_instance_v2","restarts":4,"revision_name":"my-app","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_memory_limit":"4G","status":"pending","system_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}},"user_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}}}],"total_count":2,"limit":1}' + mock_response2 = '{"instances":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-app-00001-deployment-6c9b5cf966-wjs44","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_instance_v2","restarts":4,"revision_name":"my-app","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_memory_limit":"4G","status":"pending","system_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}},"user_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}}}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = AppInstancesPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + app_name='my-app', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_app_instances_with_pager_get_all(self): + """ + test_list_app_instances_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/apps/my-app/instances') + mock_response1 = '{"next":{"start":"1"},"instances":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-app-00001-deployment-6c9b5cf966-wjs44","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_instance_v2","restarts":4,"revision_name":"my-app","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_memory_limit":"4G","status":"pending","system_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}},"user_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}}}],"total_count":2,"limit":1}' + mock_response2 = '{"instances":[{"app_name":"my-app","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/apps/my-app/instances","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-app-00001-deployment-6c9b5cf966-wjs44","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"app_instance_v2","restarts":4,"revision_name":"my-app","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_memory_limit":"4G","status":"pending","system_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}},"user_container":{"current_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"},"last_observed_state":{"completed_at":"2022-09-22T17:40:00Z","container_status":"container_status","exit_code":100,"reason":"ready","started_at":"2022-09-22T17:34:00Z"}}}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = AppInstancesPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + app_name='my-app', + limit=100, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + # endregion ############################################################################## # End of Service: Applications @@ -1489,8 +2468,14 @@ def test_list_jobs_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response = '{"first": {"href": "href"}, "jobs": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}], "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "jobs": [{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1498,7 +2483,12 @@ def test_list_jobs_all_params(self): start = 'testString' # Invoke method - response = _service.list_jobs(project_id, limit=limit, start=start, headers={}) + response = _service.list_jobs( + project_id, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1525,14 +2515,23 @@ def test_list_jobs_required_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response = '{"first": {"href": "href"}, "jobs": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}], "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "jobs": [{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_jobs(project_id, headers={}) + response = _service.list_jobs( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1554,8 +2553,14 @@ def test_list_jobs_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response = '{"first": {"href": "href"}, "jobs": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}], "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "jobs": [{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1585,10 +2590,22 @@ def test_list_jobs_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"jobs":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' - mock_response2 = '{"total_count":2,"jobs":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"jobs":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' + mock_response2 = '{"total_count":2,"jobs":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -1610,10 +2627,22 @@ def test_list_jobs_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"jobs":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' - mock_response2 = '{"total_count":2,"jobs":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"jobs":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' + mock_response2 = '{"total_count":2,"jobs":[{"build":"my-build","build_run":"my-build-run","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","name":"my-job","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3}],"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = JobsPager( @@ -1638,8 +2667,14 @@ def test_create_job_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -1729,6 +2764,110 @@ def test_create_job_all_params_with_retries(self): _service.disable_retries() self.test_create_job_all_params() + @responses.activate + def test_create_job_required_params(self): + """ + test_create_job_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a VolumeMountPrototype model + volume_mount_prototype_model = {} + volume_mount_prototype_model['mount_path'] = '/app' + volume_mount_prototype_model['name'] = 'codeengine-mount-b69u90' + volume_mount_prototype_model['reference'] = 'my-secret' + volume_mount_prototype_model['type'] = 'secret' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + image_reference = 'icr.io/codeengine/helloworld' + name = 'my-job' + image_secret = 'my-secret' + run_arguments = ['testString'] + run_as_user = 1001 + run_commands = ['testString'] + run_env_variables = [env_var_prototype_model] + run_mode = 'task' + run_service_account = 'default' + run_volume_mounts = [volume_mount_prototype_model] + scale_array_spec = '1-5,7-8,10' + scale_cpu_limit = '1' + scale_ephemeral_storage_limit = '4G' + scale_max_execution_time = 7200 + scale_memory_limit = '4G' + scale_retry_limit = 3 + + # Invoke method + response = _service.create_job( + project_id, + image_reference, + name, + image_secret=image_secret, + run_arguments=run_arguments, + run_as_user=run_as_user, + run_commands=run_commands, + run_env_variables=run_env_variables, + run_mode=run_mode, + run_service_account=run_service_account, + run_volume_mounts=run_volume_mounts, + scale_array_spec=scale_array_spec, + scale_cpu_limit=scale_cpu_limit, + scale_ephemeral_storage_limit=scale_ephemeral_storage_limit, + scale_max_execution_time=scale_max_execution_time, + scale_memory_limit=scale_memory_limit, + scale_retry_limit=scale_retry_limit, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['image_reference'] == 'icr.io/codeengine/helloworld' + assert req_body['name'] == 'my-job' + assert req_body['image_secret'] == 'my-secret' + assert req_body['run_arguments'] == ['testString'] + assert req_body['run_as_user'] == 1001 + assert req_body['run_commands'] == ['testString'] + assert req_body['run_env_variables'] == [env_var_prototype_model] + assert req_body['run_mode'] == 'task' + assert req_body['run_service_account'] == 'default' + assert req_body['run_volume_mounts'] == [volume_mount_prototype_model] + assert req_body['scale_array_spec'] == '1-5,7-8,10' + assert req_body['scale_cpu_limit'] == '1' + assert req_body['scale_ephemeral_storage_limit'] == '4G' + assert req_body['scale_max_execution_time'] == 7200 + assert req_body['scale_memory_limit'] == '4G' + assert req_body['scale_retry_limit'] == 3 + + def test_create_job_required_params_with_retries(self): + # Enable retries and run test_create_job_required_params. + _service.enable_retries() + self.test_create_job_required_params() + + # Disable retries and run test_create_job_required_params. + _service.disable_retries() + self.test_create_job_required_params() + @responses.activate def test_create_job_value_error(self): """ @@ -1736,8 +2875,14 @@ def test_create_job_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -1807,15 +2952,25 @@ def test_get_job_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-job' # Invoke method - response = _service.get_job(project_id, name, headers={}) + response = _service.get_job( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1830,6 +2985,46 @@ def test_get_job_all_params_with_retries(self): _service.disable_retries() self.test_get_job_all_params() + @responses.activate + def test_get_job_required_params(self): + """ + test_get_job_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-job' + + # Invoke method + response = _service.get_job( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_job_required_params_with_retries(self): + # Enable retries and run test_get_job_required_params. + _service.enable_retries() + self.test_get_job_required_params() + + # Disable retries and run test_get_job_required_params. + _service.disable_retries() + self.test_get_job_required_params() + @responses.activate def test_get_job_value_error(self): """ @@ -1837,8 +3032,14 @@ def test_get_job_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1876,14 +3077,22 @@ def test_delete_job_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-job' # Invoke method - response = _service.delete_job(project_id, name, headers={}) + response = _service.delete_job( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -1898,6 +3107,43 @@ def test_delete_job_all_params_with_retries(self): _service.disable_retries() self.test_delete_job_all_params() + @responses.activate + def test_delete_job_required_params(self): + """ + test_delete_job_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-job' + + # Invoke method + response = _service.delete_job( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_job_required_params_with_retries(self): + # Enable retries and run test_delete_job_required_params. + _service.enable_retries() + self.test_delete_job_required_params() + + # Disable retries and run test_delete_job_required_params. + _service.disable_retries() + self.test_delete_job_required_params() + @responses.activate def test_delete_job_value_error(self): """ @@ -1905,7 +3151,11 @@ def test_delete_job_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -1943,8 +3193,14 @@ def test_update_job_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' - responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -1987,7 +3243,13 @@ def test_update_job_all_params(self): job = job_patch_model # Invoke method - response = _service.update_job(project_id, name, if_match, job, headers={}) + response = _service.update_job( + project_id, + name, + if_match, + job, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -2005,6 +3267,87 @@ def test_update_job_all_params_with_retries(self): _service.disable_retries() self.test_update_job_all_params() + @responses.activate + def test_update_job_required_params(self): + """ + test_update_job_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a VolumeMountPrototype model + volume_mount_prototype_model = {} + volume_mount_prototype_model['mount_path'] = '/app' + volume_mount_prototype_model['name'] = 'codeengine-mount-b69u90' + volume_mount_prototype_model['reference'] = 'my-secret' + volume_mount_prototype_model['type'] = 'secret' + + # Construct a dict representation of a JobPatch model + job_patch_model = {} + job_patch_model['image_reference'] = 'icr.io/codeengine/helloworld' + job_patch_model['image_secret'] = 'my-secret' + job_patch_model['run_arguments'] = ['testString'] + job_patch_model['run_as_user'] = 1001 + job_patch_model['run_commands'] = ['testString'] + job_patch_model['run_env_variables'] = [env_var_prototype_model] + job_patch_model['run_mode'] = 'task' + job_patch_model['run_service_account'] = 'default' + job_patch_model['run_volume_mounts'] = [volume_mount_prototype_model] + job_patch_model['scale_array_spec'] = '1-5,7-8,10' + job_patch_model['scale_cpu_limit'] = '1' + job_patch_model['scale_ephemeral_storage_limit'] = '4G' + job_patch_model['scale_max_execution_time'] = 7200 + job_patch_model['scale_memory_limit'] = '4G' + job_patch_model['scale_retry_limit'] = 3 + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-job' + if_match = 'testString' + job = job_patch_model + + # Invoke method + response = _service.update_job( + project_id, + name, + if_match, + job, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == job + + def test_update_job_required_params_with_retries(self): + # Enable retries and run test_update_job_required_params. + _service.enable_retries() + self.test_update_job_required_params() + + # Disable retries and run test_update_job_required_params. + _service.disable_retries() + self.test_update_job_required_params() + @responses.activate def test_update_job_value_error(self): """ @@ -2012,8 +3355,14 @@ def test_update_job_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/jobs/my-job') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' - responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"build": "my-build", "build_run": "my-build-run", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/jobs/my-job", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "name": "my-job", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -2089,8 +3438,14 @@ def test_list_job_runs_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response = '{"first": {"href": "href"}, "job_runs": [{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}], "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "job_runs": [{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -2099,7 +3454,13 @@ def test_list_job_runs_all_params(self): start = 'testString' # Invoke method - response = _service.list_job_runs(project_id, job_name=job_name, limit=limit, start=start, headers={}) + response = _service.list_job_runs( + project_id, + job_name=job_name, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -2127,14 +3488,23 @@ def test_list_job_runs_required_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response = '{"first": {"href": "href"}, "job_runs": [{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}], "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "job_runs": [{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_job_runs(project_id, headers={}) + response = _service.list_job_runs( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -2156,8 +3526,14 @@ def test_list_job_runs_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response = '{"first": {"href": "href"}, "job_runs": [{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}], "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "job_runs": [{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -2187,10 +3563,22 @@ def test_list_job_runs_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response1 = '{"next":{"start":"1"},"job_runs":[{"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"completed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"pending":0,"requested":0,"running":0,"start_time":"2022-09-22T17:34:00Z","succeeded":1,"unknown":0}}],"total_count":2,"limit":1}' - mock_response2 = '{"job_runs":[{"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"completed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"pending":0,"requested":0,"running":0,"start_time":"2022-09-22T17:34:00Z","succeeded":1,"unknown":0}}],"total_count":2,"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"job_runs":[{"computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_size_variable_override":2,"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"failed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"failed_indices":"1,5","pending":0,"pending_indices":"9,12-15","requested":0,"running":0,"running_indices":"10-11","start_time":"2022-09-22T17:34:00Z","succeeded":1,"succeeded_indices":"2-4,6-8","unknown":0}}],"total_count":2,"limit":1}' + mock_response2 = '{"job_runs":[{"computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_size_variable_override":2,"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"failed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"failed_indices":"1,5","pending":0,"pending_indices":"9,12-15","requested":0,"running":0,"running_indices":"10-11","start_time":"2022-09-22T17:34:00Z","succeeded":1,"succeeded_indices":"2-4,6-8","unknown":0}}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -2213,10 +3601,22 @@ def test_list_job_runs_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response1 = '{"next":{"start":"1"},"job_runs":[{"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"completed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"pending":0,"requested":0,"running":0,"start_time":"2022-09-22T17:34:00Z","succeeded":1,"unknown":0}}],"total_count":2,"limit":1}' - mock_response2 = '{"job_runs":[{"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"completed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"pending":0,"requested":0,"running":0,"start_time":"2022-09-22T17:34:00Z","succeeded":1,"unknown":0}}],"total_count":2,"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"job_runs":[{"computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_size_variable_override":2,"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"failed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"failed_indices":"1,5","pending":0,"pending_indices":"9,12-15","requested":0,"running":0,"running_indices":"10-11","start_time":"2022-09-22T17:34:00Z","succeeded":1,"succeeded_indices":"2-4,6-8","unknown":0}}],"total_count":2,"limit":1}' + mock_response2 = '{"job_runs":[{"computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","image_reference":"icr.io/codeengine/helloworld","image_secret":"my-secret","job_name":"my-job","name":"my-job-run","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"job_run_v2","run_arguments":["run_arguments"],"run_as_user":1001,"run_commands":["run_commands"],"run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"run_mode":"task","run_service_account":"default","run_volume_mounts":[{"mount_path":"/app","name":"codeengine-mount-b69u90","reference":"my-secret","type":"secret"}],"scale_array_size_variable_override":2,"scale_array_spec":"1-5,7-8,10","scale_cpu_limit":"1","scale_ephemeral_storage_limit":"4G","scale_max_execution_time":7200,"scale_memory_limit":"4G","scale_retry_limit":3,"status":"failed","status_details":{"completion_time":"2022-09-22T17:40:00Z","failed":0,"failed_indices":"1,5","pending":0,"pending_indices":"9,12-15","requested":0,"running":0,"running_indices":"10-11","start_time":"2022-09-22T17:34:00Z","succeeded":1,"succeeded_indices":"2-4,6-8","unknown":0}}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = JobRunsPager( @@ -2242,8 +3642,14 @@ def test_create_job_run_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) + mock_response = '{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -2274,6 +3680,7 @@ def test_create_job_run_all_params(self): run_mode = 'task' run_service_account = 'default' run_volume_mounts = [volume_mount_prototype_model] + scale_array_size_variable_override = 2 scale_array_spec = '1-5,7-8,10' scale_cpu_limit = '1' scale_ephemeral_storage_limit = '4G' @@ -2295,6 +3702,7 @@ def test_create_job_run_all_params(self): run_mode=run_mode, run_service_account=run_service_account, run_volume_mounts=run_volume_mounts, + scale_array_size_variable_override=scale_array_size_variable_override, scale_array_spec=scale_array_spec, scale_cpu_limit=scale_cpu_limit, scale_ephemeral_storage_limit=scale_ephemeral_storage_limit, @@ -2320,6 +3728,7 @@ def test_create_job_run_all_params(self): assert req_body['run_mode'] == 'task' assert req_body['run_service_account'] == 'default' assert req_body['run_volume_mounts'] == [volume_mount_prototype_model] + assert req_body['scale_array_size_variable_override'] == 2 assert req_body['scale_array_spec'] == '1-5,7-8,10' assert req_body['scale_cpu_limit'] == '1' assert req_body['scale_ephemeral_storage_limit'] == '4G' @@ -2337,14 +3746,20 @@ def test_create_job_run_all_params_with_retries(self): self.test_create_job_run_all_params() @responses.activate - def test_create_job_run_value_error(self): + def test_create_job_run_required_params(self): """ - test_create_job_run_value_error() + test_create_job_run_required_params() """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) + mock_response = '{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) # Construct a dict representation of a EnvVarPrototype model env_var_prototype_model = {} @@ -2375,6 +3790,7 @@ def test_create_job_run_value_error(self): run_mode = 'task' run_service_account = 'default' run_volume_mounts = [volume_mount_prototype_model] + scale_array_size_variable_override = 2 scale_array_spec = '1-5,7-8,10' scale_cpu_limit = '1' scale_ephemeral_storage_limit = '4G' @@ -2382,18 +3798,128 @@ def test_create_job_run_value_error(self): scale_memory_limit = '4G' scale_retry_limit = 3 - # Pass in all but one required param and check for a ValueError - req_param_dict = { - "project_id": project_id, - } - for param in req_param_dict.keys(): - req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} - with pytest.raises(ValueError): - _service.create_job_run(**req_copy) - - def test_create_job_run_value_error_with_retries(self): - # Enable retries and run test_create_job_run_value_error. - _service.enable_retries() + # Invoke method + response = _service.create_job_run( + project_id, + image_reference=image_reference, + image_secret=image_secret, + job_name=job_name, + name=name, + run_arguments=run_arguments, + run_as_user=run_as_user, + run_commands=run_commands, + run_env_variables=run_env_variables, + run_mode=run_mode, + run_service_account=run_service_account, + run_volume_mounts=run_volume_mounts, + scale_array_size_variable_override=scale_array_size_variable_override, + scale_array_spec=scale_array_spec, + scale_cpu_limit=scale_cpu_limit, + scale_ephemeral_storage_limit=scale_ephemeral_storage_limit, + scale_max_execution_time=scale_max_execution_time, + scale_memory_limit=scale_memory_limit, + scale_retry_limit=scale_retry_limit, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['image_reference'] == 'icr.io/codeengine/helloworld' + assert req_body['image_secret'] == 'my-secret' + assert req_body['job_name'] == 'my-job' + assert req_body['name'] == 'my-job-run' + assert req_body['run_arguments'] == ['testString'] + assert req_body['run_as_user'] == 1001 + assert req_body['run_commands'] == ['testString'] + assert req_body['run_env_variables'] == [env_var_prototype_model] + assert req_body['run_mode'] == 'task' + assert req_body['run_service_account'] == 'default' + assert req_body['run_volume_mounts'] == [volume_mount_prototype_model] + assert req_body['scale_array_size_variable_override'] == 2 + assert req_body['scale_array_spec'] == '1-5,7-8,10' + assert req_body['scale_cpu_limit'] == '1' + assert req_body['scale_ephemeral_storage_limit'] == '4G' + assert req_body['scale_max_execution_time'] == 7200 + assert req_body['scale_memory_limit'] == '4G' + assert req_body['scale_retry_limit'] == 3 + + def test_create_job_run_required_params_with_retries(self): + # Enable retries and run test_create_job_run_required_params. + _service.enable_retries() + self.test_create_job_run_required_params() + + # Disable retries and run test_create_job_run_required_params. + _service.disable_retries() + self.test_create_job_run_required_params() + + @responses.activate + def test_create_job_run_value_error(self): + """ + test_create_job_run_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs') + mock_response = '{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a VolumeMountPrototype model + volume_mount_prototype_model = {} + volume_mount_prototype_model['mount_path'] = '/app' + volume_mount_prototype_model['name'] = 'codeengine-mount-b69u90' + volume_mount_prototype_model['reference'] = 'my-secret' + volume_mount_prototype_model['type'] = 'secret' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + image_reference = 'icr.io/codeengine/helloworld' + image_secret = 'my-secret' + job_name = 'my-job' + name = 'my-job-run' + run_arguments = ['testString'] + run_as_user = 1001 + run_commands = ['testString'] + run_env_variables = [env_var_prototype_model] + run_mode = 'task' + run_service_account = 'default' + run_volume_mounts = [volume_mount_prototype_model] + scale_array_size_variable_override = 2 + scale_array_spec = '1-5,7-8,10' + scale_cpu_limit = '1' + scale_ephemeral_storage_limit = '4G' + scale_max_execution_time = 7200 + scale_memory_limit = '4G' + scale_retry_limit = 3 + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_job_run(**req_copy) + + def test_create_job_run_value_error_with_retries(self): + # Enable retries and run test_create_job_run_value_error. + _service.enable_retries() self.test_create_job_run_value_error() # Disable retries and run test_create_job_run_value_error. @@ -2413,15 +3939,25 @@ def test_get_job_run_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs/my-job-run') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-job-run' # Invoke method - response = _service.get_job_run(project_id, name, headers={}) + response = _service.get_job_run( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -2436,6 +3972,46 @@ def test_get_job_run_all_params_with_retries(self): _service.disable_retries() self.test_get_job_run_all_params() + @responses.activate + def test_get_job_run_required_params(self): + """ + test_get_job_run_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs/my-job-run') + mock_response = '{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-job-run' + + # Invoke method + response = _service.get_job_run( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_job_run_required_params_with_retries(self): + # Enable retries and run test_get_job_run_required_params. + _service.enable_retries() + self.test_get_job_run_required_params() + + # Disable retries and run test_get_job_run_required_params. + _service.disable_retries() + self.test_get_job_run_required_params() + @responses.activate def test_get_job_run_value_error(self): """ @@ -2443,8 +4019,14 @@ def test_get_job_run_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs/my-job-run') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "completed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "pending": 0, "requested": 0, "running": 0, "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "unknown": 0}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/job_runs/my-job-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "image_reference": "icr.io/codeengine/helloworld", "image_secret": "my-secret", "job_name": "my-job", "name": "my-job-run", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "job_run_v2", "run_arguments": ["run_arguments"], "run_as_user": 1001, "run_commands": ["run_commands"], "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "run_mode": "task", "run_service_account": "default", "run_volume_mounts": [{"mount_path": "/app", "name": "codeengine-mount-b69u90", "reference": "my-secret", "type": "secret"}], "scale_array_size_variable_override": 2, "scale_array_spec": "1-5,7-8,10", "scale_cpu_limit": "1", "scale_ephemeral_storage_limit": "4G", "scale_max_execution_time": 7200, "scale_memory_limit": "4G", "scale_retry_limit": 3, "status": "failed", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "failed": 0, "failed_indices": "1,5", "pending": 0, "pending_indices": "9,12-15", "requested": 0, "running": 0, "running_indices": "10-11", "start_time": "2022-09-22T17:34:00Z", "succeeded": 1, "succeeded_indices": "2-4,6-8", "unknown": 0}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -2482,14 +4064,22 @@ def test_delete_job_run_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs/my-job-run') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-job-run' # Invoke method - response = _service.delete_job_run(project_id, name, headers={}) + response = _service.delete_job_run( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -2511,7 +4101,11 @@ def test_delete_job_run_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/job_runs/my-job-run') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -2543,7 +4137,7 @@ def test_delete_job_run_value_error_with_retries(self): ############################################################################## ############################################################################## -# Start of Service: Builds +# Start of Service: Functions ############################################################################## # region @@ -2576,20 +4170,64 @@ def test_new_instance_without_authenticator(self): ) -class TestListBuilds: +class TestListFunctionRuntimes: """ - Test Class for list_builds + Test Class for list_function_runtimes """ @responses.activate - def test_list_builds_all_params(self): + def test_list_function_runtimes_all_params(self): """ - list_builds() + list_function_runtimes() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response = '{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/function_runtimes') + mock_response = '{"function_runtimes": [{"default": true, "deprecated": false, "family": "nodejs", "id": "nodejs-18", "name": "Node.js 18", "optimized": true}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Invoke method + response = _service.list_function_runtimes() + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_function_runtimes_all_params_with_retries(self): + # Enable retries and run test_list_function_runtimes_all_params. + _service.enable_retries() + self.test_list_function_runtimes_all_params() + + # Disable retries and run test_list_function_runtimes_all_params. + _service.disable_retries() + self.test_list_function_runtimes_all_params() + + +class TestListFunctions: + """ + Test Class for list_functions + """ + + @responses.activate + def test_list_functions_all_params(self): + """ + list_functions() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response = '{"first": {"href": "href"}, "functions": [{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -2597,7 +4235,12 @@ def test_list_builds_all_params(self): start = 'testString' # Invoke method - response = _service.list_builds(project_id, limit=limit, start=start, headers={}) + response = _service.list_functions( + project_id, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -2608,53 +4251,68 @@ def test_list_builds_all_params(self): assert 'limit={}'.format(limit) in query_string assert 'start={}'.format(start) in query_string - def test_list_builds_all_params_with_retries(self): - # Enable retries and run test_list_builds_all_params. + def test_list_functions_all_params_with_retries(self): + # Enable retries and run test_list_functions_all_params. _service.enable_retries() - self.test_list_builds_all_params() + self.test_list_functions_all_params() - # Disable retries and run test_list_builds_all_params. + # Disable retries and run test_list_functions_all_params. _service.disable_retries() - self.test_list_builds_all_params() + self.test_list_functions_all_params() @responses.activate - def test_list_builds_required_params(self): + def test_list_functions_required_params(self): """ - test_list_builds_required_params() + test_list_functions_required_params() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response = '{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response = '{"first": {"href": "href"}, "functions": [{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_builds(project_id, headers={}) + response = _service.list_functions( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - def test_list_builds_required_params_with_retries(self): - # Enable retries and run test_list_builds_required_params. + def test_list_functions_required_params_with_retries(self): + # Enable retries and run test_list_functions_required_params. _service.enable_retries() - self.test_list_builds_required_params() + self.test_list_functions_required_params() - # Disable retries and run test_list_builds_required_params. + # Disable retries and run test_list_functions_required_params. _service.disable_retries() - self.test_list_builds_required_params() + self.test_list_functions_required_params() @responses.activate - def test_list_builds_value_error(self): + def test_list_functions_value_error(self): """ - test_list_builds_value_error() + test_list_functions_value_error() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response = '{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response = '{"first": {"href": "href"}, "functions": [{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}], "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -2666,32 +4324,44 @@ def test_list_builds_value_error(self): for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.list_builds(**req_copy) + _service.list_functions(**req_copy) - def test_list_builds_value_error_with_retries(self): - # Enable retries and run test_list_builds_value_error. + def test_list_functions_value_error_with_retries(self): + # Enable retries and run test_list_functions_value_error. _service.enable_retries() - self.test_list_builds_value_error() + self.test_list_functions_value_error() - # Disable retries and run test_list_builds_value_error. + # Disable retries and run test_list_functions_value_error. _service.disable_retries() - self.test_list_builds_value_error() + self.test_list_functions_value_error() @responses.activate - def test_list_builds_with_pager_get_next(self): + def test_list_functions_with_pager_get_next(self): """ - test_list_builds_with_pager_get_next() + test_list_functions_with_pager_get_next() """ # Set up a two-page mock response - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - mock_response2 = '{"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response1 = '{"next":{"start":"1"},"functions":[{"code_binary":false,"code_main":"main","code_reference":"data:text/plain;base64,","code_secret":"my-secret","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-function.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","managed_domain_mappings":"local_public","name":"my-function","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"function_v2","run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"runtime":"nodejs-18","scale_concurrency":1,"scale_cpu_limit":"1","scale_down_delay":300,"scale_max_execution_time":60,"scale_memory_limit":"1G","status":"offline","status_details":{"reason":"offline"}}],"total_count":2,"limit":1}' + mock_response2 = '{"functions":[{"code_binary":false,"code_main":"main","code_reference":"data:text/plain;base64,","code_secret":"my-secret","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-function.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","managed_domain_mappings":"local_public","name":"my-function","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"function_v2","run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"runtime":"nodejs-18","scale_concurrency":1,"scale_cpu_limit":"1","scale_down_delay":300,"scale_max_execution_time":60,"scale_memory_limit":"1G","status":"offline","status_details":{"reason":"offline"}}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] - pager = BuildsPager( + pager = FunctionsPager( client=_service, project_id='15314cc3-85b4-4338-903f-c28cdee6d005', limit=100, @@ -2703,19 +4373,31 @@ def test_list_builds_with_pager_get_next(self): assert len(all_results) == 2 @responses.activate - def test_list_builds_with_pager_get_all(self): + def test_list_functions_with_pager_get_all(self): """ - test_list_builds_with_pager_get_all() + test_list_functions_with_pager_get_all() """ # Set up a two-page mock response - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - mock_response2 = '{"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response1 = '{"next":{"start":"1"},"functions":[{"code_binary":false,"code_main":"main","code_reference":"data:text/plain;base64,","code_secret":"my-secret","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-function.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","managed_domain_mappings":"local_public","name":"my-function","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"function_v2","run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"runtime":"nodejs-18","scale_concurrency":1,"scale_cpu_limit":"1","scale_down_delay":300,"scale_max_execution_time":60,"scale_memory_limit":"1G","status":"offline","status_details":{"reason":"offline"}}],"total_count":2,"limit":1}' + mock_response2 = '{"functions":[{"code_binary":false,"code_main":"main","code_reference":"data:text/plain;base64,","code_secret":"my-secret","computed_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"created_at":"2022-09-13T11:41:35+02:00","endpoint":"https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud","endpoint_internal":"http://my-function.vg67hzldruk.svc.cluster.local","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","managed_domain_mappings":"local_public","name":"my-function","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"function_v2","run_env_variables":[{"key":"MY_VARIABLE","name":"SOME","prefix":"PREFIX_","reference":"my-secret","type":"literal","value":"VALUE"}],"runtime":"nodejs-18","scale_concurrency":1,"scale_cpu_limit":"1","scale_down_delay":300,"scale_max_execution_time":60,"scale_memory_limit":"1G","status":"offline","status_details":{"reason":"offline"}}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation - pager = BuildsPager( + pager = FunctionsPager( client=_service, project_id='15314cc3-85b4-4338-903f-c28cdee6d005', limit=100, @@ -2725,178 +4407,354 @@ def test_list_builds_with_pager_get_all(self): assert len(all_results) == 2 -class TestCreateBuild: +class TestCreateFunction: """ - Test Class for create_build + Test Class for create_function """ @responses.activate - def test_create_build_all_params(self): + def test_create_function_all_params(self): """ - create_build() + create_function() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' - output_image = 'private.de.icr.io/icr_namespace/image-name' - output_secret = 'ce-auto-icr-private-eu-de' - source_url = 'https://github.com/IBM/CodeEngine' - strategy_type = 'dockerfile' - source_context_dir = 'some/subfolder' - source_revision = 'main' - source_secret = 'testString' - source_type = 'git' - strategy_size = 'medium' - strategy_spec_file = 'Dockerfile' - timeout = 600 + code_reference = 'data:text/plain;base64,' + name = 'my-function' + runtime = 'nodejs-18' + code_binary = False + code_main = 'main' + code_secret = 'my-secret' + managed_domain_mappings = 'local_public' + run_env_variables = [env_var_prototype_model] + scale_concurrency = 1 + scale_cpu_limit = '1' + scale_down_delay = 300 + scale_max_execution_time = 60 + scale_memory_limit = '1G' # Invoke method - response = _service.create_build( + response = _service.create_function( project_id, + code_reference, name, - output_image, - output_secret, - source_url, - strategy_type, - source_context_dir=source_context_dir, - source_revision=source_revision, - source_secret=source_secret, - source_type=source_type, - strategy_size=strategy_size, - strategy_spec_file=strategy_spec_file, - timeout=timeout, - headers={}, - ) - + runtime, + code_binary=code_binary, + code_main=code_main, + code_secret=code_secret, + managed_domain_mappings=managed_domain_mappings, + run_env_variables=run_env_variables, + scale_concurrency=scale_concurrency, + scale_cpu_limit=scale_cpu_limit, + scale_down_delay=scale_down_delay, + scale_max_execution_time=scale_max_execution_time, + scale_memory_limit=scale_memory_limit, + headers={}, + ) + # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['name'] == 'my-build' - assert req_body['output_image'] == 'private.de.icr.io/icr_namespace/image-name' - assert req_body['output_secret'] == 'ce-auto-icr-private-eu-de' - assert req_body['source_url'] == 'https://github.com/IBM/CodeEngine' - assert req_body['strategy_type'] == 'dockerfile' - assert req_body['source_context_dir'] == 'some/subfolder' - assert req_body['source_revision'] == 'main' - assert req_body['source_secret'] == 'testString' - assert req_body['source_type'] == 'git' - assert req_body['strategy_size'] == 'medium' - assert req_body['strategy_spec_file'] == 'Dockerfile' - assert req_body['timeout'] == 600 + assert req_body['code_reference'] == 'data:text/plain;base64,' + assert req_body['name'] == 'my-function' + assert req_body['runtime'] == 'nodejs-18' + assert req_body['code_binary'] == False + assert req_body['code_main'] == 'main' + assert req_body['code_secret'] == 'my-secret' + assert req_body['managed_domain_mappings'] == 'local_public' + assert req_body['run_env_variables'] == [env_var_prototype_model] + assert req_body['scale_concurrency'] == 1 + assert req_body['scale_cpu_limit'] == '1' + assert req_body['scale_down_delay'] == 300 + assert req_body['scale_max_execution_time'] == 60 + assert req_body['scale_memory_limit'] == '1G' - def test_create_build_all_params_with_retries(self): - # Enable retries and run test_create_build_all_params. + def test_create_function_all_params_with_retries(self): + # Enable retries and run test_create_function_all_params. _service.enable_retries() - self.test_create_build_all_params() + self.test_create_function_all_params() - # Disable retries and run test_create_build_all_params. + # Disable retries and run test_create_function_all_params. _service.disable_retries() - self.test_create_build_all_params() + self.test_create_function_all_params() @responses.activate - def test_create_build_value_error(self): + def test_create_function_required_params(self): """ - test_create_build_value_error() + test_create_function_required_params() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' - output_image = 'private.de.icr.io/icr_namespace/image-name' - output_secret = 'ce-auto-icr-private-eu-de' - source_url = 'https://github.com/IBM/CodeEngine' - strategy_type = 'dockerfile' - source_context_dir = 'some/subfolder' - source_revision = 'main' - source_secret = 'testString' - source_type = 'git' - strategy_size = 'medium' - strategy_spec_file = 'Dockerfile' - timeout = 600 + code_reference = 'data:text/plain;base64,' + name = 'my-function' + runtime = 'nodejs-18' + code_binary = False + code_main = 'main' + code_secret = 'my-secret' + managed_domain_mappings = 'local_public' + run_env_variables = [env_var_prototype_model] + scale_concurrency = 1 + scale_cpu_limit = '1' + scale_down_delay = 300 + scale_max_execution_time = 60 + scale_memory_limit = '1G' + + # Invoke method + response = _service.create_function( + project_id, + code_reference, + name, + runtime, + code_binary=code_binary, + code_main=code_main, + code_secret=code_secret, + managed_domain_mappings=managed_domain_mappings, + run_env_variables=run_env_variables, + scale_concurrency=scale_concurrency, + scale_cpu_limit=scale_cpu_limit, + scale_down_delay=scale_down_delay, + scale_max_execution_time=scale_max_execution_time, + scale_memory_limit=scale_memory_limit, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['code_reference'] == 'data:text/plain;base64,' + assert req_body['name'] == 'my-function' + assert req_body['runtime'] == 'nodejs-18' + assert req_body['code_binary'] == False + assert req_body['code_main'] == 'main' + assert req_body['code_secret'] == 'my-secret' + assert req_body['managed_domain_mappings'] == 'local_public' + assert req_body['run_env_variables'] == [env_var_prototype_model] + assert req_body['scale_concurrency'] == 1 + assert req_body['scale_cpu_limit'] == '1' + assert req_body['scale_down_delay'] == 300 + assert req_body['scale_max_execution_time'] == 60 + assert req_body['scale_memory_limit'] == '1G' + + def test_create_function_required_params_with_retries(self): + # Enable retries and run test_create_function_required_params. + _service.enable_retries() + self.test_create_function_required_params() + + # Disable retries and run test_create_function_required_params. + _service.disable_retries() + self.test_create_function_required_params() + + @responses.activate + def test_create_function_value_error(self): + """ + test_create_function_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + code_reference = 'data:text/plain;base64,' + name = 'my-function' + runtime = 'nodejs-18' + code_binary = False + code_main = 'main' + code_secret = 'my-secret' + managed_domain_mappings = 'local_public' + run_env_variables = [env_var_prototype_model] + scale_concurrency = 1 + scale_cpu_limit = '1' + scale_down_delay = 300 + scale_max_execution_time = 60 + scale_memory_limit = '1G' # Pass in all but one required param and check for a ValueError req_param_dict = { "project_id": project_id, + "code_reference": code_reference, "name": name, - "output_image": output_image, - "output_secret": output_secret, - "source_url": source_url, - "strategy_type": strategy_type, + "runtime": runtime, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.create_build(**req_copy) + _service.create_function(**req_copy) - def test_create_build_value_error_with_retries(self): - # Enable retries and run test_create_build_value_error. + def test_create_function_value_error_with_retries(self): + # Enable retries and run test_create_function_value_error. _service.enable_retries() - self.test_create_build_value_error() + self.test_create_function_value_error() - # Disable retries and run test_create_build_value_error. + # Disable retries and run test_create_function_value_error. _service.disable_retries() - self.test_create_build_value_error() + self.test_create_function_value_error() -class TestGetBuild: +class TestGetFunction: """ - Test Class for get_build + Test Class for get_function """ @responses.activate - def test_get_build_all_params(self): + def test_get_function_all_params(self): """ - get_build() + get_function() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' + name = 'my-function' # Invoke method - response = _service.get_build(project_id, name, headers={}) + response = _service.get_function( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - def test_get_build_all_params_with_retries(self): - # Enable retries and run test_get_build_all_params. + def test_get_function_all_params_with_retries(self): + # Enable retries and run test_get_function_all_params. _service.enable_retries() - self.test_get_build_all_params() + self.test_get_function_all_params() - # Disable retries and run test_get_build_all_params. + # Disable retries and run test_get_function_all_params. _service.disable_retries() - self.test_get_build_all_params() + self.test_get_function_all_params() @responses.activate - def test_get_build_value_error(self): + def test_get_function_required_params(self): """ - test_get_build_value_error() + test_get_function_required_params() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' + name = 'my-function' + + # Invoke method + response = _service.get_function( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_function_required_params_with_retries(self): + # Enable retries and run test_get_function_required_params. + _service.enable_retries() + self.test_get_function_required_params() + + # Disable retries and run test_get_function_required_params. + _service.disable_retries() + self.test_get_function_required_params() + + @responses.activate + def test_get_function_value_error(self): + """ + test_get_function_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-function' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -2906,64 +4764,113 @@ def test_get_build_value_error(self): for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.get_build(**req_copy) + _service.get_function(**req_copy) - def test_get_build_value_error_with_retries(self): - # Enable retries and run test_get_build_value_error. + def test_get_function_value_error_with_retries(self): + # Enable retries and run test_get_function_value_error. _service.enable_retries() - self.test_get_build_value_error() + self.test_get_function_value_error() - # Disable retries and run test_get_build_value_error. + # Disable retries and run test_get_function_value_error. _service.disable_retries() - self.test_get_build_value_error() + self.test_get_function_value_error() -class TestDeleteBuild: +class TestDeleteFunction: """ - Test Class for delete_build + Test Class for delete_function """ @responses.activate - def test_delete_build_all_params(self): + def test_delete_function_all_params(self): """ - delete_build() + delete_function() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') - responses.add(responses.DELETE, url, status=202) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' + name = 'my-function' # Invoke method - response = _service.delete_build(project_id, name, headers={}) + response = _service.delete_function( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 202 - def test_delete_build_all_params_with_retries(self): - # Enable retries and run test_delete_build_all_params. + def test_delete_function_all_params_with_retries(self): + # Enable retries and run test_delete_function_all_params. _service.enable_retries() - self.test_delete_build_all_params() + self.test_delete_function_all_params() - # Disable retries and run test_delete_build_all_params. + # Disable retries and run test_delete_function_all_params. _service.disable_retries() - self.test_delete_build_all_params() + self.test_delete_function_all_params() @responses.activate - def test_delete_build_value_error(self): + def test_delete_function_required_params(self): """ - test_delete_build_value_error() + test_delete_function_required_params() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') - responses.add(responses.DELETE, url, status=202) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' + name = 'my-function' + + # Invoke method + response = _service.delete_function( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_function_required_params_with_retries(self): + # Enable retries and run test_delete_function_required_params. + _service.enable_retries() + self.test_delete_function_required_params() + + # Disable retries and run test_delete_function_required_params. + _service.disable_retries() + self.test_delete_function_required_params() + + @responses.activate + def test_delete_function_value_error(self): + """ + test_delete_function_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-function' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -2973,81 +4880,1361 @@ def test_delete_build_value_error(self): for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.delete_build(**req_copy) + _service.delete_function(**req_copy) - def test_delete_build_value_error_with_retries(self): - # Enable retries and run test_delete_build_value_error. + def test_delete_function_value_error_with_retries(self): + # Enable retries and run test_delete_function_value_error. _service.enable_retries() - self.test_delete_build_value_error() + self.test_delete_function_value_error() - # Disable retries and run test_delete_build_value_error. + # Disable retries and run test_delete_function_value_error. _service.disable_retries() - self.test_delete_build_value_error() + self.test_delete_function_value_error() -class TestUpdateBuild: +class TestUpdateFunction: """ - Test Class for update_build + Test Class for update_function """ @responses.activate - def test_update_build_all_params(self): + def test_update_function_all_params(self): """ - update_build() + update_function() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) - # Construct a dict representation of a BuildPatch model - build_patch_model = {} - build_patch_model['output_image'] = 'private.de.icr.io/icr_namespace/image-name' - build_patch_model['output_secret'] = 'ce-auto-icr-private-eu-de' - build_patch_model['source_context_dir'] = 'some/subfolder' - build_patch_model['source_revision'] = 'main' - build_patch_model['source_secret'] = 'testString' - build_patch_model['source_type'] = 'git' - build_patch_model['source_url'] = 'https://github.com/IBM/CodeEngine' - build_patch_model['strategy_size'] = 'medium' - build_patch_model['strategy_spec_file'] = 'Dockerfile' - build_patch_model['strategy_type'] = 'dockerfile' - build_patch_model['timeout'] = 600 + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a FunctionPatch model + function_patch_model = {} + function_patch_model['code_binary'] = False + function_patch_model['code_main'] = 'main' + function_patch_model['code_reference'] = 'data:text/plain;base64,' + function_patch_model['code_secret'] = 'my-secret' + function_patch_model['managed_domain_mappings'] = 'local_public' + function_patch_model['run_env_variables'] = [env_var_prototype_model] + function_patch_model['runtime'] = 'nodejs-18' + function_patch_model['scale_concurrency'] = 1 + function_patch_model['scale_cpu_limit'] = '1' + function_patch_model['scale_down_delay'] = 300 + function_patch_model['scale_max_execution_time'] = 60 + function_patch_model['scale_memory_limit'] = '1G' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' + name = 'my-function' if_match = 'testString' - build = build_patch_model + function = function_patch_model # Invoke method - response = _service.update_build(project_id, name, if_match, build, headers={}) + response = _service.update_function( + project_id, + name, + if_match, + function, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body == build + assert req_body == function - def test_update_build_all_params_with_retries(self): - # Enable retries and run test_update_build_all_params. + def test_update_function_all_params_with_retries(self): + # Enable retries and run test_update_function_all_params. _service.enable_retries() - self.test_update_build_all_params() + self.test_update_function_all_params() - # Disable retries and run test_update_build_all_params. + # Disable retries and run test_update_function_all_params. _service.disable_retries() - self.test_update_build_all_params() + self.test_update_function_all_params() @responses.activate - def test_update_build_value_error(self): + def test_update_function_required_params(self): """ - test_update_build_value_error() + test_update_function_required_params() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a FunctionPatch model + function_patch_model = {} + function_patch_model['code_binary'] = False + function_patch_model['code_main'] = 'main' + function_patch_model['code_reference'] = 'data:text/plain;base64,' + function_patch_model['code_secret'] = 'my-secret' + function_patch_model['managed_domain_mappings'] = 'local_public' + function_patch_model['run_env_variables'] = [env_var_prototype_model] + function_patch_model['runtime'] = 'nodejs-18' + function_patch_model['scale_concurrency'] = 1 + function_patch_model['scale_cpu_limit'] = '1' + function_patch_model['scale_down_delay'] = 300 + function_patch_model['scale_max_execution_time'] = 60 + function_patch_model['scale_memory_limit'] = '1G' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-function' + if_match = 'testString' + function = function_patch_model + + # Invoke method + response = _service.update_function( + project_id, + name, + if_match, + function, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == function + + def test_update_function_required_params_with_retries(self): + # Enable retries and run test_update_function_required_params. + _service.enable_retries() + self.test_update_function_required_params() + + # Disable retries and run test_update_function_required_params. + _service.disable_retries() + self.test_update_function_required_params() + + @responses.activate + def test_update_function_value_error(self): + """ + test_update_function_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/functions/my-function') + mock_response = '{"code_binary": false, "code_main": "main", "code_reference": "data:text/plain;base64,", "code_secret": "my-secret", "computed_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "created_at": "2022-09-13T11:41:35+02:00", "endpoint": "https://my-function.vg67hzldruk.eu-de.codeengine.appdomain.cloud", "endpoint_internal": "http://my-function.vg67hzldruk.svc.cluster.local", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/functions/my-function", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "managed_domain_mappings": "local_public", "name": "my-function", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "function_v2", "run_env_variables": [{"key": "MY_VARIABLE", "name": "SOME", "prefix": "PREFIX_", "reference": "my-secret", "type": "literal", "value": "VALUE"}], "runtime": "nodejs-18", "scale_concurrency": 1, "scale_cpu_limit": "1", "scale_down_delay": 300, "scale_max_execution_time": 60, "scale_memory_limit": "1G", "status": "offline", "status_details": {"reason": "offline"}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a EnvVarPrototype model + env_var_prototype_model = {} + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a dict representation of a FunctionPatch model + function_patch_model = {} + function_patch_model['code_binary'] = False + function_patch_model['code_main'] = 'main' + function_patch_model['code_reference'] = 'data:text/plain;base64,' + function_patch_model['code_secret'] = 'my-secret' + function_patch_model['managed_domain_mappings'] = 'local_public' + function_patch_model['run_env_variables'] = [env_var_prototype_model] + function_patch_model['runtime'] = 'nodejs-18' + function_patch_model['scale_concurrency'] = 1 + function_patch_model['scale_cpu_limit'] = '1' + function_patch_model['scale_down_delay'] = 300 + function_patch_model['scale_max_execution_time'] = 60 + function_patch_model['scale_memory_limit'] = '1G' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-function' + if_match = 'testString' + function = function_patch_model + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + "if_match": if_match, + "function": function, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_function(**req_copy) + + def test_update_function_value_error_with_retries(self): + # Enable retries and run test_update_function_value_error. + _service.enable_retries() + self.test_update_function_value_error() + + # Disable retries and run test_update_function_value_error. + _service.disable_retries() + self.test_update_function_value_error() + + +# endregion +############################################################################## +# End of Service: Functions +############################################################################## + +############################################################################## +# Start of Service: ServiceBindings +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = CodeEngineV2.new_instance( + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, CodeEngineV2) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = CodeEngineV2.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) + + +class TestListBindings: + """ + Test Class for list_bindings + """ + + @responses.activate + def test_list_bindings_all_params(self): + """ + list_bindings() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response = '{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + limit = 100 + start = 'testString' + + # Invoke method + response = _service.list_bindings( + project_id, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_bindings_all_params_with_retries(self): + # Enable retries and run test_list_bindings_all_params. + _service.enable_retries() + self.test_list_bindings_all_params() + + # Disable retries and run test_list_bindings_all_params. + _service.disable_retries() + self.test_list_bindings_all_params() + + @responses.activate + def test_list_bindings_required_params(self): + """ + test_list_bindings_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response = '{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Invoke method + response = _service.list_bindings( + project_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_bindings_required_params_with_retries(self): + # Enable retries and run test_list_bindings_required_params. + _service.enable_retries() + self.test_list_bindings_required_params() + + # Disable retries and run test_list_bindings_required_params. + _service.disable_retries() + self.test_list_bindings_required_params() + + @responses.activate + def test_list_bindings_value_error(self): + """ + test_list_bindings_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response = '{"bindings": [{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_bindings(**req_copy) + + def test_list_bindings_value_error_with_retries(self): + # Enable retries and run test_list_bindings_value_error. + _service.enable_retries() + self.test_list_bindings_value_error() + + # Disable retries and run test_list_bindings_value_error. + _service.disable_retries() + self.test_list_bindings_value_error() + + @responses.activate + def test_list_bindings_with_pager_get_next(self): + """ + test_list_bindings_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}' + mock_response2 = '{"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = BindingsPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_bindings_with_pager_get_all(self): + """ + test_list_bindings_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}' + mock_response2 = '{"total_count":2,"bindings":[{"component":{"name":"my-app-1","resource_type":"app_v2"},"href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding","id":"a172ced-b5f21bc-71ba50c-1638604","prefix":"MY_COS","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"binding_v2","secret_name":"my-service-access","status":"active"}],"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = BindingsPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateBinding: + """ + Test Class for create_binding + """ + + @responses.activate + def test_create_binding_all_params(self): + """ + create_binding() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response = '{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ComponentRef model + component_ref_model = {} + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + component = component_ref_model + prefix = 'MY_COS' + secret_name = 'my-service-access' + + # Invoke method + response = _service.create_binding( + project_id, + component, + prefix, + secret_name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['component'] == component_ref_model + assert req_body['prefix'] == 'MY_COS' + assert req_body['secret_name'] == 'my-service-access' + + def test_create_binding_all_params_with_retries(self): + # Enable retries and run test_create_binding_all_params. + _service.enable_retries() + self.test_create_binding_all_params() + + # Disable retries and run test_create_binding_all_params. + _service.disable_retries() + self.test_create_binding_all_params() + + @responses.activate + def test_create_binding_value_error(self): + """ + test_create_binding_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings') + mock_response = '{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ComponentRef model + component_ref_model = {} + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + component = component_ref_model + prefix = 'MY_COS' + secret_name = 'my-service-access' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "component": component, + "prefix": prefix, + "secret_name": secret_name, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_binding(**req_copy) + + def test_create_binding_value_error_with_retries(self): + # Enable retries and run test_create_binding_value_error. + _service.enable_retries() + self.test_create_binding_value_error() + + # Disable retries and run test_create_binding_value_error. + _service.disable_retries() + self.test_create_binding_value_error() + + +class TestGetBinding: + """ + Test Class for get_binding + """ + + @responses.activate + def test_get_binding_all_params(self): + """ + get_binding() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604') + mock_response = '{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + id = 'a172ced-b5f21bc-71ba50c-1638604' + + # Invoke method + response = _service.get_binding( + project_id, + id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_binding_all_params_with_retries(self): + # Enable retries and run test_get_binding_all_params. + _service.enable_retries() + self.test_get_binding_all_params() + + # Disable retries and run test_get_binding_all_params. + _service.disable_retries() + self.test_get_binding_all_params() + + @responses.activate + def test_get_binding_value_error(self): + """ + test_get_binding_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604') + mock_response = '{"component": {"name": "my-app-1", "resource_type": "app_v2"}, "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/bindings/my-binding", "id": "a172ced-b5f21bc-71ba50c-1638604", "prefix": "MY_COS", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "binding_v2", "secret_name": "my-service-access", "status": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + id = 'a172ced-b5f21bc-71ba50c-1638604' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "id": id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_binding(**req_copy) + + def test_get_binding_value_error_with_retries(self): + # Enable retries and run test_get_binding_value_error. + _service.enable_retries() + self.test_get_binding_value_error() + + # Disable retries and run test_get_binding_value_error. + _service.disable_retries() + self.test_get_binding_value_error() + + +class TestDeleteBinding: + """ + Test Class for delete_binding + """ + + @responses.activate + def test_delete_binding_all_params(self): + """ + delete_binding() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + id = 'a172ced-b5f21bc-71ba50c-1638604' + + # Invoke method + response = _service.delete_binding( + project_id, + id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_binding_all_params_with_retries(self): + # Enable retries and run test_delete_binding_all_params. + _service.enable_retries() + self.test_delete_binding_all_params() + + # Disable retries and run test_delete_binding_all_params. + _service.disable_retries() + self.test_delete_binding_all_params() + + @responses.activate + def test_delete_binding_value_error(self): + """ + test_delete_binding_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/bindings/a172ced-b5f21bc-71ba50c-1638604') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + id = 'a172ced-b5f21bc-71ba50c-1638604' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "id": id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_binding(**req_copy) + + def test_delete_binding_value_error_with_retries(self): + # Enable retries and run test_delete_binding_value_error. + _service.enable_retries() + self.test_delete_binding_value_error() + + # Disable retries and run test_delete_binding_value_error. + _service.disable_retries() + self.test_delete_binding_value_error() + + +# endregion +############################################################################## +# End of Service: ServiceBindings +############################################################################## + +############################################################################## +# Start of Service: ImageBuilds +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = CodeEngineV2.new_instance( + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, CodeEngineV2) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = CodeEngineV2.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) + + +class TestListBuilds: + """ + Test Class for list_builds + """ + + @responses.activate + def test_list_builds_all_params(self): + """ + list_builds() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response = '{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + limit = 100 + start = 'testString' + + # Invoke method + response = _service.list_builds( + project_id, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_builds_all_params_with_retries(self): + # Enable retries and run test_list_builds_all_params. + _service.enable_retries() + self.test_list_builds_all_params() + + # Disable retries and run test_list_builds_all_params. + _service.disable_retries() + self.test_list_builds_all_params() + + @responses.activate + def test_list_builds_required_params(self): + """ + test_list_builds_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response = '{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Invoke method + response = _service.list_builds( + project_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_builds_required_params_with_retries(self): + # Enable retries and run test_list_builds_required_params. + _service.enable_retries() + self.test_list_builds_required_params() + + # Disable retries and run test_list_builds_required_params. + _service.disable_retries() + self.test_list_builds_required_params() + + @responses.activate + def test_list_builds_value_error(self): + """ + test_list_builds_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response = '{"builds": [{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_builds(**req_copy) + + def test_list_builds_value_error_with_retries(self): + # Enable retries and run test_list_builds_value_error. + _service.enable_retries() + self.test_list_builds_value_error() + + # Disable retries and run test_list_builds_value_error. + _service.disable_retries() + self.test_list_builds_value_error() + + @responses.activate + def test_list_builds_with_pager_get_next(self): + """ + test_list_builds_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + mock_response2 = '{"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = BuildsPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_builds_with_pager_get_all(self): + """ + test_list_builds_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + mock_response2 = '{"total_count":2,"limit":1,"builds":[{"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_v2","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"ready","status_details":{"reason":"registered"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = BuildsPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + limit=100, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateBuild: + """ + Test Class for create_build + """ + + @responses.activate + def test_create_build_all_params(self): + """ + create_build() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + output_image = 'private.de.icr.io/icr_namespace/image-name' + output_secret = 'ce-auto-icr-private-eu-de' + strategy_type = 'dockerfile' + source_context_dir = 'some/subfolder' + source_revision = 'main' + source_secret = 'testString' + source_type = 'git' + source_url = 'https://github.com/IBM/CodeEngine' + strategy_size = 'medium' + strategy_spec_file = 'Dockerfile' + timeout = 600 + + # Invoke method + response = _service.create_build( + project_id, + name, + output_image, + output_secret, + strategy_type, + source_context_dir=source_context_dir, + source_revision=source_revision, + source_secret=source_secret, + source_type=source_type, + source_url=source_url, + strategy_size=strategy_size, + strategy_spec_file=strategy_spec_file, + timeout=timeout, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'my-build' + assert req_body['output_image'] == 'private.de.icr.io/icr_namespace/image-name' + assert req_body['output_secret'] == 'ce-auto-icr-private-eu-de' + assert req_body['strategy_type'] == 'dockerfile' + assert req_body['source_context_dir'] == 'some/subfolder' + assert req_body['source_revision'] == 'main' + assert req_body['source_secret'] == 'testString' + assert req_body['source_type'] == 'git' + assert req_body['source_url'] == 'https://github.com/IBM/CodeEngine' + assert req_body['strategy_size'] == 'medium' + assert req_body['strategy_spec_file'] == 'Dockerfile' + assert req_body['timeout'] == 600 + + def test_create_build_all_params_with_retries(self): + # Enable retries and run test_create_build_all_params. + _service.enable_retries() + self.test_create_build_all_params() + + # Disable retries and run test_create_build_all_params. + _service.disable_retries() + self.test_create_build_all_params() + + @responses.activate + def test_create_build_value_error(self): + """ + test_create_build_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds') + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + output_image = 'private.de.icr.io/icr_namespace/image-name' + output_secret = 'ce-auto-icr-private-eu-de' + strategy_type = 'dockerfile' + source_context_dir = 'some/subfolder' + source_revision = 'main' + source_secret = 'testString' + source_type = 'git' + source_url = 'https://github.com/IBM/CodeEngine' + strategy_size = 'medium' + strategy_spec_file = 'Dockerfile' + timeout = 600 + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + "output_image": output_image, + "output_secret": output_secret, + "strategy_type": strategy_type, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_build(**req_copy) + + def test_create_build_value_error_with_retries(self): + # Enable retries and run test_create_build_value_error. + _service.enable_retries() + self.test_create_build_value_error() + + # Disable retries and run test_create_build_value_error. + _service.disable_retries() + self.test_create_build_value_error() + + +class TestGetBuild: + """ + Test Class for get_build + """ + + @responses.activate + def test_get_build_all_params(self): + """ + get_build() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + + # Invoke method + response = _service.get_build( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_build_all_params_with_retries(self): + # Enable retries and run test_get_build_all_params. + _service.enable_retries() + self.test_get_build_all_params() + + # Disable retries and run test_get_build_all_params. + _service.disable_retries() + self.test_get_build_all_params() + + @responses.activate + def test_get_build_value_error(self): + """ + test_get_build_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_build(**req_copy) + + def test_get_build_value_error_with_retries(self): + # Enable retries and run test_get_build_value_error. + _service.enable_retries() + self.test_get_build_value_error() + + # Disable retries and run test_get_build_value_error. + _service.disable_retries() + self.test_get_build_value_error() + + +class TestDeleteBuild: + """ + Test Class for delete_build + """ + + @responses.activate + def test_delete_build_all_params(self): + """ + delete_build() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + + # Invoke method + response = _service.delete_build( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_build_all_params_with_retries(self): + # Enable retries and run test_delete_build_all_params. + _service.enable_retries() + self.test_delete_build_all_params() + + # Disable retries and run test_delete_build_all_params. + _service.disable_retries() + self.test_delete_build_all_params() + + @responses.activate + def test_delete_build_value_error(self): + """ + test_delete_build_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_build(**req_copy) + + def test_delete_build_value_error_with_retries(self): + # Enable retries and run test_delete_build_value_error. + _service.enable_retries() + self.test_delete_build_value_error() + + # Disable retries and run test_delete_build_value_error. + _service.disable_retries() + self.test_delete_build_value_error() + + +class TestUpdateBuild: + """ + Test Class for update_build + """ + + @responses.activate + def test_update_build_all_params(self): + """ + update_build() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a BuildPatch model + build_patch_model = {} + build_patch_model['output_image'] = 'private.de.icr.io/icr_namespace/image-name' + build_patch_model['output_secret'] = 'ce-auto-icr-private-eu-de' + build_patch_model['source_context_dir'] = 'some/subfolder' + build_patch_model['source_revision'] = 'main' + build_patch_model['source_secret'] = 'testString' + build_patch_model['source_type'] = 'git' + build_patch_model['source_url'] = 'https://github.com/IBM/CodeEngine' + build_patch_model['strategy_size'] = 'medium' + build_patch_model['strategy_spec_file'] = 'Dockerfile' + build_patch_model['strategy_type'] = 'dockerfile' + build_patch_model['timeout'] = 600 + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build' + if_match = 'testString' + build = build_patch_model + + # Invoke method + response = _service.update_build( + project_id, + name, + if_match, + build, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == build + + def test_update_build_all_params_with_retries(self): + # Enable retries and run test_update_build_all_params. + _service.enable_retries() + self.test_update_build_all_params() + + # Disable retries and run test_update_build_all_params. + _service.disable_retries() + self.test_update_build_all_params() + + @responses.activate + def test_update_build_value_error(self): + """ + test_update_build_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/builds/my-build') + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/builds/my-build", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_v2", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "ready", "status_details": {"reason": "registered"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Construct a dict representation of a BuildPatch model build_patch_model = {} @@ -3065,55 +6252,611 @@ def test_update_build_value_error(self): # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build' - if_match = 'testString' - build = build_patch_model + name = 'my-build' + if_match = 'testString' + build = build_patch_model + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + "if_match": if_match, + "build": build, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_build(**req_copy) + + def test_update_build_value_error_with_retries(self): + # Enable retries and run test_update_build_value_error. + _service.enable_retries() + self.test_update_build_value_error() + + # Disable retries and run test_update_build_value_error. + _service.disable_retries() + self.test_update_build_value_error() + + +class TestListBuildRuns: + """ + Test Class for list_build_runs + """ + + @responses.activate + def test_list_build_runs_all_params(self): + """ + list_build_runs() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response = '{"build_runs": [{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + build_name = 'my-build' + limit = 100 + start = 'testString' + + # Invoke method + response = _service.list_build_runs( + project_id, + build_name=build_name, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'build_name={}'.format(build_name) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_build_runs_all_params_with_retries(self): + # Enable retries and run test_list_build_runs_all_params. + _service.enable_retries() + self.test_list_build_runs_all_params() + + # Disable retries and run test_list_build_runs_all_params. + _service.disable_retries() + self.test_list_build_runs_all_params() + + @responses.activate + def test_list_build_runs_required_params(self): + """ + test_list_build_runs_required_params() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response = '{"build_runs": [{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Invoke method + response = _service.list_build_runs( + project_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_build_runs_required_params_with_retries(self): + # Enable retries and run test_list_build_runs_required_params. + _service.enable_retries() + self.test_list_build_runs_required_params() + + # Disable retries and run test_list_build_runs_required_params. + _service.disable_retries() + self.test_list_build_runs_required_params() + + @responses.activate + def test_list_build_runs_value_error(self): + """ + test_list_build_runs_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response = '{"build_runs": [{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_build_runs(**req_copy) + + def test_list_build_runs_value_error_with_retries(self): + # Enable retries and run test_list_build_runs_value_error. + _service.enable_retries() + self.test_list_build_runs_value_error() + + # Disable retries and run test_list_build_runs_value_error. + _service.disable_retries() + self.test_list_build_runs_value_error() + + @responses.activate + def test_list_build_runs_with_pager_get_next(self): + """ + test_list_build_runs_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + mock_response2 = '{"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = BuildRunsPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + build_name='my-build', + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_build_runs_with_pager_get_all(self): + """ + test_list_build_runs_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + mock_response2 = '{"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = BuildRunsPager( + client=_service, + project_id='15314cc3-85b4-4338-903f-c28cdee6d005', + build_name='my-build', + limit=100, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateBuildRun: + """ + Test Class for create_build_run + """ + + @responses.activate + def test_create_build_run_all_params(self): + """ + create_build_run() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + build_name = 'testString' + name = 'testString' + output_image = 'private.de.icr.io/icr_namespace/image-name' + output_secret = 'ce-auto-icr-private-eu-de' + service_account = 'default' + source_context_dir = 'some/subfolder' + source_revision = 'main' + source_secret = 'testString' + source_type = 'git' + source_url = 'https://github.com/IBM/CodeEngine' + strategy_size = 'medium' + strategy_spec_file = 'Dockerfile' + strategy_type = 'dockerfile' + timeout = 600 + + # Invoke method + response = _service.create_build_run( + project_id, + build_name=build_name, + name=name, + output_image=output_image, + output_secret=output_secret, + service_account=service_account, + source_context_dir=source_context_dir, + source_revision=source_revision, + source_secret=source_secret, + source_type=source_type, + source_url=source_url, + strategy_size=strategy_size, + strategy_spec_file=strategy_spec_file, + strategy_type=strategy_type, + timeout=timeout, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['build_name'] == 'testString' + assert req_body['name'] == 'testString' + assert req_body['output_image'] == 'private.de.icr.io/icr_namespace/image-name' + assert req_body['output_secret'] == 'ce-auto-icr-private-eu-de' + assert req_body['service_account'] == 'default' + assert req_body['source_context_dir'] == 'some/subfolder' + assert req_body['source_revision'] == 'main' + assert req_body['source_secret'] == 'testString' + assert req_body['source_type'] == 'git' + assert req_body['source_url'] == 'https://github.com/IBM/CodeEngine' + assert req_body['strategy_size'] == 'medium' + assert req_body['strategy_spec_file'] == 'Dockerfile' + assert req_body['strategy_type'] == 'dockerfile' + assert req_body['timeout'] == 600 + + def test_create_build_run_all_params_with_retries(self): + # Enable retries and run test_create_build_run_all_params. + _service.enable_retries() + self.test_create_build_run_all_params() + + # Disable retries and run test_create_build_run_all_params. + _service.disable_retries() + self.test_create_build_run_all_params() + + @responses.activate + def test_create_build_run_value_error(self): + """ + test_create_build_run_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') + mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + build_name = 'testString' + name = 'testString' + output_image = 'private.de.icr.io/icr_namespace/image-name' + output_secret = 'ce-auto-icr-private-eu-de' + service_account = 'default' + source_context_dir = 'some/subfolder' + source_revision = 'main' + source_secret = 'testString' + source_type = 'git' + source_url = 'https://github.com/IBM/CodeEngine' + strategy_size = 'medium' + strategy_spec_file = 'Dockerfile' + strategy_type = 'dockerfile' + timeout = 600 + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_build_run(**req_copy) + + def test_create_build_run_value_error_with_retries(self): + # Enable retries and run test_create_build_run_value_error. + _service.enable_retries() + self.test_create_build_run_value_error() + + # Disable retries and run test_create_build_run_value_error. + _service.disable_retries() + self.test_create_build_run_value_error() + + +class TestGetBuildRun: + """ + Test Class for get_build_run + """ + + @responses.activate + def test_get_build_run_all_params(self): + """ + get_build_run() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') + mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build-run' + + # Invoke method + response = _service.get_build_run( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_build_run_all_params_with_retries(self): + # Enable retries and run test_get_build_run_all_params. + _service.enable_retries() + self.test_get_build_run_all_params() + + # Disable retries and run test_get_build_run_all_params. + _service.disable_retries() + self.test_get_build_run_all_params() + + @responses.activate + def test_get_build_run_value_error(self): + """ + test_get_build_run_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') + mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build-run' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_build_run(**req_copy) + + def test_get_build_run_value_error_with_retries(self): + # Enable retries and run test_get_build_run_value_error. + _service.enable_retries() + self.test_get_build_run_value_error() + + # Disable retries and run test_get_build_run_value_error. + _service.disable_retries() + self.test_get_build_run_value_error() + + +class TestDeleteBuildRun: + """ + Test Class for delete_build_run + """ + + @responses.activate + def test_delete_build_run_all_params(self): + """ + delete_build_run() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build-run' + + # Invoke method + response = _service.delete_build_run( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_build_run_all_params_with_retries(self): + # Enable retries and run test_delete_build_run_all_params. + _service.enable_retries() + self.test_delete_build_run_all_params() + + # Disable retries and run test_delete_build_run_all_params. + _service.disable_retries() + self.test_delete_build_run_all_params() + + @responses.activate + def test_delete_build_run_value_error(self): + """ + test_delete_build_run_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'my-build-run' # Pass in all but one required param and check for a ValueError req_param_dict = { "project_id": project_id, "name": name, - "if_match": if_match, - "build": build, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.update_build(**req_copy) + _service.delete_build_run(**req_copy) - def test_update_build_value_error_with_retries(self): - # Enable retries and run test_update_build_value_error. + def test_delete_build_run_value_error_with_retries(self): + # Enable retries and run test_delete_build_run_value_error. _service.enable_retries() - self.test_update_build_value_error() + self.test_delete_build_run_value_error() - # Disable retries and run test_update_build_value_error. + # Disable retries and run test_delete_build_run_value_error. _service.disable_retries() - self.test_update_build_value_error() + self.test_delete_build_run_value_error() -class TestListBuildRuns: +# endregion +############################################################################## +# End of Service: ImageBuilds +############################################################################## + +############################################################################## +# Start of Service: DomainMappings +############################################################################## +# region + + +class TestNewInstance: """ - Test Class for list_build_runs + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = CodeEngineV2.new_instance( + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, CodeEngineV2) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = CodeEngineV2.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) + + +class TestListDomainMappings: + """ + Test Class for list_domain_mappings """ @responses.activate - def test_list_build_runs_all_params(self): + def test_list_domain_mappings_all_params(self): """ - list_build_runs() + list_domain_mappings() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response = '{"build_runs": [{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response = '{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - build_name = 'my-build' limit = 100 start = 'testString' # Invoke method - response = _service.list_build_runs(project_id, build_name=build_name, limit=limit, start=start, headers={}) + response = _service.list_domain_mappings( + project_id, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3121,57 +6864,71 @@ def test_list_build_runs_all_params(self): # Validate query params query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) - assert 'build_name={}'.format(build_name) in query_string assert 'limit={}'.format(limit) in query_string assert 'start={}'.format(start) in query_string - def test_list_build_runs_all_params_with_retries(self): - # Enable retries and run test_list_build_runs_all_params. + def test_list_domain_mappings_all_params_with_retries(self): + # Enable retries and run test_list_domain_mappings_all_params. _service.enable_retries() - self.test_list_build_runs_all_params() + self.test_list_domain_mappings_all_params() - # Disable retries and run test_list_build_runs_all_params. + # Disable retries and run test_list_domain_mappings_all_params. _service.disable_retries() - self.test_list_build_runs_all_params() + self.test_list_domain_mappings_all_params() @responses.activate - def test_list_build_runs_required_params(self): + def test_list_domain_mappings_required_params(self): """ - test_list_build_runs_required_params() + test_list_domain_mappings_required_params() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response = '{"build_runs": [{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response = '{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_build_runs(project_id, headers={}) + response = _service.list_domain_mappings( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - def test_list_build_runs_required_params_with_retries(self): - # Enable retries and run test_list_build_runs_required_params. + def test_list_domain_mappings_required_params_with_retries(self): + # Enable retries and run test_list_domain_mappings_required_params. _service.enable_retries() - self.test_list_build_runs_required_params() + self.test_list_domain_mappings_required_params() - # Disable retries and run test_list_build_runs_required_params. + # Disable retries and run test_list_domain_mappings_required_params. _service.disable_retries() - self.test_list_build_runs_required_params() + self.test_list_domain_mappings_required_params() @responses.activate - def test_list_build_runs_value_error(self): + def test_list_domain_mappings_value_error(self): """ - test_list_build_runs_value_error() + test_list_domain_mappings_value_error() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response = '{"build_runs": [{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response = '{"domain_mappings": [{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3183,35 +6940,46 @@ def test_list_build_runs_value_error(self): for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.list_build_runs(**req_copy) + _service.list_domain_mappings(**req_copy) - def test_list_build_runs_value_error_with_retries(self): - # Enable retries and run test_list_build_runs_value_error. + def test_list_domain_mappings_value_error_with_retries(self): + # Enable retries and run test_list_domain_mappings_value_error. _service.enable_retries() - self.test_list_build_runs_value_error() + self.test_list_domain_mappings_value_error() - # Disable retries and run test_list_build_runs_value_error. + # Disable retries and run test_list_domain_mappings_value_error. _service.disable_retries() - self.test_list_build_runs_value_error() + self.test_list_domain_mappings_value_error() @responses.activate - def test_list_build_runs_with_pager_get_next(self): + def test_list_domain_mappings_with_pager_get_next(self): """ - test_list_build_runs_with_pager_get_next() + test_list_domain_mappings_with_pager_get_next() """ # Set up a two-page mock response - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - mock_response2 = '{"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response1 = '{"next":{"start":"1"},"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":true,"visibility":"public"}],"total_count":2,"limit":1}' + mock_response2 = '{"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":true,"visibility":"public"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] - pager = BuildRunsPager( + pager = DomainMappingsPager( client=_service, project_id='15314cc3-85b4-4338-903f-c28cdee6d005', - build_name='my-build', limit=100, ) while pager.has_next(): @@ -3221,22 +6989,33 @@ def test_list_build_runs_with_pager_get_next(self): assert len(all_results) == 2 @responses.activate - def test_list_build_runs_with_pager_get_all(self): + def test_list_domain_mappings_with_pager_get_all(self): """ - test_list_build_runs_with_pager_get_all() + test_list_domain_mappings_with_pager_get_all() """ # Set up a two-page mock response - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - mock_response2 = '{"total_count":2,"limit":1,"build_runs":[{"build_name":"build_name","created_at":"2022-09-13T11:41:35+02:00","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-build-run","output_image":"private.de.icr.io/icr_namespace/image-name","output_secret":"ce-auto-icr-private-eu-de","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"build_run_v2","service_account":"default","source_context_dir":"some/subfolder","source_revision":"main","source_secret":"source_secret","source_type":"git","source_url":"https://github.com/IBM/CodeEngine","status":"succeeded","status_details":{"completion_time":"2022-09-22T17:40:00Z","output_digest":"sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384","reason":"succeeded","start_time":"2022-09-22T17:34:00Z"},"strategy_size":"medium","strategy_spec_file":"Dockerfile","strategy_type":"dockerfile","timeout":600}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response1 = '{"next":{"start":"1"},"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":true,"visibility":"public"}],"total_count":2,"limit":1}' + mock_response2 = '{"domain_mappings":[{"cname_target":"custom.abcdabcdabc.us-east.codeengine.appdomain.cloud","component":{"name":"my-app-1","resource_type":"app_v2"},"created_at":"2022-09-13T11:41:35+02:00","entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"www.example.com","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"domain_mapping_v2","status":"ready","status_details":{"reason":"ready"},"tls_secret":"my-tls-secret","user_managed":true,"visibility":"public"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation - pager = BuildRunsPager( + pager = DomainMappingsPager( client=_service, project_id='15314cc3-85b4-4338-903f-c28cdee6d005', - build_name='my-build', limit=100, ) all_results = pager.get_all() @@ -3244,181 +7023,257 @@ def test_list_build_runs_with_pager_get_all(self): assert len(all_results) == 2 -class TestCreateBuildRun: +class TestCreateDomainMapping: """ - Test Class for create_build_run + Test Class for create_domain_mapping """ @responses.activate - def test_create_build_run_all_params(self): + def test_create_domain_mapping_all_params(self): """ - create_build_run() + create_domain_mapping() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response = '{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ComponentRef model + component_ref_model = {} + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - build_name = 'testString' - name = 'testString' - output_image = 'private.de.icr.io/icr_namespace/image-name' - output_secret = 'ce-auto-icr-private-eu-de' - service_account = 'default' - source_context_dir = 'some/subfolder' - source_revision = 'main' - source_secret = 'testString' - source_type = 'git' - source_url = 'https://github.com/IBM/CodeEngine' - strategy_size = 'medium' - strategy_spec_file = 'Dockerfile' - strategy_type = 'dockerfile' - timeout = 600 + component = component_ref_model + name = 'www.example.com' + tls_secret = 'my-tls-secret' # Invoke method - response = _service.create_build_run( + response = _service.create_domain_mapping( project_id, - build_name=build_name, - name=name, - output_image=output_image, - output_secret=output_secret, - service_account=service_account, - source_context_dir=source_context_dir, - source_revision=source_revision, - source_secret=source_secret, - source_type=source_type, - source_url=source_url, - strategy_size=strategy_size, - strategy_spec_file=strategy_spec_file, - strategy_type=strategy_type, - timeout=timeout, + component, + name, + tls_secret, headers={}, ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 202 + assert response.status_code == 201 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['build_name'] == 'testString' - assert req_body['name'] == 'testString' - assert req_body['output_image'] == 'private.de.icr.io/icr_namespace/image-name' - assert req_body['output_secret'] == 'ce-auto-icr-private-eu-de' - assert req_body['service_account'] == 'default' - assert req_body['source_context_dir'] == 'some/subfolder' - assert req_body['source_revision'] == 'main' - assert req_body['source_secret'] == 'testString' - assert req_body['source_type'] == 'git' - assert req_body['source_url'] == 'https://github.com/IBM/CodeEngine' - assert req_body['strategy_size'] == 'medium' - assert req_body['strategy_spec_file'] == 'Dockerfile' - assert req_body['strategy_type'] == 'dockerfile' - assert req_body['timeout'] == 600 + assert req_body['component'] == component_ref_model + assert req_body['name'] == 'www.example.com' + assert req_body['tls_secret'] == 'my-tls-secret' - def test_create_build_run_all_params_with_retries(self): - # Enable retries and run test_create_build_run_all_params. + def test_create_domain_mapping_all_params_with_retries(self): + # Enable retries and run test_create_domain_mapping_all_params. _service.enable_retries() - self.test_create_build_run_all_params() + self.test_create_domain_mapping_all_params() - # Disable retries and run test_create_build_run_all_params. + # Disable retries and run test_create_domain_mapping_all_params. _service.disable_retries() - self.test_create_build_run_all_params() + self.test_create_domain_mapping_all_params() @responses.activate - def test_create_build_run_value_error(self): + def test_create_domain_mapping_value_error(self): """ - test_create_build_run_value_error() + test_create_domain_mapping_value_error() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs') - mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings') + mock_response = '{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a ComponentRef model + component_ref_model = {} + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - build_name = 'testString' - name = 'testString' - output_image = 'private.de.icr.io/icr_namespace/image-name' - output_secret = 'ce-auto-icr-private-eu-de' - service_account = 'default' - source_context_dir = 'some/subfolder' - source_revision = 'main' - source_secret = 'testString' - source_type = 'git' - source_url = 'https://github.com/IBM/CodeEngine' - strategy_size = 'medium' - strategy_spec_file = 'Dockerfile' - strategy_type = 'dockerfile' - timeout = 600 + component = component_ref_model + name = 'www.example.com' + tls_secret = 'my-tls-secret' # Pass in all but one required param and check for a ValueError req_param_dict = { "project_id": project_id, + "component": component, + "name": name, + "tls_secret": tls_secret, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.create_build_run(**req_copy) + _service.create_domain_mapping(**req_copy) - def test_create_build_run_value_error_with_retries(self): - # Enable retries and run test_create_build_run_value_error. + def test_create_domain_mapping_value_error_with_retries(self): + # Enable retries and run test_create_domain_mapping_value_error. _service.enable_retries() - self.test_create_build_run_value_error() + self.test_create_domain_mapping_value_error() - # Disable retries and run test_create_build_run_value_error. + # Disable retries and run test_create_domain_mapping_value_error. _service.disable_retries() - self.test_create_build_run_value_error() + self.test_create_domain_mapping_value_error() -class TestGetBuildRun: +class TestGetDomainMapping: """ - Test Class for get_build_run + Test Class for get_domain_mapping """ @responses.activate - def test_get_build_run_all_params(self): + def test_get_domain_mapping_all_params(self): """ - get_build_run() + get_domain_mapping() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') - mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com') + mock_response = '{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build-run' + name = 'www.example.com' # Invoke method - response = _service.get_build_run(project_id, name, headers={}) + response = _service.get_domain_mapping( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - def test_get_build_run_all_params_with_retries(self): - # Enable retries and run test_get_build_run_all_params. + def test_get_domain_mapping_all_params_with_retries(self): + # Enable retries and run test_get_domain_mapping_all_params. _service.enable_retries() - self.test_get_build_run_all_params() + self.test_get_domain_mapping_all_params() - # Disable retries and run test_get_build_run_all_params. + # Disable retries and run test_get_domain_mapping_all_params. _service.disable_retries() - self.test_get_build_run_all_params() + self.test_get_domain_mapping_all_params() + + @responses.activate + def test_get_domain_mapping_value_error(self): + """ + test_get_domain_mapping_value_error() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com') + mock_response = '{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'www.example.com' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "project_id": project_id, + "name": name, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_domain_mapping(**req_copy) + + def test_get_domain_mapping_value_error_with_retries(self): + # Enable retries and run test_get_domain_mapping_value_error. + _service.enable_retries() + self.test_get_domain_mapping_value_error() + + # Disable retries and run test_get_domain_mapping_value_error. + _service.disable_retries() + self.test_get_domain_mapping_value_error() + + +class TestDeleteDomainMapping: + """ + Test Class for delete_domain_mapping + """ + + @responses.activate + def test_delete_domain_mapping_all_params(self): + """ + delete_domain_mapping() + """ + # Set up mock + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' + name = 'www.example.com' + + # Invoke method + response = _service.delete_domain_mapping( + project_id, + name, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_domain_mapping_all_params_with_retries(self): + # Enable retries and run test_delete_domain_mapping_all_params. + _service.enable_retries() + self.test_delete_domain_mapping_all_params() + + # Disable retries and run test_delete_domain_mapping_all_params. + _service.disable_retries() + self.test_delete_domain_mapping_all_params() @responses.activate - def test_get_build_run_value_error(self): + def test_delete_domain_mapping_value_error(self): """ - test_get_build_run_value_error() + test_delete_domain_mapping_value_error() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') - mock_response = '{"build_name": "build_name", "created_at": "2022-09-13T11:41:35+02:00", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/build_runs/my-build-run", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-build-run", "output_image": "private.de.icr.io/icr_namespace/image-name", "output_secret": "ce-auto-icr-private-eu-de", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "build_run_v2", "service_account": "default", "source_context_dir": "some/subfolder", "source_revision": "main", "source_secret": "source_secret", "source_type": "git", "source_url": "https://github.com/IBM/CodeEngine", "status": "succeeded", "status_details": {"completion_time": "2022-09-22T17:40:00Z", "output_digest": "sha256:9a3d845c629d2b4a6b271b1d526dfafc1e7d9511f8863b43b5bb0483ef626384", "reason": "succeeded", "start_time": "2022-09-22T17:34:00Z"}, "strategy_size": "medium", "strategy_spec_file": "Dockerfile", "strategy_type": "dockerfile", "timeout": 600}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com') + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build-run' + name = 'www.example.com' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -3428,92 +7283,141 @@ def test_get_build_run_value_error(self): for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.get_build_run(**req_copy) + _service.delete_domain_mapping(**req_copy) - def test_get_build_run_value_error_with_retries(self): - # Enable retries and run test_get_build_run_value_error. + def test_delete_domain_mapping_value_error_with_retries(self): + # Enable retries and run test_delete_domain_mapping_value_error. _service.enable_retries() - self.test_get_build_run_value_error() + self.test_delete_domain_mapping_value_error() - # Disable retries and run test_get_build_run_value_error. + # Disable retries and run test_delete_domain_mapping_value_error. _service.disable_retries() - self.test_get_build_run_value_error() + self.test_delete_domain_mapping_value_error() -class TestDeleteBuildRun: +class TestUpdateDomainMapping: """ - Test Class for delete_build_run + Test Class for update_domain_mapping """ @responses.activate - def test_delete_build_run_all_params(self): + def test_update_domain_mapping_all_params(self): """ - delete_build_run() + update_domain_mapping() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') - responses.add(responses.DELETE, url, status=202) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com') + mock_response = '{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a ComponentRef model + component_ref_model = {} + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' + + # Construct a dict representation of a DomainMappingPatch model + domain_mapping_patch_model = {} + domain_mapping_patch_model['component'] = component_ref_model + domain_mapping_patch_model['tls_secret'] = 'my-tls-secret' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build-run' + name = 'www.example.com' + if_match = 'testString' + domain_mapping = domain_mapping_patch_model # Invoke method - response = _service.delete_build_run(project_id, name, headers={}) + response = _service.update_domain_mapping( + project_id, + name, + if_match, + domain_mapping, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 - assert response.status_code == 202 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == domain_mapping - def test_delete_build_run_all_params_with_retries(self): - # Enable retries and run test_delete_build_run_all_params. + def test_update_domain_mapping_all_params_with_retries(self): + # Enable retries and run test_update_domain_mapping_all_params. _service.enable_retries() - self.test_delete_build_run_all_params() + self.test_update_domain_mapping_all_params() - # Disable retries and run test_delete_build_run_all_params. + # Disable retries and run test_update_domain_mapping_all_params. _service.disable_retries() - self.test_delete_build_run_all_params() + self.test_update_domain_mapping_all_params() @responses.activate - def test_delete_build_run_value_error(self): + def test_update_domain_mapping_value_error(self): """ - test_delete_build_run_value_error() + test_update_domain_mapping_value_error() """ # Set up mock - url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/build_runs/my-build-run') - responses.add(responses.DELETE, url, status=202) + url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/domain_mappings/www.example.com') + mock_response = '{"cname_target": "custom.abcdabcdabc.us-east.codeengine.appdomain.cloud", "component": {"name": "my-app-1", "resource_type": "app_v2"}, "created_at": "2022-09-13T11:41:35+02:00", "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/domain_mappings/www.example.com", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "www.example.com", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "domain_mapping_v2", "status": "ready", "status_details": {"reason": "ready"}, "tls_secret": "my-tls-secret", "user_managed": true, "visibility": "public"}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a ComponentRef model + component_ref_model = {} + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' + + # Construct a dict representation of a DomainMappingPatch model + domain_mapping_patch_model = {} + domain_mapping_patch_model['component'] = component_ref_model + domain_mapping_patch_model['tls_secret'] = 'my-tls-secret' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' - name = 'my-build-run' + name = 'www.example.com' + if_match = 'testString' + domain_mapping = domain_mapping_patch_model # Pass in all but one required param and check for a ValueError req_param_dict = { "project_id": project_id, "name": name, + "if_match": if_match, + "domain_mapping": domain_mapping, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): - _service.delete_build_run(**req_copy) + _service.update_domain_mapping(**req_copy) - def test_delete_build_run_value_error_with_retries(self): - # Enable retries and run test_delete_build_run_value_error. + def test_update_domain_mapping_value_error_with_retries(self): + # Enable retries and run test_update_domain_mapping_value_error. _service.enable_retries() - self.test_delete_build_run_value_error() + self.test_update_domain_mapping_value_error() - # Disable retries and run test_delete_build_run_value_error. + # Disable retries and run test_update_domain_mapping_value_error. _service.disable_retries() - self.test_delete_build_run_value_error() + self.test_update_domain_mapping_value_error() # endregion ############################################################################## -# End of Service: Builds +# End of Service: DomainMappings ############################################################################## ############################################################################## -# Start of Service: SecretsAndConfigMaps +# Start of Service: SecretsAndConfigmaps ############################################################################## # region @@ -3558,8 +7462,14 @@ def test_list_config_maps_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response = '{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3567,7 +7477,12 @@ def test_list_config_maps_all_params(self): start = 'testString' # Invoke method - response = _service.list_config_maps(project_id, limit=limit, start=start, headers={}) + response = _service.list_config_maps( + project_id, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3594,14 +7509,23 @@ def test_list_config_maps_required_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response = '{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_config_maps(project_id, headers={}) + response = _service.list_config_maps( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3623,8 +7547,14 @@ def test_list_config_maps_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response = '{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"config_maps": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}], "first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3654,10 +7584,22 @@ def test_list_config_maps_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response1 = '{"next":{"start":"1"},"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' - mock_response2 = '{"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' + mock_response2 = '{"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -3679,10 +7621,22 @@ def test_list_config_maps_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response1 = '{"next":{"start":"1"},"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' - mock_response2 = '{"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' + mock_response2 = '{"config_maps":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-config-map","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"config_map_v2"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = ConfigMapsPager( @@ -3707,8 +7661,14 @@ def test_create_config_map_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3716,7 +7676,12 @@ def test_create_config_map_all_params(self): data = {'key1': 'testString'} # Invoke method - response = _service.create_config_map(project_id, name, data=data, headers={}) + response = _service.create_config_map( + project_id, + name, + data=data, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3742,8 +7707,14 @@ def test_create_config_map_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3782,15 +7753,25 @@ def test_get_config_map_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-config-map' # Invoke method - response = _service.get_config_map(project_id, name, headers={}) + response = _service.get_config_map( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3812,8 +7793,14 @@ def test_get_config_map_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3851,8 +7838,14 @@ def test_replace_config_map_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}' - responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3861,7 +7854,13 @@ def test_replace_config_map_all_params(self): data = {'key1': 'testString'} # Invoke method - response = _service.replace_config_map(project_id, name, if_match, data=data, headers={}) + response = _service.replace_config_map( + project_id, + name, + if_match, + data=data, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3886,8 +7885,14 @@ def test_replace_config_map_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "config_map_v2"}' - responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/config_maps/my-config-map", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-config-map", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "config_map_v2"}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3928,14 +7933,22 @@ def test_delete_config_map_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-config-map' # Invoke method - response = _service.delete_config_map(project_id, name, headers={}) + response = _service.delete_config_map( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -3957,7 +7970,11 @@ def test_delete_config_map_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/config_maps/my-config-map') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -3995,8 +8012,14 @@ def test_list_secrets_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -4004,7 +8027,12 @@ def test_list_secrets_all_params(self): start = 'testString' # Invoke method - response = _service.list_secrets(project_id, limit=limit, start=start, headers={}) + response = _service.list_secrets( + project_id, + limit=limit, + start=start, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -4031,14 +8059,23 @@ def test_list_secrets_required_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' # Invoke method - response = _service.list_secrets(project_id, headers={}) + response = _service.list_secrets( + project_id, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -4060,8 +8097,14 @@ def test_list_secrets_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}]}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"first": {"href": "href"}, "limit": 100, "next": {"href": "href", "start": "start"}, "secrets": [{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -4091,10 +8134,22 @@ def test_list_secrets_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"resource_type"}]}' - mock_response2 = '{"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"resource_type"}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"resource_type","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"type"},"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["resource_group_ids"],"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":true}}]}' + mock_response2 = '{"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"resource_type","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"type"},"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["resource_group_ids"],"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":true}}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation all_results = [] @@ -4116,10 +8171,22 @@ def test_list_secrets_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"resource_type"}]}' - mock_response2 = '{"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","resource_type":"resource_type"}]}' - responses.add(responses.GET, url, body=mock_response1, content_type='application/json', status=200) - responses.add(responses.GET, url, body=mock_response2, content_type='application/json', status=200) + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"resource_type","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"type"},"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["resource_group_ids"],"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":true}}]}' + mock_response2 = '{"total_count":2,"limit":1,"secrets":[{"created_at":"2022-09-13T11:41:35+02:00","data":{"mapKey":"inner"},"entity_tag":"2385407409","format":"generic","href":"https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret","id":"e33b1cv7-7390-4437-a5c2-130d5ccdddc3","name":"my-secret","project_id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","region":"us-east","resource_type":"resource_type","service_access":{"resource_key":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","name":"name"},"role":{"crn":"crn:v1:bluemix:public:iam::::serviceRole:Writer","name":"Manager"},"service_instance":{"id":"4e49b3e0-27a8-48d2-a784-c7ee48bb863b","type":"type"},"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}},"service_operator":{"apikey_id":"ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b","resource_group_ids":["resource_group_ids"],"serviceid":{"crn":"crn","id":"ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"},"user_managed":true}}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) # Exercise the pager class for this operation pager = SecretsPager( @@ -4144,23 +8211,70 @@ def test_create_secret_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) - # Construct a dict representation of a SecretDataSSHSecretData model + # Construct a dict representation of a SecretDataGenericSecretData model secret_data_model = {} - secret_data_model['ssh_key'] = 'testString' - secret_data_model['known_hosts'] = 'testString' secret_data_model['foo'] = 'testString' + # Construct a dict representation of a ResourceKeyRefPrototype model + resource_key_ref_prototype_model = {} + resource_key_ref_prototype_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + # Construct a dict representation of a RoleRefPrototype model + role_ref_prototype_model = {} + role_ref_prototype_model['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + + # Construct a dict representation of a ServiceInstanceRefPrototype model + service_instance_ref_prototype_model = {} + service_instance_ref_prototype_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + # Construct a dict representation of a ServiceIDRef model + service_id_ref_model = {} + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a dict representation of a ServiceAccessSecretPrototypeProps model + service_access_secret_prototype_props_model = {} + service_access_secret_prototype_props_model['resource_key'] = resource_key_ref_prototype_model + service_access_secret_prototype_props_model['role'] = role_ref_prototype_model + service_access_secret_prototype_props_model['service_instance'] = service_instance_ref_prototype_model + service_access_secret_prototype_props_model['serviceid'] = service_id_ref_model + + # Construct a dict representation of a ServiceIDRefPrototype model + service_id_ref_prototype_model = {} + service_id_ref_prototype_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a dict representation of a OperatorSecretPrototypeProps model + operator_secret_prototype_props_model = {} + operator_secret_prototype_props_model['resource_group_ids'] = ['testString'] + operator_secret_prototype_props_model['serviceid'] = service_id_ref_prototype_model + # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' format = 'generic' name = 'my-secret' data = secret_data_model + service_access = service_access_secret_prototype_props_model + service_operator = operator_secret_prototype_props_model # Invoke method - response = _service.create_secret(project_id, format, name, data=data, headers={}) + response = _service.create_secret( + project_id, + format, + name, + data=data, + service_access=service_access, + service_operator=service_operator, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -4170,6 +8284,8 @@ def test_create_secret_all_params(self): assert req_body['format'] == 'generic' assert req_body['name'] == 'my-secret' assert req_body['data'] == secret_data_model + assert req_body['service_access'] == service_access_secret_prototype_props_model + assert req_body['service_operator'] == operator_secret_prototype_props_model def test_create_secret_all_params_with_retries(self): # Enable retries and run test_create_secret_all_params. @@ -4187,20 +8303,59 @@ def test_create_secret_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}' - responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) - # Construct a dict representation of a SecretDataSSHSecretData model + # Construct a dict representation of a SecretDataGenericSecretData model secret_data_model = {} - secret_data_model['ssh_key'] = 'testString' - secret_data_model['known_hosts'] = 'testString' secret_data_model['foo'] = 'testString' + # Construct a dict representation of a ResourceKeyRefPrototype model + resource_key_ref_prototype_model = {} + resource_key_ref_prototype_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + # Construct a dict representation of a RoleRefPrototype model + role_ref_prototype_model = {} + role_ref_prototype_model['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + + # Construct a dict representation of a ServiceInstanceRefPrototype model + service_instance_ref_prototype_model = {} + service_instance_ref_prototype_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + # Construct a dict representation of a ServiceIDRef model + service_id_ref_model = {} + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a dict representation of a ServiceAccessSecretPrototypeProps model + service_access_secret_prototype_props_model = {} + service_access_secret_prototype_props_model['resource_key'] = resource_key_ref_prototype_model + service_access_secret_prototype_props_model['role'] = role_ref_prototype_model + service_access_secret_prototype_props_model['service_instance'] = service_instance_ref_prototype_model + service_access_secret_prototype_props_model['serviceid'] = service_id_ref_model + + # Construct a dict representation of a ServiceIDRefPrototype model + service_id_ref_prototype_model = {} + service_id_ref_prototype_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a dict representation of a OperatorSecretPrototypeProps model + operator_secret_prototype_props_model = {} + operator_secret_prototype_props_model['resource_group_ids'] = ['testString'] + operator_secret_prototype_props_model['serviceid'] = service_id_ref_prototype_model + # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' format = 'generic' name = 'my-secret' data = secret_data_model + service_access = service_access_secret_prototype_props_model + service_operator = operator_secret_prototype_props_model # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -4235,15 +8390,25 @@ def test_get_secret_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-secret' # Invoke method - response = _service.get_secret(project_id, name, headers={}) + response = _service.get_secret( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -4265,8 +8430,14 @@ def test_get_secret_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}' - responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -4304,32 +8475,43 @@ def test_replace_secret_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}' - responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) - # Construct a dict representation of a SecretDataSSHSecretData model + # Construct a dict representation of a SecretDataGenericSecretData model secret_data_model = {} - secret_data_model['ssh_key'] = 'testString' - secret_data_model['known_hosts'] = 'testString' secret_data_model['foo'] = 'testString' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-secret' if_match = 'testString' - data = secret_data_model format = 'generic' + data = secret_data_model # Invoke method - response = _service.replace_secret(project_id, name, if_match, data=data, format=format, headers={}) + response = _service.replace_secret( + project_id, + name, + if_match, + format, + data=data, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['data'] == secret_data_model assert req_body['format'] == 'generic' + assert req_body['data'] == secret_data_model def test_replace_secret_all_params_with_retries(self): # Enable retries and run test_replace_secret_all_params. @@ -4347,27 +8529,32 @@ def test_replace_secret_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret') - mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "resource_type": "resource_type"}' - responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) + mock_response = '{"created_at": "2022-09-13T11:41:35+02:00", "data": {"mapKey": "inner"}, "entity_tag": "2385407409", "format": "generic", "href": "https://api.eu-de.codeengine.cloud.ibm.com/v2/projects/4e49b3e0-27a8-48d2-a784-c7ee48bb863b/secrets/my-secret", "id": "e33b1cv7-7390-4437-a5c2-130d5ccdddc3", "name": "my-secret", "project_id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "region": "us-east", "resource_type": "resource_type", "service_access": {"resource_key": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "name": "name"}, "role": {"crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer", "name": "Manager"}, "service_instance": {"id": "4e49b3e0-27a8-48d2-a784-c7ee48bb863b", "type": "type"}, "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}}, "service_operator": {"apikey_id": "ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b", "resource_group_ids": ["resource_group_ids"], "serviceid": {"crn": "crn", "id": "ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637"}, "user_managed": true}}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) - # Construct a dict representation of a SecretDataSSHSecretData model + # Construct a dict representation of a SecretDataGenericSecretData model secret_data_model = {} - secret_data_model['ssh_key'] = 'testString' - secret_data_model['known_hosts'] = 'testString' secret_data_model['foo'] = 'testString' # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-secret' if_match = 'testString' - data = secret_data_model format = 'generic' + data = secret_data_model # Pass in all but one required param and check for a ValueError req_param_dict = { "project_id": project_id, "name": name, "if_match": if_match, + "format": format, } for param in req_param_dict.keys(): req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} @@ -4396,14 +8583,22 @@ def test_delete_secret_all_params(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' name = 'my-secret' # Invoke method - response = _service.delete_secret(project_id, name, headers={}) + response = _service.delete_secret( + project_id, + name, + headers={}, + ) # Check for correct operation assert len(responses.calls) == 1 @@ -4425,7 +8620,11 @@ def test_delete_secret_value_error(self): """ # Set up mock url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/secrets/my-secret') - responses.add(responses.DELETE, url, status=202) + responses.add( + responses.DELETE, + url, + status=202, + ) # Set up parameter values project_id = '15314cc3-85b4-4338-903f-c28cdee6d005' @@ -4453,7 +8652,7 @@ def test_delete_secret_value_error_with_retries(self): # endregion ############################################################################## -# End of Service: SecretsAndConfigMaps +# End of Service: SecretsAndConfigmaps ############################################################################## @@ -4461,6 +8660,8 @@ def test_delete_secret_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region + + class TestModel_App: """ Test Class for App @@ -4475,11 +8676,20 @@ def test_app_serialization(self): env_var_model = {} # EnvVar env_var_model['key'] = 'MY_VARIABLE' - env_var_model['name'] = 'CE_SUBDOMAIN' + env_var_model['name'] = 'SOME' env_var_model['prefix'] = 'PREFIX_' env_var_model['reference'] = 'my-secret' env_var_model['type'] = 'literal' - env_var_model['value'] = 'uyh5shf7s0f' + env_var_model['value'] = 'VALUE' + + probe_model = {} # Probe + probe_model['failure_threshold'] = 5 + probe_model['initial_delay'] = 5 + probe_model['interval'] = 5 + probe_model['path'] = 'testString' + probe_model['port'] = 8080 + probe_model['timeout'] = 300 + probe_model['type'] = 'tcp' volume_mount_model = {} # VolumeMount volume_mount_model['mount_path'] = '/app' @@ -4491,12 +8701,15 @@ def test_app_serialization(self): # Construct a json representation of a App model app_model_json = {} + app_model_json['computed_env_variables'] = [env_var_model] app_model_json['entity_tag'] = '2385407409' app_model_json['image_port'] = 8080 app_model_json['image_reference'] = 'icr.io/codeengine/helloworld' app_model_json['image_secret'] = 'my-secret' app_model_json['managed_domain_mappings'] = 'local_public' app_model_json['name'] = 'my-app' + app_model_json['probe_liveness'] = probe_model + app_model_json['probe_readiness'] = probe_model app_model_json['run_arguments'] = ['testString'] app_model_json['run_as_user'] = 1001 app_model_json['run_commands'] = ['testString'] @@ -4506,6 +8719,7 @@ def test_app_serialization(self): app_model_json['scale_concurrency'] = 100 app_model_json['scale_concurrency_target'] = 80 app_model_json['scale_cpu_limit'] = '1' + app_model_json['scale_down_delay'] = 300 app_model_json['scale_ephemeral_storage_limit'] = '4G' app_model_json['scale_initial_instances'] = 1 app_model_json['scale_max_instances'] = 10 @@ -4530,6 +8744,109 @@ def test_app_serialization(self): assert app_model_json2 == app_model_json +class TestModel_AppInstance: + """ + Test Class for AppInstance + """ + + def test_app_instance_serialization(self): + """ + Test serialization/deserialization for AppInstance + """ + + # Construct dict forms of any model objects needed in order to build this model. + + container_status_details_model = {} # ContainerStatusDetails + + container_status_model = {} # ContainerStatus + container_status_model['current_state'] = container_status_details_model + container_status_model['last_observed_state'] = container_status_details_model + + # Construct a json representation of a AppInstance model + app_instance_model_json = {} + app_instance_model_json['app_name'] = 'my-app' + app_instance_model_json['revision_name'] = 'my-app' + app_instance_model_json['scale_cpu_limit'] = '1' + app_instance_model_json['scale_ephemeral_storage_limit'] = '4G' + app_instance_model_json['scale_memory_limit'] = '4G' + app_instance_model_json['system_container'] = container_status_model + app_instance_model_json['user_container'] = container_status_model + + # Construct a model instance of AppInstance by calling from_dict on the json representation + app_instance_model = AppInstance.from_dict(app_instance_model_json) + assert app_instance_model != False + + # Construct a model instance of AppInstance by calling from_dict on the json representation + app_instance_model_dict = AppInstance.from_dict(app_instance_model_json).__dict__ + app_instance_model2 = AppInstance(**app_instance_model_dict) + + # Verify the model instances are equivalent + assert app_instance_model == app_instance_model2 + + # Convert model instance back to dict and verify no loss of data + app_instance_model_json2 = app_instance_model.to_dict() + assert app_instance_model_json2 == app_instance_model_json + + +class TestModel_AppInstanceList: + """ + Test Class for AppInstanceList + """ + + def test_app_instance_list_serialization(self): + """ + Test serialization/deserialization for AppInstanceList + """ + + # Construct dict forms of any model objects needed in order to build this model. + + list_first_metadata_model = {} # ListFirstMetadata + list_first_metadata_model['href'] = ( + 'https://api.us-east.codeengine.cloud.ibm.com/v2/projects/230828b4-4f15-40a9-b183-1268c6ab88d5/apps/my-app/instances?limit=50' + ) + + container_status_details_model = {} # ContainerStatusDetails + + container_status_model = {} # ContainerStatus + container_status_model['current_state'] = container_status_details_model + container_status_model['last_observed_state'] = container_status_details_model + + app_instance_model = {} # AppInstance + app_instance_model['app_name'] = 'crash' + app_instance_model['revision_name'] = 'crash-00001' + app_instance_model['scale_cpu_limit'] = '0.125' + app_instance_model['scale_ephemeral_storage_limit'] = '400M' + app_instance_model['scale_memory_limit'] = '250M' + app_instance_model['system_container'] = container_status_model + app_instance_model['user_container'] = container_status_model + + list_next_metadata_model = {} # ListNextMetadata + list_next_metadata_model['href'] = 'testString' + list_next_metadata_model['start'] = 'testString' + + # Construct a json representation of a AppInstanceList model + app_instance_list_model_json = {} + app_instance_list_model_json['first'] = list_first_metadata_model + app_instance_list_model_json['instances'] = [app_instance_model] + app_instance_list_model_json['limit'] = 100 + app_instance_list_model_json['next'] = list_next_metadata_model + + # Construct a model instance of AppInstanceList by calling from_dict on the json representation + app_instance_list_model = AppInstanceList.from_dict(app_instance_list_model_json) + assert app_instance_list_model != False + + # Construct a model instance of AppInstanceList by calling from_dict on the json representation + app_instance_list_model_dict = AppInstanceList.from_dict(app_instance_list_model_json).__dict__ + app_instance_list_model2 = AppInstanceList(**app_instance_list_model_dict) + + # Verify the model instances are equivalent + assert app_instance_list_model == app_instance_list_model2 + + # Convert model instance back to dict and verify no loss of data + app_instance_list_model_json2 = app_instance_list_model.to_dict() + assert app_instance_list_model_json2 == app_instance_list_model_json + + class TestModel_AppList: """ Test Class for AppList @@ -4544,11 +8861,20 @@ def test_app_list_serialization(self): env_var_model = {} # EnvVar env_var_model['key'] = 'MY_VARIABLE' - env_var_model['name'] = 'CE_SUBDOMAIN' + env_var_model['name'] = 'SOME' env_var_model['prefix'] = 'PREFIX_' env_var_model['reference'] = 'my-secret' env_var_model['type'] = 'literal' - env_var_model['value'] = 'uyh5shf7s0f' + env_var_model['value'] = 'VALUE' + + probe_model = {} # Probe + probe_model['failure_threshold'] = 5 + probe_model['initial_delay'] = 5 + probe_model['interval'] = 5 + probe_model['path'] = 'testString' + probe_model['port'] = 8080 + probe_model['timeout'] = 300 + probe_model['type'] = 'tcp' volume_mount_model = {} # VolumeMount volume_mount_model['mount_path'] = '/app' @@ -4559,12 +8885,15 @@ def test_app_list_serialization(self): app_status_model = {} # AppStatus app_model = {} # App + app_model['computed_env_variables'] = [env_var_model] app_model['entity_tag'] = '1' app_model['image_port'] = 8080 app_model['image_reference'] = 'icr.io/codeengine/helloworld' app_model['image_secret'] = 'my-secret' app_model['managed_domain_mappings'] = 'local_public' app_model['name'] = 'my-app' + app_model['probe_liveness'] = probe_model + app_model['probe_readiness'] = probe_model app_model['run_arguments'] = [] app_model['run_as_user'] = 1001 app_model['run_commands'] = [] @@ -4574,6 +8903,7 @@ def test_app_list_serialization(self): app_model['scale_concurrency'] = 100 app_model['scale_concurrency_target'] = 80 app_model['scale_cpu_limit'] = '1' + app_model['scale_down_delay'] = 300 app_model['scale_ephemeral_storage_limit'] = '400M' app_model['scale_initial_instances'] = 1 app_model['scale_max_instances'] = 10 @@ -4624,6 +8954,15 @@ def test_app_patch_serialization(self): # Construct dict forms of any model objects needed in order to build this model. + probe_prototype_model = {} # ProbePrototype + probe_prototype_model['failure_threshold'] = 5 + probe_prototype_model['initial_delay'] = 5 + probe_prototype_model['interval'] = 5 + probe_prototype_model['path'] = 'testString' + probe_prototype_model['port'] = 8080 + probe_prototype_model['timeout'] = 300 + probe_prototype_model['type'] = 'tcp' + env_var_prototype_model = {} # EnvVarPrototype env_var_prototype_model['key'] = 'MY_VARIABLE' env_var_prototype_model['name'] = 'SOME' @@ -4644,6 +8983,8 @@ def test_app_patch_serialization(self): app_patch_model_json['image_reference'] = 'icr.io/codeengine/helloworld' app_patch_model_json['image_secret'] = 'my-secret' app_patch_model_json['managed_domain_mappings'] = 'local_public' + app_patch_model_json['probe_liveness'] = probe_prototype_model + app_patch_model_json['probe_readiness'] = probe_prototype_model app_patch_model_json['run_arguments'] = ['testString'] app_patch_model_json['run_as_user'] = 1001 app_patch_model_json['run_commands'] = ['testString'] @@ -4653,6 +8994,7 @@ def test_app_patch_serialization(self): app_patch_model_json['scale_concurrency'] = 100 app_patch_model_json['scale_concurrency_target'] = 80 app_patch_model_json['scale_cpu_limit'] = '1' + app_patch_model_json['scale_down_delay'] = 300 app_patch_model_json['scale_ephemeral_storage_limit'] = '4G' app_patch_model_json['scale_initial_instances'] = 1 app_patch_model_json['scale_max_instances'] = 10 @@ -4690,11 +9032,20 @@ def test_app_revision_serialization(self): env_var_model = {} # EnvVar env_var_model['key'] = 'MY_VARIABLE' - env_var_model['name'] = 'CE_SUBDOMAIN' + env_var_model['name'] = 'SOME' env_var_model['prefix'] = 'PREFIX_' env_var_model['reference'] = 'my-secret' env_var_model['type'] = 'literal' - env_var_model['value'] = 'uyh5shf7s0f' + env_var_model['value'] = 'VALUE' + + probe_model = {} # Probe + probe_model['failure_threshold'] = 5 + probe_model['initial_delay'] = 5 + probe_model['interval'] = 5 + probe_model['path'] = 'testString' + probe_model['port'] = 8080 + probe_model['timeout'] = 300 + probe_model['type'] = 'tcp' volume_mount_model = {} # VolumeMount volume_mount_model['mount_path'] = '/app' @@ -4707,9 +9058,12 @@ def test_app_revision_serialization(self): # Construct a json representation of a AppRevision model app_revision_model_json = {} app_revision_model_json['app_name'] = 'my-app' + app_revision_model_json['computed_env_variables'] = [env_var_model] app_revision_model_json['image_port'] = 8080 app_revision_model_json['image_reference'] = 'icr.io/codeengine/helloworld' app_revision_model_json['image_secret'] = 'my-secret' + app_revision_model_json['probe_liveness'] = probe_model + app_revision_model_json['probe_readiness'] = probe_model app_revision_model_json['run_arguments'] = ['testString'] app_revision_model_json['run_as_user'] = 1001 app_revision_model_json['run_commands'] = ['testString'] @@ -4719,6 +9073,7 @@ def test_app_revision_serialization(self): app_revision_model_json['scale_concurrency'] = 100 app_revision_model_json['scale_concurrency_target'] = 80 app_revision_model_json['scale_cpu_limit'] = '1' + app_revision_model_json['scale_down_delay'] = 300 app_revision_model_json['scale_ephemeral_storage_limit'] = '4G' app_revision_model_json['scale_initial_instances'] = 1 app_revision_model_json['scale_max_instances'] = 10 @@ -4764,11 +9119,20 @@ def test_app_revision_list_serialization(self): env_var_model = {} # EnvVar env_var_model['key'] = 'MY_VARIABLE' - env_var_model['name'] = 'CE_SUBDOMAIN' + env_var_model['name'] = 'SOME' env_var_model['prefix'] = 'PREFIX_' env_var_model['reference'] = 'my-secret' env_var_model['type'] = 'literal' - env_var_model['value'] = 'uyh5shf7s0f' + env_var_model['value'] = 'VALUE' + + probe_model = {} # Probe + probe_model['failure_threshold'] = 5 + probe_model['initial_delay'] = 5 + probe_model['interval'] = 5 + probe_model['path'] = 'testString' + probe_model['port'] = 8080 + probe_model['timeout'] = 300 + probe_model['type'] = 'tcp' volume_mount_model = {} # VolumeMount volume_mount_model['mount_path'] = '/app' @@ -4780,9 +9144,12 @@ def test_app_revision_list_serialization(self): app_revision_model = {} # AppRevision app_revision_model['app_name'] = 'my-app' + app_revision_model['computed_env_variables'] = [env_var_model] app_revision_model['image_port'] = 8080 app_revision_model['image_reference'] = 'icr.io/codeengine/helloworld' app_revision_model['image_secret'] = 'my-secret' + app_revision_model['probe_liveness'] = probe_model + app_revision_model['probe_readiness'] = probe_model app_revision_model['run_arguments'] = [] app_revision_model['run_as_user'] = 1001 app_revision_model['run_commands'] = [] @@ -4792,6 +9159,7 @@ def test_app_revision_list_serialization(self): app_revision_model['scale_concurrency'] = 100 app_revision_model['scale_concurrency_target'] = 80 app_revision_model['scale_cpu_limit'] = '1' + app_revision_model['scale_down_delay'] = 300 app_revision_model['scale_ephemeral_storage_limit'] = '400M' app_revision_model['scale_initial_instances'] = 1 app_revision_model['scale_max_instances'] = 10 @@ -4862,23 +9230,112 @@ def test_app_status_serialization(self): Test serialization/deserialization for AppStatus """ - # Construct a json representation of a AppStatus model - app_status_model_json = {} + # Construct a json representation of a AppStatus model + app_status_model_json = {} + + # Construct a model instance of AppStatus by calling from_dict on the json representation + app_status_model = AppStatus.from_dict(app_status_model_json) + assert app_status_model != False + + # Construct a model instance of AppStatus by calling from_dict on the json representation + app_status_model_dict = AppStatus.from_dict(app_status_model_json).__dict__ + app_status_model2 = AppStatus(**app_status_model_dict) + + # Verify the model instances are equivalent + assert app_status_model == app_status_model2 + + # Convert model instance back to dict and verify no loss of data + app_status_model_json2 = app_status_model.to_dict() + assert app_status_model_json2 == app_status_model_json + + +class TestModel_Binding: + """ + Test Class for Binding + """ + + def test_binding_serialization(self): + """ + Test serialization/deserialization for Binding + """ + + # Construct dict forms of any model objects needed in order to build this model. + + component_ref_model = {} # ComponentRef + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' + + # Construct a json representation of a Binding model + binding_model_json = {} + binding_model_json['component'] = component_ref_model + binding_model_json['prefix'] = 'MY_COS' + binding_model_json['secret_name'] = 'my-service-access' + + # Construct a model instance of Binding by calling from_dict on the json representation + binding_model = Binding.from_dict(binding_model_json) + assert binding_model != False + + # Construct a model instance of Binding by calling from_dict on the json representation + binding_model_dict = Binding.from_dict(binding_model_json).__dict__ + binding_model2 = Binding(**binding_model_dict) + + # Verify the model instances are equivalent + assert binding_model == binding_model2 + + # Convert model instance back to dict and verify no loss of data + binding_model_json2 = binding_model.to_dict() + assert binding_model_json2 == binding_model_json + + +class TestModel_BindingList: + """ + Test Class for BindingList + """ + + def test_binding_list_serialization(self): + """ + Test serialization/deserialization for BindingList + """ + + # Construct dict forms of any model objects needed in order to build this model. + + component_ref_model = {} # ComponentRef + component_ref_model['name'] = 'my-app-1' + component_ref_model['resource_type'] = 'app_v2' + + binding_model = {} # Binding + binding_model['component'] = component_ref_model + binding_model['prefix'] = 'PREFIX' + binding_model['secret_name'] = 'my-service-access' + + list_first_metadata_model = {} # ListFirstMetadata + list_first_metadata_model['href'] = 'testString' + + list_next_metadata_model = {} # ListNextMetadata + list_next_metadata_model['href'] = 'testString' + list_next_metadata_model['start'] = 'testString' + + # Construct a json representation of a BindingList model + binding_list_model_json = {} + binding_list_model_json['bindings'] = [binding_model] + binding_list_model_json['first'] = list_first_metadata_model + binding_list_model_json['limit'] = 100 + binding_list_model_json['next'] = list_next_metadata_model - # Construct a model instance of AppStatus by calling from_dict on the json representation - app_status_model = AppStatus.from_dict(app_status_model_json) - assert app_status_model != False + # Construct a model instance of BindingList by calling from_dict on the json representation + binding_list_model = BindingList.from_dict(binding_list_model_json) + assert binding_list_model != False - # Construct a model instance of AppStatus by calling from_dict on the json representation - app_status_model_dict = AppStatus.from_dict(app_status_model_json).__dict__ - app_status_model2 = AppStatus(**app_status_model_dict) + # Construct a model instance of BindingList by calling from_dict on the json representation + binding_list_model_dict = BindingList.from_dict(binding_list_model_json).__dict__ + binding_list_model2 = BindingList(**binding_list_model_dict) # Verify the model instances are equivalent - assert app_status_model == app_status_model2 + assert binding_list_model == binding_list_model2 # Convert model instance back to dict and verify no loss of data - app_status_model_json2 = app_status_model.to_dict() - assert app_status_model_json2 == app_status_model_json + binding_list_model_json2 = binding_list_model.to_dict() + assert binding_list_model_json2 == binding_list_model_json class TestModel_Build: @@ -5195,6 +9652,37 @@ def test_build_status_serialization(self): assert build_status_model_json2 == build_status_model_json +class TestModel_ComponentRef: + """ + Test Class for ComponentRef + """ + + def test_component_ref_serialization(self): + """ + Test serialization/deserialization for ComponentRef + """ + + # Construct a json representation of a ComponentRef model + component_ref_model_json = {} + component_ref_model_json['name'] = 'my-app-1' + component_ref_model_json['resource_type'] = 'app_v2' + + # Construct a model instance of ComponentRef by calling from_dict on the json representation + component_ref_model = ComponentRef.from_dict(component_ref_model_json) + assert component_ref_model != False + + # Construct a model instance of ComponentRef by calling from_dict on the json representation + component_ref_model_dict = ComponentRef.from_dict(component_ref_model_json).__dict__ + component_ref_model2 = ComponentRef(**component_ref_model_dict) + + # Verify the model instances are equivalent + assert component_ref_model == component_ref_model2 + + # Convert model instance back to dict and verify no loss of data + component_ref_model_json2 = component_ref_model.to_dict() + assert component_ref_model_json2 == component_ref_model_json + + class TestModel_ConfigMap: """ Test Class for ConfigMap @@ -5274,6 +9762,235 @@ def test_config_map_list_serialization(self): assert config_map_list_model_json2 == config_map_list_model_json +class TestModel_ContainerStatus: + """ + Test Class for ContainerStatus + """ + + def test_container_status_serialization(self): + """ + Test serialization/deserialization for ContainerStatus + """ + + # Construct dict forms of any model objects needed in order to build this model. + + container_status_details_model = {} # ContainerStatusDetails + + # Construct a json representation of a ContainerStatus model + container_status_model_json = {} + container_status_model_json['current_state'] = container_status_details_model + container_status_model_json['last_observed_state'] = container_status_details_model + + # Construct a model instance of ContainerStatus by calling from_dict on the json representation + container_status_model = ContainerStatus.from_dict(container_status_model_json) + assert container_status_model != False + + # Construct a model instance of ContainerStatus by calling from_dict on the json representation + container_status_model_dict = ContainerStatus.from_dict(container_status_model_json).__dict__ + container_status_model2 = ContainerStatus(**container_status_model_dict) + + # Verify the model instances are equivalent + assert container_status_model == container_status_model2 + + # Convert model instance back to dict and verify no loss of data + container_status_model_json2 = container_status_model.to_dict() + assert container_status_model_json2 == container_status_model_json + + +class TestModel_ContainerStatusDetails: + """ + Test Class for ContainerStatusDetails + """ + + def test_container_status_details_serialization(self): + """ + Test serialization/deserialization for ContainerStatusDetails + """ + + # Construct a json representation of a ContainerStatusDetails model + container_status_details_model_json = {} + + # Construct a model instance of ContainerStatusDetails by calling from_dict on the json representation + container_status_details_model = ContainerStatusDetails.from_dict(container_status_details_model_json) + assert container_status_details_model != False + + # Construct a model instance of ContainerStatusDetails by calling from_dict on the json representation + container_status_details_model_dict = ContainerStatusDetails.from_dict( + container_status_details_model_json + ).__dict__ + container_status_details_model2 = ContainerStatusDetails(**container_status_details_model_dict) + + # Verify the model instances are equivalent + assert container_status_details_model == container_status_details_model2 + + # Convert model instance back to dict and verify no loss of data + container_status_details_model_json2 = container_status_details_model.to_dict() + assert container_status_details_model_json2 == container_status_details_model_json + + +class TestModel_DomainMapping: + """ + Test Class for DomainMapping + """ + + def test_domain_mapping_serialization(self): + """ + Test serialization/deserialization for DomainMapping + """ + + # Construct dict forms of any model objects needed in order to build this model. + + component_ref_model = {} # ComponentRef + component_ref_model['name'] = 'my-app' + component_ref_model['resource_type'] = 'app_v2' + + domain_mapping_status_model = {} # DomainMappingStatus + + # Construct a json representation of a DomainMapping model + domain_mapping_model_json = {} + domain_mapping_model_json['component'] = component_ref_model + domain_mapping_model_json['entity_tag'] = '2385407409' + domain_mapping_model_json['name'] = 'www.example.com' + domain_mapping_model_json['status_details'] = domain_mapping_status_model + domain_mapping_model_json['tls_secret'] = 'my-tls-secret' + + # Construct a model instance of DomainMapping by calling from_dict on the json representation + domain_mapping_model = DomainMapping.from_dict(domain_mapping_model_json) + assert domain_mapping_model != False + + # Construct a model instance of DomainMapping by calling from_dict on the json representation + domain_mapping_model_dict = DomainMapping.from_dict(domain_mapping_model_json).__dict__ + domain_mapping_model2 = DomainMapping(**domain_mapping_model_dict) + + # Verify the model instances are equivalent + assert domain_mapping_model == domain_mapping_model2 + + # Convert model instance back to dict and verify no loss of data + domain_mapping_model_json2 = domain_mapping_model.to_dict() + assert domain_mapping_model_json2 == domain_mapping_model_json + + +class TestModel_DomainMappingList: + """ + Test Class for DomainMappingList + """ + + def test_domain_mapping_list_serialization(self): + """ + Test serialization/deserialization for DomainMappingList + """ + + # Construct dict forms of any model objects needed in order to build this model. + + component_ref_model = {} # ComponentRef + component_ref_model['name'] = 'my-app' + component_ref_model['resource_type'] = 'app_v2' + + domain_mapping_status_model = {} # DomainMappingStatus + + domain_mapping_model = {} # DomainMapping + domain_mapping_model['component'] = component_ref_model + domain_mapping_model['entity_tag'] = '2385407409' + domain_mapping_model['name'] = 'www.example.com' + domain_mapping_model['status_details'] = domain_mapping_status_model + domain_mapping_model['tls_secret'] = 'my-tls-secret' + + list_first_metadata_model = {} # ListFirstMetadata + list_first_metadata_model['href'] = 'testString' + + list_next_metadata_model = {} # ListNextMetadata + list_next_metadata_model['href'] = 'testString' + list_next_metadata_model['start'] = 'testString' + + # Construct a json representation of a DomainMappingList model + domain_mapping_list_model_json = {} + domain_mapping_list_model_json['domain_mappings'] = [domain_mapping_model] + domain_mapping_list_model_json['first'] = list_first_metadata_model + domain_mapping_list_model_json['limit'] = 100 + domain_mapping_list_model_json['next'] = list_next_metadata_model + + # Construct a model instance of DomainMappingList by calling from_dict on the json representation + domain_mapping_list_model = DomainMappingList.from_dict(domain_mapping_list_model_json) + assert domain_mapping_list_model != False + + # Construct a model instance of DomainMappingList by calling from_dict on the json representation + domain_mapping_list_model_dict = DomainMappingList.from_dict(domain_mapping_list_model_json).__dict__ + domain_mapping_list_model2 = DomainMappingList(**domain_mapping_list_model_dict) + + # Verify the model instances are equivalent + assert domain_mapping_list_model == domain_mapping_list_model2 + + # Convert model instance back to dict and verify no loss of data + domain_mapping_list_model_json2 = domain_mapping_list_model.to_dict() + assert domain_mapping_list_model_json2 == domain_mapping_list_model_json + + +class TestModel_DomainMappingPatch: + """ + Test Class for DomainMappingPatch + """ + + def test_domain_mapping_patch_serialization(self): + """ + Test serialization/deserialization for DomainMappingPatch + """ + + # Construct dict forms of any model objects needed in order to build this model. + + component_ref_model = {} # ComponentRef + component_ref_model['name'] = 'my-app' + component_ref_model['resource_type'] = 'app_v2' + + # Construct a json representation of a DomainMappingPatch model + domain_mapping_patch_model_json = {} + domain_mapping_patch_model_json['component'] = component_ref_model + domain_mapping_patch_model_json['tls_secret'] = 'my-tls-secret' + + # Construct a model instance of DomainMappingPatch by calling from_dict on the json representation + domain_mapping_patch_model = DomainMappingPatch.from_dict(domain_mapping_patch_model_json) + assert domain_mapping_patch_model != False + + # Construct a model instance of DomainMappingPatch by calling from_dict on the json representation + domain_mapping_patch_model_dict = DomainMappingPatch.from_dict(domain_mapping_patch_model_json).__dict__ + domain_mapping_patch_model2 = DomainMappingPatch(**domain_mapping_patch_model_dict) + + # Verify the model instances are equivalent + assert domain_mapping_patch_model == domain_mapping_patch_model2 + + # Convert model instance back to dict and verify no loss of data + domain_mapping_patch_model_json2 = domain_mapping_patch_model.to_dict() + assert domain_mapping_patch_model_json2 == domain_mapping_patch_model_json + + +class TestModel_DomainMappingStatus: + """ + Test Class for DomainMappingStatus + """ + + def test_domain_mapping_status_serialization(self): + """ + Test serialization/deserialization for DomainMappingStatus + """ + + # Construct a json representation of a DomainMappingStatus model + domain_mapping_status_model_json = {} + + # Construct a model instance of DomainMappingStatus by calling from_dict on the json representation + domain_mapping_status_model = DomainMappingStatus.from_dict(domain_mapping_status_model_json) + assert domain_mapping_status_model != False + + # Construct a model instance of DomainMappingStatus by calling from_dict on the json representation + domain_mapping_status_model_dict = DomainMappingStatus.from_dict(domain_mapping_status_model_json).__dict__ + domain_mapping_status_model2 = DomainMappingStatus(**domain_mapping_status_model_dict) + + # Verify the model instances are equivalent + assert domain_mapping_status_model == domain_mapping_status_model2 + + # Convert model instance back to dict and verify no loss of data + domain_mapping_status_model_json2 = domain_mapping_status_model.to_dict() + assert domain_mapping_status_model_json2 == domain_mapping_status_model_json + + class TestModel_EnvVar: """ Test Class for EnvVar @@ -5337,11 +10054,281 @@ def test_env_var_prototype_serialization(self): env_var_prototype_model2 = EnvVarPrototype(**env_var_prototype_model_dict) # Verify the model instances are equivalent - assert env_var_prototype_model == env_var_prototype_model2 + assert env_var_prototype_model == env_var_prototype_model2 + + # Convert model instance back to dict and verify no loss of data + env_var_prototype_model_json2 = env_var_prototype_model.to_dict() + assert env_var_prototype_model_json2 == env_var_prototype_model_json + + +class TestModel_Function: + """ + Test Class for Function + """ + + def test_function_serialization(self): + """ + Test serialization/deserialization for Function + """ + + # Construct dict forms of any model objects needed in order to build this model. + + env_var_model = {} # EnvVar + env_var_model['key'] = 'MY_VARIABLE' + env_var_model['name'] = 'SOME' + env_var_model['prefix'] = 'PREFIX_' + env_var_model['reference'] = 'my-secret' + env_var_model['type'] = 'literal' + env_var_model['value'] = 'VALUE' + + function_status_model = {} # FunctionStatus + + # Construct a json representation of a Function model + function_model_json = {} + function_model_json['code_binary'] = False + function_model_json['code_main'] = 'main' + function_model_json['code_reference'] = 'data:text/plain;base64,' + function_model_json['code_secret'] = 'my-secret' + function_model_json['computed_env_variables'] = [env_var_model] + function_model_json['entity_tag'] = '2385407409' + function_model_json['managed_domain_mappings'] = 'local_public' + function_model_json['name'] = 'my-function' + function_model_json['run_env_variables'] = [env_var_model] + function_model_json['runtime'] = 'nodejs-18' + function_model_json['scale_concurrency'] = 1 + function_model_json['scale_cpu_limit'] = '1' + function_model_json['scale_down_delay'] = 300 + function_model_json['scale_max_execution_time'] = 60 + function_model_json['scale_memory_limit'] = '1G' + function_model_json['status_details'] = function_status_model + + # Construct a model instance of Function by calling from_dict on the json representation + function_model = Function.from_dict(function_model_json) + assert function_model != False + + # Construct a model instance of Function by calling from_dict on the json representation + function_model_dict = Function.from_dict(function_model_json).__dict__ + function_model2 = Function(**function_model_dict) + + # Verify the model instances are equivalent + assert function_model == function_model2 + + # Convert model instance back to dict and verify no loss of data + function_model_json2 = function_model.to_dict() + assert function_model_json2 == function_model_json + + +class TestModel_FunctionList: + """ + Test Class for FunctionList + """ + + def test_function_list_serialization(self): + """ + Test serialization/deserialization for FunctionList + """ + + # Construct dict forms of any model objects needed in order to build this model. + + list_first_metadata_model = {} # ListFirstMetadata + list_first_metadata_model['href'] = 'testString' + + env_var_model = {} # EnvVar + env_var_model['key'] = 'MY_VARIABLE' + env_var_model['name'] = 'SOME' + env_var_model['prefix'] = 'PREFIX_' + env_var_model['reference'] = 'my-secret' + env_var_model['type'] = 'literal' + env_var_model['value'] = 'VALUE' + + function_status_model = {} # FunctionStatus + + function_model = {} # Function + function_model['code_binary'] = True + function_model['code_main'] = 'main' + function_model['code_reference'] = 'icr.io/codeengine/samples/function-nodejs-codebundle' + function_model['code_secret'] = 'my-secret' + function_model['computed_env_variables'] = [env_var_model] + function_model['entity_tag'] = '1' + function_model['managed_domain_mappings'] = 'local_public' + function_model['name'] = 'my-function' + function_model['run_env_variables'] = [env_var_model] + function_model['runtime'] = 'nodejs-18' + function_model['scale_concurrency'] = 1 + function_model['scale_cpu_limit'] = '0.5' + function_model['scale_down_delay'] = 0 + function_model['scale_max_execution_time'] = 60 + function_model['scale_memory_limit'] = '2G' + function_model['status_details'] = function_status_model + + list_next_metadata_model = {} # ListNextMetadata + list_next_metadata_model['href'] = 'testString' + list_next_metadata_model['start'] = 'testString' + + # Construct a json representation of a FunctionList model + function_list_model_json = {} + function_list_model_json['first'] = list_first_metadata_model + function_list_model_json['functions'] = [function_model] + function_list_model_json['limit'] = 100 + function_list_model_json['next'] = list_next_metadata_model + + # Construct a model instance of FunctionList by calling from_dict on the json representation + function_list_model = FunctionList.from_dict(function_list_model_json) + assert function_list_model != False + + # Construct a model instance of FunctionList by calling from_dict on the json representation + function_list_model_dict = FunctionList.from_dict(function_list_model_json).__dict__ + function_list_model2 = FunctionList(**function_list_model_dict) + + # Verify the model instances are equivalent + assert function_list_model == function_list_model2 + + # Convert model instance back to dict and verify no loss of data + function_list_model_json2 = function_list_model.to_dict() + assert function_list_model_json2 == function_list_model_json + + +class TestModel_FunctionPatch: + """ + Test Class for FunctionPatch + """ + + def test_function_patch_serialization(self): + """ + Test serialization/deserialization for FunctionPatch + """ + + # Construct dict forms of any model objects needed in order to build this model. + + env_var_prototype_model = {} # EnvVarPrototype + env_var_prototype_model['key'] = 'MY_VARIABLE' + env_var_prototype_model['name'] = 'SOME' + env_var_prototype_model['prefix'] = 'PREFIX_' + env_var_prototype_model['reference'] = 'my-secret' + env_var_prototype_model['type'] = 'literal' + env_var_prototype_model['value'] = 'VALUE' + + # Construct a json representation of a FunctionPatch model + function_patch_model_json = {} + function_patch_model_json['code_binary'] = False + function_patch_model_json['code_main'] = 'main' + function_patch_model_json['code_reference'] = 'data:text/plain;base64,' + function_patch_model_json['code_secret'] = 'my-secret' + function_patch_model_json['managed_domain_mappings'] = 'local_public' + function_patch_model_json['run_env_variables'] = [env_var_prototype_model] + function_patch_model_json['runtime'] = 'nodejs-18' + function_patch_model_json['scale_concurrency'] = 1 + function_patch_model_json['scale_cpu_limit'] = '1' + function_patch_model_json['scale_down_delay'] = 300 + function_patch_model_json['scale_max_execution_time'] = 60 + function_patch_model_json['scale_memory_limit'] = '1G' + + # Construct a model instance of FunctionPatch by calling from_dict on the json representation + function_patch_model = FunctionPatch.from_dict(function_patch_model_json) + assert function_patch_model != False + + # Construct a model instance of FunctionPatch by calling from_dict on the json representation + function_patch_model_dict = FunctionPatch.from_dict(function_patch_model_json).__dict__ + function_patch_model2 = FunctionPatch(**function_patch_model_dict) + + # Verify the model instances are equivalent + assert function_patch_model == function_patch_model2 + + # Convert model instance back to dict and verify no loss of data + function_patch_model_json2 = function_patch_model.to_dict() + assert function_patch_model_json2 == function_patch_model_json + + +class TestModel_FunctionRuntime: + """ + Test Class for FunctionRuntime + """ + + def test_function_runtime_serialization(self): + """ + Test serialization/deserialization for FunctionRuntime + """ + + # Construct a json representation of a FunctionRuntime model + function_runtime_model_json = {} + + # Construct a model instance of FunctionRuntime by calling from_dict on the json representation + function_runtime_model = FunctionRuntime.from_dict(function_runtime_model_json) + assert function_runtime_model != False + + # Construct a model instance of FunctionRuntime by calling from_dict on the json representation + function_runtime_model_dict = FunctionRuntime.from_dict(function_runtime_model_json).__dict__ + function_runtime_model2 = FunctionRuntime(**function_runtime_model_dict) + + # Verify the model instances are equivalent + assert function_runtime_model == function_runtime_model2 + + # Convert model instance back to dict and verify no loss of data + function_runtime_model_json2 = function_runtime_model.to_dict() + assert function_runtime_model_json2 == function_runtime_model_json + + +class TestModel_FunctionRuntimeList: + """ + Test Class for FunctionRuntimeList + """ + + def test_function_runtime_list_serialization(self): + """ + Test serialization/deserialization for FunctionRuntimeList + """ + + # Construct dict forms of any model objects needed in order to build this model. + + function_runtime_model = {} # FunctionRuntime + + # Construct a json representation of a FunctionRuntimeList model + function_runtime_list_model_json = {} + function_runtime_list_model_json['function_runtimes'] = [function_runtime_model] + + # Construct a model instance of FunctionRuntimeList by calling from_dict on the json representation + function_runtime_list_model = FunctionRuntimeList.from_dict(function_runtime_list_model_json) + assert function_runtime_list_model != False + + # Construct a model instance of FunctionRuntimeList by calling from_dict on the json representation + function_runtime_list_model_dict = FunctionRuntimeList.from_dict(function_runtime_list_model_json).__dict__ + function_runtime_list_model2 = FunctionRuntimeList(**function_runtime_list_model_dict) + + # Verify the model instances are equivalent + assert function_runtime_list_model == function_runtime_list_model2 + + # Convert model instance back to dict and verify no loss of data + function_runtime_list_model_json2 = function_runtime_list_model.to_dict() + assert function_runtime_list_model_json2 == function_runtime_list_model_json + + +class TestModel_FunctionStatus: + """ + Test Class for FunctionStatus + """ + + def test_function_status_serialization(self): + """ + Test serialization/deserialization for FunctionStatus + """ + + # Construct a json representation of a FunctionStatus model + function_status_model_json = {} + + # Construct a model instance of FunctionStatus by calling from_dict on the json representation + function_status_model = FunctionStatus.from_dict(function_status_model_json) + assert function_status_model != False + + # Construct a model instance of FunctionStatus by calling from_dict on the json representation + function_status_model_dict = FunctionStatus.from_dict(function_status_model_json).__dict__ + function_status_model2 = FunctionStatus(**function_status_model_dict) + + # Verify the model instances are equivalent + assert function_status_model == function_status_model2 # Convert model instance back to dict and verify no loss of data - env_var_prototype_model_json2 = env_var_prototype_model.to_dict() - assert env_var_prototype_model_json2 == env_var_prototype_model_json + function_status_model_json2 = function_status_model.to_dict() + assert function_status_model_json2 == function_status_model_json class TestModel_Job: @@ -5372,6 +10359,7 @@ def test_job_serialization(self): # Construct a json representation of a Job model job_model_json = {} + job_model_json['computed_env_variables'] = [env_var_model] job_model_json['entity_tag'] = '2385407409' job_model_json['image_reference'] = 'icr.io/codeengine/helloworld' job_model_json['image_secret'] = 'my-secret' @@ -5436,6 +10424,7 @@ def test_job_list_serialization(self): volume_mount_model['type'] = 'secret' job_model = {} # Job + job_model['computed_env_variables'] = [env_var_model] job_model['entity_tag'] = '2386231540' job_model['image_reference'] = 'icr.io/codeengine/helloworld' job_model['image_secret'] = 'my-secret' @@ -5571,6 +10560,7 @@ def test_job_run_serialization(self): # Construct a json representation of a JobRun model job_run_model_json = {} + job_run_model_json['computed_env_variables'] = [env_var_model] job_run_model_json['image_reference'] = 'icr.io/codeengine/helloworld' job_run_model_json['image_secret'] = 'my-secret' job_run_model_json['job_name'] = 'my-job' @@ -5582,6 +10572,7 @@ def test_job_run_serialization(self): job_run_model_json['run_mode'] = 'task' job_run_model_json['run_service_account'] = 'default' job_run_model_json['run_volume_mounts'] = [volume_mount_model] + job_run_model_json['scale_array_size_variable_override'] = 2 job_run_model_json['scale_array_spec'] = '1-5,7-8,10' job_run_model_json['scale_cpu_limit'] = '1' job_run_model_json['scale_ephemeral_storage_limit'] = '4G' @@ -5638,6 +10629,7 @@ def test_job_run_list_serialization(self): job_run_status_model = {} # JobRunStatus job_run_model = {} # JobRun + job_run_model['computed_env_variables'] = [env_var_model] job_run_model['image_reference'] = 'icr.io/codeengine/helloworld' job_run_model['image_secret'] = 'my-secret' job_run_model['job_name'] = 'my-job' @@ -5649,6 +10641,7 @@ def test_job_run_list_serialization(self): job_run_model['run_mode'] = 'task' job_run_model['run_service_account'] = 'default' job_run_model['run_volume_mounts'] = [volume_mount_model] + job_run_model['scale_array_size_variable_override'] = 2 job_run_model['scale_array_spec'] = '0' job_run_model['scale_cpu_limit'] = '1' job_run_model['scale_ephemeral_storage_limit'] = '400M' @@ -5774,6 +10767,159 @@ def test_list_next_metadata_serialization(self): assert list_next_metadata_model_json2 == list_next_metadata_model_json +class TestModel_OperatorSecretProps: + """ + Test Class for OperatorSecretProps + """ + + def test_operator_secret_props_serialization(self): + """ + Test serialization/deserialization for OperatorSecretProps + """ + + # Construct dict forms of any model objects needed in order to build this model. + + service_id_ref_model = {} # ServiceIDRef + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a json representation of a OperatorSecretProps model + operator_secret_props_model_json = {} + operator_secret_props_model_json['apikey_id'] = 'ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b' + operator_secret_props_model_json['resource_group_ids'] = ['testString'] + operator_secret_props_model_json['serviceid'] = service_id_ref_model + operator_secret_props_model_json['user_managed'] = True + + # Construct a model instance of OperatorSecretProps by calling from_dict on the json representation + operator_secret_props_model = OperatorSecretProps.from_dict(operator_secret_props_model_json) + assert operator_secret_props_model != False + + # Construct a model instance of OperatorSecretProps by calling from_dict on the json representation + operator_secret_props_model_dict = OperatorSecretProps.from_dict(operator_secret_props_model_json).__dict__ + operator_secret_props_model2 = OperatorSecretProps(**operator_secret_props_model_dict) + + # Verify the model instances are equivalent + assert operator_secret_props_model == operator_secret_props_model2 + + # Convert model instance back to dict and verify no loss of data + operator_secret_props_model_json2 = operator_secret_props_model.to_dict() + assert operator_secret_props_model_json2 == operator_secret_props_model_json + + +class TestModel_OperatorSecretPrototypeProps: + """ + Test Class for OperatorSecretPrototypeProps + """ + + def test_operator_secret_prototype_props_serialization(self): + """ + Test serialization/deserialization for OperatorSecretPrototypeProps + """ + + # Construct dict forms of any model objects needed in order to build this model. + + service_id_ref_prototype_model = {} # ServiceIDRefPrototype + service_id_ref_prototype_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a json representation of a OperatorSecretPrototypeProps model + operator_secret_prototype_props_model_json = {} + operator_secret_prototype_props_model_json['resource_group_ids'] = ['testString'] + operator_secret_prototype_props_model_json['serviceid'] = service_id_ref_prototype_model + + # Construct a model instance of OperatorSecretPrototypeProps by calling from_dict on the json representation + operator_secret_prototype_props_model = OperatorSecretPrototypeProps.from_dict( + operator_secret_prototype_props_model_json + ) + assert operator_secret_prototype_props_model != False + + # Construct a model instance of OperatorSecretPrototypeProps by calling from_dict on the json representation + operator_secret_prototype_props_model_dict = OperatorSecretPrototypeProps.from_dict( + operator_secret_prototype_props_model_json + ).__dict__ + operator_secret_prototype_props_model2 = OperatorSecretPrototypeProps( + **operator_secret_prototype_props_model_dict + ) + + # Verify the model instances are equivalent + assert operator_secret_prototype_props_model == operator_secret_prototype_props_model2 + + # Convert model instance back to dict and verify no loss of data + operator_secret_prototype_props_model_json2 = operator_secret_prototype_props_model.to_dict() + assert operator_secret_prototype_props_model_json2 == operator_secret_prototype_props_model_json + + +class TestModel_Probe: + """ + Test Class for Probe + """ + + def test_probe_serialization(self): + """ + Test serialization/deserialization for Probe + """ + + # Construct a json representation of a Probe model + probe_model_json = {} + probe_model_json['failure_threshold'] = 5 + probe_model_json['initial_delay'] = 5 + probe_model_json['interval'] = 5 + probe_model_json['path'] = 'testString' + probe_model_json['port'] = 8080 + probe_model_json['timeout'] = 300 + probe_model_json['type'] = 'tcp' + + # Construct a model instance of Probe by calling from_dict on the json representation + probe_model = Probe.from_dict(probe_model_json) + assert probe_model != False + + # Construct a model instance of Probe by calling from_dict on the json representation + probe_model_dict = Probe.from_dict(probe_model_json).__dict__ + probe_model2 = Probe(**probe_model_dict) + + # Verify the model instances are equivalent + assert probe_model == probe_model2 + + # Convert model instance back to dict and verify no loss of data + probe_model_json2 = probe_model.to_dict() + assert probe_model_json2 == probe_model_json + + +class TestModel_ProbePrototype: + """ + Test Class for ProbePrototype + """ + + def test_probe_prototype_serialization(self): + """ + Test serialization/deserialization for ProbePrototype + """ + + # Construct a json representation of a ProbePrototype model + probe_prototype_model_json = {} + probe_prototype_model_json['failure_threshold'] = 5 + probe_prototype_model_json['initial_delay'] = 5 + probe_prototype_model_json['interval'] = 5 + probe_prototype_model_json['path'] = 'testString' + probe_prototype_model_json['port'] = 8080 + probe_prototype_model_json['timeout'] = 300 + probe_prototype_model_json['type'] = 'tcp' + + # Construct a model instance of ProbePrototype by calling from_dict on the json representation + probe_prototype_model = ProbePrototype.from_dict(probe_prototype_model_json) + assert probe_prototype_model != False + + # Construct a model instance of ProbePrototype by calling from_dict on the json representation + probe_prototype_model_dict = ProbePrototype.from_dict(probe_prototype_model_json).__dict__ + probe_prototype_model2 = ProbePrototype(**probe_prototype_model_dict) + + # Verify the model instances are equivalent + assert probe_prototype_model == probe_prototype_model2 + + # Convert model instance back to dict and verify no loss of data + probe_prototype_model_json2 = probe_prototype_model.to_dict() + assert probe_prototype_model_json2 == probe_prototype_model_json + + class TestModel_Project: """ Test Class for Project @@ -5884,6 +11030,162 @@ def test_project_list_serialization(self): assert project_list_model_json2 == project_list_model_json +class TestModel_ProjectStatusDetails: + """ + Test Class for ProjectStatusDetails + """ + + def test_project_status_details_serialization(self): + """ + Test serialization/deserialization for ProjectStatusDetails + """ + + # Construct a json representation of a ProjectStatusDetails model + project_status_details_model_json = {} + project_status_details_model_json['domain'] = 'unknown' + project_status_details_model_json['project'] = 'enabled' + project_status_details_model_json['vpe_not_enabled'] = True + + # Construct a model instance of ProjectStatusDetails by calling from_dict on the json representation + project_status_details_model = ProjectStatusDetails.from_dict(project_status_details_model_json) + assert project_status_details_model != False + + # Construct a model instance of ProjectStatusDetails by calling from_dict on the json representation + project_status_details_model_dict = ProjectStatusDetails.from_dict(project_status_details_model_json).__dict__ + project_status_details_model2 = ProjectStatusDetails(**project_status_details_model_dict) + + # Verify the model instances are equivalent + assert project_status_details_model == project_status_details_model2 + + # Convert model instance back to dict and verify no loss of data + project_status_details_model_json2 = project_status_details_model.to_dict() + assert project_status_details_model_json2 == project_status_details_model_json + + +class TestModel_ResourceKeyRef: + """ + Test Class for ResourceKeyRef + """ + + def test_resource_key_ref_serialization(self): + """ + Test serialization/deserialization for ResourceKeyRef + """ + + # Construct a json representation of a ResourceKeyRef model + resource_key_ref_model_json = {} + resource_key_ref_model_json['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + resource_key_ref_model_json['name'] = 'testString' + + # Construct a model instance of ResourceKeyRef by calling from_dict on the json representation + resource_key_ref_model = ResourceKeyRef.from_dict(resource_key_ref_model_json) + assert resource_key_ref_model != False + + # Construct a model instance of ResourceKeyRef by calling from_dict on the json representation + resource_key_ref_model_dict = ResourceKeyRef.from_dict(resource_key_ref_model_json).__dict__ + resource_key_ref_model2 = ResourceKeyRef(**resource_key_ref_model_dict) + + # Verify the model instances are equivalent + assert resource_key_ref_model == resource_key_ref_model2 + + # Convert model instance back to dict and verify no loss of data + resource_key_ref_model_json2 = resource_key_ref_model.to_dict() + assert resource_key_ref_model_json2 == resource_key_ref_model_json + + +class TestModel_ResourceKeyRefPrototype: + """ + Test Class for ResourceKeyRefPrototype + """ + + def test_resource_key_ref_prototype_serialization(self): + """ + Test serialization/deserialization for ResourceKeyRefPrototype + """ + + # Construct a json representation of a ResourceKeyRefPrototype model + resource_key_ref_prototype_model_json = {} + resource_key_ref_prototype_model_json['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + # Construct a model instance of ResourceKeyRefPrototype by calling from_dict on the json representation + resource_key_ref_prototype_model = ResourceKeyRefPrototype.from_dict(resource_key_ref_prototype_model_json) + assert resource_key_ref_prototype_model != False + + # Construct a model instance of ResourceKeyRefPrototype by calling from_dict on the json representation + resource_key_ref_prototype_model_dict = ResourceKeyRefPrototype.from_dict( + resource_key_ref_prototype_model_json + ).__dict__ + resource_key_ref_prototype_model2 = ResourceKeyRefPrototype(**resource_key_ref_prototype_model_dict) + + # Verify the model instances are equivalent + assert resource_key_ref_prototype_model == resource_key_ref_prototype_model2 + + # Convert model instance back to dict and verify no loss of data + resource_key_ref_prototype_model_json2 = resource_key_ref_prototype_model.to_dict() + assert resource_key_ref_prototype_model_json2 == resource_key_ref_prototype_model_json + + +class TestModel_RoleRef: + """ + Test Class for RoleRef + """ + + def test_role_ref_serialization(self): + """ + Test serialization/deserialization for RoleRef + """ + + # Construct a json representation of a RoleRef model + role_ref_model_json = {} + role_ref_model_json['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + role_ref_model_json['name'] = 'Manager' + + # Construct a model instance of RoleRef by calling from_dict on the json representation + role_ref_model = RoleRef.from_dict(role_ref_model_json) + assert role_ref_model != False + + # Construct a model instance of RoleRef by calling from_dict on the json representation + role_ref_model_dict = RoleRef.from_dict(role_ref_model_json).__dict__ + role_ref_model2 = RoleRef(**role_ref_model_dict) + + # Verify the model instances are equivalent + assert role_ref_model == role_ref_model2 + + # Convert model instance back to dict and verify no loss of data + role_ref_model_json2 = role_ref_model.to_dict() + assert role_ref_model_json2 == role_ref_model_json + + +class TestModel_RoleRefPrototype: + """ + Test Class for RoleRefPrototype + """ + + def test_role_ref_prototype_serialization(self): + """ + Test serialization/deserialization for RoleRefPrototype + """ + + # Construct a json representation of a RoleRefPrototype model + role_ref_prototype_model_json = {} + role_ref_prototype_model_json['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + + # Construct a model instance of RoleRefPrototype by calling from_dict on the json representation + role_ref_prototype_model = RoleRefPrototype.from_dict(role_ref_prototype_model_json) + assert role_ref_prototype_model != False + + # Construct a model instance of RoleRefPrototype by calling from_dict on the json representation + role_ref_prototype_model_dict = RoleRefPrototype.from_dict(role_ref_prototype_model_json).__dict__ + role_ref_prototype_model2 = RoleRefPrototype(**role_ref_prototype_model_dict) + + # Verify the model instances are equivalent + assert role_ref_prototype_model == role_ref_prototype_model2 + + # Convert model instance back to dict and verify no loss of data + role_ref_prototype_model_json2 = role_ref_prototype_model.to_dict() + assert role_ref_prototype_model_json2 == role_ref_prototype_model_json + + class TestModel_Secret: """ Test Class for Secret @@ -5894,12 +11196,44 @@ def test_secret_serialization(self): Test serialization/deserialization for Secret """ + # Construct dict forms of any model objects needed in order to build this model. + + resource_key_ref_model = {} # ResourceKeyRef + resource_key_ref_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + resource_key_ref_model['name'] = 'testString' + + role_ref_model = {} # RoleRef + role_ref_model['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + role_ref_model['name'] = 'Manager' + + service_instance_ref_model = {} # ServiceInstanceRef + service_instance_ref_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + service_instance_ref_model['type'] = 'testString' + + service_id_ref_model = {} # ServiceIDRef + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + service_access_secret_props_model = {} # ServiceAccessSecretProps + service_access_secret_props_model['resource_key'] = resource_key_ref_model + service_access_secret_props_model['role'] = role_ref_model + service_access_secret_props_model['service_instance'] = service_instance_ref_model + service_access_secret_props_model['serviceid'] = service_id_ref_model + + operator_secret_props_model = {} # OperatorSecretProps + operator_secret_props_model['apikey_id'] = 'ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b' + operator_secret_props_model['resource_group_ids'] = ['testString'] + operator_secret_props_model['serviceid'] = service_id_ref_model + operator_secret_props_model['user_managed'] = True + # Construct a json representation of a Secret model secret_model_json = {} secret_model_json['data'] = {'key1': 'testString'} secret_model_json['entity_tag'] = '2385407409' secret_model_json['format'] = 'generic' secret_model_json['name'] = 'my-secret' + secret_model_json['service_access'] = service_access_secret_props_model + secret_model_json['service_operator'] = operator_secret_props_model # Construct a model instance of Secret by calling from_dict on the json representation secret_model = Secret.from_dict(secret_model_json) @@ -5936,11 +11270,41 @@ def test_secret_list_serialization(self): list_next_metadata_model['href'] = 'testString' list_next_metadata_model['start'] = 'testString' + resource_key_ref_model = {} # ResourceKeyRef + resource_key_ref_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + resource_key_ref_model['name'] = 'testString' + + role_ref_model = {} # RoleRef + role_ref_model['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + role_ref_model['name'] = 'Manager' + + service_instance_ref_model = {} # ServiceInstanceRef + service_instance_ref_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + service_instance_ref_model['type'] = 'testString' + + service_id_ref_model = {} # ServiceIDRef + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + service_access_secret_props_model = {} # ServiceAccessSecretProps + service_access_secret_props_model['resource_key'] = resource_key_ref_model + service_access_secret_props_model['role'] = role_ref_model + service_access_secret_props_model['service_instance'] = service_instance_ref_model + service_access_secret_props_model['serviceid'] = service_id_ref_model + + operator_secret_props_model = {} # OperatorSecretProps + operator_secret_props_model['apikey_id'] = 'ApiKey-17041d26-55e4-40a8-8ab5-5a69b68e204b' + operator_secret_props_model['resource_group_ids'] = ['testString'] + operator_secret_props_model['serviceid'] = service_id_ref_model + operator_secret_props_model['user_managed'] = True + secret_model = {} # Secret secret_model['data'] = {'key1': 'testString'} secret_model['entity_tag'] = '2386255530' secret_model['format'] = 'generic' secret_model['name'] = 'my-secret' + secret_model['service_access'] = service_access_secret_props_model + secret_model['service_operator'] = operator_secret_props_model # Construct a json representation of a SecretList model secret_list_model_json = {} @@ -5965,6 +11329,241 @@ def test_secret_list_serialization(self): assert secret_list_model_json2 == secret_list_model_json +class TestModel_ServiceAccessSecretProps: + """ + Test Class for ServiceAccessSecretProps + """ + + def test_service_access_secret_props_serialization(self): + """ + Test serialization/deserialization for ServiceAccessSecretProps + """ + + # Construct dict forms of any model objects needed in order to build this model. + + resource_key_ref_model = {} # ResourceKeyRef + resource_key_ref_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + resource_key_ref_model['name'] = 'testString' + + role_ref_model = {} # RoleRef + role_ref_model['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + role_ref_model['name'] = 'Manager' + + service_instance_ref_model = {} # ServiceInstanceRef + service_instance_ref_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + service_instance_ref_model['type'] = 'testString' + + service_id_ref_model = {} # ServiceIDRef + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a json representation of a ServiceAccessSecretProps model + service_access_secret_props_model_json = {} + service_access_secret_props_model_json['resource_key'] = resource_key_ref_model + service_access_secret_props_model_json['role'] = role_ref_model + service_access_secret_props_model_json['service_instance'] = service_instance_ref_model + service_access_secret_props_model_json['serviceid'] = service_id_ref_model + + # Construct a model instance of ServiceAccessSecretProps by calling from_dict on the json representation + service_access_secret_props_model = ServiceAccessSecretProps.from_dict(service_access_secret_props_model_json) + assert service_access_secret_props_model != False + + # Construct a model instance of ServiceAccessSecretProps by calling from_dict on the json representation + service_access_secret_props_model_dict = ServiceAccessSecretProps.from_dict( + service_access_secret_props_model_json + ).__dict__ + service_access_secret_props_model2 = ServiceAccessSecretProps(**service_access_secret_props_model_dict) + + # Verify the model instances are equivalent + assert service_access_secret_props_model == service_access_secret_props_model2 + + # Convert model instance back to dict and verify no loss of data + service_access_secret_props_model_json2 = service_access_secret_props_model.to_dict() + assert service_access_secret_props_model_json2 == service_access_secret_props_model_json + + +class TestModel_ServiceAccessSecretPrototypeProps: + """ + Test Class for ServiceAccessSecretPrototypeProps + """ + + def test_service_access_secret_prototype_props_serialization(self): + """ + Test serialization/deserialization for ServiceAccessSecretPrototypeProps + """ + + # Construct dict forms of any model objects needed in order to build this model. + + resource_key_ref_prototype_model = {} # ResourceKeyRefPrototype + resource_key_ref_prototype_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + role_ref_prototype_model = {} # RoleRefPrototype + role_ref_prototype_model['crn'] = 'crn:v1:bluemix:public:iam::::serviceRole:Writer' + + service_instance_ref_prototype_model = {} # ServiceInstanceRefPrototype + service_instance_ref_prototype_model['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + service_id_ref_model = {} # ServiceIDRef + service_id_ref_model['crn'] = 'testString' + service_id_ref_model['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a json representation of a ServiceAccessSecretPrototypeProps model + service_access_secret_prototype_props_model_json = {} + service_access_secret_prototype_props_model_json['resource_key'] = resource_key_ref_prototype_model + service_access_secret_prototype_props_model_json['role'] = role_ref_prototype_model + service_access_secret_prototype_props_model_json['service_instance'] = service_instance_ref_prototype_model + service_access_secret_prototype_props_model_json['serviceid'] = service_id_ref_model + + # Construct a model instance of ServiceAccessSecretPrototypeProps by calling from_dict on the json representation + service_access_secret_prototype_props_model = ServiceAccessSecretPrototypeProps.from_dict( + service_access_secret_prototype_props_model_json + ) + assert service_access_secret_prototype_props_model != False + + # Construct a model instance of ServiceAccessSecretPrototypeProps by calling from_dict on the json representation + service_access_secret_prototype_props_model_dict = ServiceAccessSecretPrototypeProps.from_dict( + service_access_secret_prototype_props_model_json + ).__dict__ + service_access_secret_prototype_props_model2 = ServiceAccessSecretPrototypeProps( + **service_access_secret_prototype_props_model_dict + ) + + # Verify the model instances are equivalent + assert service_access_secret_prototype_props_model == service_access_secret_prototype_props_model2 + + # Convert model instance back to dict and verify no loss of data + service_access_secret_prototype_props_model_json2 = service_access_secret_prototype_props_model.to_dict() + assert service_access_secret_prototype_props_model_json2 == service_access_secret_prototype_props_model_json + + +class TestModel_ServiceIDRef: + """ + Test Class for ServiceIDRef + """ + + def test_service_id_ref_serialization(self): + """ + Test serialization/deserialization for ServiceIDRef + """ + + # Construct a json representation of a ServiceIDRef model + service_id_ref_model_json = {} + service_id_ref_model_json['crn'] = 'testString' + service_id_ref_model_json['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a model instance of ServiceIDRef by calling from_dict on the json representation + service_id_ref_model = ServiceIDRef.from_dict(service_id_ref_model_json) + assert service_id_ref_model != False + + # Construct a model instance of ServiceIDRef by calling from_dict on the json representation + service_id_ref_model_dict = ServiceIDRef.from_dict(service_id_ref_model_json).__dict__ + service_id_ref_model2 = ServiceIDRef(**service_id_ref_model_dict) + + # Verify the model instances are equivalent + assert service_id_ref_model == service_id_ref_model2 + + # Convert model instance back to dict and verify no loss of data + service_id_ref_model_json2 = service_id_ref_model.to_dict() + assert service_id_ref_model_json2 == service_id_ref_model_json + + +class TestModel_ServiceIDRefPrototype: + """ + Test Class for ServiceIDRefPrototype + """ + + def test_service_id_ref_prototype_serialization(self): + """ + Test serialization/deserialization for ServiceIDRefPrototype + """ + + # Construct a json representation of a ServiceIDRefPrototype model + service_id_ref_prototype_model_json = {} + service_id_ref_prototype_model_json['id'] = 'ServiceId-8fa4bc74-6441-4e5b-af3a-2b1af325a637' + + # Construct a model instance of ServiceIDRefPrototype by calling from_dict on the json representation + service_id_ref_prototype_model = ServiceIDRefPrototype.from_dict(service_id_ref_prototype_model_json) + assert service_id_ref_prototype_model != False + + # Construct a model instance of ServiceIDRefPrototype by calling from_dict on the json representation + service_id_ref_prototype_model_dict = ServiceIDRefPrototype.from_dict( + service_id_ref_prototype_model_json + ).__dict__ + service_id_ref_prototype_model2 = ServiceIDRefPrototype(**service_id_ref_prototype_model_dict) + + # Verify the model instances are equivalent + assert service_id_ref_prototype_model == service_id_ref_prototype_model2 + + # Convert model instance back to dict and verify no loss of data + service_id_ref_prototype_model_json2 = service_id_ref_prototype_model.to_dict() + assert service_id_ref_prototype_model_json2 == service_id_ref_prototype_model_json + + +class TestModel_ServiceInstanceRef: + """ + Test Class for ServiceInstanceRef + """ + + def test_service_instance_ref_serialization(self): + """ + Test serialization/deserialization for ServiceInstanceRef + """ + + # Construct a json representation of a ServiceInstanceRef model + service_instance_ref_model_json = {} + service_instance_ref_model_json['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + service_instance_ref_model_json['type'] = 'testString' + + # Construct a model instance of ServiceInstanceRef by calling from_dict on the json representation + service_instance_ref_model = ServiceInstanceRef.from_dict(service_instance_ref_model_json) + assert service_instance_ref_model != False + + # Construct a model instance of ServiceInstanceRef by calling from_dict on the json representation + service_instance_ref_model_dict = ServiceInstanceRef.from_dict(service_instance_ref_model_json).__dict__ + service_instance_ref_model2 = ServiceInstanceRef(**service_instance_ref_model_dict) + + # Verify the model instances are equivalent + assert service_instance_ref_model == service_instance_ref_model2 + + # Convert model instance back to dict and verify no loss of data + service_instance_ref_model_json2 = service_instance_ref_model.to_dict() + assert service_instance_ref_model_json2 == service_instance_ref_model_json + + +class TestModel_ServiceInstanceRefPrototype: + """ + Test Class for ServiceInstanceRefPrototype + """ + + def test_service_instance_ref_prototype_serialization(self): + """ + Test serialization/deserialization for ServiceInstanceRefPrototype + """ + + # Construct a json representation of a ServiceInstanceRefPrototype model + service_instance_ref_prototype_model_json = {} + service_instance_ref_prototype_model_json['id'] = '4e49b3e0-27a8-48d2-a784-c7ee48bb863b' + + # Construct a model instance of ServiceInstanceRefPrototype by calling from_dict on the json representation + service_instance_ref_prototype_model = ServiceInstanceRefPrototype.from_dict( + service_instance_ref_prototype_model_json + ) + assert service_instance_ref_prototype_model != False + + # Construct a model instance of ServiceInstanceRefPrototype by calling from_dict on the json representation + service_instance_ref_prototype_model_dict = ServiceInstanceRefPrototype.from_dict( + service_instance_ref_prototype_model_json + ).__dict__ + service_instance_ref_prototype_model2 = ServiceInstanceRefPrototype(**service_instance_ref_prototype_model_dict) + + # Verify the model instances are equivalent + assert service_instance_ref_prototype_model == service_instance_ref_prototype_model2 + + # Convert model instance back to dict and verify no loss of data + service_instance_ref_prototype_model_json2 = service_instance_ref_prototype_model.to_dict() + assert service_instance_ref_prototype_model_json2 == service_instance_ref_prototype_model_json + + class TestModel_VolumeMount: """ Test Class for VolumeMount @@ -6076,7 +11675,7 @@ def test_secret_data_basic_auth_secret_data_serialization(self): expected_dict = {'foo': 'testString'} secret_data_basic_auth_secret_data_model.set_properties(expected_dict) actual_dict = secret_data_basic_auth_secret_data_model.get_properties() - assert actual_dict == expected_dict + assert actual_dict.keys() == expected_dict.keys() class TestModel_SecretDataGenericSecretData: @@ -6122,7 +11721,7 @@ def test_secret_data_generic_secret_data_serialization(self): expected_dict = {'foo': 'testString'} secret_data_generic_secret_data_model.set_properties(expected_dict) actual_dict = secret_data_generic_secret_data_model.get_properties() - assert actual_dict == expected_dict + assert actual_dict.keys() == expected_dict.keys() class TestModel_SecretDataRegistrySecretData: @@ -6172,7 +11771,7 @@ def test_secret_data_registry_secret_data_serialization(self): expected_dict = {'foo': 'testString'} secret_data_registry_secret_data_model.set_properties(expected_dict) actual_dict = secret_data_registry_secret_data_model.get_properties() - assert actual_dict == expected_dict + assert actual_dict.keys() == expected_dict.keys() class TestModel_SecretDataSSHSecretData: @@ -6216,7 +11815,7 @@ def test_secret_data_ssh_secret_data_serialization(self): expected_dict = {'foo': 'testString'} secret_data_ssh_secret_data_model.set_properties(expected_dict) actual_dict = secret_data_ssh_secret_data_model.get_properties() - assert actual_dict == expected_dict + assert actual_dict.keys() == expected_dict.keys() class TestModel_SecretDataTLSSecretData: @@ -6260,7 +11859,7 @@ def test_secret_data_tls_secret_data_serialization(self): expected_dict = {'foo': 'testString'} secret_data_tls_secret_data_model.set_properties(expected_dict) actual_dict = secret_data_tls_secret_data_model.get_properties() - assert actual_dict == expected_dict + assert actual_dict.keys() == expected_dict.keys() # endregion