• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartsheet / smartsheet-java-sdk / #41

24 Aug 2023 04:59PM UTC coverage: 50.458% (+0.01%) from 50.444%
#41

push

github-actions

web-flow
Fix Checkstyle Violations in "Impl" Classes (#53)

241 of 241 new or added lines in 32 files covered. (100.0%)

3417 of 6772 relevant lines covered (50.46%)

0.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.38
/src/main/java/com/smartsheet/api/internal/SheetAutomationRuleResourcesImpl.java
1
package com.smartsheet.api.internal;
2

3
/*
4
 * #[license]
5
 * Smartsheet SDK for Java
6
 * %%
7
 * Copyright (C) 2023 Smartsheet
8
 * %%
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *      http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 * %[license]
21
 */
22

23
import com.smartsheet.api.SheetAutomationRuleResources;
24
import com.smartsheet.api.SmartsheetException;
25
import com.smartsheet.api.internal.util.QueryUtil;
26
import com.smartsheet.api.internal.util.Util;
27
import com.smartsheet.api.models.AutomationRule;
28
import com.smartsheet.api.models.PagedResult;
29
import com.smartsheet.api.models.PaginationParameters;
30

31
import java.util.HashMap;
32
import java.util.Map;
33

34
public class SheetAutomationRuleResourcesImpl extends AbstractResources implements SheetAutomationRuleResources {
35

36
    private static final String SHEETS_PATH = "sheets/";
37

38
    private static final String AUTOMATION_RULES = "automationrules";
39

40
    /**
41
     * Constructor.
42
     * <p>
43
     * Exceptions: - IllegalArgumentException : if any argument is null
44
     *
45
     * @param smartsheet the smartsheet
46
     */
47
    public SheetAutomationRuleResourcesImpl(SmartsheetImpl smartsheet) {
48
        super(smartsheet);
1✔
49
    }
1✔
50

51
    /**
52
     * Get all automation rules for this sheet
53
     * <p>
54
     * It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/automationrules
55
     * <p>
56
     * Exceptions:
57
     *   IllegalArgumentException : if any argument is null
58
     *   InvalidRequestException : if there is any problem with the REST API request
59
     *   AuthorizationException : if there is any problem with the REST API authorization(access token)
60
     *   ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
61
     *   SmartsheetRestException : if there is any other REST API related error occurred during the operation
62
     *   SmartsheetException : if there is any other error occurred during the operation
63
     *
64
     * @param sheetId the sheet ID
65
     * @param pagination the pagination pagination
66
     * @return all the automation rules
67
     * @throws SmartsheetException the smartsheet exception
68
     */
69
    public PagedResult<AutomationRule> listAutomationRules(long sheetId, PaginationParameters pagination) throws SmartsheetException {
70
        String path = SHEETS_PATH + sheetId + "/" + AUTOMATION_RULES;
×
71
        Map<String, Object> parameters = new HashMap<>();
×
72

73
        if (pagination != null) {
×
74
            parameters = pagination.toHashMap();
×
75
        }
76
        path += QueryUtil.generateUrl(null, parameters);
×
77

78
        return this.listResourcesWithWrapper(path, AutomationRule.class);
×
79
    }
80

81
    /**
82
     * Get a automation rule.
83
     * <p>
84
     * It mirrors to the following Smartsheet REST API method: GET /sheets/{sheetId}/automationrules/{automationRuleId}
85
     * <p>
86
     * Exceptions:
87
     *   InvalidRequestException : if there is any problem with the REST API request
88
     *   AuthorizationException : if there is any problem with the REST API authorization(access token)
89
     *   ResourceNotFoundException : if the resource can not be found
90
     *   ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
91
     *   SmartsheetRestException : if there is any other REST API related error occurred during the operation
92
     *   SmartsheetException : if there is any other error occurred during the operation
93
     *
94
     * @param sheetId the sheetId
95
     * @param automationRuleId the automation rule ID
96
     * @return the automation rule
97
     * @throws SmartsheetException the smartsheet exception
98
     */
99
    public AutomationRule getAutomationRule(long sheetId, long automationRuleId) throws SmartsheetException {
100
        return this.getResource(SHEETS_PATH + sheetId + "/" + AUTOMATION_RULES + "/" + automationRuleId, AutomationRule.class);
×
101
    }
102

103
    /**
104
     * Updates an automation rule.
105
     * <p>
106
     * It mirrors to the following Smartsheet REST API method: PUT /sheets/{sheetId}/automationrules/{automationRuleId}
107
     * <p>
108
     * Exceptions:
109
     *   IllegalArgumentException : if any argument is null
110
     *   InvalidRequestException : if there is any problem with the REST API request
111
     *   AuthorizationException : if there is any problem with the REST API authorization(access token)
112
     *   ResourceNotFoundException : if the resource can not be found
113
     *   ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
114
     *   SmartsheetRestException : if there is any other REST API related error occurred during the operation
115
     *   SmartsheetException : if there is any other error occurred during the operation
116
     *
117
     * @param sheetId the sheetId
118
     * @param automationRule the automation rule to update
119
     * @return the updated automation rule (note that if there is no such resource, this method will throw
120
     *     ResourceNotFoundException rather than returning null).
121
     * @throws SmartsheetException the smartsheet exception
122
     */
123
    public AutomationRule updateAutomationRule(long sheetId, AutomationRule automationRule) throws SmartsheetException {
124
        Util.throwIfNull(automationRule);
×
125
        return this.updateResource(SHEETS_PATH + sheetId + "/" + AUTOMATION_RULES + "/" + automationRule.getId(),
×
126
                AutomationRule.class, automationRule);
127
    }
128

129
    /**
130
     * Delete an automation rule.
131
     * <p>
132
     * It mirrors to the following Smartsheet REST API method: DELETE /sheets/{sheetId}/automationrules/{automationRuleId}
133
     * <p>
134
     * Exceptions:
135
     *   IllegalArgumentException : if any argument is null
136
     *   InvalidRequestException : if there is any problem with the REST API request
137
     *   AuthorizationException : if there is any problem with the REST API authorization(access token)
138
     *   ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
139
     *   SmartsheetRestException : if there is any other REST API related error occurred during the operation
140
     *   SmartsheetException : if there is any other error occurred during the operation
141
     *
142
     * @param sheetId the sheet ID
143
     * @param automationRuleId the automation rule ID
144
     * @throws SmartsheetException the smartsheet exception
145
     */
146
    public void deleteAutomationRule(long sheetId, long automationRuleId) throws SmartsheetException {
147
        this.deleteResource(SHEETS_PATH + sheetId + "/" + AUTOMATION_RULES + "/" + automationRuleId, AutomationRule.class);
×
148
    }
×
149
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc