-
Notifications
You must be signed in to change notification settings - Fork 22
Create Product Consumption Tracking Module #689
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
Open
agzaiyenth
wants to merge
18
commits into
wso2-open-operations:main
Choose a base branch
from
agzaiyenth:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
828c37c
Created Product Consumption Tracking Module
agzaiyenth 1532794
updated request body
agzaiyenth e6390da
Update client.bal
agzaiyenth 7c6fd38
Update constants.bal
agzaiyenth 838f126
updated rest api endpoint
agzaiyenth 5725a50
Update apps/customer-portal/backend/modules/product_consumption_track…
agzaiyenth a7a4213
Update apps/customer-portal/backend/modules/product_consumption_track…
agzaiyenth 63dc846
Update apps/customer-portal/backend/modules/product_consumption_track…
agzaiyenth 4cf2f26
Update apps/customer-portal/backend/service.bal
agzaiyenth 29f12dc
Update apps/customer-portal/backend/modules/product_consumption_track…
agzaiyenth 78d3a59
Update apps/customer-portal/backend/service.bal
agzaiyenth ca7254c
Update apps/customer-portal/backend/modules/product_consumption_track…
agzaiyenth 4e7184c
Update product_consumption_tracking.bal
agzaiyenth da5ef75
Use ImportRequest payload for deployment import
agzaiyenth 1e669ce
Update apps/customer-portal/backend/service.bal
agzaiyenth 7b1438d
Use constants for HTTP retry config
agzaiyenth 759bab8
Update constants.bal
agzaiyenth 44b2701
Rename deployment-usage endpoint to deployment-usages
agzaiyenth 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
Some comments aren't visible on the classic Files Changed page.
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
42 changes: 42 additions & 0 deletions
42
apps/customer-portal/backend/modules/product_consumption_tracking/client.bal
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,42 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you 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. | ||
|
|
||
| import ballerina/http; | ||
|
|
||
| configurable string productConsumptionTrackingBaseUrl = ?; | ||
| configurable ClientCredentialsOauth2Config clientCredentialsOauth2Config = ?; | ||
|
|
||
| @display { | ||
| label: "Product Consumption Tracking", | ||
| id: "product-consumption-tracking" | ||
| } | ||
| final http:Client productConsumptionTrackingClient = check new (productConsumptionTrackingBaseUrl, { | ||
| auth: {...clientCredentialsOauth2Config}, | ||
| httpVersion: http:HTTP_1_1, | ||
| http1Settings: {keepAlive: http:KEEPALIVE_NEVER}, | ||
| timeout: 300.0, | ||
| retryConfig: { | ||
| count: RETRY_COUNT, | ||
| interval: RETRY_INTERVAL, | ||
| statusCodes: [ | ||
| http:STATUS_INTERNAL_SERVER_ERROR, | ||
| http:STATUS_REQUEST_TIMEOUT, | ||
| http:STATUS_BAD_GATEWAY, | ||
| http:STATUS_SERVICE_UNAVAILABLE, | ||
| http:STATUS_GATEWAY_TIMEOUT | ||
| ] | ||
| } | ||
|
agzaiyenth marked this conversation as resolved.
|
||
| }); | ||
19 changes: 19 additions & 0 deletions
19
apps/customer-portal/backend/modules/product_consumption_tracking/constants.bal
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,19 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you 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. | ||
|
|
||
| const CONTENT_TYPE_APPLICATION_ZIP = "application/zip"; | ||
| const RETRY_COUNT = 3; | ||
| const RETRY_INTERVAL = 2.0d; |
32 changes: 32 additions & 0 deletions
32
...omer-portal/backend/modules/product_consumption_tracking/product_consumption_tracking.bal
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,32 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you 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. | ||
|
|
||
| # Import deployment usage data from a zip file. | ||
| # | ||
| # + email - Email address of the importing user | ||
| # + zipFile - Zip file content as bytes | ||
| # + return - Deployment usage import response or error | ||
| public isolated function importDeploymentUsage(string email, byte[] zipFile) | ||
| returns DeploymentUsageImportResponse|error { | ||
|
|
||
| ImportRequest payload = { | ||
| email: email, | ||
| zip: zipFile.toBase64() | ||
| }; | ||
|
|
||
| return productConsumptionTrackingClient->/deployment\-usages.post(payload); | ||
|
|
||
|
agzaiyenth marked this conversation as resolved.
|
||
| } | ||
45 changes: 45 additions & 0 deletions
45
apps/customer-portal/backend/modules/product_consumption_tracking/types.bal
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,45 @@ | ||
| // Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). | ||
| // | ||
| // WSO2 LLC. licenses this file to you 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. | ||
|
|
||
| # [Configurable] Client credentials grant type oauth2 configuration. | ||
| public type ClientCredentialsOauth2Config record {| | ||
| # Token URL | ||
| string tokenUrl; | ||
| # Client ID | ||
| string clientId; | ||
| # Client Secret | ||
| string clientSecret; | ||
|
agzaiyenth marked this conversation as resolved.
|
||
| # Scopes | ||
| string[] scopes = []; | ||
| |}; | ||
|
|
||
| # Deployment usage import response. | ||
| public type DeploymentUsageImportResponse record {| | ||
| # Response message | ||
| string message?; | ||
| # Response result | ||
| json result?; | ||
|
agzaiyenth marked this conversation as resolved.
|
||
| json...; | ||
| |}; | ||
|
|
||
| # Import Request payload. | ||
| # | ||
| # + email - email address of the user performing the import operation | ||
| # + zip - zip file content as base64 string | ||
| public type ImportRequest record { | ||
|
agzaiyenth marked this conversation as resolved.
|
||
| string email; | ||
| string zip; | ||
| }; | ||
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
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.