Skip to content

Commit

Permalink
fix(Global Tagging): update service after recent API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx committed Jan 19, 2021
1 parent 3fe93b6 commit 1dbbf61
Show file tree
Hide file tree
Showing 4 changed files with 811 additions and 105 deletions.
59 changes: 39 additions & 20 deletions examples/test_global_tagging_v1_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# 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.

"""
Examples for GlobalTaggingV1
"""
Expand Down Expand Up @@ -48,7 +47,6 @@ class TestGlobalTaggingV1Examples():
"""
Example Test Class for GlobalTaggingV1
"""

@classmethod
def setup_class(cls):
global global_tagging_service
Expand All @@ -73,8 +71,27 @@ def setup_class(cls):
print('Setup complete.')

needscredentials = pytest.mark.skipif(
not os.path.exists(config_file), reason="External configuration not available, skipping..."
)
not os.path.exists(config_file),
reason="External configuration not available, skipping...")

@needscredentials
def test_create_tag_example(self):
"""
create_tag request example
"""
try:
# begin-create_tag

create_tag_results = global_tagging_service.create_tag(
tag_names=['env:example-access-tag'],
tag_type='access').get_result()

print(json.dumps(create_tag_results, indent=2))

# end-create_tag

except ApiException as e:
pytest.fail(str(e))

@needscredentials
def test_list_tags_example(self):
Expand All @@ -85,7 +102,11 @@ def test_list_tags_example(self):
# begin-list_tags

tag_list = global_tagging_service.list_tags(
attached_only=True).get_result()
tag_type='user',
attached_only=True,
full_data=True,
providers=['ghost'],
order_by_name='asc').get_result()

print(json.dumps(tag_list, indent=2))

Expand All @@ -102,14 +123,12 @@ def test_attach_tag_example(self):
try:
# begin-attach_tag

resource_model = {
'resource_id': resource_crn
}
resource_model = {'resource_id': resource_crn}

tag_results = global_tagging_service.attach_tag(
resources=[resource_model],
tag_names=['tag_test_1', 'tag_test_2']
).get_result()
tag_names=['tag_test_1', 'tag_test_2'],
tag_type='user').get_result()

print(json.dumps(tag_results, indent=2))

Expand All @@ -126,14 +145,12 @@ def test_detach_tag_example(self):
try:
# begin-detach_tag

resource_model = {
'resource_id': resource_crn
}
resource_model = {'resource_id': resource_crn}

tag_results = global_tagging_service.detach_tag(
resources=[resource_model],
tag_names=['tag_test_1', 'tag_test_2']
).get_result()
tag_names=['tag_test_1', 'tag_test_2'],
tag_type='user').get_result()

print(json.dumps(tag_results, indent=2))

Expand All @@ -142,7 +159,7 @@ def test_detach_tag_example(self):
except ApiException as e:
pytest.fail(str(e))

@ needscredentials
@needscredentials
def test_delete_tag_example(self):
"""
delete_tag request example
Expand All @@ -151,8 +168,8 @@ def test_delete_tag_example(self):
# begin-delete_tag

delete_tag_results = global_tagging_service.delete_tag(
tag_name='tag_test_1'
).get_result()
tag_name='env:example-access-tag',
tag_type='access').get_result()

print(json.dumps(delete_tag_results, indent=2))

Expand All @@ -161,15 +178,16 @@ def test_delete_tag_example(self):
except ApiException as e:
pytest.fail(str(e))

@ needscredentials
@needscredentials
def test_delete_tag_all_example(self):
"""
delete_tag_all request example
"""
try:
# begin-delete_tag_all

delete_tags_result = global_tagging_service.delete_tag_all().get_result()
delete_tags_result = global_tagging_service.delete_tag_all(
tag_type='user').get_result()

print(json.dumps(delete_tags_result, indent=2))

Expand All @@ -178,6 +196,7 @@ def test_delete_tag_all_example(self):
except ApiException as e:
pytest.fail(str(e))


# endregion
##############################################################################
# End of Examples for Service: GlobalTaggingV1
Expand Down
Loading

0 comments on commit 1dbbf61

Please sign in to comment.