001package com.box.sdkgen.schemas.retentionpolicy;
002
003import com.box.sdkgen.internal.utils.DateTimeUtils;
004import com.box.sdkgen.schemas.retentionpolicybase.RetentionPolicyBaseTypeField;
005import com.box.sdkgen.schemas.retentionpolicymaxextensionlengthresponse.RetentionPolicyMaxExtensionLengthResponse;
006import com.box.sdkgen.schemas.retentionpolicymaxextensionlengthresponse.RetentionPolicyMaxExtensionLengthResponseEnum;
007import com.box.sdkgen.schemas.retentionpolicymini.RetentionPolicyMini;
008import com.box.sdkgen.schemas.retentionpolicymini.RetentionPolicyMiniDispositionActionField;
009import com.box.sdkgen.schemas.usermini.UserMini;
010import com.box.sdkgen.serialization.json.EnumWrapper;
011import com.fasterxml.jackson.annotation.JsonFilter;
012import com.fasterxml.jackson.annotation.JsonProperty;
013import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
014import com.fasterxml.jackson.databind.annotation.JsonSerialize;
015import java.time.OffsetDateTime;
016import java.util.List;
017import java.util.Objects;
018
019/**
020 * A retention policy blocks permanent deletion of content for a specified amount of time. Admins
021 * can create retention policies and then later assign them to specific folders, metadata templates,
022 * or their entire enterprise. To use this feature, you must have the manage retention policies
023 * scope enabled for your API key via your application management console.
024 */
025@JsonFilter("nullablePropertyFilter")
026public class RetentionPolicy extends RetentionPolicyMini {
027
028  /** The additional text description of the retention policy. */
029  protected String description;
030
031  /**
032   * The type of the retention policy. A retention policy type can either be `finite`, where a
033   * specific amount of time to retain the content is known upfront, or `indefinite`, where the
034   * amount of time to retain the content is still unknown.
035   */
036  @JsonDeserialize(
037      using = RetentionPolicyPolicyTypeField.RetentionPolicyPolicyTypeFieldDeserializer.class)
038  @JsonSerialize(
039      using = RetentionPolicyPolicyTypeField.RetentionPolicyPolicyTypeFieldSerializer.class)
040  @JsonProperty("policy_type")
041  protected EnumWrapper<RetentionPolicyPolicyTypeField> policyType;
042
043  /**
044   * Specifies the retention type:
045   *
046   * <p>* `modifiable`: You can modify the retention policy. For example, you can add or remove
047   * folders, shorten or lengthen the policy duration, or delete the assignment. Use this type if
048   * your retention policy is not related to any regulatory purposes.
049   *
050   * <p>* `non-modifiable`: You can modify the retention policy only in a limited way: add a folder,
051   * lengthen the duration, retire the policy, change the disposition action or notification
052   * settings. You cannot perform other actions, such as deleting the assignment or shortening the
053   * policy duration. Use this type to ensure compliance with regulatory retention policies.
054   */
055  @JsonDeserialize(
056      using = RetentionPolicyRetentionTypeField.RetentionPolicyRetentionTypeFieldDeserializer.class)
057  @JsonSerialize(
058      using = RetentionPolicyRetentionTypeField.RetentionPolicyRetentionTypeFieldSerializer.class)
059  @JsonProperty("retention_type")
060  protected EnumWrapper<RetentionPolicyRetentionTypeField> retentionType;
061
062  /**
063   * The status of the retention policy. The status of a policy will be `active`, unless explicitly
064   * retired by an administrator, in which case the status will be `retired`. Once a policy has been
065   * retired, it cannot become active again.
066   */
067  @JsonDeserialize(using = RetentionPolicyStatusField.RetentionPolicyStatusFieldDeserializer.class)
068  @JsonSerialize(using = RetentionPolicyStatusField.RetentionPolicyStatusFieldSerializer.class)
069  protected EnumWrapper<RetentionPolicyStatusField> status;
070
071  @JsonProperty("created_by")
072  protected UserMini createdBy;
073
074  /** When the retention policy object was created. */
075  @JsonProperty("created_at")
076  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
077  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
078  protected OffsetDateTime createdAt;
079
080  /** When the retention policy object was last modified. */
081  @JsonProperty("modified_at")
082  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
083  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
084  protected OffsetDateTime modifiedAt;
085
086  /**
087   * Determines if the owner of items under the policy can extend the retention when the original
088   * retention duration is about to end.
089   */
090  @JsonProperty("can_owner_extend_retention")
091  protected Boolean canOwnerExtendRetention;
092
093  /**
094   * Determines if owners and co-owners of items under the policy are notified when the retention
095   * duration is about to end.
096   */
097  @JsonProperty("are_owners_notified")
098  protected Boolean areOwnersNotified;
099
100  /** A list of users notified when the retention policy duration is about to end. */
101  @JsonProperty("custom_notification_recipients")
102  protected List<UserMini> customNotificationRecipients;
103
104  /** Counts the retention policy assignments for each item type. */
105  @JsonProperty("assignment_counts")
106  protected RetentionPolicyAssignmentCountsField assignmentCounts;
107
108  public RetentionPolicy(@JsonProperty("id") String id) {
109    super(id);
110  }
111
112  protected RetentionPolicy(Builder builder) {
113    super(builder);
114    this.description = builder.description;
115    this.policyType = builder.policyType;
116    this.retentionType = builder.retentionType;
117    this.status = builder.status;
118    this.createdBy = builder.createdBy;
119    this.createdAt = builder.createdAt;
120    this.modifiedAt = builder.modifiedAt;
121    this.canOwnerExtendRetention = builder.canOwnerExtendRetention;
122    this.areOwnersNotified = builder.areOwnersNotified;
123    this.customNotificationRecipients = builder.customNotificationRecipients;
124    this.assignmentCounts = builder.assignmentCounts;
125    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
126  }
127
128  public String getDescription() {
129    return description;
130  }
131
132  public EnumWrapper<RetentionPolicyPolicyTypeField> getPolicyType() {
133    return policyType;
134  }
135
136  public EnumWrapper<RetentionPolicyRetentionTypeField> getRetentionType() {
137    return retentionType;
138  }
139
140  public EnumWrapper<RetentionPolicyStatusField> getStatus() {
141    return status;
142  }
143
144  public UserMini getCreatedBy() {
145    return createdBy;
146  }
147
148  public OffsetDateTime getCreatedAt() {
149    return createdAt;
150  }
151
152  public OffsetDateTime getModifiedAt() {
153    return modifiedAt;
154  }
155
156  public Boolean getCanOwnerExtendRetention() {
157    return canOwnerExtendRetention;
158  }
159
160  public Boolean getAreOwnersNotified() {
161    return areOwnersNotified;
162  }
163
164  public List<UserMini> getCustomNotificationRecipients() {
165    return customNotificationRecipients;
166  }
167
168  public RetentionPolicyAssignmentCountsField getAssignmentCounts() {
169    return assignmentCounts;
170  }
171
172  @Override
173  public boolean equals(Object o) {
174    if (this == o) {
175      return true;
176    }
177    if (o == null || getClass() != o.getClass()) {
178      return false;
179    }
180    RetentionPolicy casted = (RetentionPolicy) o;
181    return Objects.equals(id, casted.id)
182        && Objects.equals(type, casted.type)
183        && Objects.equals(policyName, casted.policyName)
184        && Objects.equals(retentionLength, casted.retentionLength)
185        && Objects.equals(dispositionAction, casted.dispositionAction)
186        && Objects.equals(maxExtensionLength, casted.maxExtensionLength)
187        && Objects.equals(description, casted.description)
188        && Objects.equals(policyType, casted.policyType)
189        && Objects.equals(retentionType, casted.retentionType)
190        && Objects.equals(status, casted.status)
191        && Objects.equals(createdBy, casted.createdBy)
192        && Objects.equals(createdAt, casted.createdAt)
193        && Objects.equals(modifiedAt, casted.modifiedAt)
194        && Objects.equals(canOwnerExtendRetention, casted.canOwnerExtendRetention)
195        && Objects.equals(areOwnersNotified, casted.areOwnersNotified)
196        && Objects.equals(customNotificationRecipients, casted.customNotificationRecipients)
197        && Objects.equals(assignmentCounts, casted.assignmentCounts);
198  }
199
200  @Override
201  public int hashCode() {
202    return Objects.hash(
203        id,
204        type,
205        policyName,
206        retentionLength,
207        dispositionAction,
208        maxExtensionLength,
209        description,
210        policyType,
211        retentionType,
212        status,
213        createdBy,
214        createdAt,
215        modifiedAt,
216        canOwnerExtendRetention,
217        areOwnersNotified,
218        customNotificationRecipients,
219        assignmentCounts);
220  }
221
222  @Override
223  public String toString() {
224    return "RetentionPolicy{"
225        + "id='"
226        + id
227        + '\''
228        + ", "
229        + "type='"
230        + type
231        + '\''
232        + ", "
233        + "policyName='"
234        + policyName
235        + '\''
236        + ", "
237        + "retentionLength='"
238        + retentionLength
239        + '\''
240        + ", "
241        + "dispositionAction='"
242        + dispositionAction
243        + '\''
244        + ", "
245        + "maxExtensionLength='"
246        + maxExtensionLength
247        + '\''
248        + ", "
249        + "description='"
250        + description
251        + '\''
252        + ", "
253        + "policyType='"
254        + policyType
255        + '\''
256        + ", "
257        + "retentionType='"
258        + retentionType
259        + '\''
260        + ", "
261        + "status='"
262        + status
263        + '\''
264        + ", "
265        + "createdBy='"
266        + createdBy
267        + '\''
268        + ", "
269        + "createdAt='"
270        + createdAt
271        + '\''
272        + ", "
273        + "modifiedAt='"
274        + modifiedAt
275        + '\''
276        + ", "
277        + "canOwnerExtendRetention='"
278        + canOwnerExtendRetention
279        + '\''
280        + ", "
281        + "areOwnersNotified='"
282        + areOwnersNotified
283        + '\''
284        + ", "
285        + "customNotificationRecipients='"
286        + customNotificationRecipients
287        + '\''
288        + ", "
289        + "assignmentCounts='"
290        + assignmentCounts
291        + '\''
292        + "}";
293  }
294
295  public static class Builder extends RetentionPolicyMini.Builder {
296
297    protected String description;
298
299    protected EnumWrapper<RetentionPolicyPolicyTypeField> policyType;
300
301    protected EnumWrapper<RetentionPolicyRetentionTypeField> retentionType;
302
303    protected EnumWrapper<RetentionPolicyStatusField> status;
304
305    protected UserMini createdBy;
306
307    protected OffsetDateTime createdAt;
308
309    protected OffsetDateTime modifiedAt;
310
311    protected Boolean canOwnerExtendRetention;
312
313    protected Boolean areOwnersNotified;
314
315    protected List<UserMini> customNotificationRecipients;
316
317    protected RetentionPolicyAssignmentCountsField assignmentCounts;
318
319    public Builder(String id) {
320      super(id);
321    }
322
323    public Builder description(String description) {
324      this.description = description;
325      return this;
326    }
327
328    public Builder policyType(RetentionPolicyPolicyTypeField policyType) {
329      this.policyType = new EnumWrapper<RetentionPolicyPolicyTypeField>(policyType);
330      return this;
331    }
332
333    public Builder policyType(EnumWrapper<RetentionPolicyPolicyTypeField> policyType) {
334      this.policyType = policyType;
335      return this;
336    }
337
338    public Builder retentionType(RetentionPolicyRetentionTypeField retentionType) {
339      this.retentionType = new EnumWrapper<RetentionPolicyRetentionTypeField>(retentionType);
340      return this;
341    }
342
343    public Builder retentionType(EnumWrapper<RetentionPolicyRetentionTypeField> retentionType) {
344      this.retentionType = retentionType;
345      return this;
346    }
347
348    public Builder status(RetentionPolicyStatusField status) {
349      this.status = new EnumWrapper<RetentionPolicyStatusField>(status);
350      return this;
351    }
352
353    public Builder status(EnumWrapper<RetentionPolicyStatusField> status) {
354      this.status = status;
355      return this;
356    }
357
358    public Builder createdBy(UserMini createdBy) {
359      this.createdBy = createdBy;
360      return this;
361    }
362
363    public Builder createdAt(OffsetDateTime createdAt) {
364      this.createdAt = createdAt;
365      return this;
366    }
367
368    public Builder modifiedAt(OffsetDateTime modifiedAt) {
369      this.modifiedAt = modifiedAt;
370      return this;
371    }
372
373    public Builder canOwnerExtendRetention(Boolean canOwnerExtendRetention) {
374      this.canOwnerExtendRetention = canOwnerExtendRetention;
375      return this;
376    }
377
378    public Builder areOwnersNotified(Boolean areOwnersNotified) {
379      this.areOwnersNotified = areOwnersNotified;
380      return this;
381    }
382
383    public Builder customNotificationRecipients(List<UserMini> customNotificationRecipients) {
384      this.customNotificationRecipients = customNotificationRecipients;
385      return this;
386    }
387
388    public Builder assignmentCounts(RetentionPolicyAssignmentCountsField assignmentCounts) {
389      this.assignmentCounts = assignmentCounts;
390      return this;
391    }
392
393    @Override
394    public Builder type(RetentionPolicyBaseTypeField type) {
395      this.type = new EnumWrapper<RetentionPolicyBaseTypeField>(type);
396      return this;
397    }
398
399    @Override
400    public Builder type(EnumWrapper<RetentionPolicyBaseTypeField> type) {
401      this.type = type;
402      return this;
403    }
404
405    @Override
406    public Builder policyName(String policyName) {
407      this.policyName = policyName;
408      return this;
409    }
410
411    @Override
412    public Builder retentionLength(String retentionLength) {
413      this.retentionLength = retentionLength;
414      return this;
415    }
416
417    @Override
418    public Builder dispositionAction(RetentionPolicyMiniDispositionActionField dispositionAction) {
419      this.dispositionAction =
420          new EnumWrapper<RetentionPolicyMiniDispositionActionField>(dispositionAction);
421      return this;
422    }
423
424    @Override
425    public Builder dispositionAction(
426        EnumWrapper<RetentionPolicyMiniDispositionActionField> dispositionAction) {
427      this.dispositionAction = dispositionAction;
428      return this;
429    }
430
431    @Override
432    public Builder maxExtensionLength(
433        RetentionPolicyMaxExtensionLengthResponseEnum maxExtensionLength) {
434      this.maxExtensionLength = new RetentionPolicyMaxExtensionLengthResponse(maxExtensionLength);
435      return this;
436    }
437
438    @Override
439    public Builder maxExtensionLength(String maxExtensionLength) {
440      this.maxExtensionLength = new RetentionPolicyMaxExtensionLengthResponse(maxExtensionLength);
441      return this;
442    }
443
444    @Override
445    public Builder maxExtensionLength(
446        RetentionPolicyMaxExtensionLengthResponse maxExtensionLength) {
447      this.maxExtensionLength = maxExtensionLength;
448      return this;
449    }
450
451    public RetentionPolicy build() {
452      if (this.type == null) {
453        this.type =
454            new EnumWrapper<RetentionPolicyBaseTypeField>(
455                RetentionPolicyBaseTypeField.RETENTION_POLICY);
456      }
457      return new RetentionPolicy(this);
458    }
459  }
460}