Skip to content

Commit a6e6258

Browse files
committed
Using lombok builder and proper dependency management
1 parent 1bb588e commit a6e6258

File tree

10 files changed

+384
-723
lines changed

10 files changed

+384
-723
lines changed

iam/iam-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>com.salesforce.multicloudj</groupId>
1111
<artifactId>iam</artifactId>
12-
<version>${revision}</version>
12+
<version>0.2.10-SNAPSHOT</version>
1313
<relativePath>../pom.xml</relativePath>
1414
</parent>
1515

Lines changed: 40 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,60 @@
11
package com.salesforce.multicloudj.iam.model;
22

3-
import lombok.Getter;
4-
53
import java.util.Objects;
4+
import lombok.Builder;
5+
import lombok.Getter;
66

77
/**
88
* Optional configuration for identity creation operations.
99
*
1010
* <p>This class provides additional options that can be set during identity creation,
1111
* such as path specifications, session duration limits, and permission boundaries.
1212
*
13-
* <p>Permission boundary identifiers are provider-specific and translated internally:
14-
* - AWS: IAM Policy ARN format (arn:aws:iam::account:policy/name)
15-
* - GCP: Organization Policy constraint name or IAM Condition expression
16-
* - AliCloud: Not supported (AliCloud RAM does not have permission boundaries)
13+
* <p>Permission boundary identifiers are provider-specific and translated internally
14+
* by the implementation layer. The client accepts the native format for the target
15+
* cloud provider.
1716
*
18-
* <p>Usage examples by provider:
17+
* <p>Usage example:
1918
* <pre>
20-
* // AWS Example
21-
* CreateOptions awsOptions = CreateOptions.builder()
22-
* .path("/foo/")
23-
* .maxSessionDuration(43200) // 12 hours
24-
* .permissionBoundary("arn:aws:iam::123456789012:policy/PowerUserBoundary")
25-
* .build();
26-
*
27-
* // GCP Example (using organization policy constraint)
28-
* CreateOptions gcpOptions = CreateOptions.builder()
29-
* .path("/foo/")
30-
* .maxSessionDuration(3600) // 1 hour
31-
* .permissionBoundary("constraints/compute.restrictLoadBalancerCreationForTypes")
32-
* .build();
33-
*
34-
* // AliCloud Example (permission boundaries not supported)
35-
* CreateOptions aliOptions = CreateOptions.builder()
36-
* .path("/foo/")
37-
* .maxSessionDuration(7200) // 2 hours
38-
* // .permissionBoundary() - Not supported in AliCloud RAM
19+
* CreateOptions options = CreateOptions.builder()
20+
* .path("/service-roles/")
21+
* .maxSessionDuration(3600) // 1 hour in seconds
22+
* .permissionBoundary("policy-identifier") // Provider-specific format
3923
* .build();
4024
* </pre>
4125
*/
4226
@Getter
27+
@Builder
4328
public class CreateOptions {
44-
private final String path;
45-
private final Integer maxSessionDuration;
46-
private final String permissionBoundary;
47-
48-
private CreateOptions(Builder builder) {
49-
this.path = builder.path;
50-
this.maxSessionDuration = builder.maxSessionDuration;
51-
this.permissionBoundary = builder.permissionBoundary;
52-
}
53-
54-
/**
55-
* Creates a new builder for CreateOptions.
56-
*
57-
* @return a new Builder instance
58-
*/
59-
public static Builder builder() {
60-
return new Builder();
29+
private final String path;
30+
private final Integer maxSessionDuration;
31+
private final String permissionBoundary;
32+
33+
@Override
34+
public boolean equals(Object o) {
35+
if (this == o) {
36+
return true;
6137
}
62-
63-
64-
@Override
65-
public boolean equals(Object o) {
66-
if (this == o) return true;
67-
if (o == null || getClass() != o.getClass()) return false;
68-
CreateOptions that = (CreateOptions) o;
69-
return Objects.equals(path, that.path) &&
70-
Objects.equals(maxSessionDuration, that.maxSessionDuration) &&
71-
Objects.equals(permissionBoundary, that.permissionBoundary);
72-
}
73-
74-
@Override
75-
public int hashCode() {
76-
return Objects.hash(path, maxSessionDuration, permissionBoundary);
77-
}
78-
79-
@Override
80-
public String toString() {
81-
return "CreateOptions{" +
82-
"path='" + path + '\'' +
83-
", maxSessionDuration=" + maxSessionDuration +
84-
", permissionBoundary='" + permissionBoundary + '\'' +
85-
'}';
86-
}
87-
88-
/**
89-
* Builder class for CreateOptions.
90-
*/
91-
public static class Builder {
92-
private String path;
93-
private Integer maxSessionDuration;
94-
private String permissionBoundary;
95-
96-
private Builder() {
97-
}
98-
99-
/**
100-
* Sets the path for the identity.
101-
*
102-
* @param path the path (e.g., "/foo/") for organizing identities
103-
* @return this Builder instance
104-
*/
105-
public Builder path(String path) {
106-
this.path = path;
107-
return this;
108-
}
109-
110-
/**
111-
* Sets the maximum session duration in seconds.
112-
*
113-
* @param maxSessionDuration the maximum session duration (typically up to 12 hours = 43200 seconds)
114-
* @return this Builder instance
115-
*/
116-
public Builder maxSessionDuration(Integer maxSessionDuration) {
117-
this.maxSessionDuration = maxSessionDuration;
118-
return this;
119-
}
120-
121-
/**
122-
* Sets the permission boundary policy identifier.
123-
*
124-
* @param permissionBoundary the cloud-native identifier of the policy that acts as a permission boundary
125-
* (AWS: policy ARN, GCP: constraint name, AliCloud: not supported)
126-
* @return this Builder instance
127-
*/
128-
public Builder permissionBoundary(String permissionBoundary) {
129-
this.permissionBoundary = permissionBoundary;
130-
return this;
131-
}
132-
133-
/**
134-
* Builds and returns a CreateOptions instance.
135-
*
136-
* @return a new CreateOptions instance
137-
*/
138-
public CreateOptions build() {
139-
return new CreateOptions(this);
140-
}
38+
if (o == null || getClass() != o.getClass()) {
39+
return false;
14140
}
41+
CreateOptions that = (CreateOptions) o;
42+
return Objects.equals(path, that.path)
43+
&& Objects.equals(maxSessionDuration, that.maxSessionDuration)
44+
&& Objects.equals(permissionBoundary, that.permissionBoundary);
45+
}
46+
47+
@Override
48+
public int hashCode() {
49+
return Objects.hash(path, maxSessionDuration, permissionBoundary);
50+
}
51+
52+
@Override
53+
public String toString() {
54+
return "CreateOptions{"
55+
+ "path='" + path + '\''
56+
+ ", maxSessionDuration=" + maxSessionDuration
57+
+ ", permissionBoundary='" + permissionBoundary + '\''
58+
+ '}';
59+
}
14260
}

0 commit comments

Comments
 (0)