com.smartsheet.api.ShareResources Maven / Gradle / Ivy
Show all versions of smartsheet-sdk-java Show documentation
/*
* Copyright (C) 2023 Smartsheet
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.smartsheet.api;
import com.smartsheet.api.models.PagedResult;
import com.smartsheet.api.models.PaginationParameters;
import com.smartsheet.api.models.Share;
import java.util.List;
/**
* This interface provides methods to access Share resources.
*
* Thread Safety: Implementation of this interface must be thread safe.
*/
public interface ShareResources {
/**
* List shares of a given object.
*
* It mirrors to the following Smartsheet REST API method:
* GET /workspace/{id}/shares
* GET /sheet/{id}/shares
*
* @param objectId the object id
* @param parameters the pagination parameters
* @return the list of Share objects (note that an empty list will be returned if there is none).
* @throws IllegalArgumentException if any argument is null or empty string
* @throws InvalidRequestException if there is any problem with the REST API request
* @throws AuthorizationException if there is any problem with the REST API authorization (access token)
* @throws ResourceNotFoundException if the resource cannot be found
* @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
* @throws SmartsheetException if there is any other error during the operation
* @deprecated As of release 2.0. Please use the other listShares method in this class and pass `includeWorkspaceShares` as `false`
*/
@Deprecated(since = "2.0.0", forRemoval = true)
PagedResult listShares(long objectId, PaginationParameters parameters) throws SmartsheetException;
/**
* List shares of a given object.
*
* It mirrors to the following Smartsheet REST API method:
* GET /workspace/{id}/shares
* GET /sheet/{id}/shares
*
* @param objectId the object id
* @param parameters the pagination parameters
* @param includeWorkspaceShares include workspace shares in enumeration
* @return the list of Share objects (note that an empty list will be returned if there is none).
* @throws IllegalArgumentException if any argument is null or empty string
* @throws InvalidRequestException if there is any problem with the REST API request
* @throws AuthorizationException if there is any problem with the REST API authorization (access token)
* @throws ResourceNotFoundException if the resource cannot be found
* @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
* @throws SmartsheetException if there is any other error during the operation
*/
PagedResult listShares(
long objectId,
PaginationParameters parameters,
Boolean includeWorkspaceShares
) throws SmartsheetException;
/**
* Get a Share.
*
* It mirrors to the following Smartsheet REST API method:
* GET /workspaces/{workspaceId}/shares/{shareId}
* GET /sheets/{sheetId}/shares/{shareId}
* GET /reports/{reportId}/shares
*
* Exceptions:
* InvalidRequestException : if there is any problem with the REST API request
* AuthorizationException : if there is any problem with the REST API authorization(access token)
* ResourceNotFoundException : if the resource can not be found
* ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
* SmartsheetRestException : if there is any other REST API related error occurred during the operation
* SmartsheetException : if there is any other error occurred during the operation
*
* @param objectId the ID of the object to share
* @param shareId the ID of the share
* @return the share (note that if there is no such resource, this method will throw ResourceNotFoundException
* rather than returning null).
* @throws SmartsheetException the smartsheet exception
*/
Share getShare(long objectId, String shareId) throws SmartsheetException;
/**
* Shares the object with the specified Users and Groups.
*
* It mirrors to the following Smartsheet REST API method:
* POST /workspaces/{id}/shares
* POST /sheets/{id}/shares
* POST /reports/{reportId}/shares
*
* Exceptions:
* IllegalArgumentException : if multiShare is null
* InvalidRequestException : if there is any problem with the REST API request
* AuthorizationException : if there is any problem with the REST API authorization(access token)
* ResourceNotFoundException : if the resource can not be found
* ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
* SmartsheetRestException : if there is any other REST API related error occurred during the operation
* SmartsheetException : if there is any other error occurred during the operation
*
* @param objectId the ID of the object to share
* @param shares list of share objects
* @param sendEmail whether to send email
* @return the created shares
* @throws SmartsheetException the smartsheet exception
*/
List shareTo(long objectId, List shares, Boolean sendEmail) throws SmartsheetException;
/**
* Update a share.
*
* It mirrors to the following Smartsheet REST API method:
* PUT /workspaces/{workspaceId}/shares/{shareId}
* PUT /sheets/{sheetId}/shares/{shareId}
* PUT /reports/{reportId}/shares/{shareId}
*
* @param objectId the ID of the object to share
* @param share the share
* @return the updated share (note that if there is no such resource, this method will throw
* ResourceNotFoundException rather than returning null).
* @throws IllegalArgumentException if any argument is null or empty string
* @throws InvalidRequestException if there is any problem with the REST API request
* @throws AuthorizationException if there is any problem with the REST API authorization (access token)
* @throws ResourceNotFoundException if the resource cannot be found
* @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
* @throws SmartsheetException if there is any other error during the operation
*/
Share updateShare(long objectId, Share share) throws SmartsheetException;
/**
* Delete a share.
*
* It mirrors to the following Smartsheet REST API method:
* DELETE /workspaces/{workspaceId}/shares/{shareId}
* DELETE /sheets/{sheetId}/shares/{shareId}
* DELETE /reports/{reportId}/shares/{shareId}
*
* Exceptions:
* InvalidRequestException : if there is any problem with the REST API request
* AuthorizationException : if there is any problem with the REST API authorization(access token)
* ResourceNotFoundException : if the resource can not be found
* ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
* SmartsheetRestException : if there is any other REST API related error occurred during the operation
* SmartsheetException : if there is any other error occurred during the operation
*
* @param objectId the ID of the object to share
* @param shareId the ID of the share to delete
* @throws SmartsheetException the smartsheet exception
*/
void deleteShare(long objectId, String shareId) throws SmartsheetException;
}