Skip to content
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

Add REST API Implementation for fetching Key Manager usages and delete Keys #12345

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

SavinduDimal
Copy link
Contributor

Purpose

Description

GET key-managers/{key-manager-id}/api-usages

  • Sample cURL :
curl 'https://localhost:9443/api/am/admin/v4/key-managers/096c55a5-b447-4c2e-9e9e-7eeae8d9db56/api-usages?offset=0&limit=10' \
  -H 'accept: application/json' \
  -H 'authorization: Bearer 4999ed52-e2bd-3317' \
  • Sample response:
{
    "apiCount": 2,
    "apis": [
        {
            "id": "f66aaff3-4a37-467e-a153-fe0a10cf61d3",
            "type": "API",
            "name": "api1",
            "transportType": "HTTP",
            "description": null,
            "context": "/api1/{version}",
            "version": "v1",
            "provider": "admin",
            "status": "PUBLISHED",
            "thumbnailUri": null,
            "advertiseOnly": false,
            "keyManagerEntry": "Resident Key Manager"
        },
        {
            "id": "574dcb8b-60d1-4576-8416-f7479306b408",
            "type": "API",
            "name": "PizzaShackAPI",
            "transportType": "HTTP",
            "description": "This is a simple API for Pizza Shack online pizza delivery store.",
            "context": "/pizzashack/{version}",
            "version": "1.0.0",
            "provider": "admin",
            "status": "PUBLISHED",
            "thumbnailUri": null,
            "advertiseOnly": false,
            "keyManagerEntry": "auth0Normal , Resident Key Manager"
        }
    ]
}

GET key-managers/{key-manager-id}/app-usages

  • Sample cURL :
curl 'https://localhost:9443/api/am/admin/v4/key-managers/096c55a5-b447-4c2e-9e9e-7eeae8d9db56/app-usages?offset=0&limit=10' \
  -H 'accept: application/json' \
  -H 'authorization: Bearer 4999ed52-e2bd-3317' \
  • Sample response:
{
    "applicationCount": 2,
    "applications": [
        {
            "name": "app3",
            "uuid": "08d4b95c-f715-47c4-8588-406d6857a677",
            "organizationId": null,
            "owner": "admin",
            "organization": "carbon.super"
        },
        {
            "name": "app7",
            "uuid": "36817dfa-3934-496f-be9b-632d6274fe26",
            "organizationId": null,
            "owner": "admin",
            "organization": "carbon.super"
        }
    ]
}

DELETE applications/{application-id}/oauth-keys/{keyMappingId}

  • Sample cURL :
curl 'https://localhost:9443/api/am/devportal/v3/applications/e6a3875a-1f3a-4d27-af49-401715a821bf/oauth-keys/64a25d15-661e-40d5-a11a-fa6991cea3e1' \
  -X 'DELETE' \
  -H 'Accept: */*' \
  -H 'X-WSO2-Tenant: carbon.super' \
  -H 'authorization: Bearer ef77a93e-ae56-3511' \

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 11.81619% with 403 lines in your changes are missing coverage. Please review.

Project coverage is 47.38%. Comparing base (1d952de) to head (3488aae).
Report is 17 commits behind head on master.

Files Patch % Lines
...gt/rest/api/admin/v1/dto/APIInfoKeyManagerDTO.java 0.00% 110 Missing ⚠️
...api/admin/v1/dto/ApplicationInfoKeyManagerDTO.java 0.00% 54 Missing ⚠️
...admin/v1/utils/mappings/KeyManagerMappingUtil.java 2.22% 44 Missing ⚠️
.../rest/api/admin/v1/dto/KeyManagerAPIUsagesDTO.java 0.00% 30 Missing ⚠️
.../rest/api/admin/v1/dto/KeyManagerAppUsagesDTO.java 0.00% 30 Missing ⚠️
...a/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java 3.33% 29 Missing ⚠️
...ava/org/wso2/carbon/apimgt/impl/dao/ApiMgtDAO.java 17.14% 26 Missing and 3 partials ⚠️
...t/api/admin/v1/impl/KeyManagersApiServiceImpl.java 4.16% 23 Missing ⚠️
...java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java 56.81% 14 Missing and 5 partials ⚠️
.../api/store/v1/impl/ApplicationsApiServiceImpl.java 0.00% 11 Missing ⚠️
... and 8 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12345      +/-   ##
============================================
+ Coverage     41.78%   47.38%   +5.59%     
- Complexity        0     4190    +4190     
============================================
  Files          1860     1866       +6     
  Lines        137434   137895     +461     
  Branches      19859    19921      +62     
============================================
+ Hits          57424    65338    +7914     
+ Misses        73104    64858    -8246     
- Partials       6906     7699     +793     
Flag Coverage Δ
integration_tests 42.23% <11.62%> (+6.85%) ⬆️
unit_tests 20.05% <0.45%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Add REST API to get key manager usages
- Add REST API to delete generated keys
- Add REST APIs to fetch key manager API usages and Application usages
- Remove key manager usages API
- Add isUsed parameter when fetching keymanager list
Remove unused methods
Fix API total in GET key manager API usage response
Refactor code
Copy link
Contributor

@chamilaadhi chamilaadhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AnuGayan AnuGayan merged commit eb243c2 into wso2:master Mar 25, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants