Skip to content

Commit

Permalink
adding update security group api
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslav-tomov committed Jul 7, 2023
1 parent 696c8b0 commit c4fe290
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void list() {
.id("a89a788e-671f-4549-814d-e34c1b2f533a")
.createdAt("2020-02-20T17:42:08Z")
.updatedAt("2020-02-20T17:42:08Z")
.relationships(Relationships.builder().build())
.globallyEnabled(GloballyEnabled
.builder()
.staging(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public interface SecurityGroupsV3 {
*/
Mono<ListSecurityGroupsResponse> list(ListSecurityGroupsRequest request);

/**
* Makes the <a href=
*
* "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#update-a-security-group">Update
* Security Groups</a> request
*
* @param request the Update Security Group request
* @return the response from the List Security Group request
*/
Mono<UpdateSecurityGroupResponse> update(UpdateSecurityGroupRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import org.cloudfoundry.Nullable;
import org.immutables.value.Value;

/**
Expand All @@ -17,13 +19,15 @@ abstract class _GloballyEnabled {
* applications
*/
@JsonProperty("running")
@Nullable
abstract Boolean getRunning();

/**
* Specifies whether the group should be applied globally to all staging
* applications
*/
@JsonProperty("staging")
@Nullable
abstract Boolean getStaging();

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

import org.immutables.value.Value;

import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The request payload for the Create a Security Group operation
*/
@JsonSerialize
@Value.Immutable
abstract class _UpdateSecurityGroupRequest {
/**
* Name of the security group
*/
@JsonProperty("name")
abstract String getName();

/**
* Object that controls if the group is applied globally to the lifecycle of all
* applications
*/
@JsonProperty("globally_enabled")
abstract GloballyEnabled getGloballyEnabled();

/**
* Rules that will be applied by this security group
*/
@JsonProperty("rules")
abstract List<Rule> getRules();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2013-2021 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.securitygroups;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.immutables.value.Value;

/**
* The response payload for the Update a Security Group operation
*/
@JsonDeserialize
@Value.Immutable
abstract class _UpdateSecurityGroupResponse extends SecurityGroup {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.cloudfoundry.client.v3.securitygroups;

import org.junit.Test;

public class UpdateSecurityGroupRequestTest {

@Test(expected = IllegalStateException.class)
public void noName() {
UpdateSecurityGroupRequest.builder()
.build();
}

@Test()
public void valid() {
UpdateSecurityGroupRequest.builder()
.name("my-group0")
.globallyEnabled(GloballyEnabled
.builder()
.running(true)
.build())
.rules(Rule.builder()
.protocol(Protocol.TCP)
.destination("10.10.10.0/24")
.ports("443,80,8080")
.build())
.rules(Rule.builder()
.protocol(Protocol.ICMP)
.destination("10.10.10.0/24")
.description("Allow ping requests to private services")
.type(8)
.code(0)
.build())
.build();

}

}

0 comments on commit c4fe290

Please sign in to comment.