Skip to content

Commit 465c164

Browse files
reggeenrGitHub Enterprise
authored andcommitted
sdk-update-20230324-173405 (#12)
* fix(generator): SDK update 20230324-173405 * fix(api): added integration tests for egress ips * fix(test): addressed linter violation
1 parent 3992431 commit 465c164

File tree

5 files changed

+229
-2
lines changed

5 files changed

+229
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ package-lock.json
8282
node_modules/
8383

8484
# ignore the generated integration test files, as they cannot be used without manual editing
85-
integration/test_code_engine_v2.py
85+
test/integration/test_code_engine_v2.py

examples/test_code_engine_v2_examples.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,27 @@ def test_get_project_example(self):
141141
except ApiException as e:
142142
pytest.fail(str(e))
143143

144+
@needscredentials
145+
def test_get_project_egress_ips_example(self):
146+
"""
147+
get_project_egress_ips request example
148+
"""
149+
try:
150+
print('\nget_project_egress_ips() result:')
151+
# begin-get_project_egress_ips
152+
153+
response = code_engine_service.get_project_egress_ips(
154+
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
155+
)
156+
project_egress_ip_addresses = response.get_result()
157+
158+
print(json.dumps(project_egress_ip_addresses, indent=2))
159+
160+
# end-get_project_egress_ips
161+
162+
except ApiException as e:
163+
pytest.fail(str(e))
164+
144165
@needscredentials
145166
def test_list_apps_example(self):
146167
"""

ibm_code_engine_sdk/code_engine_v2.py

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

17-
# IBM OpenAPI SDK Code Generator Version: 3.64.0-959a5845-20230112-195144
17+
# IBM OpenAPI SDK Code Generator Version: 3.66.0-d6c2d7e0-20230215-221247
1818

1919
"""
2020
REST API for Code Engine
@@ -232,6 +232,41 @@ def delete_project(self, id: str, **kwargs) -> DetailedResponse:
232232
response = self.send(request, **kwargs)
233233
return response
234234

235+
def get_project_egress_ips(self, project_id: str, **kwargs) -> DetailedResponse:
236+
"""
237+
List egress IP addresses.
238+
239+
Lists all egress IP addresses (public and private) that are used by components
240+
running in this project.
241+
242+
:param str project_id: The ID of the project.
243+
:param dict headers: A `dict` containing the request headers
244+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
245+
:rtype: DetailedResponse with `dict` result representing a `ProjectEgressIPAddresses` object
246+
"""
247+
248+
if not project_id:
249+
raise ValueError('project_id must be provided')
250+
headers = {}
251+
sdk_headers = get_sdk_headers(
252+
service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_project_egress_ips'
253+
)
254+
headers.update(sdk_headers)
255+
256+
if 'headers' in kwargs:
257+
headers.update(kwargs.get('headers'))
258+
del kwargs['headers']
259+
headers['Accept'] = 'application/json'
260+
261+
path_param_keys = ['project_id']
262+
path_param_values = self.encode_path_vars(project_id)
263+
path_param_dict = dict(zip(path_param_keys, path_param_values))
264+
url = '/projects/{project_id}/egress_ips'.format(**path_param_dict)
265+
request = self.prepare_request(method='GET', url=url, headers=headers)
266+
267+
response = self.send(request, **kwargs)
268+
return response
269+
235270
#########################
236271
# Applications
237272
#########################
@@ -7257,6 +7292,68 @@ class StatusEnum(str, Enum):
72577292
CREATION_FAILED = 'creation_failed'
72587293

72597294

7295+
class ProjectEgressIPAddresses:
7296+
"""
7297+
Describes the model of egress IP addresses.
7298+
7299+
:attr List[str] private: (optional) List of IBM private network IP addresses.
7300+
:attr List[str] public: (optional) List of public IP addresses.
7301+
"""
7302+
7303+
def __init__(self, *, private: List[str] = None, public: List[str] = None) -> None:
7304+
"""
7305+
Initialize a ProjectEgressIPAddresses object.
7306+
7307+
:param List[str] private: (optional) List of IBM private network IP
7308+
addresses.
7309+
:param List[str] public: (optional) List of public IP addresses.
7310+
"""
7311+
self.private = private
7312+
self.public = public
7313+
7314+
@classmethod
7315+
def from_dict(cls, _dict: Dict) -> 'ProjectEgressIPAddresses':
7316+
"""Initialize a ProjectEgressIPAddresses object from a json dictionary."""
7317+
args = {}
7318+
if 'private' in _dict:
7319+
args['private'] = _dict.get('private')
7320+
if 'public' in _dict:
7321+
args['public'] = _dict.get('public')
7322+
return cls(**args)
7323+
7324+
@classmethod
7325+
def _from_dict(cls, _dict):
7326+
"""Initialize a ProjectEgressIPAddresses object from a json dictionary."""
7327+
return cls.from_dict(_dict)
7328+
7329+
def to_dict(self) -> Dict:
7330+
"""Return a json dictionary representing this model."""
7331+
_dict = {}
7332+
if hasattr(self, 'private') and self.private is not None:
7333+
_dict['private'] = self.private
7334+
if hasattr(self, 'public') and self.public is not None:
7335+
_dict['public'] = self.public
7336+
return _dict
7337+
7338+
def _to_dict(self):
7339+
"""Return a json dictionary representing this model."""
7340+
return self.to_dict()
7341+
7342+
def __str__(self) -> str:
7343+
"""Return a `str` version of this ProjectEgressIPAddresses object."""
7344+
return json.dumps(self.to_dict(), indent=2)
7345+
7346+
def __eq__(self, other: 'ProjectEgressIPAddresses') -> bool:
7347+
"""Return `true` when self and other are equal, false otherwise."""
7348+
if not isinstance(other, self.__class__):
7349+
return False
7350+
return self.__dict__ == other.__dict__
7351+
7352+
def __ne__(self, other: 'ProjectEgressIPAddresses') -> bool:
7353+
"""Return `true` when self and other are not equal, false otherwise."""
7354+
return not self == other
7355+
7356+
72607357
class ProjectList:
72617358
"""
72627359
Contains a list of projects and pagination information.

test/integration/test_v2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ def test_get_project(self):
132132

133133
assert obtained_project['status'] == 'active'
134134

135+
@needscredentials
136+
def test_get_project_egress_ips(self):
137+
response = self.code_engine_service.get_project_egress_ips(
138+
project_id=pytest.e2e_test_project_id,
139+
)
140+
141+
assert response.get_status_code() == 200
142+
project_egress_ip_addresses = response.get_result()
143+
assert project_egress_ip_addresses is not None
144+
135145
@needscredentials
136146
def test_list_apps(self):
137147
response = self.code_engine_service.list_apps(

test/unit/test_code_engine_v2.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,72 @@ def test_delete_project_value_error_with_retries(self):
412412
self.test_delete_project_value_error()
413413

414414

415+
class TestGetProjectEgressIps:
416+
"""
417+
Test Class for get_project_egress_ips
418+
"""
419+
420+
@responses.activate
421+
def test_get_project_egress_ips_all_params(self):
422+
"""
423+
get_project_egress_ips()
424+
"""
425+
# Set up mock
426+
url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/egress_ips')
427+
mock_response = '{"private": ["private"], "public": ["public"]}'
428+
responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200)
429+
430+
# Set up parameter values
431+
project_id = '15314cc3-85b4-4338-903f-c28cdee6d005'
432+
433+
# Invoke method
434+
response = _service.get_project_egress_ips(project_id, headers={})
435+
436+
# Check for correct operation
437+
assert len(responses.calls) == 1
438+
assert response.status_code == 200
439+
440+
def test_get_project_egress_ips_all_params_with_retries(self):
441+
# Enable retries and run test_get_project_egress_ips_all_params.
442+
_service.enable_retries()
443+
self.test_get_project_egress_ips_all_params()
444+
445+
# Disable retries and run test_get_project_egress_ips_all_params.
446+
_service.disable_retries()
447+
self.test_get_project_egress_ips_all_params()
448+
449+
@responses.activate
450+
def test_get_project_egress_ips_value_error(self):
451+
"""
452+
test_get_project_egress_ips_value_error()
453+
"""
454+
# Set up mock
455+
url = preprocess_url('/projects/15314cc3-85b4-4338-903f-c28cdee6d005/egress_ips')
456+
mock_response = '{"private": ["private"], "public": ["public"]}'
457+
responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200)
458+
459+
# Set up parameter values
460+
project_id = '15314cc3-85b4-4338-903f-c28cdee6d005'
461+
462+
# Pass in all but one required param and check for a ValueError
463+
req_param_dict = {
464+
"project_id": project_id,
465+
}
466+
for param in req_param_dict.keys():
467+
req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()}
468+
with pytest.raises(ValueError):
469+
_service.get_project_egress_ips(**req_copy)
470+
471+
def test_get_project_egress_ips_value_error_with_retries(self):
472+
# Enable retries and run test_get_project_egress_ips_value_error.
473+
_service.enable_retries()
474+
self.test_get_project_egress_ips_value_error()
475+
476+
# Disable retries and run test_get_project_egress_ips_value_error.
477+
_service.disable_retries()
478+
self.test_get_project_egress_ips_value_error()
479+
480+
415481
# endregion
416482
##############################################################################
417483
# End of Service: Projects
@@ -5739,6 +5805,39 @@ def test_project_serialization(self):
57395805
assert project_model_json2 == project_model_json
57405806

57415807

5808+
class TestModel_ProjectEgressIPAddresses:
5809+
"""
5810+
Test Class for ProjectEgressIPAddresses
5811+
"""
5812+
5813+
def test_project_egress_ip_addresses_serialization(self):
5814+
"""
5815+
Test serialization/deserialization for ProjectEgressIPAddresses
5816+
"""
5817+
5818+
# Construct a json representation of a ProjectEgressIPAddresses model
5819+
project_egress_ip_addresses_model_json = {}
5820+
project_egress_ip_addresses_model_json['private'] = ['testString']
5821+
project_egress_ip_addresses_model_json['public'] = ['testString']
5822+
5823+
# Construct a model instance of ProjectEgressIPAddresses by calling from_dict on the json representation
5824+
project_egress_ip_addresses_model = ProjectEgressIPAddresses.from_dict(project_egress_ip_addresses_model_json)
5825+
assert project_egress_ip_addresses_model != False
5826+
5827+
# Construct a model instance of ProjectEgressIPAddresses by calling from_dict on the json representation
5828+
project_egress_ip_addresses_model_dict = ProjectEgressIPAddresses.from_dict(
5829+
project_egress_ip_addresses_model_json
5830+
).__dict__
5831+
project_egress_ip_addresses_model2 = ProjectEgressIPAddresses(**project_egress_ip_addresses_model_dict)
5832+
5833+
# Verify the model instances are equivalent
5834+
assert project_egress_ip_addresses_model == project_egress_ip_addresses_model2
5835+
5836+
# Convert model instance back to dict and verify no loss of data
5837+
project_egress_ip_addresses_model_json2 = project_egress_ip_addresses_model.to_dict()
5838+
assert project_egress_ip_addresses_model_json2 == project_egress_ip_addresses_model_json
5839+
5840+
57425841
class TestModel_ProjectList:
57435842
"""
57445843
Test Class for ProjectList

0 commit comments

Comments
 (0)