|
| 1 | +/* |
| 2 | + * Copyright 2013-2023 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 5 | + * in compliance with the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 10 | + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 11 | + * or implied. See the License for the specific language governing permissions and limitations under |
| 12 | + * the License. |
| 13 | + */ |
| 14 | + |
| 15 | +package org.cloudfoundry.reactor.client.v3.securitygroups; |
| 16 | + |
| 17 | +import org.cloudfoundry.client.v3.securitygroups.SecurityGroupsV3; |
| 18 | +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; |
| 19 | +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; |
| 20 | +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; |
| 21 | +import org.cloudfoundry.client.v3.securitygroups.DeleteSecurityGroupRequest; |
| 22 | +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; |
| 23 | +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; |
| 24 | +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; |
| 25 | +import org.cloudfoundry.client.v3.servicebindings.ServiceBindingsV3; |
| 26 | +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; |
| 27 | +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; |
| 28 | +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; |
| 29 | +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsResponse; |
| 30 | +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; |
| 31 | +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsResponse; |
| 32 | +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; |
| 33 | +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupResponse; |
| 34 | +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; |
| 35 | +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupResponse; |
| 36 | +import org.cloudfoundry.client.v3.securitygroups.UnbindRunningSecurityGroupRequest; |
| 37 | +import org.cloudfoundry.client.v3.securitygroups.UnbindStagingSecurityGroupRequest; |
| 38 | +import org.cloudfoundry.reactor.ConnectionContext; |
| 39 | +import org.cloudfoundry.reactor.TokenProvider; |
| 40 | +import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; |
| 41 | +import reactor.core.publisher.Mono; |
| 42 | +import java.util.Map; |
| 43 | + |
| 44 | +/** |
| 45 | + * The Reactor-based implementation of {@link ServiceBindingsV3} |
| 46 | + */ |
| 47 | +public final class ReactorSecurityGroupsV3 extends AbstractClientV3Operations |
| 48 | + implements SecurityGroupsV3 { |
| 49 | + |
| 50 | + /** |
| 51 | + * Creates an instance |
| 52 | + * |
| 53 | + * @param connectionContext the {@link ConnectionContext} to use when communicating with the |
| 54 | + * server |
| 55 | + * @param root the root URI of the server. Typically something like |
| 56 | + * {@code https://api.run.pivotal.io}. |
| 57 | + * @param tokenProvider the {@link TokenProvider} to use when communicating with the server |
| 58 | + * @param requestTags map with custom http headers which will be added to web request |
| 59 | + */ |
| 60 | + public ReactorSecurityGroupsV3(ConnectionContext connectionContext, Mono<String> root, |
| 61 | + TokenProvider tokenProvider, Map<String, String> requestTags) { |
| 62 | + super(connectionContext, root, tokenProvider, requestTags); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public Mono<CreateSecurityGroupResponse> create(CreateSecurityGroupRequest request) { |
| 67 | + return post(request, CreateSecurityGroupResponse.class, |
| 68 | + builder -> builder.pathSegment("security_groups")).checkpoint(); |
| 69 | + |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + public Mono<GetSecurityGroupResponse> get(GetSecurityGroupRequest request) { |
| 74 | + return get(request, GetSecurityGroupResponse.class, builder -> builder |
| 75 | + .pathSegment("security_groups", request.getSecurityGroupId())) |
| 76 | + .checkpoint(); |
| 77 | + |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public Mono<ListSecurityGroupsResponse> list(ListSecurityGroupsRequest request) { |
| 82 | + return get(request, ListSecurityGroupsResponse.class, |
| 83 | + builder -> builder.pathSegment("security_groups")).checkpoint(); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public Mono<UpdateSecurityGroupResponse> update(UpdateSecurityGroupRequest request) { |
| 88 | + return patch(request, UpdateSecurityGroupResponse.class, builder -> builder |
| 89 | + .pathSegment("security_groups", request.getSecurityGroupId())) |
| 90 | + .checkpoint(); |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + public Mono<String> delete(DeleteSecurityGroupRequest request) { |
| 95 | + return delete(request, builder -> builder.pathSegment("security_groups", |
| 96 | + request.getSecurityGroupId())).checkpoint(); |
| 97 | + |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public Mono<BindRunningSecurityGroupResponse> bindRunningSecurityGroup( |
| 102 | + BindRunningSecurityGroupRequest request) { |
| 103 | + return post(request, BindRunningSecurityGroupResponse.class, |
| 104 | + builder -> builder.pathSegment("security_groups", |
| 105 | + request.getSecurityGroupId(), "relationships", |
| 106 | + "running_spaces")).checkpoint(); |
| 107 | + } |
| 108 | + |
| 109 | + @Override |
| 110 | + public Mono<BindStagingSecurityGroupResponse> bindStagingSecurityGroup( |
| 111 | + BindStagingSecurityGroupRequest request) { |
| 112 | + return post(request, BindStagingSecurityGroupResponse.class, |
| 113 | + builder -> builder.pathSegment("security_groups", |
| 114 | + request.getSecurityGroupId(), "relationships", |
| 115 | + "staging_spaces")).checkpoint(); |
| 116 | + } |
| 117 | + |
| 118 | + @Override |
| 119 | + public Mono<Void> unbindStagingSecurityGroup(UnbindStagingSecurityGroupRequest request) { |
| 120 | + return delete(request, Void.class, |
| 121 | + builder -> builder.pathSegment("security_groups", |
| 122 | + request.getSecurityGroupId(), "relationships", |
| 123 | + "staging_spaces", request.getSpaceId())) |
| 124 | + .checkpoint(); |
| 125 | + } |
| 126 | + |
| 127 | + @Override |
| 128 | + public Mono<Void> unbindRunningSecurityGroup(UnbindRunningSecurityGroupRequest request) { |
| 129 | + return delete(request, Void.class, |
| 130 | + builder -> builder.pathSegment("security_groups", |
| 131 | + request.getSecurityGroupId(), "relationships", |
| 132 | + "running_spaces", request.getSpaceId())) |
| 133 | + .checkpoint(); |
| 134 | + } |
| 135 | + |
| 136 | + @Override |
| 137 | + public Mono<ListRunningSecurityGroupsResponse> listRunning( |
| 138 | + ListRunningSecurityGroupsRequest request) { |
| 139 | + return get(request, ListRunningSecurityGroupsResponse.class, |
| 140 | + builder -> builder.pathSegment("spaces", request.getSpaceId(), |
| 141 | + "running_security_groups")).checkpoint(); |
| 142 | + } |
| 143 | + |
| 144 | + @Override |
| 145 | + public Mono<ListStagingSecurityGroupsResponse> listStaging( |
| 146 | + ListStagingSecurityGroupsRequest request) { |
| 147 | + return get(request, ListStagingSecurityGroupsResponse.class, |
| 148 | + builder -> builder.pathSegment("spaces", request.getSpaceId(), |
| 149 | + "staging_security_groups")).checkpoint(); |
| 150 | + } |
| 151 | +} |
0 commit comments