Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [x.x.x] - unreleased
### Added
- Support for PUT /sheets/{sheetId}/dataclassification endpoint (Set Data Classification)
- Support for DELETE /sheets/{sheetId}/dataclassification endpoint (Remove Data Classification)
- Added `dataClassification` field to Sheet model

## [3.11.0] - 2026-04-30
### Added
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/smartsheet/api/SheetResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.smartsheet.api;

import com.smartsheet.api.models.ContainerDestination;
import com.smartsheet.api.models.DataClassification;
import com.smartsheet.api.models.MultiRowEmail;
import com.smartsheet.api.models.PagedResult;
import com.smartsheet.api.models.PaginationParameters;
Expand Down Expand Up @@ -548,6 +549,37 @@ Sheet importXlsxInWorkspace(
*/
void deleteSheet(long id) throws SmartsheetException;

/**
* <p>Sets the data classification on a sheet.</p>
*
* <p>It mirrors to the following Smartsheet REST API method: PUT /sheets/{sheetId}/dataclassification</p>
*
* @param sheetId the sheet id
* @param dataClassification the DataClassification object
* @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
*/
void setDataClassification(long sheetId, DataClassification dataClassification) throws SmartsheetException;

/**
* <p>Removes the data classification from a sheet. Requires ADMIN or OWNER access.</p>
*
* <p>It mirrors to the following Smartsheet REST API method: DELETE /sheets/{sheetId}/dataclassification</p>
*
* @param sheetId the sheet id
* @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
*/
void deleteDataClassification(long sheetId) throws SmartsheetException;

/**
* <p>Update a sheet.</p>
*
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.smartsheet.api.internal.util.QueryUtil;
import com.smartsheet.api.internal.util.Util;
import com.smartsheet.api.models.ContainerDestination;
import com.smartsheet.api.models.DataClassification;
import com.smartsheet.api.models.MultiRowEmail;
import com.smartsheet.api.models.PagedResult;
import com.smartsheet.api.models.PaginationParameters;
Expand Down Expand Up @@ -806,6 +807,42 @@ public void deleteSheet(long id) throws SmartsheetException {
this.deleteResource(SHEETS + "/" + id, Sheet.class);
}

/**
* Sets the data classification on a sheet.
* <p>
* It mirrors to the following Smartsheet REST API method: PUT /sheets/{sheetId}/dataclassification
*
* @param sheetId the sheet id
* @param dataClassification the DataClassification object
* @throws IllegalArgumentException : if any argument is null
* @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 can not be found
* @throws ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
* @throws SmartsheetRestException : if there is any other REST API related error occurred during the operation
* @throws SmartsheetException : if there is any other error occurred during the operation
*/
public void setDataClassification(long sheetId, DataClassification dataClassification) throws SmartsheetException {
this.updateResource(SHEETS + "/" + sheetId + "/dataclassification", DataClassification.class, dataClassification);
}

/**
* Removes the data classification from a sheet. Requires ADMIN or OWNER access.
* <p>
* It mirrors to the following Smartsheet REST API method: DELETE /sheets/{sheetId}/dataclassification
*
* @param sheetId the sheet id
* @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 can not be found
* @throws ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
* @throws SmartsheetRestException : if there is any other REST API related error occurred during the operation
* @throws SmartsheetException : if there is any other error occurred during the operation
*/
public void deleteDataClassification(long sheetId) throws SmartsheetException {
this.deleteResource(SHEETS + "/" + sheetId + "/dataclassification", DataClassification.class);
}

/**
* Update a sheet.
* <p>
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/smartsheet/api/models/AbstractSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.smartsheet.api.models.enums.AccessLevel;
import com.smartsheet.api.models.enums.AttachmentType;
import com.smartsheet.api.models.enums.DataClassificationType;
import com.smartsheet.api.models.enums.ResourceManagementType;

import java.util.Date;
Expand Down Expand Up @@ -76,6 +77,11 @@ public abstract class AbstractSheet<TRow extends AbstractRow<TColumn, TCell>, TC
*/
private Boolean dependenciesEnabled;

/**
* Represents the data classification of the sheet.
*/
private DataClassificationType dataClassification;

/**
* Represents the discussions for the sheet.
*/
Expand Down Expand Up @@ -367,6 +373,26 @@ public <T extends AbstractSheet<TRow, TColumn, TCell>> T setDependenciesEnabled(
return (T) this;
}

/**
* Gets the data classification of the sheet.
*
* @return the data classification
*/
public DataClassificationType getDataClassification() {
return dataClassification;
}

/**
* Sets the data classification of the sheet.
*
* @param dataClassification the data classification
*/
@SuppressWarnings("unchecked")
public <T extends AbstractSheet<TRow, TColumn, TCell>> T setDataClassification(DataClassificationType dataClassification) {
this.dataClassification = dataClassification;
return (T) this;
}

/**
* Gets the discussions for the sheet.
*
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/smartsheet/api/models/DataClassification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2026 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.models;

import com.smartsheet.api.models.enums.DataClassificationType;

/**
* Represents the data classification of a sheet.
*/
public class DataClassification {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with the C# SDK

Suggested change
public class DataClassification {
public class SheetDataClassification {


private DataClassificationType dataClassification;

/**
* Gets the data classification.
*
* @return the data classification
*/
public DataClassificationType getDataClassification() {
return dataClassification;
}

/**
* Sets the data classification.
*
* @param dataClassification the data classification
* @return this DataClassification object for chaining
*/
public DataClassification setDataClassification(DataClassificationType dataClassification) {
this.dataClassification = dataClassification;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2026 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.models.enums;

/**
* Represents the data classification level of a sheet.
*/
public enum DataClassificationType {
PUBLIC,
INTERNAL,
CONFIDENTIAL,
SECRET,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2025 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.sdktest.sheets;

public class CommonTestConstants {
public static final long TEST_SHEET_ID = 1234567890123456L;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2025 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.sdktest.sheets;

import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import com.smartsheet.api.Smartsheet;
import com.smartsheet.api.SmartsheetException;
import com.smartsheet.api.WiremockClient;
import com.smartsheet.api.WiremockClientWrapper;
import com.smartsheet.api.sdktest.Utils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.net.URI;
import java.util.UUID;

import static com.smartsheet.api.sdktest.sheets.CommonTestConstants.TEST_SHEET_ID;
import static org.assertj.core.api.Assertions.assertThat;

public class TestDeleteDataClassification {

@Test
void testDeleteDataClassificationGeneratedUrlIsCorrect() throws SmartsheetException {
String requestId = UUID.randomUUID().toString();
WiremockClientWrapper wrapper = Utils.createWiremockSmartsheetClient(
"/sheets/delete-data-classification/all-response-body-properties",
requestId
);
Smartsheet smartsheet = wrapper.getSmartsheet();
WiremockClient wiremockClient = wrapper.getWiremockClient();

smartsheet.sheetResources().deleteDataClassification(TEST_SHEET_ID);
LoggedRequest wiremockRequest = wiremockClient.findWiremockRequest(requestId);
String path = URI.create(wiremockRequest.getUrl()).getPath();

assertThat(path).isEqualTo("/2.0/sheets/" + TEST_SHEET_ID + "/dataclassification");
}

@Test
void testDeleteDataClassificationAllResponseBodyProperties() {
String requestId = UUID.randomUUID().toString();
WiremockClientWrapper wrapper = Utils.createWiremockSmartsheetClient(
"/sheets/delete-data-classification/all-response-body-properties",
requestId
);
Smartsheet smartsheet = wrapper.getSmartsheet();

Assertions.assertDoesNotThrow(() ->
smartsheet.sheetResources().deleteDataClassification(TEST_SHEET_ID)
);
}

@Test
void testDeleteDataClassificationError500Response() {
String requestId = UUID.randomUUID().toString();
WiremockClientWrapper wrapper = Utils.createWiremockSmartsheetClient("/errors/500-response", requestId);
Smartsheet smartsheet = wrapper.getSmartsheet();

SmartsheetException exception = Assertions.assertThrows(SmartsheetException.class, () ->
smartsheet.sheetResources().deleteDataClassification(TEST_SHEET_ID)
);

assertThat(exception.getMessage()).isEqualTo("Internal Server Error");
}

@Test
void testDeleteDataClassificationError400Response() {
String requestId = UUID.randomUUID().toString();
WiremockClientWrapper wrapper = Utils.createWiremockSmartsheetClient("/errors/400-response", requestId);
Smartsheet smartsheet = wrapper.getSmartsheet();

SmartsheetException exception = Assertions.assertThrows(SmartsheetException.class, () ->
smartsheet.sheetResources().deleteDataClassification(TEST_SHEET_ID)
);

assertThat(exception.getMessage()).isEqualTo("Malformed Request");
}
}
Loading
Loading