|
| 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 | +} |
0 commit comments