-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query operations for public/target VPC endpoint services (#492)
Add query operations for public/target VPC endpoint services Add query operations for public VPC endpoint services and target VPC endpoint service Reviewed-by: Vineet Pruthi Reviewed-by: Anton Sidelnikov
- Loading branch information
Showing
10 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
"""Get Public VPC Endpoint Services.""" | ||
import openstack | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
|
||
public_services = list(conn.vpcep.public_services()) | ||
print(public_services) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
"""Get Target VPC Endpoint Service.""" | ||
import openstack | ||
|
||
openstack.enable_logging(True) | ||
conn = openstack.connect(cloud='otc') | ||
|
||
endpoint_service = 'endpoint-service' | ||
endpoint_service = conn.vpcep.get_target_service(endpoint_service) | ||
print(endpoint_service) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
from openstack import resource | ||
|
||
|
||
class PublicService(resource.Resource): | ||
base_path = '/vpc-endpoint-services/public' | ||
resources_key = 'endpoint_services' | ||
|
||
_query_mapping = resource.QueryParameters( | ||
'id', | ||
'limit', | ||
'name', | ||
'offset', | ||
'sort_key', | ||
'sort_dir', | ||
name='endpoint_service_name', | ||
) | ||
|
||
# capabilities | ||
allow_create = False | ||
allow_fetch = False | ||
allow_commit = False | ||
allow_delete = False | ||
allow_list = True | ||
|
||
# Properties | ||
#: ID of the VPC endpoint service. | ||
id = resource.Body('id') | ||
#: Owner of the VPC endpoint service. | ||
owner = resource.Body('owner') | ||
#: Name of the VPC endpoint service. | ||
service_name = resource.Body('service_name') | ||
#: Type of the VPC endpoint service. | ||
service_type = resource.Body('service_type') | ||
#: Creation time of the VPC endpoint service. | ||
created_at = resource.Body('created_at') | ||
#: If the usage of the VPC endpoint service will be charged. | ||
is_charge = resource.Body('is_charge') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
from openstack import resource | ||
|
||
|
||
class TargetService(resource.Resource): | ||
base_path = '/vpc-endpoint-services/describe' | ||
|
||
_query_mapping = resource.QueryParameters( | ||
'id', | ||
'name', | ||
name='endpoint_service_name', | ||
) | ||
|
||
# capabilities | ||
allow_create = False | ||
allow_fetch = True | ||
allow_commit = False | ||
allow_delete = False | ||
allow_list = True | ||
|
||
requires_id = False | ||
|
||
# Properties | ||
#: ID of the VPC endpoint service. | ||
id = resource.Body('id') | ||
#: Name of the VPC endpoint service. | ||
service_name = resource.Body('service_name') | ||
#: Type of the VPC endpoint service. | ||
service_type = resource.Body('service_type') | ||
#: Creation time of the VPC endpoint service. | ||
created_at = resource.Body('created_at') | ||
#: If the usage of the VPC endpoint service will be charged. | ||
is_charge = resource.Body('is_charge') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
otcextensions/tests/unit/sdk/vpcep/v1/test_public_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
from openstack.tests.unit import base | ||
from otcextensions.sdk.vpcep.v1 import public_service | ||
from otcextensions.tests.unit.sdk.utils import assert_attributes_equal | ||
|
||
|
||
EXAMPLE = { | ||
"id": "b0e22f6f-26f4-461c-b140-d873464d4fa0", | ||
"owner": "example", | ||
"service_name": "test123", | ||
"service_type": "interface", | ||
"created_at": "2018-09-10T13:13:23Z", | ||
"is_charge": "true" | ||
} | ||
|
||
|
||
class TestPublicService(base.TestCase): | ||
def test_basic(self): | ||
sot = public_service.PublicService() | ||
self.assertEqual('endpoint_services', sot.resources_key) | ||
self.assertEqual(None, sot.resource_key) | ||
self.assertEqual('/vpc-endpoint-services/public', sot.base_path) | ||
self.assertTrue(sot.allow_list) | ||
self.assertFalse(sot.allow_create) | ||
self.assertFalse(sot.allow_fetch) | ||
self.assertFalse(sot.allow_commit) | ||
self.assertFalse(sot.allow_delete) | ||
|
||
self.assertDictEqual( | ||
{ | ||
'id': 'id', | ||
'limit': 'limit', | ||
'marker': 'marker', | ||
'offset': 'offset', | ||
'name': 'endpoint_service_name', | ||
'sort_key': 'sort_key', | ||
'sort_dir': 'sort_dir', | ||
}, | ||
sot._query_mapping._mapping, | ||
) | ||
|
||
def test_make_it(self): | ||
sot = public_service.PublicService(**EXAMPLE) | ||
assert_attributes_equal(self, sot, EXAMPLE) |
52 changes: 52 additions & 0 deletions
52
otcextensions/tests/unit/sdk/vpcep/v1/test_target_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
from openstack.tests.unit import base | ||
from otcextensions.sdk.vpcep.v1 import target_service | ||
from otcextensions.tests.unit.sdk.utils import assert_attributes_equal | ||
|
||
|
||
EXAMPLE = { | ||
"id": "9d4c1028-1336-4556-9881-b5d807c1b8a8", | ||
"service_name": "test123", | ||
"service_type": "interface", | ||
"created_at": "2018-09-17T07:28:31Z", | ||
"is_charge": "true" | ||
} | ||
|
||
|
||
class TestTargetService(base.TestCase): | ||
|
||
def test_basic(self): | ||
sot = target_service.TargetService() | ||
self.assertEqual(None, sot.resources_key) | ||
self.assertEqual(None, sot.resource_key) | ||
self.assertEqual('/vpc-endpoint-services/describe', sot.base_path) | ||
self.assertTrue(sot.allow_list) | ||
self.assertTrue(sot.allow_fetch) | ||
self.assertFalse(sot.allow_create) | ||
self.assertFalse(sot.allow_commit) | ||
self.assertFalse(sot.allow_delete) | ||
|
||
self.assertDictEqual( | ||
{ | ||
'id': 'id', | ||
'limit': 'limit', | ||
'marker': 'marker', | ||
'name': 'endpoint_service_name', | ||
}, | ||
sot._query_mapping._mapping, | ||
) | ||
|
||
def test_make_it(self): | ||
sot = target_service.TargetService(**EXAMPLE) | ||
assert_attributes_equal(self, sot, EXAMPLE) |
4 changes: 4 additions & 0 deletions
4
releasenotes/notes/vpcep-target-endpoint-services-ddbab96f411fe1bc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
features: | ||
- | | ||
Add query operations for public VPC endpoint services and target VPC endpoint service. |