-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(IAM Policy Management): add nested conditions to rule.conditions (#…
…221) * fix(IAM Policy Management): Added nest conditions to rule.conditions Signed-off-by: Shaun Colley <[email protected]>
- Loading branch information
Showing
12 changed files
with
618 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
.../java/com/ibm/cloud/platform_services/iam_policy_management/v1/model/NestedCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2023. | ||
* | ||
* 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 com.ibm.cloud.platform_services.iam_policy_management.v1.model; | ||
|
||
import java.util.List; | ||
|
||
import com.ibm.cloud.sdk.core.service.model.GenericModel; | ||
|
||
/** | ||
* Condition that specifies additional conditions or RuleAttribute to grant access.s. | ||
* | ||
* Classes which extend this class: | ||
* - NestedConditionRuleAttribute | ||
* - NestedConditionRuleWithConditions | ||
*/ | ||
public class NestedCondition extends GenericModel { | ||
|
||
/** | ||
* The operator of an attribute. | ||
*/ | ||
public interface Operator { | ||
/** timeLessThan. */ | ||
String TIMELESSTHAN = "timeLessThan"; | ||
/** timeLessThanOrEquals. */ | ||
String TIMELESSTHANOREQUALS = "timeLessThanOrEquals"; | ||
/** timeGreaterThan. */ | ||
String TIMEGREATERTHAN = "timeGreaterThan"; | ||
/** timeGreaterThanOrEquals. */ | ||
String TIMEGREATERTHANOREQUALS = "timeGreaterThanOrEquals"; | ||
/** dateTimeLessThan. */ | ||
String DATETIMELESSTHAN = "dateTimeLessThan"; | ||
/** dateTimeLessThanOrEquals. */ | ||
String DATETIMELESSTHANOREQUALS = "dateTimeLessThanOrEquals"; | ||
/** dateTimeGreaterThan. */ | ||
String DATETIMEGREATERTHAN = "dateTimeGreaterThan"; | ||
/** dateTimeGreaterThanOrEquals. */ | ||
String DATETIMEGREATERTHANOREQUALS = "dateTimeGreaterThanOrEquals"; | ||
/** dayOfWeekEquals. */ | ||
String DAYOFWEEKEQUALS = "dayOfWeekEquals"; | ||
/** dayOfWeekAnyOf. */ | ||
String DAYOFWEEKANYOF = "dayOfWeekAnyOf"; | ||
} | ||
|
||
protected String key; | ||
protected String operator; | ||
protected Object value; | ||
protected List<RuleAttribute> conditions; | ||
|
||
protected NestedCondition() { } | ||
|
||
/** | ||
* Gets the key. | ||
* | ||
* The name of an attribute. | ||
* | ||
* @return the key | ||
*/ | ||
public String key() { | ||
return key; | ||
} | ||
|
||
/** | ||
* Gets the operator. | ||
* | ||
* The operator of an attribute. | ||
* | ||
* @return the operator | ||
*/ | ||
public String operator() { | ||
return operator; | ||
} | ||
|
||
/** | ||
* Gets the value. | ||
* | ||
* The value of a rule or resource attribute; can be boolean or string for resource attribute. Can be string or an | ||
* array of strings (e.g., array of days to permit access) for rule attribute. | ||
* | ||
* @return the value | ||
*/ | ||
public Object value() { | ||
return value; | ||
} | ||
|
||
/** | ||
* Gets the conditions. | ||
* | ||
* List of conditions associated with a policy, e.g., time-based conditions that grant access over a certain time | ||
* period. | ||
* | ||
* @return the conditions | ||
*/ | ||
public List<RuleAttribute> conditions() { | ||
return conditions; | ||
} | ||
} | ||
|
151 changes: 151 additions & 0 deletions
151
.../cloud/platform_services/iam_policy_management/v1/model/NestedConditionRuleAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2023. | ||
* | ||
* 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 com.ibm.cloud.platform_services.iam_policy_management.v1.model; | ||
|
||
/** | ||
* Rule that specifies additional access granted (e.g., time-based condition). | ||
*/ | ||
public class NestedConditionRuleAttribute extends NestedCondition { | ||
|
||
/** | ||
* The operator of an attribute. | ||
*/ | ||
public interface Operator { | ||
/** timeLessThan. */ | ||
String TIMELESSTHAN = "timeLessThan"; | ||
/** timeLessThanOrEquals. */ | ||
String TIMELESSTHANOREQUALS = "timeLessThanOrEquals"; | ||
/** timeGreaterThan. */ | ||
String TIMEGREATERTHAN = "timeGreaterThan"; | ||
/** timeGreaterThanOrEquals. */ | ||
String TIMEGREATERTHANOREQUALS = "timeGreaterThanOrEquals"; | ||
/** dateTimeLessThan. */ | ||
String DATETIMELESSTHAN = "dateTimeLessThan"; | ||
/** dateTimeLessThanOrEquals. */ | ||
String DATETIMELESSTHANOREQUALS = "dateTimeLessThanOrEquals"; | ||
/** dateTimeGreaterThan. */ | ||
String DATETIMEGREATERTHAN = "dateTimeGreaterThan"; | ||
/** dateTimeGreaterThanOrEquals. */ | ||
String DATETIMEGREATERTHANOREQUALS = "dateTimeGreaterThanOrEquals"; | ||
/** dayOfWeekEquals. */ | ||
String DAYOFWEEKEQUALS = "dayOfWeekEquals"; | ||
/** dayOfWeekAnyOf. */ | ||
String DAYOFWEEKANYOF = "dayOfWeekAnyOf"; | ||
} | ||
|
||
|
||
/** | ||
* Builder. | ||
*/ | ||
public static class Builder { | ||
private String key; | ||
private String operator; | ||
private Object value; | ||
|
||
/** | ||
* Instantiates a new Builder from an existing NestedConditionRuleAttribute instance. | ||
* | ||
* @param nestedConditionRuleAttribute the instance to initialize the Builder with | ||
*/ | ||
public Builder(NestedCondition nestedConditionRuleAttribute) { | ||
this.key = nestedConditionRuleAttribute.key; | ||
this.operator = nestedConditionRuleAttribute.operator; | ||
this.value = nestedConditionRuleAttribute.value; | ||
} | ||
|
||
/** | ||
* Instantiates a new builder. | ||
*/ | ||
public Builder() { | ||
} | ||
|
||
/** | ||
* Instantiates a new builder with required properties. | ||
* | ||
* @param key the key | ||
* @param operator the operator | ||
* @param value the value | ||
*/ | ||
public Builder(String key, String operator, Object value) { | ||
this.key = key; | ||
this.operator = operator; | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Builds a NestedConditionRuleAttribute. | ||
* | ||
* @return the new NestedConditionRuleAttribute instance | ||
*/ | ||
public NestedConditionRuleAttribute build() { | ||
return new NestedConditionRuleAttribute(this); | ||
} | ||
|
||
/** | ||
* Set the key. | ||
* | ||
* @param key the key | ||
* @return the NestedConditionRuleAttribute builder | ||
*/ | ||
public Builder key(String key) { | ||
this.key = key; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the operator. | ||
* | ||
* @param operator the operator | ||
* @return the NestedConditionRuleAttribute builder | ||
*/ | ||
public Builder operator(String operator) { | ||
this.operator = operator; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the value. | ||
* | ||
* @param value the value | ||
* @return the NestedConditionRuleAttribute builder | ||
*/ | ||
public Builder value(Object value) { | ||
this.value = value; | ||
return this; | ||
} | ||
} | ||
|
||
protected NestedConditionRuleAttribute() { } | ||
|
||
protected NestedConditionRuleAttribute(Builder builder) { | ||
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.key, | ||
"key cannot be null"); | ||
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.operator, | ||
"operator cannot be null"); | ||
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.value, | ||
"value cannot be null"); | ||
key = builder.key; | ||
operator = builder.operator; | ||
value = builder.value; | ||
} | ||
|
||
/** | ||
* New builder. | ||
* | ||
* @return a NestedConditionRuleAttribute builder | ||
*/ | ||
public Builder newBuilder() { | ||
return new Builder(this); | ||
} | ||
} | ||
|
Oops, something went wrong.