-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/create api marketplace metrics #37
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
jordivx
wants to merge
24
commits into
develop
Choose a base branch
from
feature/create-api-marketplace-metrics
base: develop
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
24 commits
Select commit
Hold shift + click to select a range
9eaae82
[update-marketplace-to-consume-metrics] - Add new endpoint configurat…
sergio-soria-bi 60a2329
[update-marketplace-to-consume-metrics] - Add new endpoint configurat…
sergio-soria-bi ff9df9b
[update-marketplace-to-consume-metrics] - Whitelist new method so it …
sergio-soria-bi fe3d8c5
[update-marketplace-to-consume-metrics] - Add new endpoint to client …
sergio-soria-bi 99243f7
[update-marketplace-to-consume-metrics] - Add unit tests.
sergio-soria-bi 5721ecc
[update-marketplace-to-consume-metrics] - Fix missdefinition.
sergio-soria-bi 4fc4869
[update-marketplace-to-consume-metrics] - Add JWT token generation co…
sergio-soria-bi 119d8f4
[update-marketplace-to-consume-metrics] - Fix unit tests.
sergio-soria-bi f9a5ba2
Create api-marketplace-metrics module
jordivx 0cb6827
Fixes to integrate metrics e2e
jordivx e01ea54
Feature/update marketplace client to consume new endpoint (#35)
sergio-soria-bi 4bb965d
Add unit tests
jordivx b06b057
Rename properly properties
jordivx a069870
Add liquibasemigration to include new api in api_definitions
jordivx dea1628
Merge from develop to master (#42)
BraisVQ 7ddf3f1
Upgrade version from 0.0.3 to 0.0.4
jordivx 5faf796
Merge remote-tracking branch 'origin/master' into feature/create-api-…
jordivx 770e18f
[all-catalog-items] - Set new/updated catalog items endpoint. (#40)
sergio-soria-bi ef995c9
Apply PR feedback
jordivx 1bf2134
Feature/remove auto generated code from git repo (#41)
sergio-soria-bi 9a4e968
Apply PR feedback about exception handling + override + cors configur…
jordivx 4d35302
Use bad gateway exception instead of internal server when issues in m…
jordivx dc58d22
Apply PR feedback
jordivx c4c9d3c
Fix unit tests failing
jordivx 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * text=auto eol=lf |
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
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,76 @@ | ||
| # Marketplace Metrics API Module | ||
|
|
||
| This module provides REST API endpoint to obtain metrics from the Marketplace. | ||
|
|
||
| ## Integration with Core Application | ||
|
|
||
| To integrate these modules with your core application: | ||
|
|
||
| 1. **Add module dependencies** to your core `pom.xml`: | ||
|
|
||
| ```xml | ||
|
|
||
| <dependency> | ||
| <groupId>org.opendevstack.apiservice</groupId> | ||
| <artifactId>api-marketplace-metrics</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
|
|
||
| ``` | ||
| ## Error Handling | ||
|
|
||
| The API provides comprehensive error handling with structured error responses: | ||
|
|
||
| - **400 Bad Request**: Invalid request data | ||
| - **404 Not Found**: Resource not found (project, user) | ||
| - **409 Conflict**: Resource already exists | ||
| - **500 Internal Server Error**: System errors, automation platform failures | ||
|
|
||
| ## Monitoring and Observability | ||
|
|
||
| The modules provide comprehensive logging and can be monitored through: | ||
|
|
||
| 1. **Application Logs**: Structured logging for all operations | ||
| 2. **Metrics**: Integration with Spring Boot Actuator | ||
| 3. **Health Checks**: Automation platform connectivity checks | ||
| 4. **Distributed Tracing**: Support for distributed tracing systems with Opentelemetry and Dynatrace | ||
|
|
||
| ## Testing | ||
|
|
||
| Both modules include comprehensive test suites: | ||
|
|
||
| - **Unit Tests**: Business logic validation | ||
| - **Integration Tests**: API endpoint testing | ||
| - **Mock Tests**: Automation platform interaction testing | ||
|
|
||
| Run tests with: | ||
|
|
||
| ```bash | ||
| ./mvnw test | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Building the Modules | ||
|
|
||
| ```bash | ||
| # Build all modules | ||
| ./mvnw clean install | ||
|
|
||
| # Build specific module | ||
| ./mvnw clean install -pl api-project-users | ||
| ./mvnw clean install -pl api-marketplace-metrics | ||
| ./mvnw clean install -pl external-service-app | ||
| ``` | ||
|
|
||
| ### Running Locally | ||
|
|
||
| ```bash | ||
| # Run with dev profile | ||
| ./mvnw spring-boot:run -Dspring-boot.run.profiles=dev | ||
| ``` | ||
|
|
||
| ### API Documentation | ||
|
|
||
| Swagger UI is available at: `http://localhost:8080/swagger-ui.html` | ||
|
|
289 changes: 289 additions & 0 deletions
289
api-marketplace-metrics/openapi/api-marketplace-metrics.yaml
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,289 @@ | ||
| openapi: 3.0.3 | ||
| info: | ||
| title: ODS API Server | ||
| description: API documentation for ODS (Open DevStack) API Service | ||
| contact: | ||
| name: ODS Team | ||
| version: v0.0.1 | ||
| servers: | ||
| - url: http://{baseurl}/api/v1 | ||
| variables: | ||
| baseurl: | ||
| default: localhost:8080 | ||
| description: Development environment | ||
| tags: | ||
| - name: Marketplace metrics | ||
| description: API for managing marketplace metrics | ||
| paths: | ||
| /marketplace/project-components: | ||
| get: | ||
| tags: | ||
| - MarketplaceMetrics | ||
| summary: Get Marketplace metrics regarding project components. | ||
| description: Returns all the components that were provisioned from the Marketplace in all the projects. | ||
| operationId: getMarketplaceProjectComponentsMetrics | ||
| parameters: | ||
| - name: page | ||
| in: query | ||
| description: Page number (from 0 until limit) | ||
| required: false | ||
| schema: | ||
| type: integer | ||
| default: 0 | ||
| - name: size | ||
| in: query | ||
| description: Page size | ||
| required: false | ||
| schema: | ||
| type: integer | ||
| default: 20 | ||
| responses: | ||
| "200": | ||
| description: A paginated list of all the provisioned project components | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: "#/components/schemas/MarketplaceProjectComponentsMetrics" | ||
| "401": | ||
| $ref: "#/components/responses/UnauthorizedResponse" | ||
| "403": | ||
| $ref: "#/components/responses/ForbiddenResponse" | ||
| "404": | ||
| $ref: "#/components/responses/NotFoundResponse" | ||
| "500": | ||
| $ref: "#/components/responses/InternalErrorResponse" | ||
| "502": | ||
| $ref: "#/components/responses/BadGatewayResponse" | ||
|
|
||
| /marketplace/catalog-items: | ||
| get: | ||
| tags: | ||
| - MarketplaceMetrics | ||
| summary: Get Marketplace metrics regarding catalog items. | ||
| description: Returns usage metrics of catalog items available in the marketplace. | ||
| operationId: getMarketplaceCatalogItemsMetrics | ||
| responses: | ||
| "200": | ||
| description: A list of catalog items metrics | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: "#/components/schemas/MarketplaceCatalogItemsMetrics" | ||
| "401": | ||
| $ref: "#/components/responses/UnauthorizedResponse" | ||
| "403": | ||
| $ref: "#/components/responses/ForbiddenResponse" | ||
| "404": | ||
| $ref: "#/components/responses/NotFoundResponse" | ||
| "500": | ||
| $ref: "#/components/responses/InternalErrorResponse" | ||
|
jordivx marked this conversation as resolved.
|
||
| "502": | ||
| $ref: "#/components/responses/BadGatewayResponse" | ||
|
|
||
| components: | ||
| responses: | ||
| UnauthorizedResponse: | ||
| description: Invalid client token | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/RestErrorMessage' | ||
| ForbiddenResponse: | ||
| description: Insufficient permissions | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/RestErrorMessage' | ||
| NotFoundResponse: | ||
| description: Resource not found | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/RestErrorMessage' | ||
| BadGatewayResponse: | ||
| description: Bad gateway | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/RestErrorMessage' | ||
| InternalErrorResponse: | ||
| description: Server error | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/RestErrorMessage' | ||
|
|
||
| schemas: | ||
| RestErrorMessage: | ||
| type: object | ||
| properties: | ||
| message: | ||
| type: string | ||
| required: | ||
| - message | ||
|
|
||
| MarketplaceProjectComponentsMetrics: | ||
| type: object | ||
| example: | ||
| data: | ||
| - projectKey: SOMEPROJECT | ||
| componentId: any-component-id-from-backend | ||
| caller: some-person@email.com | ||
| catalogItemSlug: some_technology-name | ||
| createdAt: 1707043200000 | ||
| updatedAt: 1707043200000 | ||
| - projectKey: ANOTHERPROJECT | ||
| componentId: another-component-id-from-backend | ||
| caller: some-person2@email.com | ||
| catalogItemSlug: another_technology-name | ||
| createdAt: 1707043200001 | ||
| updatedAt: 1707043200002 | ||
| pagination: | ||
| page: 0 | ||
| size: 20 | ||
| totalElements: 117 | ||
| totalPages: 6 | ||
| next: https://api.example.com/resources?page=1&size=20 | ||
| previous: null | ||
| properties: | ||
| data: | ||
| type: array | ||
| items: | ||
| $ref: '#/components/schemas/MarketplaceProjectComponentMetrics' | ||
| pagination: | ||
| $ref: '#/components/schemas/MarketplaceProjectComponentsMetricsPagination' | ||
| MarketplaceProjectComponentMetrics: | ||
| type: object | ||
| example: | ||
| projectKey: SOMEPROJECT | ||
| componentId: any-component-id-from-backend | ||
| caller: some-person@email.com | ||
| catalogItemSlug: some_technology-name | ||
| createdAt: 1707043200000 | ||
| updatedAt: 1707043200000 | ||
| properties: | ||
| projectKey: | ||
| description: The projectKey which the component is provisioned for. | ||
| example: SOMEPROJECT | ||
| type: string | ||
| componentId: | ||
| description: The componentId set by the user. | ||
| example: any-component-id-from-backend | ||
| minLength: 1 | ||
| pattern: ^(?!\s*$).+ | ||
| type: string | ||
| caller: | ||
| description: The email of who provisioned the component. | ||
| example: some-person@email.com | ||
| type: string | ||
| catalogItemSlug: | ||
| description: The provisioned catalog item slug. | ||
| example: some_technology-name | ||
| type: string | ||
| createdAt: | ||
| description: The timestamp of the provision action. | ||
| example: 1707043200000 | ||
| type: number | ||
| updatedAt: | ||
| description: The timestamp of the last change of the provisioned component. | ||
| example: 1707043200000 | ||
| type: number | ||
| MarketplaceProjectComponentsMetricsPagination: | ||
| type: object | ||
| example: | ||
| page: 0 | ||
| size: 20 | ||
| totalElements: 117 | ||
| totalPages: 6 | ||
| next: "https://api.example.com/resources?page=1&size=20" | ||
| previous: null | ||
| properties: | ||
| page: | ||
| type: integer | ||
| example: 0 | ||
| description: Current page of the response. | ||
| size: | ||
| type: integer | ||
| example: 20 | ||
| description: Current page size of the response. | ||
| totalElements: | ||
| type: integer | ||
| format: integer | ||
| example: 117 | ||
| description: Total number of elements. | ||
| totalPages: | ||
| type: integer | ||
| example: 6 | ||
| description: Total number of pages of this exact size. | ||
| next: | ||
| type: string | ||
| format: uri | ||
| nullable: true | ||
| example: "https://api.example.com/resources?page=1&size=20" | ||
| description: URL of the next page (or null if the current is the last one) | ||
| previous: | ||
| type: string | ||
| format: uri | ||
| nullable: true | ||
| example: "https://api.example.com/resources?page=0&size=20" | ||
| description: URL of the previous page (or null if the current is the first one) | ||
|
|
||
| MarketplaceCatalogItemsMetrics: | ||
| type: object | ||
| example: | ||
| data: | ||
| - id: aSdFam...yCg== | ||
| slug: myproject_my-component-repo | ||
| title: An item title | ||
| shortDescription: Example description | ||
| date: "2021-07-01T00:00:00Z" | ||
| properties: | ||
| data: | ||
| type: array | ||
| items: | ||
| $ref: '#/components/schemas/CatalogItem' | ||
|
|
||
| CatalogItem: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: string | ||
| slug: | ||
| type: string | ||
| path: | ||
| type: string | ||
| title: | ||
| type: string | ||
| shortDescription: | ||
| type: string | ||
| descriptionFileId: | ||
| type: string | ||
| imageFileId: | ||
| type: string | ||
| description: | ||
| type: string | ||
| description: Resolved description content of the catalog item (e.g. markdown converted to plain text or HTML) | ||
| example: "This component provides a reusable service for handling..." | ||
| itemSrc: | ||
| type: string | ||
| tags: | ||
| type: array | ||
| items: | ||
| $ref: '#/components/schemas/CatalogItemTag' | ||
| authors: | ||
| type: array | ||
| items: | ||
| type: string | ||
| date: | ||
| type: string | ||
| format: date-time | ||
|
|
||
| CatalogItemTag: | ||
| type: object | ||
| properties: | ||
| label: | ||
| type: string | ||
| options: | ||
| type: array | ||
| items: | ||
| type: string | ||
Oops, something went wrong.
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.