code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public Token refreshToken(Token token) throws OAuthTokenException, JSONSerializerException, HttpClientException, URISyntaxException, InvalidRequestException {
// Prepare the hash
String doHash = clientSecret + "|" + token.getRefreshToken();
MessageDigest md;
try {
md = Messag... | java |
private Token requestToken(String url) throws OAuthTokenException, JSONSerializerException, HttpClientException,
URISyntaxException, InvalidRequestException {
// Create the request and send it to get the response/token.
HttpRequest request = new HttpRequest();
request.setUri(new URI... | java |
public void revokeAccessToken(Token token) throws OAuthTokenException, JSONSerializerException, HttpClientException,
URISyntaxException, InvalidRequestException{
HttpRequest request = new HttpRequest();
request.setUri(new URI(tokenURL));
request.setMethod(HttpMethod.DELETE);
... | java |
public Discussion createDiscussion(long sheetId, long rowId, Discussion discussion) throws SmartsheetException{
return this.createResource("sheets/" + sheetId + "/rows/" + rowId + "/discussions", Discussion.class, discussion);
} | java |
public PagedResult<Discussion> listDiscussions(long sheetId, long rowId, PaginationParameters pagination, EnumSet<DiscussionInclusion> includes) throws SmartsheetException{
String path = "sheets/" + sheetId + "/rows/" + rowId + "/discussions" ;
HashMap<String, Object> parameters = new HashMap<String, Ob... | java |
public <T> String serialize(T object) throws JSONSerializerException {
Util.throwIfNull(object);
String value;
try {
value= OBJECT_MAPPER.writeValueAsString(object);
} catch (JsonGenerationException e) {
throw new JSONSerializerException(e);
} catch (Json... | java |
@Override
public CopyOrMoveRowResult deserializeCopyOrMoveRow(java.io.InputStream inputStream) throws JSONSerializerException{
Util.throwIfNull(inputStream);
CopyOrMoveRowResult rw = null;
try {
// Read the json input stream into a List.
rw = OBJECT_MAPPER.readValue... | java |
public PagedResult<UpdateRequest> listUpdateRequests(long sheetId, PaginationParameters paging) throws SmartsheetException {
String path = "sheets/" + sheetId + "/updaterequests";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (paging != null) {
parameters = ... | java |
public UpdateRequest updateUpdateRequest(long sheetId, UpdateRequest updateRequest) throws SmartsheetException {
return this.updateResource("sheets/" + sheetId + "/updaterequests/" + updateRequest.getId(),
UpdateRequest.class, updateRequest);
} | java |
public PagedResult<SentUpdateRequest> listSentUpdateRequests(long sheetId, PaginationParameters paging) throws SmartsheetException {
String path = "sheets/" + sheetId + "/sentupdaterequests";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (paging != null) {
p... | java |
public PagedResult<Attachment> listAllVersions(long sheetId, long attachmentId, PaginationParameters parameters) throws SmartsheetException {
String path = "sheets/"+ sheetId + "/attachments/" + attachmentId + "/versions";
if (parameters != null) {
path += parameters.toQueryString();
... | java |
private Attachment attachNewVersion (long sheetId, long attachmentId, InputStream inputStream, String contentType, long contentLength, String attachmentName)
throws SmartsheetException {
return super.attachFile("sheets/"+ sheetId + "/attachments/"+ attachmentId +"/versions", inputStream, contentType... | java |
public PagedResult<User> listUsers(Set<String> email, PaginationParameters pagination) throws SmartsheetException {
String path = "users";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (pagination != null){
parameters = pagination.toHashMap();
}
... | java |
public User addUser(User user, boolean sendEmail) throws SmartsheetException {
return this.createResource("users?sendEmail=" + sendEmail, User.class, user);
} | java |
public PagedResult<AlternateEmail> listAlternateEmails(long userId, PaginationParameters pagination) throws SmartsheetException {
String path = "users/" + userId + "/alternateemails";
if (pagination != null) {
path += pagination.toQueryString();
}
return this.listResource... | java |
public List<AlternateEmail> addAlternateEmail(long userId, List<AlternateEmail> altEmails) throws SmartsheetException {
Util.throwIfNull(altEmails);
if (altEmails.size() == 0) {
return altEmails;
}
return this.postAndReceiveList("users/" + userId + "/alternateemails", altEmai... | java |
public AlternateEmail promoteAlternateEmail(long userId, long altEmailId) throws SmartsheetException {
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(
"users/" + userId + "/alternateemails/" + altEmailId + "/makeprimary"), HttpMethod.POST);
Object obj = null;
... | java |
public User addProfileImage(long userId, String file, String fileType) throws SmartsheetException, FileNotFoundException {
return attachProfileImage("users/" + userId + "/profileimage", file, fileType);
} | java |
public Attachment attachFile(long sheetId, long commentId, File file, String contentType) throws FileNotFoundException,
SmartsheetException {
Util.throwIfNull(sheetId, commentId, file, contentType);
Util.throwIfEmpty(contentType);
return attachFile(sheetId, commentId, new FileInputS... | java |
public void setMaxRetryTimeMillis(long maxRetryTimeMillis) {
if (this.httpClient instanceof DefaultHttpClient) {
((DefaultHttpClient) this.httpClient).setMaxRetryTimeMillis(maxRetryTimeMillis);
}
else
throw new UnsupportedOperationException("Invalid operation for class " ... | java |
public void setTracePrettyPrint(boolean pretty) {
if (this.httpClient instanceof DefaultHttpClient) {
((DefaultHttpClient)this.httpClient).setTracePrettyPrint(pretty);
}
else
throw new UnsupportedOperationException("Invalid operation for class " + this.httpClient.getClass... | java |
public HomeResources homeResources() {
if (home.get() == null) {
home.compareAndSet(null, new HomeResourcesImpl(this));
}
return home.get();
} | java |
public WorkspaceResources workspaceResources() {
if (workspaces.get() == null) {
workspaces.compareAndSet(null, new WorkspaceResourcesImpl(this));
}
return workspaces.get();
} | java |
public FolderResources folderResources() {
if (folders.get() == null) {
folders.compareAndSet(null, new FolderResourcesImpl(this));
}
return folders.get();
} | java |
public TemplateResources templateResources() {
if (templates.get() == null) {
templates.compareAndSet(null, new TemplateResourcesImpl(this));
}
return templates.get();
} | java |
public SheetResources sheetResources() {
if (sheets.get() == null) {
sheets.compareAndSet(null, new SheetResourcesImpl(this));
}
return sheets.get();
} | java |
public SightResources sightResources() {
if (sights.get() == null) {
sights.compareAndSet(null, new SightResourcesImpl(this));
}
return sights.get();
} | java |
public FavoriteResources favoriteResources() {
if (favorites.get() == null) {
favorites.compareAndSet(null, new FavoriteResourcesImpl(this));
}
return favorites.get();
} | java |
public TokenResources tokenResources() {
if (tokens.get() == null) {
tokens.compareAndSet(null, new TokenResourcesImpl(this));
}
return tokens.get();
} | java |
public ContactResources contactResources() {
if (contacts.get() == null) {
contacts.compareAndSet(null, new ContactResourcesImpl(this));
}
return contacts.get();
} | java |
public ImageUrlResources imageUrlResources() {
if (imageUrls.get() == null) {
imageUrls.compareAndSet(null, new ImageUrlResourcesImpl(this));
}
return imageUrls.get();
} | java |
public WebhookResources webhookResources() {
if (webhooks.get() == null) {
webhooks.compareAndSet(null, new WebhookResourcesImpl(this));
}
return webhooks.get();
} | java |
public PassthroughResources passthroughResources() {
if (passthrough.get() == null) {
passthrough.compareAndSet(null, new PassthroughResourcesImpl(this));
}
return passthrough.get();
} | java |
public Webhook updateWebhook(Webhook webhook) throws SmartsheetException {
return this.updateResource("webhooks/" + webhook.getId(), Webhook.class, webhook);
} | java |
public WebhookSharedSecret resetSharedSecret(long webhookId) throws SmartsheetException {
HttpRequest request = createHttpRequest(this.getSmartsheet().getBaseURI().resolve("webhooks/" +
webhookId + "/resetsharedsecret"), HttpMethod.POST);
HttpResponse response = getSmartsheet().getHttpC... | java |
public static void throwIfNull(Object obj1, Object obj2) {
if(obj1 == null){
throw new IllegalArgumentException();
}
if(obj2 == null){
throw new IllegalArgumentException();
}
} | java |
public List<Row> addRows(long sheetId, List<Row> rows) throws SmartsheetException {
return this.postAndReceiveList("sheets/" + sheetId + "/rows", rows, Row.class);
} | java |
public Row getRow(long sheetId, long rowId, EnumSet<RowInclusion> includes, EnumSet<ObjectExclusion> excludes) throws SmartsheetException {
String path = "sheets/" + sheetId + "/rows/" + rowId;
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put("include", QueryU... | java |
public List<Row> updateRows(long sheetId, List<Row> rows) throws SmartsheetException {
return this.putAndReceiveList("sheets/" + sheetId + "/rows", rows, Row.class);
} | java |
public static byte[] readBytesFromStream(InputStream source, int bufferSize) throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
copyContentIntoOutputStream(source, buffer, bufferSize, true);
return buffer.toByteArray();
} | java |
public static long copyContentIntoOutputStream(InputStream source, OutputStream target, int bufferSize,
boolean readToEOF) throws IOException {
byte[] tempBuf = new byte[Math.max(ONE_KB, bufferSize)]; // at least a 1k buffer
long bytesWritten = 0;
... | java |
public static InputStream cloneContent(InputStream source, int readbackSize, ByteArrayOutputStream target) throws IOException {
if (source == null) {
return null;
}
// if the source supports mark/reset then we read and then reset up to the read-back size
if (source.markSuppor... | java |
public String getRequest(String endpoint, HashMap<String, Object> parameters) throws SmartsheetException {
return passthroughRequest(HttpMethod.GET, endpoint, null, parameters);
} | java |
public String postRequest(String endpoint, String payload, HashMap<String, Object> parameters) throws SmartsheetException {
Util.throwIfNull(payload);
return passthroughRequest(HttpMethod.POST, endpoint, payload, parameters);
} | java |
public String putRequest(String endpoint, String payload, HashMap<String, Object> parameters) throws SmartsheetException {
Util.throwIfNull(payload);
return passthroughRequest(HttpMethod.PUT, endpoint, payload, parameters);
} | java |
public String deleteRequest(String endpoint) throws SmartsheetException {
return passthroughRequest(HttpMethod.DELETE, endpoint, null, null);
} | java |
public Comment addCommentWithAttachment(long sheetId, long discussionId, Comment comment, File file, String contentType) throws SmartsheetException, IOException{
String path = "sheets/" + sheetId + "/discussions/" + discussionId + "/comments";
Util.throwIfNull(sheetId, comment, file, contentType);
... | java |
public Comment updateComment(long sheetId, Comment comment) throws SmartsheetException {
return this.updateResource("sheets/" + sheetId + "/comments/" + comment.getId(), Comment.class, comment);
} | java |
public ImageUrlMap getImageUrls(List<ImageUrl> requestUrls) throws SmartsheetException
{
Util.throwIfNull(requestUrls);
HttpRequest request;
request = createHttpRequest(smartsheet.getBaseURI().resolve("imageurls"), HttpMethod.POST);
ByteArrayOutputStream baos = new ByteArrayOutputS... | java |
public PagedResult<Workspace> listWorkspaces(PaginationParameters parameters) throws SmartsheetException {
String path = "workspaces";
if (parameters != null) {
path += parameters.toQueryString();
}
return this.listResourcesWithWrapper(path, Workspace.class);
} | java |
public Workspace getWorkspace(long id, Boolean loadAll, EnumSet<SourceInclusion> includes) throws SmartsheetException {
String path = "workspaces/" + id;
// Add the parameters to a map and build the query string at the end
HashMap<String, Object> parameters = new HashMap<String, Object>();
... | java |
public Workspace updateWorkspace(Workspace workspace) throws SmartsheetException {
return this.updateResource("workspaces/" + workspace.getId(), Workspace.class, workspace);
} | java |
public PagedResult<Sheet> listSheets(EnumSet<SourceInclusion> includes, PaginationParameters pagination) throws SmartsheetException {
return this.listSheets(includes, pagination, null);
} | java |
@Deprecated
public PagedResult<Sheet> listOrganizationSheets(PaginationParameters parameters) throws SmartsheetException {
String path = "users/sheets";
if (parameters != null) {
path += parameters.toQueryString();
}
return this.listResourcesWithWrapper(path, Sheet.class... | java |
public Sheet getSheet(long id, EnumSet<SheetInclusion> includes, EnumSet<ObjectExclusion> excludes, Set<Long> rowIds, Set<Integer> rowNumbers, Set<Long> columnIds, Integer pageSize, Integer page) throws SmartsheetException {
return this.getSheet(id, includes, excludes, rowIds, rowNumbers, columnIds, pageSize, p... | java |
public void getSheetAsPDF(long id, OutputStream outputStream, PaperSize paperSize) throws SmartsheetException {
getSheetAsFile(id, paperSize, outputStream, "application/pdf");
} | java |
public Sheet importCsv(String file, String sheetName, Integer headerRowIndex, Integer primaryRowIndex) throws SmartsheetException {
return importFile("sheets/import", file,"text/csv", sheetName, headerRowIndex, primaryRowIndex);
} | java |
public Sheet importCsvInFolder(long folderId, String file, String sheetName, Integer headerRowIndex, Integer primaryRowIndex) throws SmartsheetException {
return importFile("folders/" + folderId + "/sheets/import", file,"text/csv",
sheetName, headerRowIndex, primaryRowIndex);
} | java |
public Sheet createSheetInWorkspace(long workspaceId, Sheet sheet) throws SmartsheetException {
return this.createResource("workspaces/" + workspaceId + "/sheets", Sheet.class, sheet);
} | java |
public Sheet importCsvInWorkspace(long workspaceId, String file, String sheetName, Integer headerRowIndex, Integer primaryRowIndex) throws SmartsheetException {
return importFile("workspaces/" + workspaceId + "/sheets/import", file,
"text/csv", sheetName, headerRowIndex, primaryRowIndex);
} | java |
public SheetPublish updatePublishStatus(long id, SheetPublish publish) throws SmartsheetException{
return this.updateResource("sheets/" + id + "/publish", SheetPublish.class, publish);
} | java |
private Sheet importFile(String path, String file, String contentType, String sheetName, Integer headerRowIndex,
Integer primaryRowIndex) throws SmartsheetException {
Util.throwIfNull(path, file, contentType);
Util.throwIfEmpty(path, file, contentType);
File f = new... | java |
public Sheet moveSheet(long sheetId, ContainerDestination containerDestination) throws SmartsheetException {
String path = "sheets/" + sheetId + "/move";
return this.createResource(path, Sheet.class, containerDestination);
} | java |
public Attachment attachFile(long objectId, InputStream inputStream, String contentType, long contentLength, String fileName) {
throw new UnsupportedOperationException("Attachments can only be attached to comments, not discussions.");
} | java |
public PagedResult<Column> listColumns(long sheetId, EnumSet<ColumnInclusion> includes, PaginationParameters pagination) throws SmartsheetException {
String path = "sheets/" + sheetId + "/columns";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (pagination != null) {
... | java |
public List<Column> addColumns(long sheetId, List<Column> columns) throws SmartsheetException {
return this.postAndReceiveList("sheets/" + sheetId + "/columns", columns, Column.class);
} | java |
public Column updateColumn(long sheetId, Column column) throws SmartsheetException {
Util.throwIfNull(column);
return this.updateResource("sheets/" + sheetId + "/columns/" + column.getId(), Column.class, column);
} | java |
public Column getColumn(long sheetId, long columnId, EnumSet<ColumnInclusion> includes) throws SmartsheetException {
String path = "sheets/" + sheetId + "/columns/" + columnId;
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put("include", QueryUtil.generateComma... | java |
public TColumn getColumnByIndex(int index) {
if (columns == null) {
return null;
}
TColumn result = null;
for (TColumn column : columns) {
if (column.getIndex() == index) {
result = column;
break;
}
}
re... | java |
public AbstractSheet<TRow, TColumn, TCell> setColumns(List<TColumn> columns) {
this.columns = columns;
return this;
} | java |
public AbstractSheet<TRow, TColumn, TCell> setRows(List<TRow> rows) {
this.rows = rows;
return this;
} | java |
public AbstractSheet<TRow, TColumn, TCell> setDiscussions(List<Discussion> discussions) {
this.discussions = discussions;
return this;
} | java |
public AbstractSheet<TRow, TColumn, TCell> setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
return this;
} | java |
public AbstractSheet<TRow, TColumn, TCell> setEffectiveAttachmentOptions(EnumSet<AttachmentType> effectiveAttachmentOptions) {
this.effectiveAttachmentOptions = effectiveAttachmentOptions;
return this;
} | java |
public AbstractSheet<TRow, TColumn, TCell> setFilters(List<SheetFilter> filters) {
this.filters = filters;
return this;
} | java |
public AbstractSheet<TRow, TColumn, TCell> setCrossSheetReferences(List<CrossSheetReference> crossSheetReferences) {
this.crossSheetReferences = crossSheetReferences;
return this;
} | java |
public HttpRequestBase createApacheRequest(HttpRequest smartsheetRequest) {
HttpRequestBase apacheHttpRequest;
// Create Apache HTTP request based on the smartsheetRequest request type
switch (smartsheetRequest.getMethod()) {
case GET:
apacheHttpRequest = new HttpGet... | java |
public long calcBackoff(int previousAttempts, long totalElapsedTimeMillis, Error error) {
long backoffMillis = (long)(Math.pow(2, previousAttempts) * 1000) + new Random().nextInt(1000);
if(totalElapsedTimeMillis + backoffMillis > maxRetryTimeMillis) {
logger.info("Elapsed time " + totalEla... | java |
public boolean shouldRetry(int previousAttempts, long totalElapsedTimeMillis, HttpResponse response) {
String contentType = response.getEntity().getContentType();
if (contentType != null && !contentType.startsWith(JSON_MIME_TYPE)) {
// it's not JSON; don't even try to parse it
re... | java |
public void setTraces(Trace... traces) {
this.traces.clear();
for (Trace trace : traces) {
if (!trace.addReplacements(this.traces)) {
this.traces.add(trace);
}
}
} | java |
public PagedResult<Attachment> getAttachments(long sheetId, long rowId, PaginationParameters parameters) throws SmartsheetException {
String path= "sheets/" + sheetId + "/rows/" + rowId + "/attachments";
if (parameters != null) {
path += parameters.toQueryString();
}
return t... | java |
public Attachment attachFile(long sheetId, long rowId, InputStream inputStream, String contentType, long contentLength, String attachmentName)
throws SmartsheetException {
Util.throwIfNull(inputStream, contentType);
return super.attachFile("sheets/" + sheetId + "/rows/" + rowId + "/attachmen... | java |
public Discussion createDiscussion(long sheetId, Discussion discussion) throws SmartsheetException{
Util.throwIfNull(sheetId, discussion);
return this.createResource("sheets/" + sheetId + "/discussions",
Discussion.class, discussion);
} | java |
public Discussion createDiscussionWithAttachment(long sheetId, Discussion discussion, File file, String contentType) throws SmartsheetException, IOException{
Util.throwIfNull(discussion, file, contentType);
String path = "sheets/" + sheetId + "/discussions";
return this.createDiscussionWithAtta... | java |
public static RequestAndResponseData of(HttpRequestBase request, HttpEntitySnapshot requestEntity,
HttpResponse response, HttpEntitySnapshot responseEntity,
Set<Trace> traces)
throws IOException {
RequestData.Bui... | java |
protected <T> T getResource(String path, Class<T> objectClass) throws SmartsheetException {
Util.throwIfNull(path, objectClass);
if(path.isEmpty()) {
com.smartsheet.api.models.Error error = new com.smartsheet.api.models.Error();
error.setMessage("An empty path was provided.");
... | java |
protected <T> List<T> listResources(String path, Class<T> objectClass) throws SmartsheetException {
Util.throwIfNull(path, objectClass);
Util.throwIfEmpty(path);
HttpRequest request;
request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.GET);
List<T> ob... | java |
protected <T> void deleteResource(String path, Class<T> objectClass) throws SmartsheetException {
Util.throwIfNull(path, objectClass);
Util.throwIfEmpty(path);
HttpRequest request;
request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.DELETE);
try {
... | java |
protected <T> List<T> deleteListResources(String path, Class<T> objectClass) throws SmartsheetException {
Util.throwIfNull(path, objectClass);
Util.throwIfEmpty(path);
Result<List<T>> obj = null;
HttpRequest request;
request = createHttpRequest(smartsheet.getBaseURI().resolve(pa... | java |
protected <T, S> List<S> postAndReceiveList(String path, T objectToPost, Class<S> objectClassToReceive) throws SmartsheetException {
Util.throwIfNull(path, objectToPost, objectClassToReceive);
Util.throwIfEmpty(path);
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path)... | java |
protected CopyOrMoveRowResult postAndReceiveRowObject(String path, CopyOrMoveRowDirective objectToPost) throws SmartsheetException {
Util.throwIfNull(path, objectToPost);
Util.throwIfEmpty(path);
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
... | java |
public <T> Attachment attachFile(String url, T t, String partName, InputStream inputstream, String contentType, String attachmentName)
throws SmartsheetException {
Util.throwIfNull(inputstream, contentType);
Attachment attachment = null;
final String boundary = "----" + System.curren... | java |
@Deprecated // replace with StreamUtil.copyContentIntoOutputStream()
private static void copyStream(InputStream input, OutputStream output) throws IOException {
byte[] buffer = new byte[BUFFER_SIZE];
int len;
while ((len = input.read(buffer)) != -1) {
output.write(buffer, 0, len)... | java |
public PagedResult<Share> listShares(long objectId, PaginationParameters pagination) throws SmartsheetException {
return this.listShares(objectId, pagination, false);
} | java |
public Share getShare(long objectId, String shareId) throws SmartsheetException{
return this.getResource(getMasterResourceType() + "/" + objectId + "/shares/" + shareId, Share.class);
} | java |
public List<Share> shareTo(long objectId, List<Share> shares, Boolean sendEmail) throws SmartsheetException {
String path = getMasterResourceType() + "/" + objectId + "/shares";
if (sendEmail != null){
path += "?sendEmail=" + sendEmail;
}
return this.postAndReceiveList(path, ... | java |
public void deleteShare(long objectId, String shareId) throws SmartsheetException {
this.deleteResource(getMasterResourceType() + "/" + objectId + "/shares/" + shareId, Share.class);
} | java |
public ReportPublish updatePublishStatus(long id, ReportPublish reportPublish) throws SmartsheetException{
return this.updateResource("reports/" + id + "/publish", ReportPublish.class, reportPublish);
} | java |
public PagedResult<SheetFilter> listFilters(long sheetId, PaginationParameters pagination) throws SmartsheetException {
String path = "sheets/" + sheetId + "/filters";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (pagination != null) {
parameters = paginati... | java |
public PagedResult<Sight> listSights(PaginationParameters paging, Date modifiedSince) throws SmartsheetException {
String path = "sights";
HashMap<String, Object> parameters = new HashMap<String, Object>();
if (paging != null) {
parameters = paging.toHashMap();
}
if ... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.