Skip to content

Commit

Permalink
minor changes to ResourceManagerRpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Nov 3, 2015
1 parent 57df7ac commit 10904d9
Showing 1 changed file with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@

package com.google.gcloud.spi;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.api.services.cloudresourcemanager.model.Policy;
import com.google.api.services.cloudresourcemanager.model.Project;
import com.google.gcloud.resourcemanager.ResourceManagerException;

import java.util.Collections;
import java.util.List;

public interface ResourceManagerRpc {

public enum Permission {
CREATE,
DELETE,
GET,
LIST,
UPDATE,
GET_IAM_POLICY,
SET_IAM_POLICY;
}

class Tuple<X, Y> {
private final X x;
private final Y y;
Expand All @@ -49,20 +62,24 @@ public Y y() {
public class ListOptions {
private List<String> filters;
private String pageToken;
private int pageSize;

private static final ListOptions DEFAULT_INSTANCE = new ListOptions(null, null);
private static final ListOptions DEFAULT_INSTANCE =
new ListOptions(Collections.<String>emptyList(), null, -1);

ListOptions(List<String> filters, String pageToken) {
this.filters = filters;
ListOptions(List<String> filters, String pageToken, int pageSize) {
this.filters = checkNotNull(filters);
this.pageToken = pageToken;
this.pageSize = pageSize;
}

public static ListOptions getDefaultInstance() {
return DEFAULT_INSTANCE;
}

public static ListOptions createListOption(List<String> filters, String pageToken) {
return new ListOptions(filters, pageToken);
public static ListOptions createListOption(
List<String> filters, String pageToken, int pageSize) {
return new ListOptions(filters, pageToken, pageSize);
}

public String pageToken() {
Expand All @@ -72,6 +89,10 @@ public String pageToken() {
public List<String> filters() {
return filters;
}

public int pageSize() {
return pageSize;
}
}

Project create(Project project) throws ResourceManagerException;
Expand All @@ -90,6 +111,6 @@ public List<String> filters() {

void setIamPolicy(String projectId, Policy policy) throws ResourceManagerException;

boolean hasPermissions(String projectId, List<String> permissions)
List<Boolean> hasPermissions(String projectId, List<Permission> permissions)
throws ResourceManagerException;
}

0 comments on commit 10904d9

Please sign in to comment.