1616
1717package com .google .gcloud .resourcemanager ;
1818
19- import static com .google .common .base .Preconditions .checkNotNull ;
20-
21- import com .google .common .collect .ImmutableList ;
2219import com .google .gcloud .Page ;
2320import com .google .gcloud .Service ;
24-
25- import java .util .Collections ;
26- import java .util .List ;
21+ import com .google .gcloud .spi .ResourceManagerRpc ;
2722
2823/**
2924 * An interface for Google Cloud Resource Manager.
@@ -34,39 +29,66 @@ public interface ResourceManager extends Service<ResourceManagerOptions> {
3429
3530 public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream" ;
3631
37- public class ListOptions {
38- private List <String > filters ;
39- private String pageToken ;
40- private int pageSize ;
41-
42- private static final ListOptions DEFAULT_INSTANCE =
43- new ListOptions (Collections .<String >emptyList (), null , -1 );
44-
45- ListOptions (List <String > filters , String pageToken , int pageSize ) {
46- this .filters = checkNotNull (ImmutableList .copyOf (filters ));
47- this .pageToken = pageToken ;
48- this .pageSize = pageSize ;
49- }
32+ /**
33+ * Class for specifying project list options.
34+ */
35+ public class ProjectListOption extends Option {
5036
51- public static ListOptions getDefaultInstance () {
52- return DEFAULT_INSTANCE ;
53- }
37+ private static final long serialVersionUID = 7888768979702012328L ;
5438
55- public static ListOptions createListOption (
56- List <String > filters , String pageToken , int pageSize ) {
57- return new ListOptions (filters , pageToken , pageSize );
39+ private ProjectListOption (ResourceManagerRpc .Option option , Object value ) {
40+ super (option , value );
5841 }
5942
60- public String pageToken () {
61- return pageToken ;
43+ /**
44+ * Returns an option to specify a page token.
45+ *
46+ * The page token (returned from a previous call to list) indicates from where listing should
47+ * continue. Pagination is not yet supported; the server ignores this field. Optional.
48+ */
49+ public static ProjectListOption pageToken (String pageToken ) {
50+ // return new ProjectListOption(ResourceManagerRpc.Option.PAGE_TOKEN, pageToken);
51+ throw new UnsupportedOperationException ("paging for project lists is not implemented yet." );
6252 }
6353
64- public List <String > filters () {
65- return filters ;
54+ /**
55+ * Returns an option to specify a filter.
56+ *
57+ * Filter rules are case insensitive. The fields eligible for filtering are:
58+ * <ul>
59+ * <li>name
60+ * <li>id
61+ * <li>labels.key, where key is the name of a label
62+ * </ul>
63+ *
64+ * Some examples of using labels as filters:
65+ * <ul>
66+ * <li> name:* The project has a name.
67+ * <li> name:Howl The project's name is Howl or howl.
68+ * <li> name:HOWL Equivalent to above.
69+ * <li> NAME:howl Equivalent to above.
70+ * <li> labels.color:* The project has the label color.
71+ * <li> labels.color:red The project's label color has the value red.
72+ * <li> labels.color:red label.size:big The project's label color has the value red and its
73+ * label size has the value big.
74+ * </ul>
75+ *
76+ * Optional.
77+ */
78+ public static ProjectListOption filter (String filter ) {
79+ return new ProjectListOption (ResourceManagerRpc .Option .FILTER , filter );
6680 }
6781
68- public int pageSize () {
69- return pageSize ;
82+ /**
83+ * The maximum number of projects to return in the response.
84+ *
85+ * The server can return fewer projects than requested. If unspecified, server picks an
86+ * appropriate default. Note: pagination is not yet supported; the server ignores this field.
87+ * Optional.
88+ */
89+ public static ProjectListOption pageSize (int pageSize ) {
90+ // return new ProjectListOption(ResourceManagerRpc.Option.PAGE_SIZE, pageSize);
91+ throw new UnsupportedOperationException ("paging for project lists is not implemented yet." );
7092 }
7193 }
7294
@@ -127,15 +149,16 @@ public int pageSize() {
127149 * Lists the projects visible to the current user.
128150 *
129151 * This method returns projects in an unspecified order. New projects do not necessarily appear at
130- * the end of the list. Use {@link ListOptions} to filter this list, set page size, and set page
131- * tokens. Note that pagination is currently not implemented by the Cloud Resource Manager API.
152+ * the end of the list. Use {@link ProjectListOption} to filter this list, set page size, and set
153+ * page tokens. Note that pagination is currently not implemented by the Cloud Resource Manager
154+ * API.
132155 *
133156 * @see <a href="https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/list">
134157 * Cloud Resource Manager list</a>
135158 * @return {@code Page<ProjectInfo>}, a page of projects.
136159 * @throws ResourceManagerException upon failure
137160 */
138- Page <ProjectInfo > list (ListOptions listOptions );
161+ Page <ProjectInfo > list (ProjectListOption ... options );
139162
140163 /**
141164 * Replaces the attributes of the project.
0 commit comments