io.cloudshiftdev.awscdk.services.iam.GrantOnPrincipalAndResourceOptions.kt Maven / Gradle / Ivy
The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package io.cloudshiftdev.awscdk.services.iam
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.Any
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
/**
* Options for a grant operation to both identity and resource.
*
* Example:
*
* ```
* // The code below shows an example of how to instantiate this type.
* // The values are placeholders you should change.
* import io.cloudshiftdev.awscdk.services.iam.*;
* Object conditions;
* IGrantable grantable;
* IPrincipal principal;
* IResourceWithPolicy resourceWithPolicy;
* GrantOnPrincipalAndResourceOptions grantOnPrincipalAndResourceOptions =
* GrantOnPrincipalAndResourceOptions.builder()
* .actions(List.of("actions"))
* .grantee(grantable)
* .resource(resourceWithPolicy)
* .resourceArns(List.of("resourceArns"))
* // the properties below are optional
* .conditions(Map.of(
* "conditionsKey", Map.of(
* "conditionsKey", conditions)))
* .resourcePolicyPrincipal(principal)
* .resourceSelfArns(List.of("resourceSelfArns"))
* .build();
* ```
*/
public interface GrantOnPrincipalAndResourceOptions : CommonGrantOptions {
/**
* The resource with a resource policy.
*
* The statement will always be added to the resource policy.
*/
public fun resource(): IResourceWithPolicy
/**
* The principal to use in the statement for the resource policy.
*
* Default: - the principal of the grantee will be used
*/
public fun resourcePolicyPrincipal(): IPrincipal? =
unwrap(this).getResourcePolicyPrincipal()?.let(IPrincipal::wrap)
/**
* When referring to the resource in a resource policy, use this as ARN.
*
* (Depending on the resource type, this needs to be '*' in a resource policy).
*
* Default: Same as regular resource ARNs
*/
public fun resourceSelfArns(): List = unwrap(this).getResourceSelfArns() ?: emptyList()
/**
* A builder for [GrantOnPrincipalAndResourceOptions]
*/
@CdkDslMarker
public interface Builder {
/**
* @param actions The actions to grant.
*/
public fun actions(actions: List)
/**
* @param actions The actions to grant.
*/
public fun actions(vararg actions: String)
/**
* @param conditions Any conditions to attach to the grant.
*/
public fun conditions(conditions: Map>)
/**
* @param grantee The principal to grant to.
*/
public fun grantee(grantee: IGrantable)
/**
* @param resource The resource with a resource policy.
* The statement will always be added to the resource policy.
*/
public fun resource(resource: IResourceWithPolicy)
/**
* @param resourceArns The resource ARNs to grant to.
*/
public fun resourceArns(resourceArns: List)
/**
* @param resourceArns The resource ARNs to grant to.
*/
public fun resourceArns(vararg resourceArns: String)
/**
* @param resourcePolicyPrincipal The principal to use in the statement for the resource policy.
*/
public fun resourcePolicyPrincipal(resourcePolicyPrincipal: IPrincipal)
/**
* @param resourceSelfArns When referring to the resource in a resource policy, use this as ARN.
* (Depending on the resource type, this needs to be '*' in a resource policy).
*/
public fun resourceSelfArns(resourceSelfArns: List)
/**
* @param resourceSelfArns When referring to the resource in a resource policy, use this as ARN.
* (Depending on the resource type, this needs to be '*' in a resource policy).
*/
public fun resourceSelfArns(vararg resourceSelfArns: String)
}
private class BuilderImpl : Builder {
private val cdkBuilder:
software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions.Builder =
software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions.builder()
/**
* @param actions The actions to grant.
*/
override fun actions(actions: List) {
cdkBuilder.actions(actions)
}
/**
* @param actions The actions to grant.
*/
override fun actions(vararg actions: String): Unit = actions(actions.toList())
/**
* @param conditions Any conditions to attach to the grant.
*/
override fun conditions(conditions: Map>) {
cdkBuilder.conditions(conditions)
}
/**
* @param grantee The principal to grant to.
*/
override fun grantee(grantee: IGrantable) {
cdkBuilder.grantee(grantee.let(IGrantable.Companion::unwrap))
}
/**
* @param resource The resource with a resource policy.
* The statement will always be added to the resource policy.
*/
override fun resource(resource: IResourceWithPolicy) {
cdkBuilder.resource(resource.let(IResourceWithPolicy.Companion::unwrap))
}
/**
* @param resourceArns The resource ARNs to grant to.
*/
override fun resourceArns(resourceArns: List) {
cdkBuilder.resourceArns(resourceArns)
}
/**
* @param resourceArns The resource ARNs to grant to.
*/
override fun resourceArns(vararg resourceArns: String): Unit =
resourceArns(resourceArns.toList())
/**
* @param resourcePolicyPrincipal The principal to use in the statement for the resource policy.
*/
override fun resourcePolicyPrincipal(resourcePolicyPrincipal: IPrincipal) {
cdkBuilder.resourcePolicyPrincipal(resourcePolicyPrincipal.let(IPrincipal.Companion::unwrap))
}
/**
* @param resourceSelfArns When referring to the resource in a resource policy, use this as ARN.
* (Depending on the resource type, this needs to be '*' in a resource policy).
*/
override fun resourceSelfArns(resourceSelfArns: List) {
cdkBuilder.resourceSelfArns(resourceSelfArns)
}
/**
* @param resourceSelfArns When referring to the resource in a resource policy, use this as ARN.
* (Depending on the resource type, this needs to be '*' in a resource policy).
*/
override fun resourceSelfArns(vararg resourceSelfArns: String): Unit =
resourceSelfArns(resourceSelfArns.toList())
public fun build(): software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions =
cdkBuilder.build()
}
private class Wrapper(
cdkObject: software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions,
) : CdkObject(cdkObject),
GrantOnPrincipalAndResourceOptions {
/**
* The actions to grant.
*/
override fun actions(): List = unwrap(this).getActions()
/**
* Any conditions to attach to the grant.
*
* Default: - No conditions
*/
override fun conditions(): Map> = unwrap(this).getConditions() ?:
emptyMap()
/**
* The principal to grant to.
*
* Default: if principal is undefined, no work is done.
*/
override fun grantee(): IGrantable = unwrap(this).getGrantee().let(IGrantable::wrap)
/**
* The resource with a resource policy.
*
* The statement will always be added to the resource policy.
*/
override fun resource(): IResourceWithPolicy =
unwrap(this).getResource().let(IResourceWithPolicy::wrap)
/**
* The resource ARNs to grant to.
*/
override fun resourceArns(): List = unwrap(this).getResourceArns()
/**
* The principal to use in the statement for the resource policy.
*
* Default: - the principal of the grantee will be used
*/
override fun resourcePolicyPrincipal(): IPrincipal? =
unwrap(this).getResourcePolicyPrincipal()?.let(IPrincipal::wrap)
/**
* When referring to the resource in a resource policy, use this as ARN.
*
* (Depending on the resource type, this needs to be '*' in a resource policy).
*
* Default: Same as regular resource ARNs
*/
override fun resourceSelfArns(): List = unwrap(this).getResourceSelfArns() ?:
emptyList()
}
public companion object {
public operator fun invoke(block: Builder.() -> Unit = {}): GrantOnPrincipalAndResourceOptions {
val builderImpl = BuilderImpl()
return Wrapper(builderImpl.apply(block).build())
}
internal
fun wrap(cdkObject: software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions):
GrantOnPrincipalAndResourceOptions = CdkObjectWrappers.wrap(cdkObject) as?
GrantOnPrincipalAndResourceOptions ?: Wrapper(cdkObject)
internal fun unwrap(wrapped: GrantOnPrincipalAndResourceOptions):
software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions = (wrapped as
CdkObject).cdkObject as
software.amazon.awscdk.services.iam.GrantOnPrincipalAndResourceOptions
}
}