-
Notifications
You must be signed in to change notification settings - Fork 42
feat(Partner Usage Reports): add new service to project #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
044fae1
feat(Partner Resource Usage Reports): add resource usage reports to p…
manukm-ibm 639458d
feat(Partner Resource Usage Reports): add resource usage reports IT &…
manukm-ibm a6b8daa
feat(Partner Usage Reports): Update unit test
manukm-ibm 13a1324
Merge branch 'main' into partner-resource-usage-reports
manukm-ibm 7f54da6
feat(Partner Usage Reports): Lint fixes
manukm-ibm 129ea5d
feat(Partner Usage Reports): Lint fixes
manukm-ibm 2a054fe
feat(Partner Usage Reports): Update code with latest version
manukm-ibm ce35bf9
Merge branch 'main' into partner-resource-usage-reports
padamstx 4a16070
Merge branch 'main' into partner-resource-usage-reports
manukm-ibm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,124 @@ | ||
# -*- coding: utf-8 -*- | ||
# (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. | ||
# 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. | ||
|
||
""" | ||
Examples for PartnerUsageReportsV1 | ||
""" | ||
|
||
from ibm_cloud_sdk_core import ApiException, read_external_sources | ||
import os | ||
import pytest | ||
from ibm_platform_services.partner_usage_reports_v1 import * | ||
|
||
# | ||
# This file provides an example of how to use the Partner Usage Reports service. | ||
# | ||
# The following configuration properties are assumed to be defined: | ||
# PARTNER_USAGE_REPORTS_URL=<service base url> | ||
# PARTNER_USAGE_REPORTS_AUTH_TYPE=iam | ||
# PARTNER_USAGE_REPORTS_APIKEY=<IAM apikey> | ||
# PARTNER_USAGE_REPORTS_AUTH_URL=<IAM token service base URL - omit this if using the production environment> | ||
# PARTNER_USAGE_REPORTS_PARTNER_ID=<Enterprise ID of the distributor or reseller for which the report is requested> | ||
# PARTNER_USAGE_REPORTS_CUSTOMER_ID=<Enterprise ID of the child customer for which the report is requested> | ||
# PARTNER_USAGE_REPORTS_RESELLER_ID=<Enterprise ID of the reseller for which the report is requested> | ||
# PARTNER_USAGE_REPORTS_BILLING_MONTH=<The billing month for which the usage report is requested. Format is `yyyy-mm`> | ||
# PARTNER_USAGE_REPORTS_VIEWPOINT=<Enables partner to view the cost of provisioned services as applicable at each level of the hierarchy> | ||
# | ||
# These configuration properties can be exported as environment variables, or stored | ||
# in a configuration file and then: | ||
# export IBM_CREDENTIALS_FILE=<name of configuration file> | ||
# | ||
config_file = 'partner_usage_reports_v1.env' | ||
|
||
partner_usage_reports_service = None | ||
|
||
config = None | ||
partner_id = None | ||
billing_month = None | ||
|
||
|
||
############################################################################## | ||
# Start of Examples for Service: PartnerUsageReportsV1 | ||
############################################################################## | ||
# region | ||
class TestPartnerUsageReportsV1Examples: | ||
""" | ||
Example Test Class for PartnerUsageReportsV1 | ||
""" | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
global partner_usage_reports_service | ||
if os.path.exists(config_file): | ||
os.environ['IBM_CREDENTIALS_FILE'] = config_file | ||
|
||
# begin-common | ||
|
||
partner_usage_reports_service = PartnerUsageReportsV1.new_instance() | ||
|
||
# end-common | ||
assert partner_usage_reports_service is not None | ||
|
||
# Load the configuration | ||
global config | ||
config = read_external_sources(PartnerUsageReportsV1.DEFAULT_SERVICE_NAME) | ||
|
||
global partner_id | ||
partner_id = config.get("PARTNER_ID") | ||
|
||
global billing_month | ||
billing_month = config.get("BILLING_MONTH") | ||
|
||
assert partner_id is not None | ||
assert billing_month is not None | ||
|
||
print('Setup complete.') | ||
|
||
needscredentials = pytest.mark.skipif( | ||
not os.path.exists(config_file), reason="External configuration not available, skipping..." | ||
) | ||
|
||
@needscredentials | ||
def test_get_resource_usage_report_example(self): | ||
""" | ||
get_resource_usage_report request example | ||
""" | ||
try: | ||
print('\nget_resource_usage_report() result:') | ||
# begin-get_resource_usage_report | ||
|
||
all_results = [] | ||
pager = GetResourceUsageReportPager( | ||
client=partner_usage_reports_service, | ||
partner_id=partner_id, | ||
month=billing_month, | ||
limit=10, | ||
) | ||
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-get_resource_usage_report | ||
except ApiException as e: | ||
pytest.fail(str(e)) | ||
|
||
|
||
# endregion | ||
############################################################################## | ||
# End of Examples for Service: PartnerUsageReportsV1 | ||
############################################################################## |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.