diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/GraviteeManagementV2Application.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/GraviteeManagementV2Application.java index 782261f0df1..bdc8081ac42 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/GraviteeManagementV2Application.java +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/GraviteeManagementV2Application.java @@ -35,6 +35,7 @@ import io.gravitee.rest.api.management.v2.rest.resource.installation.EnvironmentsResource; import io.gravitee.rest.api.management.v2.rest.resource.installation.GraviteeLicenseResource; import io.gravitee.rest.api.management.v2.rest.resource.installation.OrganizationResource; +import io.gravitee.rest.api.management.v2.rest.resource.integration.IntegrationsResource; import io.gravitee.rest.api.management.v2.rest.resource.plugin.ApiServicesResource; import io.gravitee.rest.api.management.v2.rest.resource.plugin.EndpointsResource; import io.gravitee.rest.api.management.v2.rest.resource.plugin.EntrypointsResource; @@ -71,6 +72,7 @@ public GraviteeManagementV2Application() { register(EntrypointsResource.class); register(ApiServicesResource.class); register(PoliciesResource.class); + register(IntegrationsResource.class); register(MultiPartFeature.class); diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/resource/integration/IntegrationsResource.java b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/resource/integration/IntegrationsResource.java new file mode 100644 index 00000000000..63f3a43561e --- /dev/null +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/java/io/gravitee/rest/api/management/v2/rest/resource/integration/IntegrationsResource.java @@ -0,0 +1,67 @@ +/* + * Copyright © 2015 The Gravitee team (http://gravitee.io) + * + * 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. + */ +package io.gravitee.rest.api.management.v2.rest.resource.integration; + +import io.gravitee.common.http.MediaType; +import io.gravitee.rest.api.management.v2.rest.model.CreateIntegration; +import io.gravitee.rest.api.management.v2.rest.model.Integration; +import io.gravitee.rest.api.management.v2.rest.resource.AbstractResource; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.Response; +import lombok.extern.slf4j.Slf4j; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author Remi Baptiste (remi.baptiste at graviteesource.com) + * @author GraviteeSource Team + */ +@Path("/environments/{envId}/integrations") +@Slf4j +public class IntegrationsResource extends AbstractResource { + + private static final List integrationsMock = new ArrayList<>(); + + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response createIntegration(@Valid @NotNull final CreateIntegration integration) { + + Integration mockIntegration = Integration.builder() + .id(UUID.randomUUID().toString()) + .name("Mock integration") + .description("Sample description") + .provider("AWS") + .build(); + integrationsMock.add(mockIntegration); + + return Response + .created(this.getLocationHeader(mockIntegration.getId())) + .entity(mockIntegration) + .build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response listIntegrations(@PathParam("envId") String environmentId) { + return Response.ok().entity(integrationsMock).build(); + } + +} diff --git a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml index dc9118b1637..3f69c159252 100644 --- a/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml +++ b/gravitee-apim-rest-api/gravitee-apim-rest-api-management-v2/gravitee-apim-rest-api-management-v2-rest/src/main/resources/openapi/openapi-apis.yaml @@ -56,6 +56,8 @@ tags: description: Everything about API subscriptions - name: Groups description: Everything about groups + - name: Integration + description: Everything about integration paths: # APIs @@ -1031,6 +1033,53 @@ paths: default: $ref: "#/components/responses/Error" + # Integration + /environments/{envId}/integrations: + parameters: + - $ref: "#/components/parameters/envIdParam" + get: + parameters: + - $ref: "#/components/parameters/pageParam" + - $ref: "#/components/parameters/perPageParam" + tags: + - Integration + summary: List Integrations + description: |- + Get the list of Integration for a specific environment.
+ The results are paginated. + + User must have the ENVIRONMENT_INTEGRATION[READ] permission. + operationId: listIntegrations + responses: + "200": + $ref: "#/components/responses/IntegrationsResponse" + default: + $ref: "#/components/responses/Error" + post: + tags: + - Integration + summary: Create an Integration + description: |- + Create a new Integration. + + User must have the ENVIRONMENT_INTEGRATION[CREATE] permission. + operationId: createIntegration + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateIntegration" + required: true + responses: + "201": + description: Integration successfully created + content: + application/json: + schema: + $ref: "#/components/schemas/Integration" + default: + $ref: "#/components/responses/Error" + # API Subscriptions /environments/{envId}/apis/{apiId}/subscribers: parameters: @@ -2958,6 +3007,21 @@ components: items: $ref: "#/components/schemas/HttpMethod" uniqueItems: true + Integration: + type: object + properties: + id: + type: string + description: Id of the integration + name: + type: string + description: Name of the integration + description: + type: string + description: Description of the integration + provider: + type: string + description: Provider of this integration Links: description: List of links for pagination properties: @@ -5776,6 +5840,19 @@ components: additionalProperties: type: object + CreateIntegration: + type: object + properties: + name: + type: string + description: Name of the integration + description: + type: string + description: Description of the integration + provider: + type: string + description: Provider of this integration + parameters: ############# # PathParam # @@ -5873,6 +5950,13 @@ components: description: Id of a policy. schema: type: string + integrationIdParam: + name: integrationId + in: path + required: true + description: Id of an integration. + schema: + type: string ############################### # Pagination Query Parameters # ############################### @@ -6105,6 +6189,22 @@ components: links: $ref: "#/components/schemas/Links" + IntegrationsResponse: + description: Page of integrations + content: + application/json: + schema: + title: "IntegrationsResponse" + properties: + data: + description: List of Integrations. + type: array + items: + $ref: "#/components/schemas/Integration" + pagination: + $ref: "#/components/schemas/Pagination" + links: + $ref: "#/components/schemas/Links" PlansResponse: description: Page of API plans content: