idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
14,600
public Token refreshToken ( Token token ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { String doHash = clientSecret + "|" + token . getRefreshToken ( ) ; MessageDigest md ; try { md = MessageDigest . getInstance ( "SHA-256" ) ; } catch ( NoSuchAlgorithmException e ) { throw new RuntimeException ( "Your JVM does not support SHA-256, which is required for OAuth with Smartsheet." , e ) ; } byte [ ] digest ; try { digest = md . digest ( doHash . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } String hash = org . apache . commons . codec . binary . Hex . encodeHexString ( digest ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "grant_type" , "refresh_token" ) ; params . put ( "client_id" , clientId ) ; params . put ( "refresh_token" , token . getRefreshToken ( ) ) ; params . put ( "redirect_uri" , redirectURL ) ; params . put ( "hash" , hash ) ; return requestToken ( QueryUtil . generateUrl ( tokenURL , params ) ) ; }
Refresh token .
14,601
private Token requestToken ( String url ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { HttpRequest request = new HttpRequest ( ) ; request . setUri ( new URI ( url ) ) ; request . setMethod ( HttpMethod . POST ) ; request . setHeaders ( new HashMap < String , String > ( ) ) ; request . getHeaders ( ) . put ( "Content-Type" , "application/x-www-form-urlencoded" ) ; HttpResponse response = httpClient . request ( request ) ; InputStream inputStream = response . getEntity ( ) . getContent ( ) ; Map < String , Object > map = jsonSerializer . deserializeMap ( inputStream ) ; httpClient . releaseConnection ( ) ; if ( response . getStatusCode ( ) != 200 && map . get ( "error" ) != null ) { String errorType = map . get ( "error" ) . toString ( ) ; String errorDescription = map . get ( "message" ) == null ? "" : ( String ) map . get ( "message" ) ; if ( "invalid_request" . equals ( errorType ) ) { throw new InvalidTokenRequestException ( errorDescription ) ; } else if ( "invalid_client" . equals ( errorType ) ) { throw new InvalidOAuthClientException ( errorDescription ) ; } else if ( "invalid_grant" . equals ( errorType ) ) { throw new InvalidOAuthGrantException ( errorDescription ) ; } else if ( "unsupported_grant_type" . equals ( errorType ) ) { throw new UnsupportedOAuthGrantTypeException ( errorDescription ) ; } else { throw new OAuthTokenException ( errorDescription ) ; } } else if ( response . getStatusCode ( ) != 200 ) { throw new OAuthTokenException ( "Token request failed with http error code: " + response . getStatusCode ( ) ) ; } Token token = new Token ( ) ; Object tempObj = map . get ( "access_token" ) ; token . setAccessToken ( tempObj == null ? "" : ( String ) tempObj ) ; tempObj = map . get ( "token_type" ) ; token . setTokenType ( tempObj == null ? "" : ( String ) tempObj ) ; tempObj = map . get ( "refresh_token" ) ; token . setRefreshToken ( tempObj == null ? "" : ( String ) tempObj ) ; Long expiresIn ; try { expiresIn = Long . parseLong ( String . valueOf ( map . get ( "expires_in" ) ) ) ; } catch ( NumberFormatException nfe ) { expiresIn = 0L ; } token . setExpiresInSeconds ( expiresIn ) ; return token ; }
Request a token .
14,602
public void revokeAccessToken ( Token token ) throws OAuthTokenException , JSONSerializerException , HttpClientException , URISyntaxException , InvalidRequestException { HttpRequest request = new HttpRequest ( ) ; request . setUri ( new URI ( tokenURL ) ) ; request . setMethod ( HttpMethod . DELETE ) ; request . setHeaders ( new HashMap < String , String > ( ) ) ; request . getHeaders ( ) . put ( "Authorization" , "Bearer " + token . getAccessToken ( ) ) ; HttpResponse response = httpClient . request ( request ) ; if ( response . getStatusCode ( ) != 200 ) { throw new OAuthTokenException ( "Token request failed with http error code: " + response . getStatusCode ( ) ) ; } httpClient . releaseConnection ( ) ; }
Revoke access token .
14,603
public Discussion createDiscussion ( long sheetId , long rowId , Discussion discussion ) throws SmartsheetException { return this . createResource ( "sheets/" + sheetId + "/rows/" + rowId + "/discussions" , Discussion . class , discussion ) ; }
Create discussion on a row .
14,604
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 , Object > ( ) ; parameters . put ( "include" , QueryUtil . generateCommaSeparatedList ( includes ) ) ; path += QueryUtil . generateUrl ( null , parameters ) ; if ( pagination != null ) { path += pagination . toQueryString ( ) ; } return this . listResourcesWithWrapper ( path , Discussion . class ) ; }
Gets a list of all Discussions associated with the specified Row .
14,605
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 ( JsonMappingException e ) { throw new JSONSerializerException ( e ) ; } catch ( IOException e ) { throw new JSONSerializerException ( e ) ; } return value ; }
Serialize an object to JSON .
14,606
public CopyOrMoveRowResult deserializeCopyOrMoveRow ( java . io . InputStream inputStream ) throws JSONSerializerException { Util . throwIfNull ( inputStream ) ; CopyOrMoveRowResult rw = null ; try { rw = OBJECT_MAPPER . readValue ( inputStream , CopyOrMoveRowResult . class ) ; } catch ( JsonParseException e ) { throw new JSONSerializerException ( e ) ; } catch ( JsonMappingException e ) { throw new JSONSerializerException ( e ) ; } catch ( IOException e ) { throw new JSONSerializerException ( e ) ; } return rw ; }
De - serialize to a CopyOrMoveRowResult object from JSON
14,607
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 = paging . toHashMap ( ) ; } path += QueryUtil . generateUrl ( null , parameters ) ; return this . listResourcesWithWrapper ( path , UpdateRequest . class ) ; }
Gets a list of all Update Requests that have future schedules associated with the specified Sheet .
14,608
public UpdateRequest updateUpdateRequest ( long sheetId , UpdateRequest updateRequest ) throws SmartsheetException { return this . updateResource ( "sheets/" + sheetId + "/updaterequests/" + updateRequest . getId ( ) , UpdateRequest . class , updateRequest ) ; }
Changes the specified Update Request for the Sheet .
14,609
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 ) { parameters = paging . toHashMap ( ) ; } path += QueryUtil . generateUrl ( null , parameters ) ; return this . listResourcesWithWrapper ( path , SentUpdateRequest . class ) ; }
Gets a list of all Sent Update Requests that have future schedules associated with the specified Sheet .
14,610
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 ( ) ; } return this . listResourcesWithWrapper ( path , Attachment . class ) ; }
Get all versions of an attachment .
14,611
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 , contentLength , attachmentName ) ; }
Attach a new version of an attachment .
14,612
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 ( ) ; } parameters . put ( "email" , QueryUtil . generateCommaSeparatedList ( email ) ) ; path += QueryUtil . generateUrl ( null , parameters ) ; return this . listResourcesWithWrapper ( path , User . class ) ; }
List all users .
14,613
public User addUser ( User user , boolean sendEmail ) throws SmartsheetException { return this . createResource ( "users?sendEmail=" + sendEmail , User . class , user ) ; }
Add a user to the organization without sending email .
14,614
public PagedResult < AlternateEmail > listAlternateEmails ( long userId , PaginationParameters pagination ) throws SmartsheetException { String path = "users/" + userId + "/alternateemails" ; if ( pagination != null ) { path += pagination . toQueryString ( ) ; } return this . listResourcesWithWrapper ( path , AlternateEmail . class ) ; }
List all user alternate emails .
14,615
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" , altEmails , AlternateEmail . class ) ; }
Add an alternate email .
14,616
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 ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : obj = this . smartsheet . getJsonSerializer ( ) . deserializeResult ( AlternateEmail . class , response . getEntity ( ) . getContent ( ) ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return ( AlternateEmail ) obj ; }
Promote and alternate email to primary .
14,617
public User addProfileImage ( long userId , String file , String fileType ) throws SmartsheetException , FileNotFoundException { return attachProfileImage ( "users/" + userId + "/profileimage" , file , fileType ) ; }
Uploads a profile image for the specified user .
14,618
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 FileInputStream ( file ) , contentType , file . length ( ) , file . getName ( ) ) ; }
Attach a file to a comment with simple upload .
14,619
public void setMaxRetryTimeMillis ( long maxRetryTimeMillis ) { if ( this . httpClient instanceof DefaultHttpClient ) { ( ( DefaultHttpClient ) this . httpClient ) . setMaxRetryTimeMillis ( maxRetryTimeMillis ) ; } else throw new UnsupportedOperationException ( "Invalid operation for class " + this . httpClient . getClass ( ) ) ; }
Sets the max retry time if the HttpClient is an instance of DefaultHttpClient
14,620
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 ( ) ) ; }
set whether or not to generate pretty formatted JSON in trace - logging
14,621
public HomeResources homeResources ( ) { if ( home . get ( ) == null ) { home . compareAndSet ( null , new HomeResourcesImpl ( this ) ) ; } return home . get ( ) ; }
Returns the HomeResources instance that provides access to Home resources .
14,622
public WorkspaceResources workspaceResources ( ) { if ( workspaces . get ( ) == null ) { workspaces . compareAndSet ( null , new WorkspaceResourcesImpl ( this ) ) ; } return workspaces . get ( ) ; }
Returns the WorkspaceResources instance that provides access to Workspace resources .
14,623
public FolderResources folderResources ( ) { if ( folders . get ( ) == null ) { folders . compareAndSet ( null , new FolderResourcesImpl ( this ) ) ; } return folders . get ( ) ; }
Returns the FolderResources instance that provides access to Folder resources .
14,624
public TemplateResources templateResources ( ) { if ( templates . get ( ) == null ) { templates . compareAndSet ( null , new TemplateResourcesImpl ( this ) ) ; } return templates . get ( ) ; }
Returns the TemplateResources instance that provides access to Template resources .
14,625
public SheetResources sheetResources ( ) { if ( sheets . get ( ) == null ) { sheets . compareAndSet ( null , new SheetResourcesImpl ( this ) ) ; } return sheets . get ( ) ; }
Returns the SheetResources instance that provides access to Sheet resources .
14,626
public SightResources sightResources ( ) { if ( sights . get ( ) == null ) { sights . compareAndSet ( null , new SightResourcesImpl ( this ) ) ; } return sights . get ( ) ; }
Returns the SightResources instance that provides access to Sight resources .
14,627
public FavoriteResources favoriteResources ( ) { if ( favorites . get ( ) == null ) { favorites . compareAndSet ( null , new FavoriteResourcesImpl ( this ) ) ; } return favorites . get ( ) ; }
Returns the FavoriteResources instance that provides access to Favorite resources .
14,628
public TokenResources tokenResources ( ) { if ( tokens . get ( ) == null ) { tokens . compareAndSet ( null , new TokenResourcesImpl ( this ) ) ; } return tokens . get ( ) ; }
Returns the TokenResources instance that provides access to token resources .
14,629
public ContactResources contactResources ( ) { if ( contacts . get ( ) == null ) { contacts . compareAndSet ( null , new ContactResourcesImpl ( this ) ) ; } return contacts . get ( ) ; }
Returns the ContactResources instance that provides access to contact resources .
14,630
public ImageUrlResources imageUrlResources ( ) { if ( imageUrls . get ( ) == null ) { imageUrls . compareAndSet ( null , new ImageUrlResourcesImpl ( this ) ) ; } return imageUrls . get ( ) ; }
Returns the ImageUrlResources instance that provides access to image url resources .
14,631
public WebhookResources webhookResources ( ) { if ( webhooks . get ( ) == null ) { webhooks . compareAndSet ( null , new WebhookResourcesImpl ( this ) ) ; } return webhooks . get ( ) ; }
Returns the WebhookResources instance that provides access to webhook resources .
14,632
public PassthroughResources passthroughResources ( ) { if ( passthrough . get ( ) == null ) { passthrough . compareAndSet ( null , new PassthroughResourcesImpl ( this ) ) ; } return passthrough . get ( ) ; }
Returns the PassthroughResources instance that provides access to passthrough resources .
14,633
public Webhook updateWebhook ( Webhook webhook ) throws SmartsheetException { return this . updateResource ( "webhooks/" + webhook . getId ( ) , Webhook . class , webhook ) ; }
Updates the webhooks specified in the URL .
14,634
public WebhookSharedSecret resetSharedSecret ( long webhookId ) throws SmartsheetException { HttpRequest request = createHttpRequest ( this . getSmartsheet ( ) . getBaseURI ( ) . resolve ( "webhooks/" + webhookId + "/resetsharedsecret" ) , HttpMethod . POST ) ; HttpResponse response = getSmartsheet ( ) . getHttpClient ( ) . request ( request ) ; WebhookSharedSecret secret = null ; switch ( response . getStatusCode ( ) ) { case 200 : try { secret = this . smartsheet . getJsonSerializer ( ) . deserialize ( WebhookSharedSecret . class , response . getEntity ( ) . getContent ( ) ) ; } catch ( JsonParseException e ) { throw new SmartsheetException ( e ) ; } catch ( JsonMappingException e ) { throw new SmartsheetException ( e ) ; } catch ( IOException e ) { throw new SmartsheetException ( e ) ; } break ; default : handleError ( response ) ; } getSmartsheet ( ) . getHttpClient ( ) . releaseConnection ( ) ; return secret ; }
Resets the shared secret for the specified Webhook . For more information about how a shared secret is used see Authenticating Callbacks .
14,635
public static void throwIfNull ( Object obj1 , Object obj2 ) { if ( obj1 == null ) { throw new IllegalArgumentException ( ) ; } if ( obj2 == null ) { throw new IllegalArgumentException ( ) ; } }
faster util method that avoids creation of array for two - arg cases
14,636
public List < Row > addRows ( long sheetId , List < Row > rows ) throws SmartsheetException { return this . postAndReceiveList ( "sheets/" + sheetId + "/rows" , rows , Row . class ) ; }
Insert rows to a sheet .
14,637
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" , QueryUtil . generateCommaSeparatedList ( includes ) ) ; parameters . put ( "exclude" , QueryUtil . generateCommaSeparatedList ( excludes ) ) ; path += QueryUtil . generateUrl ( null , parameters ) ; return this . getResource ( path , Row . class ) ; }
Get a row .
14,638
public List < Row > updateRows ( long sheetId , List < Row > rows ) throws SmartsheetException { return this . putAndReceiveList ( "sheets/" + sheetId + "/rows" , rows , Row . class ) ; }
Update rows .
14,639
public static byte [ ] readBytesFromStream ( InputStream source , int bufferSize ) throws IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; copyContentIntoOutputStream ( source , buffer , bufferSize , true ) ; return buffer . toByteArray ( ) ; }
read all bytes from an InputStream with the specified buffer size ; doesn t close input - stream
14,640
public static long copyContentIntoOutputStream ( InputStream source , OutputStream target , int bufferSize , boolean readToEOF ) throws IOException { byte [ ] tempBuf = new byte [ Math . max ( ONE_KB , bufferSize ) ] ; long bytesWritten = 0 ; while ( true ) { int bytesRead = source . read ( tempBuf ) ; if ( bytesRead < 0 ) { break ; } target . write ( tempBuf , 0 , bytesRead ) ; bytesWritten += bytesRead ; if ( ! readToEOF ) { break ; } } return bytesWritten ; }
the real work - horse behind most of these methods
14,641
public static InputStream cloneContent ( InputStream source , int readbackSize , ByteArrayOutputStream target ) throws IOException { if ( source == null ) { return null ; } if ( source . markSupported ( ) ) { readbackSize = Math . max ( TEN_KB , readbackSize ) ; source . mark ( readbackSize ) ; copyContentIntoOutputStream ( source , target , readbackSize , false ) ; source . reset ( ) ; return source ; } else { copyContentIntoOutputStream ( source , target , ONE_MB , true ) ; byte [ ] fullContentBytes = target . toByteArray ( ) ; return new ByteArrayInputStream ( fullContentBytes ) ; } }
used when you want to clone a InputStream s content and still have it appear rewound to the stream beginning
14,642
public String getRequest ( String endpoint , HashMap < String , Object > parameters ) throws SmartsheetException { return passthroughRequest ( HttpMethod . GET , endpoint , null , parameters ) ; }
Issue an HTTP GET request .
14,643
public String postRequest ( String endpoint , String payload , HashMap < String , Object > parameters ) throws SmartsheetException { Util . throwIfNull ( payload ) ; return passthroughRequest ( HttpMethod . POST , endpoint , payload , parameters ) ; }
Issue an HTTP POST request .
14,644
public String putRequest ( String endpoint , String payload , HashMap < String , Object > parameters ) throws SmartsheetException { Util . throwIfNull ( payload ) ; return passthroughRequest ( HttpMethod . PUT , endpoint , payload , parameters ) ; }
Issue an HTTP PUT request .
14,645
public String deleteRequest ( String endpoint ) throws SmartsheetException { return passthroughRequest ( HttpMethod . DELETE , endpoint , null , null ) ; }
Issue an HTTP DELETE request .
14,646
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 ) ; return this . addCommentWithAttachment ( path , comment , new FileInputStream ( file ) , contentType , file . getName ( ) ) ; }
Add a comment to a discussion with an attachment .
14,647
public Comment updateComment ( long sheetId , Comment comment ) throws SmartsheetException { return this . updateResource ( "sheets/" + sheetId + "/comments/" + comment . getId ( ) , Comment . class , comment ) ; }
Update the specified comment
14,648
public ImageUrlMap getImageUrls ( List < ImageUrl > requestUrls ) throws SmartsheetException { Util . throwIfNull ( requestUrls ) ; HttpRequest request ; request = createHttpRequest ( smartsheet . getBaseURI ( ) . resolve ( "imageurls" ) , HttpMethod . POST ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; this . smartsheet . getJsonSerializer ( ) . serialize ( requestUrls , baos ) ; HttpEntity entity = new HttpEntity ( ) ; entity . setContentType ( "application/json" ) ; entity . setContent ( new ByteArrayInputStream ( baos . toByteArray ( ) ) ) ; entity . setContentLength ( baos . size ( ) ) ; request . setEntity ( entity ) ; HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; ImageUrlMap obj = null ; switch ( response . getStatusCode ( ) ) { case 200 : try { obj = this . smartsheet . getJsonSerializer ( ) . deserialize ( ImageUrlMap . class , response . getEntity ( ) . getContent ( ) ) ; } catch ( JsonParseException e ) { throw new SmartsheetException ( e ) ; } catch ( JsonMappingException e ) { throw new SmartsheetException ( e ) ; } catch ( IOException e ) { throw new SmartsheetException ( e ) ; } break ; default : handleError ( response ) ; } smartsheet . getHttpClient ( ) . releaseConnection ( ) ; return obj ; }
Gets URLS that can be used to retieve the specified cell images .
14,649
public PagedResult < Workspace > listWorkspaces ( PaginationParameters parameters ) throws SmartsheetException { String path = "workspaces" ; if ( parameters != null ) { path += parameters . toQueryString ( ) ; } return this . listResourcesWithWrapper ( path , Workspace . class ) ; }
List all workspaces .
14,650
public Workspace getWorkspace ( long id , Boolean loadAll , EnumSet < SourceInclusion > includes ) throws SmartsheetException { String path = "workspaces/" + id ; HashMap < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "include" , QueryUtil . generateCommaSeparatedList ( includes ) ) ; if ( loadAll != null ) { parameters . put ( "loadAll" , Boolean . toString ( loadAll ) ) ; } path += QueryUtil . generateUrl ( null , parameters ) ; return this . getResource ( path , Workspace . class ) ; }
Get a workspace .
14,651
public Workspace updateWorkspace ( Workspace workspace ) throws SmartsheetException { return this . updateResource ( "workspaces/" + workspace . getId ( ) , Workspace . class , workspace ) ; }
Update a workspace .
14,652
public PagedResult < Sheet > listSheets ( EnumSet < SourceInclusion > includes , PaginationParameters pagination ) throws SmartsheetException { return this . listSheets ( includes , pagination , null ) ; }
List all sheets .
14,653
public PagedResult < Sheet > listOrganizationSheets ( PaginationParameters parameters ) throws SmartsheetException { String path = "users/sheets" ; if ( parameters != null ) { path += parameters . toQueryString ( ) ; } return this . listResourcesWithWrapper ( path , Sheet . class ) ; }
List all sheets in the organization .
14,654
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 , page , null , null ) ; }
Get a sheet .
14,655
public void getSheetAsPDF ( long id , OutputStream outputStream , PaperSize paperSize ) throws SmartsheetException { getSheetAsFile ( id , paperSize , outputStream , "application/pdf" ) ; }
Get a sheet as a PDF file .
14,656
public Sheet importCsv ( String file , String sheetName , Integer headerRowIndex , Integer primaryRowIndex ) throws SmartsheetException { return importFile ( "sheets/import" , file , "text/csv" , sheetName , headerRowIndex , primaryRowIndex ) ; }
Imports a sheet .
14,657
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 ) ; }
Imports a sheet in given folder .
14,658
public Sheet createSheetInWorkspace ( long workspaceId , Sheet sheet ) throws SmartsheetException { return this . createResource ( "workspaces/" + workspaceId + "/sheets" , Sheet . class , sheet ) ; }
Create a sheet in given workspace .
14,659
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 ) ; }
Imports a sheet in given workspace .
14,660
public SheetPublish updatePublishStatus ( long id , SheetPublish publish ) throws SmartsheetException { return this . updateResource ( "sheets/" + id + "/publish" , SheetPublish . class , publish ) ; }
Sets the publish status of a sheet and returns the new status including the URLs of any enabled publishings .
14,661
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 File ( file ) ; HashMap < String , Object > parameters = new HashMap ( ) ; if ( sheetName == null ) { sheetName = f . getName ( ) ; } parameters . put ( "sheetName" , sheetName ) ; parameters . put ( "headerRowIndex" , headerRowIndex ) ; parameters . put ( "primaryRowIndex" , primaryRowIndex ) ; path = QueryUtil . generateUrl ( path , parameters ) ; HttpRequest request = createHttpRequest ( this . smartsheet . getBaseURI ( ) . resolve ( path ) , HttpMethod . POST ) ; request . getHeaders ( ) . put ( "Content-Disposition" , "attachment" ) ; request . getHeaders ( ) . put ( "Content-Type" , contentType ) ; InputStream is = null ; try { is = new FileInputStream ( f ) ; } catch ( FileNotFoundException e ) { throw new SmartsheetException ( e ) ; } HttpEntity entity = new HttpEntity ( ) ; entity . setContentType ( contentType ) ; entity . setContent ( is ) ; entity . setContentLength ( f . length ( ) ) ; request . setEntity ( entity ) ; Sheet obj = null ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : obj = this . smartsheet . getJsonSerializer ( ) . deserializeResult ( Sheet . class , response . getEntity ( ) . getContent ( ) ) . getResult ( ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return obj ; }
Internal function used by all of the import routines
14,662
public Sheet moveSheet ( long sheetId , ContainerDestination containerDestination ) throws SmartsheetException { String path = "sheets/" + sheetId + "/move" ; return this . createResource ( path , Sheet . class , containerDestination ) ; }
Moves the specified Sheet to another location .
14,663
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." ) ; }
Throws an UnsupportedOperationException .
14,664
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 ) { parameters = pagination . toHashMap ( ) ; } parameters . put ( "include" , QueryUtil . generateCommaSeparatedList ( includes ) ) ; path += QueryUtil . generateUrl ( null , parameters ) ; return this . listResourcesWithWrapper ( path , Column . class ) ; }
List columns of a given sheet .
14,665
public List < Column > addColumns ( long sheetId , List < Column > columns ) throws SmartsheetException { return this . postAndReceiveList ( "sheets/" + sheetId + "/columns" , columns , Column . class ) ; }
Add column to a sheet .
14,666
public Column updateColumn ( long sheetId , Column column ) throws SmartsheetException { Util . throwIfNull ( column ) ; return this . updateResource ( "sheets/" + sheetId + "/columns/" + column . getId ( ) , Column . class , column ) ; }
Update a column .
14,667
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 . generateCommaSeparatedList ( includes ) ) ; path = QueryUtil . generateUrl ( path , parameters ) ; return this . getResource ( path , Column . class ) ; }
Gets the Column specified in the URL .
14,668
public TColumn getColumnByIndex ( int index ) { if ( columns == null ) { return null ; } TColumn result = null ; for ( TColumn column : columns ) { if ( column . getIndex ( ) == index ) { result = column ; break ; } } return result ; }
Get a column by index .
14,669
public AbstractSheet < TRow , TColumn , TCell > setColumns ( List < TColumn > columns ) { this . columns = columns ; return this ; }
Sets the columns for the sheet .
14,670
public AbstractSheet < TRow , TColumn , TCell > setRows ( List < TRow > rows ) { this . rows = rows ; return this ; }
Sets the rows for the sheet .
14,671
public AbstractSheet < TRow , TColumn , TCell > setDiscussions ( List < Discussion > discussions ) { this . discussions = discussions ; return this ; }
Sets the discussions for the sheet .
14,672
public AbstractSheet < TRow , TColumn , TCell > setAttachments ( List < Attachment > attachments ) { this . attachments = attachments ; return this ; }
Sets the attachments for the sheet .
14,673
public AbstractSheet < TRow , TColumn , TCell > setEffectiveAttachmentOptions ( EnumSet < AttachmentType > effectiveAttachmentOptions ) { this . effectiveAttachmentOptions = effectiveAttachmentOptions ; return this ; }
Sets the effective attachment options .
14,674
public AbstractSheet < TRow , TColumn , TCell > setFilters ( List < SheetFilter > filters ) { this . filters = filters ; return this ; }
Sets the list of sheet filters for this sheet .
14,675
public AbstractSheet < TRow , TColumn , TCell > setCrossSheetReferences ( List < CrossSheetReference > crossSheetReferences ) { this . crossSheetReferences = crossSheetReferences ; return this ; }
Sets the list of cross sheet references used by this sheet
14,676
public HttpRequestBase createApacheRequest ( HttpRequest smartsheetRequest ) { HttpRequestBase apacheHttpRequest ; switch ( smartsheetRequest . getMethod ( ) ) { case GET : apacheHttpRequest = new HttpGet ( smartsheetRequest . getUri ( ) ) ; break ; case POST : apacheHttpRequest = new HttpPost ( smartsheetRequest . getUri ( ) ) ; break ; case PUT : apacheHttpRequest = new HttpPut ( smartsheetRequest . getUri ( ) ) ; break ; case DELETE : apacheHttpRequest = new HttpDelete ( smartsheetRequest . getUri ( ) ) ; break ; default : throw new UnsupportedOperationException ( "Request method " + smartsheetRequest . getMethod ( ) + " is not supported!" ) ; } RequestConfig . Builder builder = RequestConfig . custom ( ) ; if ( apacheHttpRequest . getConfig ( ) != null ) { builder = RequestConfig . copy ( apacheHttpRequest . getConfig ( ) ) ; } builder . setRedirectsEnabled ( true ) ; RequestConfig config = builder . build ( ) ; apacheHttpRequest . setConfig ( config ) ; return apacheHttpRequest ; }
Create the Apache HTTP request . Override this function to inject additional haaders in the request or use a proxy .
14,677
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 " + totalElapsedTimeMillis + " + backoff time " + backoffMillis + " exceeds max retry time " + maxRetryTimeMillis + ", exiting retry loop" ) ; return - 1 ; } return backoffMillis ; }
The backoff calculation routine . Uses exponential backoff . If the maximum elapsed time has expired this calculation returns - 1 causing the caller to fall out of the retry loop .
14,678
public boolean shouldRetry ( int previousAttempts , long totalElapsedTimeMillis , HttpResponse response ) { String contentType = response . getEntity ( ) . getContentType ( ) ; if ( contentType != null && ! contentType . startsWith ( JSON_MIME_TYPE ) ) { return false ; } Error error ; try { error = jsonSerializer . deserialize ( Error . class , response . getEntity ( ) . getContent ( ) ) ; } catch ( IOException e ) { return false ; } switch ( error . getErrorCode ( ) ) { case 4001 : case 4002 : case 4003 : case 4004 : break ; default : return false ; } long backoffMillis = calcBackoff ( previousAttempts , totalElapsedTimeMillis , error ) ; if ( backoffMillis < 0 ) return false ; logger . info ( "HttpError StatusCode=" + response . getStatusCode ( ) + ": Retrying in " + backoffMillis + " milliseconds" ) ; try { Thread . sleep ( backoffMillis ) ; } catch ( InterruptedException e ) { logger . warn ( "sleep interrupted" , e ) ; return false ; } return true ; }
Called when an API request fails to determine if it can retry the request . Calls calcBackoff to determine the time to wait in between retries .
14,679
public void setTraces ( Trace ... traces ) { this . traces . clear ( ) ; for ( Trace trace : traces ) { if ( ! trace . addReplacements ( this . traces ) ) { this . traces . add ( trace ) ; } } }
set the traces for this client
14,680
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 this . listResourcesWithWrapper ( path , Attachment . class ) ; }
Get row attachment .
14,681
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 + "/attachments" , inputStream , contentType , contentLength , attachmentName ) ; }
Attach file for simple upload .
14,682
public Discussion createDiscussion ( long sheetId , Discussion discussion ) throws SmartsheetException { Util . throwIfNull ( sheetId , discussion ) ; return this . createResource ( "sheets/" + sheetId + "/discussions" , Discussion . class , discussion ) ; }
Create a discussion on a sheet .
14,683
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 . createDiscussionWithAttachment ( path , discussion , new FileInputStream ( file ) , contentType , file . getName ( ) ) ; }
Create a discussion with attachments on a sheet .
14,684
public static RequestAndResponseData of ( HttpRequestBase request , HttpEntitySnapshot requestEntity , HttpResponse response , HttpEntitySnapshot responseEntity , Set < Trace > traces ) throws IOException { RequestData . Builder requestBuilder = new RequestData . Builder ( ) ; ResponseData . Builder responseBuilder = new ResponseData . Builder ( ) ; if ( request != null ) { requestBuilder . withCommand ( request . getMethod ( ) + " " + request . getURI ( ) ) ; boolean binaryBody = false ; if ( traces . contains ( Trace . RequestHeaders ) && request . getAllHeaders ( ) != null ) { requestBuilder . withHeaders ( ) ; for ( Header header : request . getAllHeaders ( ) ) { String headerName = header . getName ( ) ; String headerValue = header . getValue ( ) ; if ( "Authorization" . equals ( headerName ) && headerValue . length ( ) > 0 ) { headerValue = "Bearer ****" + headerValue . substring ( Math . max ( 0 , headerValue . length ( ) - 4 ) ) ; } else if ( "Content-Disposition" . equals ( headerName ) ) { binaryBody = true ; } requestBuilder . addHeader ( headerName , headerValue ) ; } } if ( requestEntity != null ) { if ( traces . contains ( Trace . RequestBody ) ) { requestBuilder . setBody ( binaryBody ? binaryBody ( requestEntity ) : getContentAsText ( requestEntity ) ) ; } else if ( traces . contains ( Trace . RequestBodySummary ) ) { requestBuilder . setBody ( binaryBody ? binaryBody ( requestEntity ) : truncateAsNeeded ( getContentAsText ( requestEntity ) , TRUNCATE_LENGTH ) ) ; } } } if ( response != null ) { boolean binaryBody = false ; responseBuilder . withStatus ( response . getStatusText ( ) ) ; if ( traces . contains ( Trace . ResponseHeaders ) && response . getHeaders ( ) != null ) { responseBuilder . withHeaders ( ) ; for ( Map . Entry < String , String > header : response . getHeaders ( ) . entrySet ( ) ) { String headerName = header . getKey ( ) ; String headerValue = header . getValue ( ) ; if ( "Content-Disposition" . equals ( headerName ) ) { binaryBody = true ; } responseBuilder . addHeader ( headerName , headerValue ) ; } } if ( responseEntity != null ) { if ( traces . contains ( Trace . ResponseBody ) ) { responseBuilder . setBody ( binaryBody ? binaryBody ( responseEntity ) : getContentAsText ( responseEntity ) ) ; } else if ( traces . contains ( Trace . ResponseBodySummary ) ) { responseBuilder . setBody ( binaryBody ? binaryBody ( responseEntity ) : truncateAsNeeded ( getContentAsText ( responseEntity ) , TRUNCATE_LENGTH ) ) ; } } } return new RequestAndResponseData ( requestBuilder . build ( ) , responseBuilder . build ( ) ) ; }
factory method for creating a RequestAndResponseData object from request and response data with the specifid trace fields
14,685
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." ) ; throw new ResourceNotFoundException ( error ) ; } HttpRequest request = createHttpRequest ( smartsheet . getBaseURI ( ) . resolve ( path ) , HttpMethod . GET ) ; T obj = null ; String content = null ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; InputStream inputStream = response . getEntity ( ) . getContent ( ) ; switch ( response . getStatusCode ( ) ) { case 200 : try { if ( log . isInfoEnabled ( ) ) { ByteArrayOutputStream contentCopyStream = new ByteArrayOutputStream ( ) ; inputStream = StreamUtil . cloneContent ( inputStream , response . getEntity ( ) . getContentLength ( ) , contentCopyStream ) ; content = StreamUtil . toUtf8StringOrHex ( contentCopyStream , getResponseLogLength ( ) ) ; } obj = this . smartsheet . getJsonSerializer ( ) . deserialize ( objectClass , inputStream ) ; } catch ( JsonParseException e ) { log . info ( "failure parsing '{}'" , content , e ) ; throw new SmartsheetException ( e ) ; } catch ( JsonMappingException e ) { log . info ( "failure mapping '{}'" , content , e ) ; throw new SmartsheetException ( e ) ; } catch ( IOException e ) { log . info ( "failure loading '{}'" , content , e ) ; throw new SmartsheetException ( e ) ; } break ; default : handleError ( response ) ; } } catch ( JSONSerializerException jsx ) { log . info ( "failed to parse '{}'" , content , jsx ) ; throw jsx ; } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return obj ; }
Get a resource from Smartsheet REST API .
14,686
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 > obj = null ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : obj = this . smartsheet . getJsonSerializer ( ) . deserializeList ( objectClass , response . getEntity ( ) . getContent ( ) ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return obj ; }
List resources using Smartsheet REST API .
14,687
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 { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : this . smartsheet . getJsonSerializer ( ) . deserializeResult ( objectClass , response . getEntity ( ) . getContent ( ) ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } }
Delete a resource from Smartsheet REST API .
14,688
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 ( path ) , HttpMethod . DELETE ) ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : obj = this . smartsheet . getJsonSerializer ( ) . deserializeListResult ( objectClass , response . getEntity ( ) . getContent ( ) ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return obj . getResult ( ) ; }
Delete resources and return a list from Smartsheet REST API .
14,689
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 ) , HttpMethod . POST ) ; ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream ( ) ; this . smartsheet . getJsonSerializer ( ) . serialize ( objectToPost , objectBytesStream ) ; HttpEntity entity = new HttpEntity ( ) ; entity . setContentType ( "application/json" ) ; entity . setContent ( new ByteArrayInputStream ( objectBytesStream . toByteArray ( ) ) ) ; entity . setContentLength ( objectBytesStream . size ( ) ) ; request . setEntity ( entity ) ; List < S > obj = null ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : obj = this . smartsheet . getJsonSerializer ( ) . deserializeListResult ( objectClassToReceive , response . getEntity ( ) . getContent ( ) ) . getResult ( ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return obj ; }
Post an object to Smartsheet REST API and receive a list of objects from response .
14,690
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 ) ; ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream ( ) ; this . smartsheet . getJsonSerializer ( ) . serialize ( objectToPost , objectBytesStream ) ; HttpEntity entity = new HttpEntity ( ) ; entity . setContentType ( "application/json" ) ; entity . setContent ( new ByteArrayInputStream ( objectBytesStream . toByteArray ( ) ) ) ; entity . setContentLength ( objectBytesStream . size ( ) ) ; request . setEntity ( entity ) ; CopyOrMoveRowResult obj = null ; try { HttpResponse response = this . smartsheet . getHttpClient ( ) . request ( request ) ; switch ( response . getStatusCode ( ) ) { case 200 : obj = this . smartsheet . getJsonSerializer ( ) . deserializeCopyOrMoveRow ( response . getEntity ( ) . getContent ( ) ) ; break ; default : handleError ( response ) ; } } finally { smartsheet . getHttpClient ( ) . releaseConnection ( ) ; } return obj ; }
Post an object to Smartsheet REST API and receive a CopyOrMoveRowResult object from response .
14,691
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 . currentTimeMillis ( ) ; CloseableHttpClient httpClient = HttpClients . createDefault ( ) ; HttpPost uploadFile = createHttpPost ( this . getSmartsheet ( ) . getBaseURI ( ) . resolve ( url ) ) ; try { uploadFile . setHeader ( "Content-Type" , "multipart/form-data; boundary=" + boundary ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } MultipartEntityBuilder builder = MultipartEntityBuilder . create ( ) ; builder . setBoundary ( boundary ) ; builder . addTextBody ( partName , this . getSmartsheet ( ) . getJsonSerializer ( ) . serialize ( t ) , ContentType . APPLICATION_JSON ) ; builder . addBinaryBody ( "file" , inputstream , ContentType . create ( contentType ) , attachmentName ) ; org . apache . http . HttpEntity multipart = builder . build ( ) ; uploadFile . setEntity ( multipart ) ; try { CloseableHttpResponse response = httpClient . execute ( uploadFile ) ; org . apache . http . HttpEntity responseEntity = response . getEntity ( ) ; attachment = this . getSmartsheet ( ) . getJsonSerializer ( ) . deserializeResult ( Attachment . class , responseEntity . getContent ( ) ) . getResult ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } return attachment ; }
Create a multipart upload request .
14,692
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 ) ; } }
Copy stream .
14,693
public PagedResult < Share > listShares ( long objectId , PaginationParameters pagination ) throws SmartsheetException { return this . listShares ( objectId , pagination , false ) ; }
List shares of a given object .
14,694
public Share getShare ( long objectId , String shareId ) throws SmartsheetException { return this . getResource ( getMasterResourceType ( ) + "/" + objectId + "/shares/" + shareId , Share . class ) ; }
Get a Share .
14,695
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 , shares , Share . class ) ; }
Shares the object with the specified Users and Groups .
14,696
public void deleteShare ( long objectId , String shareId ) throws SmartsheetException { this . deleteResource ( getMasterResourceType ( ) + "/" + objectId + "/shares/" + shareId , Share . class ) ; }
Delete a share .
14,697
public ReportPublish updatePublishStatus ( long id , ReportPublish reportPublish ) throws SmartsheetException { return this . updateResource ( "reports/" + id + "/publish" , ReportPublish . class , reportPublish ) ; }
Sets the publish status of a report and returns the new status including the URLs of any enabled publishing .
14,698
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 = pagination . toHashMap ( ) ; } path += QueryUtil . generateUrl ( null , parameters ) ; return this . listResourcesWithWrapper ( path , SheetFilter . class ) ; }
Get all filters .
14,699
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 ( modifiedSince != null ) { String isoDate = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ssZ" ) . format ( modifiedSince ) ; parameters . put ( "modifiedSince" , isoDate ) ; } path += QueryUtil . generateUrl ( null , parameters ) ; return this . listResourcesWithWrapper ( path , Sight . class ) ; }
Gets the list of all Sights where the User has access .