Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.cloudfoundry.client.v3.organizations.ListOrganizationsRequest;
import org.cloudfoundry.client.v3.organizations.ListOrganizationsResponse;
import org.cloudfoundry.client.v3.organizations.OrganizationsV3;
import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest;
import org.cloudfoundry.client.v3.organizations.UpdateOrganizationResponse;
import org.cloudfoundry.reactor.ConnectionContext;
import org.cloudfoundry.reactor.TokenProvider;
import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations;
Expand Down Expand Up @@ -85,4 +87,10 @@ public Mono<ListOrganizationsResponse> list(ListOrganizationsRequest request) {
.checkpoint();
}

@Override
public Mono<UpdateOrganizationResponse> update(UpdateOrganizationRequest request) {
return patch(request, UpdateOrganizationResponse.class, builder -> builder.pathSegment("organizations", request.getOrganizationId()))
.checkpoint();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.cloudfoundry.reactor.client.v3.spaces;

import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest;
import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse;
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentRequest;
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse;
import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest;
Expand All @@ -27,6 +29,8 @@
import org.cloudfoundry.client.v3.spaces.ListSpacesRequest;
import org.cloudfoundry.client.v3.spaces.ListSpacesResponse;
import org.cloudfoundry.client.v3.spaces.SpacesV3;
import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest;
import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse;
import org.cloudfoundry.reactor.ConnectionContext;
import org.cloudfoundry.reactor.TokenProvider;
import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations;
Expand Down Expand Up @@ -81,4 +85,10 @@ public Mono<ListSpacesResponse> list(ListSpacesRequest request) {
.checkpoint();
}

@Override
public Mono<UpdateSpaceResponse> update(UpdateSpaceRequest request) {
return patch(request, UpdateSpaceResponse.class, builder -> builder.pathSegment("spaces", request.getSpaceId()))
.checkpoint();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@

package org.cloudfoundry.reactor.client.v3.organizations;

import org.cloudfoundry.client.v3.BuildpackData;
import org.cloudfoundry.client.v3.Lifecycle;
import org.cloudfoundry.client.v3.LifecycleType;
import org.cloudfoundry.client.v3.Link;
import org.cloudfoundry.client.v3.Metadata;
import org.cloudfoundry.client.v3.Pagination;
import org.cloudfoundry.client.v3.Relationship;
import org.cloudfoundry.client.v3.ToOneRelationship;
import org.cloudfoundry.client.v3.applications.ApplicationRelationships;
import org.cloudfoundry.client.v3.applications.ApplicationState;
import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest;
import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse;
import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentRequest;
import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentResponse;
import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest;
Expand All @@ -31,6 +39,8 @@
import org.cloudfoundry.client.v3.organizations.ListOrganizationsRequest;
import org.cloudfoundry.client.v3.organizations.ListOrganizationsResponse;
import org.cloudfoundry.client.v3.organizations.OrganizationResource;
import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest;
import org.cloudfoundry.client.v3.organizations.UpdateOrganizationResponse;
import org.cloudfoundry.reactor.InteractionContext;
import org.cloudfoundry.reactor.TestRequest;
import org.cloudfoundry.reactor.TestResponse;
Expand Down Expand Up @@ -239,4 +249,44 @@ public void list() {
.verify(Duration.ofSeconds(5));
}


@Test
public void update() {
mockRequest(InteractionContext.builder()
.request(TestRequest.builder()
.method(PATCH).path("/organizations/test-organization-id")
.payload("fixtures/client/v3/organizations/PATCH_{id}_request.json")
.build())
.response(TestResponse.builder()
.status(OK)
.payload("fixtures/client/v3/organizations/PATCH_{id}_response.json")
.build())
.build());

this.organizations
.update(UpdateOrganizationRequest.builder()
.organizationId("test-organization-id")
.metadata(Metadata.builder()
.annotation("version", "1.2.4")
.label("dept", "1234")
.build())
.build())
.as(StepVerifier::create)
.expectNext(UpdateOrganizationResponse.builder()
.createdAt("2017-02-01T01:33:58Z")
.id("24637893-3b77-489d-bb79-8466f0d88b52")
.link("self", Link.builder()
.href("https://api.example.org/v3/organizations/24637893-3b77-489d-bb79-8466f0d88b52")
.build())
.metadata(Metadata.builder()
.annotation("version", "1.2.4")
.label("dept", "1234")
.build())
.name("my-organization")
.updatedAt("2017-02-01T01:33:58Z")
.build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package org.cloudfoundry.reactor.client.v3.spaces;

import org.cloudfoundry.client.v3.Link;
import org.cloudfoundry.client.v3.Metadata;
import org.cloudfoundry.client.v3.Pagination;
import org.cloudfoundry.client.v3.Relationship;
import org.cloudfoundry.client.v3.ToOneRelationship;
import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest;
import org.cloudfoundry.client.v3.organizations.UpdateOrganizationResponse;
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentRequest;
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse;
import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest;
Expand All @@ -32,6 +35,8 @@
import org.cloudfoundry.client.v3.spaces.ListSpacesResponse;
import org.cloudfoundry.client.v3.spaces.SpaceRelationships;
import org.cloudfoundry.client.v3.spaces.SpaceResource;
import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest;
import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse;
import org.cloudfoundry.reactor.InteractionContext;
import org.cloudfoundry.reactor.TestRequest;
import org.cloudfoundry.reactor.TestResponse;
Expand Down Expand Up @@ -157,6 +162,10 @@ public void get() {
.createdAt("2017-02-01T01:33:58Z")
.updatedAt("2017-02-01T01:33:58Z")
.name("space1")
.metadata(Metadata.builder()
.annotations(Collections.emptyMap())
.labels(Collections.emptyMap())
.build())
.link("self", Link.builder()
.href("https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920")
.build())
Expand Down Expand Up @@ -247,4 +256,43 @@ public void list() {
.verify(Duration.ofSeconds(5));
}

@Test
public void update() {
mockRequest(InteractionContext.builder()
.request(TestRequest.builder()
.method(PATCH).path("/spaces/test-space-id")
.payload("fixtures/client/v3/spaces/PATCH_{id}_request.json")
.build())
.response(TestResponse.builder()
.status(OK)
.payload("fixtures/client/v3/spaces/PATCH_{id}_response.json")
.build())
.build());

this.spaces
.update(UpdateSpaceRequest.builder()
.spaceId("test-space-id")
.metadata(Metadata.builder()
.annotation("version", "1.2.4")
.label("dept", "1234")
.build())
.build())
.as(StepVerifier::create)
.expectNext(UpdateSpaceResponse.builder()
.id("885735b5-aea4-4cf5-8e44-961af0e41920")
.createdAt("2017-02-01T01:33:58Z")
.updatedAt("2017-02-01T01:33:58Z")
.name("space1")
.metadata(Metadata.builder()
.annotation("version", "1.2.4")
.label("dept", "1234")
.build())
.link("self", Link.builder()
.href("https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920")
.build())
.build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"metadata": {
"labels": {
"dept": "1234"
},
"annotations": {
"version": "1.2.4"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"guid": "24637893-3b77-489d-bb79-8466f0d88b52",
"created_at": "2017-02-01T01:33:58Z",
"updated_at": "2017-02-01T01:33:58Z",
"metadata": {
"labels": {
"dept": "1234"
},
"annotations": {
"version": "1.2.4"
}
},
"name": "my-organization",
"links": {
"self": {
"href": "https://api.example.org/v3/organizations/24637893-3b77-489d-bb79-8466f0d88b52"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"created_at": "2017-02-01T01:33:58Z",
"updated_at": "2017-02-01T01:33:58Z",
"name": "space1",
"metadata": {
"labels": {},
"annotations": {}
},
"links": {
"self": {
"href": "https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"metadata": {
"labels": {
"dept": "1234"
},
"annotations": {
"version": "1.2.4"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"guid": "885735b5-aea4-4cf5-8e44-961af0e41920",
"created_at": "2017-02-01T01:33:58Z",
"updated_at": "2017-02-01T01:33:58Z",
"metadata": {
"labels": {
"dept": "1234"
},
"annotations": {
"version": "1.2.4"
}
},
"name": "space1",
"links": {
"self": {
"href": "https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.cloudfoundry.client.v3.organizations;

import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest;
import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -63,4 +65,10 @@ public interface OrganizationsV3 {
*/
Mono<ListOrganizationsResponse> list(ListOrganizationsRequest request);

/**
* @param request the Update Organization request
* @return the response from the Update Organization request
*/
Mono<UpdateOrganizationResponse> update(UpdateOrganizationRequest request);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2013-2020 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.organizations;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.cloudfoundry.Nullable;
import org.cloudfoundry.client.v3.Metadata;
import org.immutables.value.Value;

/**
* The request payload for the Update Space operation
*/
@JsonSerialize
@Value.Immutable
abstract class _UpdateOrganizationRequest {

/**
* The space id
*/
@JsonIgnore
abstract String getOrganizationId();

/**
* The metadata
*/
@JsonProperty("metadata")
@Nullable
abstract Metadata getMetadata();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2013-2020 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.organizations;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.cloudfoundry.client.v3.spaces.Space;
import org.immutables.value.Value;

/**
* The response payload for the Update Space operation
*/
@JsonDeserialize
@Value.Immutable
abstract class _UpdateOrganizationResponse extends Organization {

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.cloudfoundry.client.v3.spaces;

import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest;
import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse;
import reactor.core.publisher.Mono;

/**
Expand Down Expand Up @@ -63,4 +65,11 @@ public interface SpacesV3 {
*/
Mono<ListSpacesResponse> list(ListSpacesRequest request);

/**
* @param request the Update Space request
* @return the response from the Update Space request
*/
Mono<UpdateSpaceResponse> update(UpdateSpaceRequest request);


}
Loading