edu.ksu.canvas.impl.RoleImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of canvas-api Show documentation
Show all versions of canvas-api Show documentation
A native Java library to talk to the Canvas REST API
package edu.ksu.canvas.impl;
import com.google.gson.reflect.TypeToken;
import edu.ksu.canvas.interfaces.*;
import edu.ksu.canvas.model.Role;
import edu.ksu.canvas.net.RestClient;
import edu.ksu.canvas.oauth.OauthToken;
import edu.ksu.canvas.requestOptions.ListRolesOptions;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;
public class RoleImpl extends BaseImpl implements RoleReader, RoleWriter {
private static final Logger LOG = Logger.getLogger(RoleImpl.class);
public RoleImpl(String canvasBaseUrl, Integer apiVersion, OauthToken oauthToken, RestClient restClient,
int connectTimeout, int readTimeout, Integer paginationPageSize, Boolean serializeNulls) {
super(canvasBaseUrl, apiVersion, oauthToken, restClient, connectTimeout, readTimeout,
paginationPageSize, serializeNulls);
}
@Override
public List listRoles(ListRolesOptions options) throws IOException {
LOG.debug("Retrieving roles for account " + options.getAccountId());
String url = buildCanvasUrl("accounts/" + options.getAccountId() + "/roles", options.getOptionsMap());
return getListFromCanvas(url);
}
@Override
protected Type listType() {
return new TypeToken>(){}.getType();
}
@Override
protected Class objectType() {
return Role.class;
}
}