pub struct SmartsheetApi<'a> { /* private fields */ }
Expand description
Client implementation for making requests to the Smartsheet API v2
§Links
Implementations§
Source§impl<'a> SmartsheetApi<'a>
impl<'a> SmartsheetApi<'a>
Sourcepub fn from_token(token: &str) -> Self
pub fn from_token(token: &str) -> Self
Initialize a new SmartsheetApi
object from an API access token.
Sourcepub fn from_env() -> Result<Self, Box<dyn Error + Send + Sync>>
pub fn from_env() -> Result<Self, Box<dyn Error + Send + Sync>>
Initialize a new SmartsheetApi
object from an API access token,
assuming this is currently set in the environment.
Sourcepub fn from_endpoint_and_token(endpoint: &'a str, token: &str) -> Self
pub fn from_endpoint_and_token(endpoint: &'a str, token: &str) -> Self
Initialize a new SmartsheetApi
object from a (custom) base API
endpoint, and an access token.
Sourcepub async fn list_sheets(
&self,
) -> Result<IndexResult<Sheet>, Box<dyn Error + Send + Sync>>
pub async fn list_sheets( &self, ) -> Result<IndexResult<Sheet>, Box<dyn Error + Send + Sync>>
List Sheets - Gets a list of all sheets that the user has access to in alphabetical order by name. The list contains an abbreviated Sheet object for each sheet.
§Docs
- https://smartsheet-platform.github.io/api-docs/#list-sheets
Sourcepub async fn list_sheets_with_params(
&self,
include: impl Into<Option<Vec<ListSheetIncludeFlags>>>,
include_all: impl Into<Option<bool>>,
modified_since: impl Into<Option<&'a str>>,
) -> Result<IndexResult<Sheet>, Box<dyn Error + Send + Sync>>
pub async fn list_sheets_with_params( &self, include: impl Into<Option<Vec<ListSheetIncludeFlags>>>, include_all: impl Into<Option<bool>>, modified_since: impl Into<Option<&'a str>>, ) -> Result<IndexResult<Sheet>, Box<dyn Error + Send + Sync>>
List Sheets - Gets a list of all sheets that the user has access to in alphabetical order by name, with included query parameters. The list contains an abbreviated Sheet object for each sheet.
§Arguments
include
- A comma-separated list of elements to include in the response.include_all
- If true, include all results (i.e. do not paginate).modified_since
- Return sheets modified since a provided datetime. Date should be in ISO-8601 format, for example,2020-01-30T13:25:32-07:00
.
§Docs
- https://smartsheet-platform.github.io/api-docs/#list-sheets
Sourcepub async fn get_sheet(
&self,
sheet_id: u64,
) -> Result<Sheet, Box<dyn Error + Send + Sync>>
pub async fn get_sheet( &self, sheet_id: u64, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>
Get Sheet - Retrieves the specified sheet. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.
§Arguments
sheet_id
- The Smartsheet to retrieve the rows and data for.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-sheet
- https://smartsheet-platform.github.io/api-docs/#row-include-flags
Sourcepub async fn get_sheet_with_multi_contact_info(
&self,
sheet_id: u64,
) -> Result<Sheet, Box<dyn Error + Send + Sync>>
pub async fn get_sheet_with_multi_contact_info( &self, sheet_id: u64, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>
Get Sheet - Retrieves the specified sheet. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.
§Note
This is a convenience method to retrieve a Sheet with the MULTI_CONTACT
cell data correctly populated. This is primarily important so that we can
retrieve the email addresses for such cells, for example.
§Arguments
sheet_id
- The Smartsheet to retrieve the rows and data for.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-sheet
- https://smartsheet-platform.github.io/api-docs/#row-include-flags
Sourcepub async fn get_sheet_with_params(
&self,
sheet_id: u64,
include: impl Into<Option<Vec<SheetIncludeFlags>>>,
exclude: impl Into<Option<Vec<SheetExcludeFlags>>>,
row_ids: impl Into<Option<Vec<u64>>>,
row_numbers: impl Into<Option<Vec<u64>>>,
column_ids: impl Into<Option<Vec<u64>>>,
rows_modified_since: impl Into<Option<&'a str>>,
level: impl Into<Option<Level>>,
) -> Result<Sheet, Box<dyn Error + Send + Sync>>
pub async fn get_sheet_with_params( &self, sheet_id: u64, include: impl Into<Option<Vec<SheetIncludeFlags>>>, exclude: impl Into<Option<Vec<SheetExcludeFlags>>>, row_ids: impl Into<Option<Vec<u64>>>, row_numbers: impl Into<Option<Vec<u64>>>, column_ids: impl Into<Option<Vec<u64>>>, rows_modified_since: impl Into<Option<&'a str>>, level: impl Into<Option<Level>>, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>
Get Sheet - Retrieves the specified sheet, with included query parameters. Returns the sheet, including rows, and optionally populated with discussion and attachment objects.
§Arguments
sheet_id
- The Smartsheet to retrieve the rows and data for.include
- A comma-separated list of elements to include in the response.exclude
- A comma-separated list of elements to not include in the response.row_ids
- A comma-separated list of Row IDs on which to filter the rows included in the result.row_numbers
- A comma-separated list of Row numbers on which to filter the rows included in the result. Non-existent row numbers are ignored.column_ids
- A comma-separated comma-separated list of Column IDs. The response will contain only the specified columns in the ‘columns’ array, and individual rows’ ‘cells’ array will only contain cells in the specified columns.rows_modified_since
- Return rows modified since a provided datetime. Date should be in ISO-8601 format, for example,2020-01-30T13:25:32-07:00
.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-sheet
- https://smartsheet-platform.github.io/api-docs/#row-include-flags
Sourcepub async fn get_row(
&self,
sheet_id: u64,
row_id: u64,
) -> Result<Row, Box<dyn Error + Send + Sync>>
pub async fn get_row( &self, sheet_id: u64, row_id: u64, ) -> Result<Row, Box<dyn Error + Send + Sync>>
Sourcepub async fn get_row_with_column_data(
&self,
sheet_id: u64,
row_id: u64,
) -> Result<Row, Box<dyn Error + Send + Sync>>
pub async fn get_row_with_column_data( &self, sheet_id: u64, row_id: u64, ) -> Result<Row, Box<dyn Error + Send + Sync>>
Sourcepub async fn get_row_with_multi_contact_info(
&self,
sheet_id: u64,
row_id: u64,
) -> Result<Row, Box<dyn Error + Send + Sync>>
pub async fn get_row_with_multi_contact_info( &self, sheet_id: u64, row_id: u64, ) -> Result<Row, Box<dyn Error + Send + Sync>>
Get Row - Retrieves the specified row from a sheet, with included Multi-contact data.
§Note
This is a convenience method to retrieve a Row with the MULTI_CONTACT
cell data correctly populated. This is primarily important so that we can
retrieve the email addresses for such cells, for example.
§Arguments
sheet_id
- The Smartsheet to retrieve the rows from.row_id
- The specified row to retrieve.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-row
Sourcepub async fn get_row_with_params(
&self,
sheet_id: u64,
row_id: u64,
include: impl Into<Option<Vec<RowIncludeFlags>>>,
exclude: impl Into<Option<Vec<RowExcludeFlags>>>,
level: impl Into<Option<Level>>,
) -> Result<Row, Box<dyn Error + Send + Sync>>
pub async fn get_row_with_params( &self, sheet_id: u64, row_id: u64, include: impl Into<Option<Vec<RowIncludeFlags>>>, exclude: impl Into<Option<Vec<RowExcludeFlags>>>, level: impl Into<Option<Level>>, ) -> Result<Row, Box<dyn Error + Send + Sync>>
Get Row - Retrieves the specified row from a sheet, with included query parameters.
§Arguments
sheet_id
- The Smartsheet to retrieve the rows from.row_id
- The specified row to retrieve.include
- A comma-separated list of elements to include in the response.exclude
- A comma-separated list of elements to not include in the response.level
- Specifies whether multi-contact data is returned in a backwards-compatible, text format, or as multi-contact data.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-row
- https://smartsheet-platform.github.io/api-docs/#row-include-flags
Sourcepub async fn add_rows(
&self,
sheet_id: u64,
rows: impl Into<Vec<Row>>,
) -> Result<RowResult, Box<dyn Error + Send + Sync>>
pub async fn add_rows( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>
Add Rows - Inserts one or more rows into the sheet.
If you want to insert the rows in any position but the default, use location-specifier attributes.
§Arguments
sheet_id
- The Smartsheet to add the rows to.rows
- An array (list) of new Rows with the cell values to add.
§Docs
Sourcepub async fn add_rows_with_params(
&self,
sheet_id: u64,
rows: impl Into<Vec<Row>>,
allow_partial_success: impl Into<Option<bool>>,
override_validation: impl Into<Option<bool>>,
) -> Result<RowResult, Box<dyn Error + Send + Sync>>
pub async fn add_rows_with_params( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, allow_partial_success: impl Into<Option<bool>>, override_validation: impl Into<Option<bool>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>
Add Rows - Inserts one or more rows into the sheet, with included query parameters.
If you want to insert the rows in any position but the default, use location-specifier attributes.
§Arguments
sheet_id
- The Smartsheet to add the rows to.rows
- An array (list) of new Rows with the cell values to add.allow_partial_success
- Default:false
. When specified with a value oftrue
, enables partial success for this bulk operation. See Partial Success for more information.override_validation
- Default:false
. If set to a value oftrue
, allows a cell value outside of the validation limits. You must also specify strict on a per-cell level with a value of false to bypass value type checking.
§Docs
Sourcepub async fn update_rows(
&self,
sheet_id: u64,
rows: impl Into<Vec<Row>>,
) -> Result<RowResult, Box<dyn Error + Send + Sync>>
pub async fn update_rows( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>
Update Rows - Updates cell values in the specified rows, expands/collapses the specified rows, and/or modifies the position of specified rows (including indenting/outdenting). For detailed information about changing row positions, see location-specifier attributes.
§Arguments
sheet_id
- The Smartsheet to update the rows in.rows
- An array (list) of Rows with the updated cell values.
§Docs
Sourcepub async fn update_rows_with_params(
&self,
sheet_id: u64,
rows: impl Into<Vec<Row>>,
allow_partial_success: impl Into<Option<bool>>,
override_validation: impl Into<Option<bool>>,
) -> Result<RowResult, Box<dyn Error + Send + Sync>>
pub async fn update_rows_with_params( &self, sheet_id: u64, rows: impl Into<Vec<Row>>, allow_partial_success: impl Into<Option<bool>>, override_validation: impl Into<Option<bool>>, ) -> Result<RowResult, Box<dyn Error + Send + Sync>>
Update Rows - Updates cell values in the specified rows, with included query parameters.
Alternatively, expands/collapses the specified rows, and/or modifies the position of specified rows (including indenting/outdenting). For detailed information about changing row positions, see location-specifier attributes.
§Arguments
sheet_id
- The Smartsheet to update the rows in.rows
- An array (list) of Rows with the updated cell values.allow_partial_success
- When specified with a value oftrue
, enables partial success for this bulk operation. See Partial Success for more information.override_validation
- If set to a value oftrue
, allows a cell value outside of the validation limits. You must also specify strict on a per-cell level with a value of false to bypass value type checking.
§Docs
Sourcepub async fn delete_rows<const N: usize>(
&self,
sheet_id: u64,
row_ids: impl Into<[u64; N]>,
) -> Result<RowResult<u64>, Box<dyn Error + Send + Sync>>
pub async fn delete_rows<const N: usize>( &self, sheet_id: u64, row_ids: impl Into<[u64; N]>, ) -> Result<RowResult<u64>, Box<dyn Error + Send + Sync>>
Sourcepub async fn delete_rows_with_params<const N: usize>(
&self,
sheet_id: u64,
row_ids: impl Into<[u64; N]>,
ignore_rows_not_found: impl Into<Option<bool>>,
) -> Result<RowResult<u64>, Box<dyn Error + Send + Sync>>
pub async fn delete_rows_with_params<const N: usize>( &self, sheet_id: u64, row_ids: impl Into<[u64; N]>, ignore_rows_not_found: impl Into<Option<bool>>, ) -> Result<RowResult<u64>, Box<dyn Error + Send + Sync>>
Delete Rows - Deletes one or more specified rows from the sheet, with included query parameters.
§Arguments
sheet_id
- The Smartsheet to delete the rows from.row_ids
- An array (list) containing the IDs of the Rows to delete from the smartsheet.ignore_rows_not_found
- Default:false
. If set tofalse
and any of the specified Row IDs are not found, no rows are deleted, and the “not found” error is returned.
§Docs
Sourcepub async fn list_columns(
&self,
sheet_id: u64,
) -> Result<IndexResult<Column>, Box<dyn Error + Send + Sync>>
pub async fn list_columns( &self, sheet_id: u64, ) -> Result<IndexResult<Column>, Box<dyn Error + Send + Sync>>
List Columns - Gets a list of all columns belonging to the specified sheet.
§Docs
- https://smartsheet-platform.github.io/api-docs/#list-columns
Sourcepub async fn list_columns_with_params(
&self,
sheet_id: u64,
level: impl Into<Option<Level>>,
include: impl Into<Option<Vec<ColumnIncludeFlags>>>,
include_all: impl Into<Option<bool>>,
) -> Result<IndexResult<Column>, Box<dyn Error + Send + Sync>>
pub async fn list_columns_with_params( &self, sheet_id: u64, level: impl Into<Option<Level>>, include: impl Into<Option<Vec<ColumnIncludeFlags>>>, include_all: impl Into<Option<bool>>, ) -> Result<IndexResult<Column>, Box<dyn Error + Send + Sync>>
List Columns - Gets a list of all columns belonging to the specified sheet, with included query parameters.
§Arguments
sheet_id
- The Smartsheet to retrieve the columns from.level
- Specifies whether multi-contact data is returned in a backwards-compatible, text format, or as multi-contact data.include
- A comma-separated list of elements to include in the response.include_all
- If true, include all results (i.e. do not paginate).
§Docs
- https://smartsheet-platform.github.io/api-docs/#list-columns
Sourcepub async fn get_column(
&self,
sheet_id: u64,
column_id: u64,
) -> Result<Column, Box<dyn Error + Send + Sync>>
pub async fn get_column( &self, sheet_id: u64, column_id: u64, ) -> Result<Column, Box<dyn Error + Send + Sync>>
Sourcepub async fn get_column_with_params(
&self,
sheet_id: u64,
column_id: u64,
level: impl Into<Option<Level>>,
include: impl Into<Option<Vec<ColumnIncludeFlags>>>,
) -> Result<Column, Box<dyn Error + Send + Sync>>
pub async fn get_column_with_params( &self, sheet_id: u64, column_id: u64, level: impl Into<Option<Level>>, include: impl Into<Option<Vec<ColumnIncludeFlags>>>, ) -> Result<Column, Box<dyn Error + Send + Sync>>
Get Column - Retrieves a column by id from the specified sheet, with included query parameters.
§Arguments
sheet_id
- The Smartsheet to retrieve the column for.column_id
- The Column Id to retrieve the data for.level
- Specifies whether multi-contact data is returned in a backwards-compatible, text format, or as multi-contact data.include
- A comma-separated list of elements to include in the response.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-column
Sourcepub async fn list_attachments(
&self,
sheet_id: u64,
) -> Result<IndexResult<AttachmentMeta>, Box<dyn Error + Send + Sync>>
pub async fn list_attachments( &self, sheet_id: u64, ) -> Result<IndexResult<AttachmentMeta>, Box<dyn Error + Send + Sync>>
Sourcepub async fn get_attachment(
&self,
sheet_id: u64,
attachment_id: u64,
) -> Result<Attachment, Box<dyn Error + Send + Sync>>
pub async fn get_attachment( &self, sheet_id: u64, attachment_id: u64, ) -> Result<Attachment, Box<dyn Error + Send + Sync>>
Get Attachment - Retrieves an attachment by id from the specified sheet.
§Notes
Fetches a temporary URL that allows you to download an attachment. The
urlExpiresInMillis
attribute tells you how long the URL is valid.
§Arguments
sheet_id
- The Smartsheet to retrieve the attachments for.attachment_id
- The Attachment Id to retrieve the data for.
§Docs
- https://smartsheet-platform.github.io/api-docs/#get-attachment
Sourcepub async fn get_sheet_by_name(
&self,
sheet_name: &'a str,
) -> Result<Sheet, Box<dyn Error + Send + Sync>>
👎Deprecated since 0.2.0: please cache the sheet id and use get_sheet
instead
pub async fn get_sheet_by_name( &self, sheet_name: &'a str, ) -> Result<Sheet, Box<dyn Error + Send + Sync>>
get_sheet
insteadGet Sheet By Name - Convenience function to retrieve a specified sheet by name. Used for those times when you don’t know the Sheet Id.
This will internally call list_sheets
and then filter the response
data by the sheet name. It returns the first matching name.
Returns the sheet, including rows, and optionally populated with discussion and attachment objects.
§Arguments
sheet_name
- The name of the Smartsheet to filter results by.
Sourcepub async fn get_column_by_title(
&self,
sheet_id: u64,
column_title: &'a str,
) -> Result<Column, Box<dyn Error + Send + Sync>>
👎Deprecated since 0.2.0: please cache the column id and use get_column
instead
pub async fn get_column_by_title( &self, sheet_id: u64, column_title: &'a str, ) -> Result<Column, Box<dyn Error + Send + Sync>>
get_column
insteadGet Column By Title - Convenience function to retrieve a specified column by title (name). Used for those times when you don’t know the Column Id.
This will internally call list_columns
and then filter the response
data by the column title. It returns the first matching name.
§Arguments
sheet_id
- The Smartsheet to retrieve the column from.column_title
- The name of the column to filter results by.