001package com.box.sdkgen.managers.retentionpolicies; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.schemas.retentionpolicymaxextensionlengthrequest.RetentionPolicyMaxExtensionLengthRequest; 006import com.box.sdkgen.schemas.retentionpolicymaxextensionlengthrequest.RetentionPolicyMaxExtensionLengthRequestEnum; 007import com.box.sdkgen.schemas.usermini.UserMini; 008import com.box.sdkgen.serialization.json.EnumWrapper; 009import com.fasterxml.jackson.annotation.JsonFilter; 010import com.fasterxml.jackson.annotation.JsonProperty; 011import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 012import com.fasterxml.jackson.databind.annotation.JsonSerialize; 013import java.util.List; 014import java.util.Objects; 015 016@JsonFilter("nullablePropertyFilter") 017public class CreateRetentionPolicyRequestBody extends SerializableObject { 018 019 /** The name for the retention policy. */ 020 @JsonProperty("policy_name") 021 protected final String policyName; 022 023 /** The additional text description of the retention policy. */ 024 protected String description; 025 026 /** 027 * The type of the retention policy. A retention policy type can either be `finite`, where a 028 * specific amount of time to retain the content is known upfront, or `indefinite`, where the 029 * amount of time to retain the content is still unknown. 030 */ 031 @JsonDeserialize( 032 using = 033 CreateRetentionPolicyRequestBodyPolicyTypeField 034 .CreateRetentionPolicyRequestBodyPolicyTypeFieldDeserializer.class) 035 @JsonSerialize( 036 using = 037 CreateRetentionPolicyRequestBodyPolicyTypeField 038 .CreateRetentionPolicyRequestBodyPolicyTypeFieldSerializer.class) 039 @JsonProperty("policy_type") 040 protected final EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> policyType; 041 042 /** 043 * The disposition action of the retention policy. `permanently_delete` deletes the content 044 * retained by the policy permanently. `remove_retention` lifts retention policy from the content, 045 * allowing it to be deleted by users once the retention policy has expired. 046 */ 047 @JsonDeserialize( 048 using = 049 CreateRetentionPolicyRequestBodyDispositionActionField 050 .CreateRetentionPolicyRequestBodyDispositionActionFieldDeserializer.class) 051 @JsonSerialize( 052 using = 053 CreateRetentionPolicyRequestBodyDispositionActionField 054 .CreateRetentionPolicyRequestBodyDispositionActionFieldSerializer.class) 055 @JsonProperty("disposition_action") 056 protected final EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> 057 dispositionAction; 058 059 /** 060 * The length of the retention policy. This value specifies the duration in days that the 061 * retention policy will be active for after being assigned to content. If the policy has a 062 * `policy_type` of `indefinite`, the `retention_length` will also be `indefinite`. 063 */ 064 @JsonProperty("retention_length") 065 protected CreateRetentionPolicyRequestBodyRetentionLengthField retentionLength; 066 067 /** 068 * Specifies the retention type: 069 * 070 * <p>* `modifiable`: You can modify the retention policy. For example, you can add or remove 071 * folders, shorten or lengthen the policy duration, or delete the assignment. Use this type if 072 * your retention policy is not related to any regulatory purposes. 073 * 074 * <p>* `non_modifiable`: You can modify the retention policy only in a limited way: add a folder, 075 * lengthen the duration, retire the policy, change the disposition action or notification 076 * settings. You cannot perform other actions, such as deleting the assignment or shortening the 077 * policy duration. Use this type to ensure compliance with regulatory retention policies. 078 */ 079 @JsonDeserialize( 080 using = 081 CreateRetentionPolicyRequestBodyRetentionTypeField 082 .CreateRetentionPolicyRequestBodyRetentionTypeFieldDeserializer.class) 083 @JsonSerialize( 084 using = 085 CreateRetentionPolicyRequestBodyRetentionTypeField 086 .CreateRetentionPolicyRequestBodyRetentionTypeFieldSerializer.class) 087 @JsonProperty("retention_type") 088 protected EnumWrapper<CreateRetentionPolicyRequestBodyRetentionTypeField> retentionType; 089 090 /** Whether the owner of a file will be allowed to extend the retention. */ 091 @JsonProperty("can_owner_extend_retention") 092 protected Boolean canOwnerExtendRetention; 093 094 @JsonProperty("max_extension_length") 095 protected RetentionPolicyMaxExtensionLengthRequest maxExtensionLength; 096 097 /** Whether owner and co-owners of a file are notified when the policy nears expiration. */ 098 @JsonProperty("are_owners_notified") 099 protected Boolean areOwnersNotified; 100 101 /** A list of users notified when the retention policy duration is about to end. */ 102 @JsonProperty("custom_notification_recipients") 103 protected List<UserMini> customNotificationRecipients; 104 105 public CreateRetentionPolicyRequestBody( 106 String policyName, 107 CreateRetentionPolicyRequestBodyPolicyTypeField policyType, 108 CreateRetentionPolicyRequestBodyDispositionActionField dispositionAction) { 109 super(); 110 this.policyName = policyName; 111 this.policyType = new EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField>(policyType); 112 this.dispositionAction = 113 new EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField>(dispositionAction); 114 } 115 116 public CreateRetentionPolicyRequestBody( 117 String policyName, 118 CreateRetentionPolicyRequestBodyPolicyTypeField policyType, 119 EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> dispositionAction) { 120 super(); 121 this.policyName = policyName; 122 this.policyType = new EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField>(policyType); 123 this.dispositionAction = dispositionAction; 124 } 125 126 public CreateRetentionPolicyRequestBody( 127 String policyName, 128 EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> policyType, 129 CreateRetentionPolicyRequestBodyDispositionActionField dispositionAction) { 130 super(); 131 this.policyName = policyName; 132 this.policyType = policyType; 133 this.dispositionAction = 134 new EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField>(dispositionAction); 135 } 136 137 public CreateRetentionPolicyRequestBody( 138 @JsonProperty("policy_name") String policyName, 139 @JsonProperty("policy_type") 140 EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> policyType, 141 @JsonProperty("disposition_action") 142 EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> dispositionAction) { 143 super(); 144 this.policyName = policyName; 145 this.policyType = policyType; 146 this.dispositionAction = dispositionAction; 147 } 148 149 protected CreateRetentionPolicyRequestBody(Builder builder) { 150 super(); 151 this.policyName = builder.policyName; 152 this.description = builder.description; 153 this.policyType = builder.policyType; 154 this.dispositionAction = builder.dispositionAction; 155 this.retentionLength = builder.retentionLength; 156 this.retentionType = builder.retentionType; 157 this.canOwnerExtendRetention = builder.canOwnerExtendRetention; 158 this.maxExtensionLength = builder.maxExtensionLength; 159 this.areOwnersNotified = builder.areOwnersNotified; 160 this.customNotificationRecipients = builder.customNotificationRecipients; 161 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 162 } 163 164 public String getPolicyName() { 165 return policyName; 166 } 167 168 public String getDescription() { 169 return description; 170 } 171 172 public EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> getPolicyType() { 173 return policyType; 174 } 175 176 public EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> 177 getDispositionAction() { 178 return dispositionAction; 179 } 180 181 public CreateRetentionPolicyRequestBodyRetentionLengthField getRetentionLength() { 182 return retentionLength; 183 } 184 185 public EnumWrapper<CreateRetentionPolicyRequestBodyRetentionTypeField> getRetentionType() { 186 return retentionType; 187 } 188 189 public Boolean getCanOwnerExtendRetention() { 190 return canOwnerExtendRetention; 191 } 192 193 public RetentionPolicyMaxExtensionLengthRequest getMaxExtensionLength() { 194 return maxExtensionLength; 195 } 196 197 public Boolean getAreOwnersNotified() { 198 return areOwnersNotified; 199 } 200 201 public List<UserMini> getCustomNotificationRecipients() { 202 return customNotificationRecipients; 203 } 204 205 @Override 206 public boolean equals(Object o) { 207 if (this == o) { 208 return true; 209 } 210 if (o == null || getClass() != o.getClass()) { 211 return false; 212 } 213 CreateRetentionPolicyRequestBody casted = (CreateRetentionPolicyRequestBody) o; 214 return Objects.equals(policyName, casted.policyName) 215 && Objects.equals(description, casted.description) 216 && Objects.equals(policyType, casted.policyType) 217 && Objects.equals(dispositionAction, casted.dispositionAction) 218 && Objects.equals(retentionLength, casted.retentionLength) 219 && Objects.equals(retentionType, casted.retentionType) 220 && Objects.equals(canOwnerExtendRetention, casted.canOwnerExtendRetention) 221 && Objects.equals(maxExtensionLength, casted.maxExtensionLength) 222 && Objects.equals(areOwnersNotified, casted.areOwnersNotified) 223 && Objects.equals(customNotificationRecipients, casted.customNotificationRecipients); 224 } 225 226 @Override 227 public int hashCode() { 228 return Objects.hash( 229 policyName, 230 description, 231 policyType, 232 dispositionAction, 233 retentionLength, 234 retentionType, 235 canOwnerExtendRetention, 236 maxExtensionLength, 237 areOwnersNotified, 238 customNotificationRecipients); 239 } 240 241 @Override 242 public String toString() { 243 return "CreateRetentionPolicyRequestBody{" 244 + "policyName='" 245 + policyName 246 + '\'' 247 + ", " 248 + "description='" 249 + description 250 + '\'' 251 + ", " 252 + "policyType='" 253 + policyType 254 + '\'' 255 + ", " 256 + "dispositionAction='" 257 + dispositionAction 258 + '\'' 259 + ", " 260 + "retentionLength='" 261 + retentionLength 262 + '\'' 263 + ", " 264 + "retentionType='" 265 + retentionType 266 + '\'' 267 + ", " 268 + "canOwnerExtendRetention='" 269 + canOwnerExtendRetention 270 + '\'' 271 + ", " 272 + "maxExtensionLength='" 273 + maxExtensionLength 274 + '\'' 275 + ", " 276 + "areOwnersNotified='" 277 + areOwnersNotified 278 + '\'' 279 + ", " 280 + "customNotificationRecipients='" 281 + customNotificationRecipients 282 + '\'' 283 + "}"; 284 } 285 286 public static class Builder extends NullableFieldTracker { 287 288 protected final String policyName; 289 290 protected String description; 291 292 protected final EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> policyType; 293 294 protected final EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> 295 dispositionAction; 296 297 protected CreateRetentionPolicyRequestBodyRetentionLengthField retentionLength; 298 299 protected EnumWrapper<CreateRetentionPolicyRequestBodyRetentionTypeField> retentionType; 300 301 protected Boolean canOwnerExtendRetention; 302 303 protected RetentionPolicyMaxExtensionLengthRequest maxExtensionLength; 304 305 protected Boolean areOwnersNotified; 306 307 protected List<UserMini> customNotificationRecipients; 308 309 public Builder( 310 String policyName, 311 CreateRetentionPolicyRequestBodyPolicyTypeField policyType, 312 CreateRetentionPolicyRequestBodyDispositionActionField dispositionAction) { 313 super(); 314 this.policyName = policyName; 315 this.policyType = 316 new EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField>(policyType); 317 this.dispositionAction = 318 new EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField>( 319 dispositionAction); 320 } 321 322 public Builder( 323 String policyName, 324 CreateRetentionPolicyRequestBodyPolicyTypeField policyType, 325 EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> dispositionAction) { 326 super(); 327 this.policyName = policyName; 328 this.policyType = 329 new EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField>(policyType); 330 this.dispositionAction = dispositionAction; 331 } 332 333 public Builder( 334 String policyName, 335 EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> policyType, 336 CreateRetentionPolicyRequestBodyDispositionActionField dispositionAction) { 337 super(); 338 this.policyName = policyName; 339 this.policyType = policyType; 340 this.dispositionAction = 341 new EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField>( 342 dispositionAction); 343 } 344 345 public Builder( 346 String policyName, 347 EnumWrapper<CreateRetentionPolicyRequestBodyPolicyTypeField> policyType, 348 EnumWrapper<CreateRetentionPolicyRequestBodyDispositionActionField> dispositionAction) { 349 super(); 350 this.policyName = policyName; 351 this.policyType = policyType; 352 this.dispositionAction = dispositionAction; 353 } 354 355 public Builder description(String description) { 356 this.description = description; 357 return this; 358 } 359 360 public Builder retentionLength(String retentionLength) { 361 this.retentionLength = 362 new CreateRetentionPolicyRequestBodyRetentionLengthField(retentionLength); 363 return this; 364 } 365 366 public Builder retentionLength(int retentionLength) { 367 this.retentionLength = 368 new CreateRetentionPolicyRequestBodyRetentionLengthField(retentionLength); 369 return this; 370 } 371 372 public Builder retentionLength( 373 CreateRetentionPolicyRequestBodyRetentionLengthField retentionLength) { 374 this.retentionLength = retentionLength; 375 return this; 376 } 377 378 public Builder retentionType(CreateRetentionPolicyRequestBodyRetentionTypeField retentionType) { 379 this.retentionType = 380 new EnumWrapper<CreateRetentionPolicyRequestBodyRetentionTypeField>(retentionType); 381 return this; 382 } 383 384 public Builder retentionType( 385 EnumWrapper<CreateRetentionPolicyRequestBodyRetentionTypeField> retentionType) { 386 this.retentionType = retentionType; 387 return this; 388 } 389 390 public Builder canOwnerExtendRetention(Boolean canOwnerExtendRetention) { 391 this.canOwnerExtendRetention = canOwnerExtendRetention; 392 return this; 393 } 394 395 public Builder maxExtensionLength( 396 RetentionPolicyMaxExtensionLengthRequestEnum maxExtensionLength) { 397 this.maxExtensionLength = new RetentionPolicyMaxExtensionLengthRequest(maxExtensionLength); 398 return this; 399 } 400 401 public Builder maxExtensionLength(String maxExtensionLength) { 402 this.maxExtensionLength = new RetentionPolicyMaxExtensionLengthRequest(maxExtensionLength); 403 return this; 404 } 405 406 public Builder maxExtensionLength(int maxExtensionLength) { 407 this.maxExtensionLength = new RetentionPolicyMaxExtensionLengthRequest(maxExtensionLength); 408 return this; 409 } 410 411 public Builder maxExtensionLength(RetentionPolicyMaxExtensionLengthRequest maxExtensionLength) { 412 this.maxExtensionLength = maxExtensionLength; 413 return this; 414 } 415 416 public Builder areOwnersNotified(Boolean areOwnersNotified) { 417 this.areOwnersNotified = areOwnersNotified; 418 return this; 419 } 420 421 public Builder customNotificationRecipients(List<UserMini> customNotificationRecipients) { 422 this.customNotificationRecipients = customNotificationRecipients; 423 return this; 424 } 425 426 public CreateRetentionPolicyRequestBody build() { 427 return new CreateRetentionPolicyRequestBody(this); 428 } 429 } 430}