Skip to content

Commit

Permalink
adding bind running/staging security group v3 api
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslav-tomov authored Jul 10, 2023
1 parent 53000cb commit 4f5437d
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.cloudfoundry.client.v3.ToManyRelationship;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@JsonSerialize
public abstract class AbstractBindSecurityGroupRequest {

/**
* The Security Group id
*/
@JsonIgnore
abstract String getSecurityGroupId();

/**
* A relationship to the spaces where the security_group is applied to
* applications during runtime
*/
@JsonProperty("data")
abstract ToManyRelationship getBoundSpaces();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.cloudfoundry.Nullable;
import org.cloudfoundry.client.v3.ToManyRelationship;

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

@JsonDeserialize
public abstract class AbstractBindSecurityGroupResponse {

/**
* A relationship to the spaces where the security_group is applied to
* applications during runtime
*/
@JsonProperty("data")
abstract ToManyRelationship getBoundSpaces();

/**
* When the resource was last updated
*/
@JsonProperty("updated_at")
@Nullable
public abstract String getUpdatedAt();
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,24 @@ public interface SecurityGroupsV3 {
* @return the response from the List Security Group request
*/
Mono<String> delete(DeleteSecurityGroupRequest request);

/**
* Makes the <a href=
* "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#bind-a-staging-security-group-to-spaces">Bind
* Staging Security Group</a> request
*
* @param request the Bind Staging Security Group request
* @return the response from the Bind Staging Security Group request
*/
Mono<BindStagingSecurityGroupResponse> bindStagingSecurityGroup(BindStagingSecurityGroupRequest request);

/**
* Makes the <a href=
* "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#bind-a-running-security-group-to-spaces">Bind
* Running Security Group</a> request
*
* @param request the Bind Running Security Group request
* @return the response from the Bind Running Security Group request
*/
Mono<BindStagingSecurityGroupResponse> bindRunningSecurityGroup(BindStagingSecurityGroupRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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;

@Value.Immutable
abstract class _BindRunningSecurityGroupRequest extends AbstractBindSecurityGroupRequest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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;

@Value.Immutable
public abstract class _BindRunningSecurityGroupResponse extends AbstractBindSecurityGroupResponse {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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;

@Value.Immutable
abstract class _BindStagingSecurityGroupRequest extends AbstractBindSecurityGroupRequest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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;

@Value.Immutable
public abstract class _BindStagingSecurityGroupResponse extends AbstractBindSecurityGroupResponse {

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

import org.cloudfoundry.client.v3.ToManyRelationship;
import org.cloudfoundry.client.v3.Relationship;
import org.junit.Test;

public class BindRunningSecurityGroupRequestTest {

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

@Test
public void valid() {
BindRunningSecurityGroupRequest.builder()
.securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a")
.boundSpaces(ToManyRelationship.builder()
.data(Relationship.builder()
.id("space-guid-1")
.build())
.build())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.cloudfoundry.client.v3.securitygroups;

import org.cloudfoundry.client.v3.ToManyRelationship;
import org.cloudfoundry.client.v3.Relationship;
import org.junit.Test;

public class BindStagingSecurityGroupRequestTest {

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

@Test
public void valid() {
BindStagingSecurityGroupRequest.builder()
.securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a")
.boundSpaces(ToManyRelationship.builder()
.data(Relationship.builder()
.id("space-guid-1")
.build())
.build())
.build();
}
}

0 comments on commit 4f5437d

Please sign in to comment.