Skip to content

Commit ff7fb96

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 1445 b: refs/heads/master c: e625c20 h: refs/heads/master i: 1443: f6ff939
1 parent 5419e81 commit ff7fb96

7 files changed

Lines changed: 102 additions & 19 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9d6fbff4ea8172f01a64a51dc78f58131e5120f0
2+
refs/heads/master: e625c20f67ee7b096f944ed744d95ffba6ad3f6d
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ProjectInfo.java

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,24 @@ public class ProjectInfo implements Serializable {
4141
private final Long createTimeMillis;
4242
private final ResourceId parent;
4343

44+
/**
45+
* The project lifecycle state.
46+
*
47+
* <ul>
48+
* <li>LIFECYCLE_STATE_UNSPECIFIED: only used/useful for distinguishing unset values
49+
* <li>ACTIVE: the normal and active state
50+
* <li>DELETE_REQUESTED: the project has been marked for deletion by the user or by the system
51+
* (Google Cloud Platform). This can generally be reversed by calling
52+
* {@link ResourceManager#undelete}.
53+
* <li>DELETE_IN_PROGRESS: the process of deleting the project has begun. Reversing the deletion
54+
* is no longer possible.
55+
* <ul>
56+
*/
4457
public enum State {
4558
LIFECYCLE_STATE_UNSPECIFIED,
4659
ACTIVE,
4760
DELETE_REQUESTED,
48-
DELETE_IN_PROGRESS;
61+
DELETE_IN_PROGRESS
4962
}
5063

5164
public static class Builder {
@@ -58,34 +71,68 @@ public static class Builder {
5871
private ResourceId parent;
5972

6073
Builder() {
61-
labels = new HashMap<String, String>();
74+
labels = new HashMap<>();
6275
}
6376

77+
/**
78+
* Set the user-assigned name of the project.
79+
*
80+
* This field is optional and can remain unset. Allowed characters are: lowercase and uppercase
81+
* letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. This
82+
* field can be changed after project creation.
83+
*/
6484
public Builder name(String name) {
6585
this.name = name;
6686
return this;
6787
}
6888

89+
/**
90+
* Set the unique, user-assigned ID of the project.
91+
*
92+
* The ID must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter.
93+
* Trailing hyphens are prohibited. This field cannot be changed after the server creates the
94+
* project.
95+
*/
6996
public Builder id(String id) {
7097
this.id = id;
7198
return this;
7299
}
73100

101+
/**
102+
* Add a label associated with this project.
103+
*
104+
* See {@link #labels} for label restrictions.
105+
*/
74106
public Builder addLabel(String key, String value) {
75107
this.labels.put(key, value);
76108
return this;
77109
}
78110

111+
/**
112+
* Remove a label associated with this project.
113+
*/
79114
public Builder removeLabel(String key) {
80115
this.labels.remove(key);
81116
return this;
82117
}
83118

119+
/**
120+
* Clear the labels associated with this project.
121+
*/
84122
public Builder clearLabels() {
85123
this.labels.clear();
86124
return this;
87125
}
88126

127+
/**
128+
* Set the labels associated with this project.
129+
*
130+
* Label keys must be between 1 and 63 characters long and must conform to the following regular
131+
* expression: [a-z]([-a-z0-9]*[a-z0-9])?. Label values must be between 0 and 63 characters long
132+
* and must conform to the regular expression ([a-z]([-a-z0-9]*[a-z0-9])?)?. No more than 256
133+
* labels can be associated with a given resource. This field can be changed after project
134+
* creation.
135+
*/
89136
public Builder labels(Map<String, String> labels) {
90137
this.labels = Maps.newHashMap(checkNotNull(labels));
91138
return this;
@@ -106,6 +153,15 @@ Builder createTimeMillis(Long createTimeMillis) {
106153
return this;
107154
}
108155

156+
/**
157+
* Set the parent of the project.
158+
*
159+
* If this field is left unset in a project creation request, the server will set this field by
160+
* default to the creator of the project. The parent cannot be changed after the server creates
161+
* the project. When calling {@link ResourceManager#replace}, be sure to set the parent of the
162+
* new ProjectInfo instance. Leaving the parent unset or setting it to null in a replace request
163+
* will cause an error.
164+
*/
109165
public Builder parent(ResourceId parent) {
110166
this.parent = parent;
111167
return this;
@@ -126,30 +182,64 @@ public ProjectInfo build() {
126182
this.parent = builder.parent;
127183
}
128184

185+
/**
186+
* Get the unique, user-assigned ID of the project.
187+
*
188+
* This field cannot be changed after the server creates the project.
189+
*/
129190
public String id() {
130191
return id;
131192
}
132193

194+
/**
195+
* Get the user-assigned name of the project.
196+
*
197+
* This field is optional, can remain unset, and can be changed after project creation.
198+
*/
133199
public String name() {
134200
return name;
135201
}
136202

203+
/**
204+
* Get number uniquely identifying the project.
205+
*
206+
* This field is set by the server and is read-only.
207+
*/
137208
public Long number() {
138209
return number;
139210
}
140211

212+
/**
213+
* Get the immutable map of labels associated with this project.
214+
*/
141215
public Map<String, String> labels() {
142216
return labels;
143217
}
144218

219+
/**
220+
* Get the project's lifecycle state.
221+
*
222+
* This is a read-only field. To change the lifecycle state of your project, use the
223+
* {@code delete} or {@code undelete} method.
224+
*/
145225
public State state() {
146226
return state;
147227
}
148228

229+
/**
230+
* Get the project's creation time (in milliseconds).
231+
*
232+
* This field is set by the server and is read-only.
233+
*/
149234
public Long createTimeMillis() {
150235
return createTimeMillis;
151236
}
152237

238+
/**
239+
* Get the parent of the project.
240+
*
241+
* The parent cannot be changed after the server creates the project.
242+
*/
153243
public ResourceId parent() {
154244
return parent;
155245
}

trunk/gcloud-java-resourcemanager/src/main/java/com/google/gcloud/resourcemanager/ResourceId.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,9 @@ public class ResourceId implements Serializable {
2626

2727
private static final long serialVersionUID = 7928469304338358885L;
2828
private final String id;
29-
private final Type type;
29+
private final String type;
3030

31-
public enum Type {
32-
ORGANIZATION,
33-
UNKNOWN;
34-
}
35-
36-
private ResourceId(String id, Type type) {
31+
private ResourceId(String id, String type) {
3732
this.id = checkNotNull(id);
3833
this.type = checkNotNull(type);
3934
}
@@ -42,7 +37,7 @@ public String id() {
4237
return id;
4338
}
4439

45-
public Type type() {
40+
public String type() {
4641
return type;
4742
}
4843

@@ -56,7 +51,7 @@ public int hashCode() {
5651
return Objects.hash(id, type);
5752
}
5853

59-
public static ResourceId of(String id, Type type) {
54+
public static ResourceId of(String id, String type) {
6055
return new ResourceId(id, type);
6156
}
6257

@@ -70,6 +65,6 @@ com.google.api.services.cloudresourcemanager.model.ResourceId toPb() {
7065

7166
static ResourceId fromPb(
7267
com.google.api.services.cloudresourcemanager.model.ResourceId resourceIdPb) {
73-
return new ResourceId(resourceIdPb.getId(), Type.valueOf(resourceIdPb.getType().toUpperCase()));
68+
return new ResourceId(resourceIdPb.getId(), resourceIdPb.getType());
7469
}
7570
}

trunk/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectInfoTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ProjectInfoTest {
3434
private static final Long NUMBER = 123L;
3535
private static final Long CREATE_TIME_MILLIS = 123456789L;
3636
private static final ProjectInfo.State STATE = ProjectInfo.State.DELETE_REQUESTED;
37-
private static final ResourceId PARENT = ResourceId.of("owner-id", ResourceId.Type.ORGANIZATION);
37+
private static final ResourceId PARENT = ResourceId.of("owner-id", "organization");
3838
private static final ProjectInfo FULL_PROJECT_INFO =
3939
ProjectInfo.builder(ID)
4040
.name(NAME)

trunk/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ProjectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class ProjectTest {
4747
private static final Long NUMBER = 123L;
4848
private static final Long CREATE_TIME_MILLIS = 123456789L;
4949
private static final ProjectInfo.State STATE = ProjectInfo.State.DELETE_REQUESTED;
50-
private static final ResourceId PARENT = ResourceId.of("owner-id", ResourceId.Type.ORGANIZATION);
50+
private static final ResourceId PARENT = ResourceId.of("owner-id", "organization");
5151
private static final ProjectInfo PROJECT_INFO =
5252
ProjectInfo.builder(ID)
5353
.name(NAME)

trunk/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/ResourceIdTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public class ResourceIdTest {
2525

2626
private static final String ID = "id";
27-
private static final ResourceId.Type TYPE = ResourceId.Type.ORGANIZATION;
27+
private static final String TYPE = "organization";
2828
private static final ResourceId RESOURCE_ID = ResourceId.of(ID, TYPE);
2929

3030
@Test
@@ -39,7 +39,6 @@ public void testEquals() {
3939
assertEquals(ID, RESOURCE_ID.id());
4040
assertEquals(TYPE, RESOURCE_ID.type());
4141
assertNotEquals(ResourceId.of("another-ID", TYPE), RESOURCE_ID);
42-
assertNotEquals(ResourceId.of(ID, ResourceId.Type.UNKNOWN), RESOURCE_ID);
4342
}
4443

4544
@Test

trunk/gcloud-java-resourcemanager/src/test/java/com/google/gcloud/resourcemanager/SerializationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141

4242
public class SerializationTest {
4343

44-
private static final ResourceId RESOURCE_ID =
45-
ResourceId.of("some id", ResourceId.Type.ORGANIZATION);
44+
private static final ResourceId RESOURCE_ID = ResourceId.of("some id", "organization");
4645
private static final List<Member> OWNER_MEMBER_LIST = ImmutableList.of(
4746
Member.user("[email protected]"), Member.group("[email protected]"));
4847
private static final List<Member> EDITOR_MEMBER_LIST =

0 commit comments

Comments
 (0)