Skip to content

Commit

Permalink
Minor docs and tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Dec 17, 2015
1 parent 0d2cd39 commit f5bd555
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions gcloud-java-resourcemanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ All you need to create a project is a globally unique project ID. You can also
import com.google.gcloud.resourcemanager.ProjectInfo;
```

Then add the following code to create a project (be sure to change `myProjectId` to be something unique).
Then add the following code to create a project (be sure to change `myProjectId` to your own unique project ID).

```java
String myProjectId = "my-globally-unique-project-id"; // Change to a unique project ID.
Expand Down Expand Up @@ -135,7 +135,7 @@ while (projectIterator.hasNext()) {

#### Complete source code

Here we put together all the code shown above into one program. This program assumes that you are running from your own desktop.
Here we put together all the code shown above into one program. This program assumes that you are running from your own desktop and used the Google Cloud SDK to authenticate yourself.

```java
import com.google.gcloud.resourcemanager.ProjectInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public class ProjectInfo implements Serializable {
*/
public enum State {
/**
* Only used/useful for distinguishing unset values
* Only used/useful for distinguishing unset values.
*/
LIFECYCLE_STATE_UNSPECIFIED,

/**
* The normal and active state
* The normal and active state.
*/
ACTIVE,

Expand All @@ -66,7 +66,7 @@ public enum State {
DELETE_REQUESTED,

/**
* the process of deleting the project has begun. Reversing the deletion is no longer possible.
* The process of deleting the project has begun. Reversing the deletion is no longer possible.
*/
DELETE_IN_PROGRESS
}
Expand Down Expand Up @@ -105,7 +105,7 @@ com.google.api.services.cloudresourcemanager.model.ResourceId toPb() {
com.google.api.services.cloudresourcemanager.model.ResourceId resourceIdPb =
new com.google.api.services.cloudresourcemanager.model.ResourceId();
resourceIdPb.setId(id);
resourceIdPb.setType(type.toString().toLowerCase());
resourceIdPb.setType(type.toLowerCase());
return resourceIdPb;
}

Expand Down Expand Up @@ -141,7 +141,8 @@ private Builder() {
/**
* Set the user-assigned name of the project.
*
* This field is optional and can remain unset. Allowed characters are: lowercase and uppercase
* <p>This field is optional and can remain unset. Allowed characters are: lowercase and
* uppercase
* letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. This
* field can be changed after project creation.
*/
Expand All @@ -153,7 +154,7 @@ public Builder name(String name) {
/**
* Set the unique, user-assigned ID of the project.
*
* The ID must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter.
* <p>The ID must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter.
* Trailing hyphens are prohibited. This field cannot be changed after the server creates the
* project.
*/
Expand All @@ -165,7 +166,7 @@ public Builder projectId(String projectId) {
/**
* Add a label associated with this project.
*
* See {@link #labels} for label restrictions.
* <p>See {@link #labels} for label restrictions.
*/
public Builder addLabel(String key, String value) {
this.labels.put(key, value);
Expand All @@ -191,7 +192,8 @@ public Builder clearLabels() {
/**
* Set the labels associated with this project.
*
* Label keys must be between 1 and 63 characters long and must conform to the following regular
* <p>Label keys must be between 1 and 63 characters long and must conform to the following
* regular
* expression: [a-z]([-a-z0-9]*[a-z0-9])?. Label values must be between 0 and 63 characters long
* and must conform to the regular expression ([a-z]([-a-z0-9]*[a-z0-9])?)?. No more than 256
* labels can be associated with a given resource. This field can be changed after project
Expand Down Expand Up @@ -240,7 +242,7 @@ public ProjectInfo build() {
/**
* Get the unique, user-assigned ID of the project.
*
* This field cannot be changed after the server creates the project.
* <p>This field cannot be changed after the server creates the project.
*/
public String projectId() {
return projectId;
Expand All @@ -249,7 +251,7 @@ public String projectId() {
/**
* Get the user-assigned name of the project.
*
* This field is optional, can remain unset, and can be changed after project creation.
* <p>This field is optional, can remain unset, and can be changed after project creation.
*/
public String name() {
return Data.isNull(name) ? null : name;
Expand All @@ -258,7 +260,7 @@ public String name() {
/**
* Get number uniquely identifying the project.
*
* This field is set by the server and is read-only.
* <p>This field is set by the server and is read-only.
*/
public Long projectNumber() {
return projectNumber;
Expand All @@ -274,7 +276,7 @@ public Map<String, String> labels() {
/**
* Get the project's lifecycle state.
*
* This is a read-only field. To change the lifecycle state of your project, use the
* <p>This is a read-only field. To change the lifecycle state of your project, use the
* {@code delete} or {@code undelete} method.
*/
public State state() {
Expand All @@ -288,7 +290,7 @@ ResourceId parent() {
/**
* Get the project's creation time (in milliseconds).
*
* This field is set by the server and is read-only.
* <p>This field is set by the server and is read-only.
*/
public Long createTimeMillis() {
return createTimeMillis;
Expand Down Expand Up @@ -332,8 +334,7 @@ com.google.api.services.cloudresourcemanager.model.Project toPb() {
}

static ProjectInfo fromPb(com.google.api.services.cloudresourcemanager.model.Project projectPb) {
ProjectInfo.Builder builder =
ProjectInfo.builder(projectPb.getProjectId()).projectNumber(projectPb.getProjectNumber());
Builder builder = builder(projectPb.getProjectId()).projectNumber(projectPb.getProjectNumber());
if (projectPb.getName() != null && !projectPb.getName().equals("Unnamed")) {
builder.name(projectPb.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void testToBuilder() {

@Test
public void testToAndFromPb() {
assertTrue(FULL_PROJECT_INFO.toPb().getCreateTime().endsWith("Z"));
compareProjects(FULL_PROJECT_INFO, ProjectInfo.fromPb(FULL_PROJECT_INFO.toPb()));
compareProjects(PARTIAL_PROJECT_INFO, ProjectInfo.fromPb(PARTIAL_PROJECT_INFO.toPb()));
compareProjects(PARTIAL_PROJECT_INFO, ProjectInfo.fromPb(UNNAMED_PROJECT_FROM_LIST.toPb()));
Expand Down

0 comments on commit f5bd555

Please sign in to comment.