diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java index e3fd2179e37..b2ea649d1aa 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java @@ -95,6 +95,7 @@ import org.cloudfoundry.reactor.client.v2.userprovidedserviceinstances.ReactorUserProvidedServiceInstances; import org.cloudfoundry.reactor.client.v2.users.ReactorUsers; import org.cloudfoundry.reactor.client.v3.applications.ReactorApplicationsV3; +import org.cloudfoundry.reactor.client.v3.auditevents.ReactorAuditEventsV3; import org.cloudfoundry.reactor.client.v3.builds.ReactorBuilds; import org.cloudfoundry.reactor.client.v3.deployments.ReactorDeploymentsV3; import org.cloudfoundry.reactor.client.v3.droplets.ReactorDroplets; @@ -189,6 +190,12 @@ public Events events() { return new ReactorEvents(getConnectionContext(), getRootV2(), getTokenProvider()); } + @Override + @Value.Derived + public ReactorAuditEventsV3 eventsV3() { + return new ReactorAuditEventsV3(getConnectionContext(), getRootV2(), getTokenProvider()); + } + @Override @Value.Derived public FeatureFlags featureFlags() { diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/auditevents/ReactorAuditEventsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/auditevents/ReactorAuditEventsV3.java new file mode 100644 index 00000000000..108862bba13 --- /dev/null +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/auditevents/ReactorAuditEventsV3.java @@ -0,0 +1,45 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.reactor.client.v3.auditevents; + +import org.cloudfoundry.client.v3.auditevents.AuditEventsV3; +import org.cloudfoundry.client.v3.auditevents.GetAuditEventRequest; +import org.cloudfoundry.client.v3.auditevents.GetAuditEventResponse; +import org.cloudfoundry.client.v3.auditevents.ListAuditEventsRequest; +import org.cloudfoundry.client.v3.auditevents.ListAuditEventsResponse; +import org.cloudfoundry.reactor.ConnectionContext; +import org.cloudfoundry.reactor.TokenProvider; +import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; +import reactor.core.publisher.Mono; + +public class ReactorAuditEventsV3 extends AbstractClientV3Operations implements AuditEventsV3 { + + public ReactorAuditEventsV3(ConnectionContext connectionContext, Mono root, TokenProvider tokenProvider) { + super(connectionContext, root, tokenProvider); + } + + @Override + public Mono get(GetAuditEventRequest request) { + return get(request, GetAuditEventResponse.class, uriComponentsBuilder -> uriComponentsBuilder.pathSegment("audit_events", request.getEventId())); + } + + @Override + public Mono list(ListAuditEventsRequest request) { + return get(request, ListAuditEventsResponse.class, uriComponentsBuilder -> uriComponentsBuilder.pathSegment("audit_events")) + .checkpoint(); + } +} diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/auditevents/ReactorAuditEventsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/auditevents/ReactorAuditEventsV3Test.java new file mode 100644 index 00000000000..b7f43a77899 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/auditevents/ReactorAuditEventsV3Test.java @@ -0,0 +1,174 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.reactor.client.v3.auditevents; + +import org.cloudfoundry.client.v3.Link; +import org.cloudfoundry.client.v3.Pagination; +import org.cloudfoundry.client.v3.auditevents.AuditEventReference; +import org.cloudfoundry.client.v3.auditevents.AuditEventRelationship; +import org.cloudfoundry.client.v3.auditevents.AuditEventResource; +import org.cloudfoundry.client.v3.auditevents.GetAuditEventRequest; +import org.cloudfoundry.client.v3.auditevents.GetAuditEventResponse; +import org.cloudfoundry.client.v3.auditevents.ListAuditEventsRequest; +import org.cloudfoundry.client.v3.auditevents.ListAuditEventsResponse; +import org.cloudfoundry.reactor.InteractionContext; +import org.cloudfoundry.reactor.TestRequest; +import org.cloudfoundry.reactor.TestResponse; +import org.cloudfoundry.reactor.client.AbstractClientApiTest; +import org.junit.Test; +import reactor.test.StepVerifier; + +import java.time.Duration; + +import static io.netty.handler.codec.http.HttpMethod.GET; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; + +public class ReactorAuditEventsV3Test extends AbstractClientApiTest { + + private ReactorAuditEventsV3 events = new ReactorAuditEventsV3(CONNECTION_CONTEXT, this.root, TOKEN_PROVIDER); + + @Test + public void get() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(GET).path("/audit_events/a595fe2f-01ff-4965-a50c-290258ab8582") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/auditevents/GET_{id}_response.json") + .build()) + .build()); + + this.events + .get(GetAuditEventRequest.builder() + .eventId("a595fe2f-01ff-4965-a50c-290258ab8582") + .build()) + .as(StepVerifier::create) + .expectNext(GetAuditEventResponse.builder() + .id("a595fe2f-01ff-4965-a50c-290258ab8582") + .createdAt("2016-11-04T16:41:23Z") + .updatedAt("2016-11-04T16:41:23Z") + .type("audit.app.update") + .auditEventActor(AuditEventReference.builder() + .id("test-user-id") + .name("admin") + .type("user") + .build()) + .auditEventTarget(AuditEventReference.builder() + .id("test-app-id") + .name("test-app") + .type("app") + .build()) + .spaceRelationship(AuditEventRelationship.builder() + .id("test-space-id") + .build()) + .organizationRelationship(AuditEventRelationship.builder() + .id("test-organization-id") + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/audit_events/a595fe2f-01ff-4965-a50c-290258ab8582") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + public void list() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(GET).path("/audit_events") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/auditevents/GET_response.json") + .build()) + .build()); + + this.events + .list(ListAuditEventsRequest.builder() + .build()) + .as(StepVerifier::create) + .expectNext(ListAuditEventsResponse.builder() + .pagination(Pagination.builder() + .totalResults(3) + .totalPages(2) + .first(Link.builder() + .href("https://api.example.org/v3/audit_events?page=1&per_page=2") + .build()) + .last(Link.builder() + .href("https://api.example.org/v3/audit_events?page=2&per_page=2") + .build()) + .next(Link.builder() + .href("https://api.example.org/v3/audit_events?page=2&per_page=2") + .build()) + .build()) + .resource(AuditEventResource.builder() + .id("a595fe2f-01ff-4965-a50c-290258ab8582") + .createdAt("2016-11-04T16:41:23Z") + .updatedAt("2016-11-04T16:41:23Z") + .type("audit.app.update") + .auditEventActor(AuditEventReference.builder() + .id("test-user-id") + .name("admin") + .type("user") + .build()) + .auditEventTarget(AuditEventReference.builder() + .id("test-app-id") + .name("test-app") + .type("app") + .build()) + .spaceRelationship(AuditEventRelationship.builder() + .id("test-space-id") + .build()) + .organizationRelationship(AuditEventRelationship.builder() + .id("test-organization-id") + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/audit_events/a595fe2f-01ff-4965-a50c-290258ab8582") + .build()) + .build()) + .resource(AuditEventResource.builder() + .id("8a8a14a3-beab-4946-ab6a-3e69741c6405") + .createdAt("2016-11-04T16:41:23Z") + .updatedAt("2016-11-04T16:41:23Z") + .type("audit.app.update") + .auditEventActor(AuditEventReference.builder() + .id("test-user-id") + .name("admin-admin") + .type("user") + .build()) + .auditEventTarget(AuditEventReference.builder() + .id("test-app-id") + .name("test-app-2") + .type("app") + .build()) + .spaceRelationship(AuditEventRelationship.builder() + .id("test-space-id-1") + .build()) + .organizationRelationship(AuditEventRelationship.builder() + .id("test-organization-id-1") + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/audit_events/8a8a14a3-beab-4946-ab6a-3e69741c6405") + .build()) + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/auditevents/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/auditevents/GET_response.json new file mode 100644 index 00000000000..2a14889ec7e --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/auditevents/GET_response.json @@ -0,0 +1,72 @@ +{ + "pagination": { + "total_results": 3, + "total_pages": 2, + "first": { + "href": "https://api.example.org/v3/audit_events?page=1&per_page=2" + }, + "last": { + "href": "https://api.example.org/v3/audit_events?page=2&per_page=2" + }, + "next": { + "href": "https://api.example.org/v3/audit_events?page=2&per_page=2" + }, + "previous": null + }, + "resources": [ + { + "guid": "a595fe2f-01ff-4965-a50c-290258ab8582", + "created_at": "2016-11-04T16:41:23Z", + "updated_at": "2016-11-04T16:41:23Z", + "type": "audit.app.update", + "actor": { + "guid": "test-user-id", + "type": "user", + "name": "admin" + }, + "target": { + "guid": "test-app-id", + "type": "app", + "name": "test-app" + }, + "space": { + "guid": "test-space-id" + }, + "organization": { + "guid": "test-organization-id" + }, + "links": { + "self": { + "href": "https://api.example.org/v3/audit_events/a595fe2f-01ff-4965-a50c-290258ab8582" + } + } + }, + { + "guid": "8a8a14a3-beab-4946-ab6a-3e69741c6405", + "created_at": "2016-11-04T16:41:23Z", + "updated_at": "2016-11-04T16:41:23Z", + "type": "audit.app.update", + "actor": { + "guid": "test-user-id", + "type": "user", + "name": "admin-admin" + }, + "target": { + "guid": "test-app-id", + "type": "app", + "name": "test-app-2" + }, + "space": { + "guid": "test-space-id-1" + }, + "organization": { + "guid": "test-organization-id-1" + }, + "links": { + "self": { + "href": "https://api.example.org/v3/audit_events/8a8a14a3-beab-4946-ab6a-3e69741c6405" + } + } + } + ] +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/auditevents/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/auditevents/GET_{id}_response.json new file mode 100644 index 00000000000..66a3789e55f --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/auditevents/GET_{id}_response.json @@ -0,0 +1,27 @@ +{ + "guid": "a595fe2f-01ff-4965-a50c-290258ab8582", + "created_at": "2016-11-04T16:41:23Z", + "updated_at": "2016-11-04T16:41:23Z", + "type": "audit.app.update", + "actor": { + "guid": "test-user-id", + "type": "user", + "name": "admin" + }, + "target": { + "guid": "test-app-id", + "type": "app", + "name": "test-app" + }, + "space": { + "guid": "test-space-id" + }, + "organization": { + "guid": "test-organization-id" + }, + "links": { + "self": { + "href": "https://api.example.org/v3/audit_events/a595fe2f-01ff-4965-a50c-290258ab8582" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java index b7ea8ed05d2..760d61ef290 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java @@ -48,6 +48,7 @@ import org.cloudfoundry.client.v2.userprovidedserviceinstances.UserProvidedServiceInstances; import org.cloudfoundry.client.v2.users.Users; import org.cloudfoundry.client.v3.applications.ApplicationsV3; +import org.cloudfoundry.client.v3.auditevents.AuditEventsV3; import org.cloudfoundry.client.v3.builds.Builds; import org.cloudfoundry.client.v3.deployments.DeploymentsV3; import org.cloudfoundry.client.v3.droplets.Droplets; @@ -126,6 +127,11 @@ public interface CloudFoundryClient { */ Events events(); + /** + * Main entry point to the Cloud Foundry Audit Events V3 Client API + */ + AuditEventsV3 eventsV3(); + /** * Main entry point to the Cloud Foundry Feature Flags Client API */ diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/AuditEvent.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/AuditEvent.java new file mode 100644 index 00000000000..491dc70c283 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/AuditEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Resource; + +import java.util.Map; + +public abstract class AuditEvent extends Resource { + + @JsonProperty("type") + abstract String getType(); + + @JsonProperty("actor") + abstract AuditEventReference getAuditEventActor(); + + @JsonProperty("target") + abstract AuditEventReference getAuditEventTarget(); + + @JsonProperty("data") + abstract Map getData(); + + @Nullable + @JsonProperty("space") + abstract AuditEventRelationship getSpaceRelationship(); + + @Nullable + @JsonProperty("organization") + abstract AuditEventRelationship getOrganizationRelationship(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/AuditEventsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/AuditEventsV3.java new file mode 100644 index 00000000000..722ae13bca9 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/AuditEventsV3.java @@ -0,0 +1,39 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import reactor.core.publisher.Mono; + +public interface AuditEventsV3 { + /** + * Makes the Get Audit Event request + * + * @param request the Get Audit Event request + * @return the response from the Get Audit Event request + */ + Mono get(GetAuditEventRequest request); + + /** + * Makes the List Audit Events request + * + * @param request the List Audit Events request + * @return the response from the List Audit Events request + */ + Mono list(ListAuditEventsRequest request); + + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventActor.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventActor.java new file mode 100644 index 00000000000..8916f3d9010 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventActor.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +@Value.Immutable +@JsonDeserialize +public abstract class _AuditEventActor { + + @JsonProperty("guid") + public abstract String getId(); + + @JsonProperty("type") + public abstract String getType(); + + @JsonProperty("name") + public abstract String getName(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventReference.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventReference.java new file mode 100644 index 00000000000..0cfe95a2829 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventReference.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +@Value.Immutable +@JsonDeserialize +public abstract class _AuditEventReference { + + @JsonProperty("guid") + public abstract String getId(); + + @JsonProperty("type") + public abstract String getType(); + + @JsonProperty("name") + public abstract String getName(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventRelationship.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventRelationship.java new file mode 100644 index 00000000000..acbebdbd3c7 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventRelationship.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +@Value.Immutable +@JsonDeserialize +public abstract class _AuditEventRelationship { + + @JsonProperty("guid") + abstract String getId(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventResource.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventResource.java new file mode 100644 index 00000000000..e00485f2b3f --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_AuditEventResource.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The Resource response payload for the List audit events operation + */ +@JsonDeserialize +@Value.Immutable +public abstract class _AuditEventResource extends AuditEvent { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_GetAuditEventRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_GetAuditEventRequest.java new file mode 100644 index 00000000000..a4f0f10e8ef --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_GetAuditEventRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import org.immutables.value.Value; + +/** + * The request payload for the Get Audit Event operation + */ +@Value.Immutable +public abstract class _GetAuditEventRequest { + + /** + * The audit event id + */ + abstract String getEventId(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_GetAuditEventResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_GetAuditEventResponse.java new file mode 100644 index 00000000000..779eb21412f --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_GetAuditEventResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Get Audit Event operation + */ +@JsonDeserialize +@Value.Immutable +public abstract class _GetAuditEventResponse extends AuditEvent{ + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_ListAuditEventsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_ListAuditEventsRequest.java new file mode 100644 index 00000000000..8bd80a67cde --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_ListAuditEventsRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import org.cloudfoundry.client.v3.FilterParameter; +import org.cloudfoundry.client.v3.PaginatedRequest; +import org.immutables.value.Value; + +import java.util.List; + +/** + * The request payload for the List Audit Events operation + */ +@Value.Immutable +public abstract class _ListAuditEventsRequest extends PaginatedRequest { + + /** + * The types + */ + @FilterParameter("types") + abstract List getTypes(); + + /** + * The request target guids + */ + @FilterParameter("target_guids") + abstract List getTargetGuids(); + + /** + * The space guids + */ + @FilterParameter("space_guids") + abstract List getSpaceGuids(); + + /** + * The organization guids + */ + @FilterParameter("organization_guids") + abstract List getOrganizationGuids(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_ListAuditEventsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_ListAuditEventsResponse.java new file mode 100644 index 00000000000..8d8ce4b8f77 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/auditevents/_ListAuditEventsResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.client.v3.PaginatedResponse; +import org.immutables.value.Value; + +/** + * The response payload for the List Audit Events operation + */ +@JsonDeserialize +@Value.Immutable +public abstract class _ListAuditEventsResponse extends PaginatedResponse { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/auditevents/GetAuditEventRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/auditevents/GetAuditEventRequestTest.java new file mode 100644 index 00000000000..ffb686c307c --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/auditevents/GetAuditEventRequestTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import org.junit.Test; + +public final class GetAuditEventRequestTest { + + @Test(expected = IllegalStateException.class) + public void invalid() { + GetAuditEventRequest.builder() + .build(); + } + + @Test + public void valid() { + GetAuditEventRequest.builder() + .eventId("test-event-id") + .build(); + } +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/auditevents/ListAuditEventsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/auditevents/ListAuditEventsRequestTest.java new file mode 100644 index 00000000000..516b8eceddf --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/auditevents/ListAuditEventsRequestTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * 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 org.cloudfoundry.client.v3.auditevents; + +import org.junit.Test; + +public class ListAuditEventsRequestTest { + + @Test + public void validWithEmptyCollections() { + ListAuditEventsRequest.builder() + .build(); + } + + @Test(expected = Exception.class) + public void invalidWithNullableCollection() { + ListAuditEventsRequest.builder() + .organizationGuids((String[]) null) + .build(); + } + + @Test + public void valid() { + ListAuditEventsRequest.builder() + .organizationGuids("organization-id-1", "organization-id-2") + .type("test-type") + .orderBy("nothing") + .targetGuid("test-target-id") + .build(); + } +}