Skip to content

Commit faef15b

Browse files
committed
Merge branch 'uaa-groups'
2 parents 8fa35f4 + 5ab201b commit faef15b

36 files changed

+1511
-2
lines changed

cloudfoundry-client-spring/src/main/java/org/cloudfoundry/reactor/uaa/ReactorUaaClient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020
import lombok.Builder;
2121
import org.cloudfoundry.reactor.uaa.authorizations.ReactorAuthorizations;
22+
import org.cloudfoundry.reactor.uaa.groups.ReactorGroups;
2223
import org.cloudfoundry.reactor.uaa.identityproviders.ReactorIdentityProviders;
2324
import org.cloudfoundry.reactor.uaa.identityzones.ReactorIdentityZones;
2425
import org.cloudfoundry.reactor.uaa.tokens.ReactorTokens;
@@ -27,6 +28,7 @@
2728
import org.cloudfoundry.reactor.util.ConnectionContextSupplier;
2829
import org.cloudfoundry.uaa.UaaClient;
2930
import org.cloudfoundry.uaa.authorizations.Authorizations;
31+
import org.cloudfoundry.uaa.groups.Groups;
3032
import org.cloudfoundry.uaa.identityproviders.IdentityProviders;
3133
import org.cloudfoundry.uaa.identityzones.IdentityZones;
3234
import org.cloudfoundry.uaa.tokens.Tokens;
@@ -41,6 +43,8 @@ public final class ReactorUaaClient implements UaaClient {
4143

4244
private final Authorizations authorizations;
4345

46+
private final Groups groups;
47+
4448
private final IdentityProviders identityProviders;
4549

4650
private final IdentityZones identityZones;
@@ -57,6 +61,7 @@ public final class ReactorUaaClient implements UaaClient {
5761

5862
ReactorUaaClient(AuthorizationProvider authorizationProvider, HttpClient httpClient, ObjectMapper objectMapper, Mono<String> root) {
5963
this.authorizations = new ReactorAuthorizations(authorizationProvider, httpClient, objectMapper, root);
64+
this.groups = new ReactorGroups(authorizationProvider, httpClient, objectMapper, root);
6065
this.identityProviders = new ReactorIdentityProviders(authorizationProvider, httpClient, objectMapper, root);
6166
this.identityZones = new ReactorIdentityZones(authorizationProvider, httpClient, objectMapper, root);
6267
this.tokens = new ReactorTokens(authorizationProvider, httpClient, objectMapper, root);
@@ -68,6 +73,11 @@ public Authorizations authorizations() {
6873
return this.authorizations;
6974
}
7075

76+
@Override
77+
public Groups groups() {
78+
return this.groups;
79+
}
80+
7181
@Override
7282
public IdentityProviders identityProviders() {
7383
return this.identityProviders;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2013-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.cloudfoundry.reactor.uaa.groups;
18+
19+
import com.fasterxml.jackson.databind.ObjectMapper;
20+
import org.cloudfoundry.reactor.uaa.AbstractUaaOperations;
21+
import org.cloudfoundry.reactor.util.AuthorizationProvider;
22+
import org.cloudfoundry.uaa.groups.CreateGroupRequest;
23+
import org.cloudfoundry.uaa.groups.CreateGroupResponse;
24+
import org.cloudfoundry.uaa.groups.DeleteGroupRequest;
25+
import org.cloudfoundry.uaa.groups.DeleteGroupResponse;
26+
import org.cloudfoundry.uaa.groups.GetGroupRequest;
27+
import org.cloudfoundry.uaa.groups.GetGroupResponse;
28+
import org.cloudfoundry.uaa.groups.Groups;
29+
import org.cloudfoundry.uaa.groups.ListGroupsRequest;
30+
import org.cloudfoundry.uaa.groups.ListGroupsResponse;
31+
import org.cloudfoundry.uaa.groups.UpdateGroupRequest;
32+
import org.cloudfoundry.uaa.groups.UpdateGroupResponse;
33+
import reactor.core.publisher.Mono;
34+
import reactor.io.netty.http.HttpClient;
35+
36+
/**
37+
* The Reactor-based implementation of {@link Groups}
38+
*/
39+
public class ReactorGroups extends AbstractUaaOperations implements Groups {
40+
41+
/**
42+
* Creates an instance
43+
*
44+
* @param authorizationProvider the {@link AuthorizationProvider} to use when communicating with the server
45+
* @param httpClient the {@link HttpClient} to use when communicating with the server
46+
* @param objectMapper the {@link ObjectMapper} to use when communicating with the server
47+
* @param root the root URI of the server. Typically something like {@code https://uaa.run.pivotal.io}.
48+
*/
49+
public ReactorGroups(AuthorizationProvider authorizationProvider, HttpClient httpClient, ObjectMapper objectMapper, Mono<String> root) {
50+
super(authorizationProvider, httpClient, objectMapper, root);
51+
}
52+
53+
@Override
54+
public Mono<CreateGroupResponse> create(CreateGroupRequest request) {
55+
return post(request, CreateGroupResponse.class, builder -> builder.pathSegment("Groups"));
56+
}
57+
58+
@Override
59+
public Mono<DeleteGroupResponse> delete(DeleteGroupRequest request) {
60+
return delete(request, DeleteGroupResponse.class, builder -> builder.pathSegment("Groups", request.getGroupId()));
61+
}
62+
63+
@Override
64+
public Mono<GetGroupResponse> get(GetGroupRequest request) {
65+
return get(request, GetGroupResponse.class, builder -> builder.pathSegment("Groups", request.getGroupId()));
66+
}
67+
68+
@Override
69+
public Mono<ListGroupsResponse> list(ListGroupsRequest request) {
70+
return get(request, ListGroupsResponse.class, builder -> builder.pathSegment("Groups"));
71+
}
72+
73+
@Override
74+
public Mono<UpdateGroupResponse> update(UpdateGroupRequest request) {
75+
return put(request, UpdateGroupResponse.class, builder -> builder.pathSegment("Groups", request.getGroupId()));
76+
}
77+
78+
}

cloudfoundry-client-spring/src/test/java/org/cloudfoundry/reactor/uaa/ReactorUaaClientTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public void authorizations() {
3030
assertNotNull(this.client.authorizations());
3131
}
3232

33+
@Test
34+
public void groups() {
35+
assertNotNull(this.client.groups());
36+
}
37+
3338
@Test
3439
public void identityProviders() {
3540
assertNotNull(this.client.identityProviders());

0 commit comments

Comments
 (0)