All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nutanix.dp1.pri.prism.v4.serviceability.UserDefinedPolicy Maven / Gradle / Ivy

/*
 * Generated file ..
 *
 * Product version: 4.0.3-alpha-2
 *
 * Part of the Nutanix Prism Versioned APIs
 *
 * (c) 2023 Nutanix Inc.  All rights reserved
 *
 */

package com.nutanix.dp1.pri.prism.v4.serviceability;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.AccessLevel;
import com.nutanix.devplatform.models.PrettyModeViews.*;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.nutanix.dp1.pri.deserializers.PriObjectTypeTypedObject;

import javax.validation.constraints.*;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;

import static com.nutanix.dp1.pri.deserializers.PriDeserializerUtils.*;





@EqualsAndHashCode(callSuper=true)
@Data
@lombok.extern.slf4j.Slf4j
public class UserDefinedPolicy extends com.nutanix.dp1.pri.common.v1.response.ExternalizableAbstractModel implements java.io.Serializable, PriObjectTypeTypedObject {

  

  public UserDefinedPolicy() {
    super();
    
  }

  @lombok.Builder(builderMethodName = "UserDefinedPolicyBuilder")
  public UserDefinedPolicy(String tenantId, String extId, java.util.List links, String title, String description, Boolean isEnabled, Boolean isAutoResolved, Object filters, java.util.List triggerConditions, java.util.List impactTypes, String createdBy, java.time.OffsetDateTime lastUpdatedTime, Boolean isExpectedToErrorOnConflict, java.util.List policiesToOverride, Long triggerWaitPeriod, java.util.List relatedPolicies, String entityType) {
    super(tenantId, extId, links);

    this.setTitle(title);

    this.setDescription(description);

    this.setIsEnabled(isEnabled);

    this.setIsAutoResolved(isAutoResolved);
    this.setFiltersInWrapper(filters);
    
    this.setTriggerConditions(triggerConditions);

    this.setImpactTypes(impactTypes);

    this.setCreatedBy(createdBy);

    this.setLastUpdatedTime(lastUpdatedTime);

    this.setIsExpectedToErrorOnConflict(isExpectedToErrorOnConflict);

    this.setPoliciesToOverride(policiesToOverride);

    this.setTriggerWaitPeriod(triggerWaitPeriod);

    this.setRelatedPolicies(relatedPolicies);

    this.setEntityType(entityType);
  }

  @Override 
  protected String initialize$objectType() {
    return "prism.v4.serviceability.UserDefinedPolicy";
  }

  @Override 
  protected String initialize$fqObjectType() {
    return "prism.v4.r0.a2.serviceability.UserDefinedPolicy";
  }


  

    
    
    
    private OffsetDateTime lastUpdatedTime = null;
  
    /**
     * Last updated time of the policy in ISO 8601 format. This value will be used as the CAS value during updates.
     */
    public void setLastUpdatedTime(OffsetDateTime lastUpdatedTime) {
      if (this.lastUpdatedTime == null) {
        this.lastUpdatedTime = lastUpdatedTime;
      }
      else {
        log.warn("Read-only property lastUpdatedTime already contains a non-null value and cannot be set again");
      }
    }
  
  

  
    /**
    * Title of the policy.
    */
    @javax.validation.constraints.Size(min = 1, max = 150)
    
    @JsonProperty("title")
    public String title = null;
  
  

  
    /**
    * Description of the policy.
    */
    @javax.validation.constraints.Size(max = 500)
    
    @JsonProperty("description")
    public String description = null;
  
  

  
    /**
    * Enable/Disable flag for the policy.
    */
    
    @JsonProperty("isEnabled")
    public Boolean isEnabled = false;
  
  

  
    /**
    * Indicates whether the auto resolve feature is enabled for this policy.
    */
    
    @JsonProperty("isAutoResolved")
    public Boolean isAutoResolved = true;
  
  
    
    
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Getter
    private String $filtersItemDiscriminator = null;
    
    @Data
    @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = OneOfFiltersWrapper.OneOfFiltersWrapperJsonDeserializer.class)
    public static class OneOfFiltersWrapper {
    
      private static final java.util.List EMPTY_LIST = new java.util.ArrayList<>();
    
      public OneOfFiltersWrapper() {
      }
    
      public OneOfFiltersWrapper(java.util.List data) {
        if(data.isEmpty()) {
          this.discriminator = "EMPTY_LIST";
          this.$objectType = "EMPTY_LIST";
          return;
        }
        Class cls = data.get(0).getClass();
        if(com.nutanix.dp1.pri.prism.v4.serviceability.EntityFilter.class.equals(cls)) {
          this.oneOfType0 = (java.util.List) data;
          this.discriminator = "List";
          this.$objectType = "List";
          return;
        }
        if(com.nutanix.dp1.pri.prism.v4.serviceability.GroupFilter.class.equals(cls)) {
          this.oneOfType1 = (java.util.List) data;
          this.discriminator = "List";
          this.$objectType = "List";
          return;
        }
        throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfFiltersWrapper:" + data.getClass().getName());
      }
    
    
    
      @com.nutanix.dp1.pri.annotations.PriJsonDeserializer
      @org.springframework.stereotype.Component("com.nutanix.dp1.pri.prism.v4.serviceability.UserDefinedPolicyJsonDeserializer")
      private static class OneOfFiltersWrapperJsonDeserializer extends com.nutanix.dp1.pri.deserializers.PriOneOfDeserializer  {
        private static final com.fasterxml.jackson.databind.type.TypeFactory TYPE_FACTORY = com.fasterxml.jackson.databind.type.TypeFactory.defaultInstance();
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE0 = TYPE_FACTORY.constructCollectionType(java.util.List.class, com.nutanix.dp1.pri.prism.v4.serviceability.EntityFilter.class);
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE1 = TYPE_FACTORY.constructCollectionType(java.util.List.class, com.nutanix.dp1.pri.prism.v4.serviceability.GroupFilter.class);
    
        public OneOfFiltersWrapperJsonDeserializer() {
          super(TYPE_FACTORY.constructType(OneOfFiltersWrapper.class));
        }
    
        @Override
        protected void setDataObject(OneOfFiltersWrapper oneOfObject, Object nestedObject) {
          if (oneOfObject == null) {
            throw new IllegalArgumentException("Instance of OneOfFiltersWrapper provided is null");
          }
          if(ONE_OF_TYPE0.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
          }
          else if(ONE_OF_TYPE1.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
          }
          else {
            throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfFiltersWrapper:" + nestedObject.getClass().getName());
          }
        }
    
        public String getPackagePrefix() {
          return "com.nutanix.dp1.pri";
        }
      }
    
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)
      private java.util.List oneOfType0;
            @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)
      private java.util.List oneOfType1;
          
      @lombok.Setter(lombok.AccessLevel.NONE)
      private String discriminator;
    
    
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Setter(lombok.AccessLevel.NONE)
      private String $objectType;
    
      @com.fasterxml.jackson.annotation.JsonGetter
      public Object getValue() {
        if("EMPTY_LIST".equals(this.discriminator)) {
          return EMPTY_LIST;
        }
        if("List".equals(this.discriminator)) {
          return this.oneOfType0;
        }
                if("List".equals(this.discriminator)) {
          return this.oneOfType1;
        }
                throw new IllegalArgumentException("Unrecognized discriminator:" + this.discriminator);
      }
    
      public void setValue(Object value) {
        if(value == null) {

          log.warn("null passed to setValue function. OneOf's value will not be set.");
          return;
        }
    
        if(setOneOfType0(value)) {
          return;
        }
                if(setOneOfType1(value)) {
          return;
        }
                throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfFiltersWrapper:" + value.getClass().getName());
      }
    
      private boolean setOneOfType0(Object value) {
        Class valueClass = com.nutanix.dp1.pri.prism.v4.serviceability.EntityFilter.class;
        if(java.util.List.class.isAssignableFrom(value.getClass())) {
          // list try to match types if list is not empty.
          if (((java.util.List) value).size() > 0) {
            // Do some extra type checking
            if (valueClass.equals(((java.util.List) value).get(0).getClass())) {
              this.discriminator = "List";
              this.$objectType = "List";
              this.oneOfType0 = (java.util.List) value;
              return true;
            }
            return false;
          } else {
            this.discriminator = "EMPTY_LIST";
            this.$objectType = "EMPTY_LIST";
            this.oneOfType0 = (List) value;
            return true;
          }
        }
        return false;
      }
    
      private boolean setOneOfType1(Object value) {
        Class valueClass = com.nutanix.dp1.pri.prism.v4.serviceability.GroupFilter.class;
        if(java.util.List.class.isAssignableFrom(value.getClass())) {
          // list try to match types if list is not empty.
          if (((java.util.List) value).size() > 0) {
            // Do some extra type checking
            if (valueClass.equals(((java.util.List) value).get(0).getClass())) {
              this.discriminator = "List";
              this.$objectType = "List";
              this.oneOfType1 = (java.util.List) value;
              return true;
            }
            return false;
          } else {
            this.discriminator = "EMPTY_LIST";
            this.$objectType = "EMPTY_LIST";
            this.oneOfType1 = (List) value;
            return true;
          }
        }
        return false;
      }
    
    }
  
    private OneOfFiltersWrapper filters = null;
  
    /**
     * @deprecated
     * @param value one of wrapper instance
     */
    public void setFilters(OneOfFiltersWrapper value) {
      log.warn("Deprecating this method, please use setDataInWrapper instead");
      if (value == null) {
        return;
      }
      this.filters = value;
      this.$filtersItemDiscriminator = this.filters.getDiscriminator();
    }
  
    /**
     * @param value value of one of field filters
     */
    @com.fasterxml.jackson.annotation.JsonIgnore
    public void setFiltersInWrapper(Object value) {
      if (value == null) {
        return;
      }
      if (this.filters == null) {
        this.filters = new OneOfFiltersWrapper();
      }
      this.filters.setValue(value);
      this.$filtersItemDiscriminator = this.filters.getDiscriminator();
    }
  
    /**
     * Get filters in one of possible types :
     * 
    *
  • EMPTY_LIST
  • *
  • List(prism.v4.serviceability.EntityFilter)
  • *
  • List(prism.v4.serviceability.GroupFilter)
  • *
* @return Object */ @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = com.nutanix.dp1.pri.serializers.PriOneOfSerializer.class) public Object getFilters() { if (this.filters == null) { log.debug("OneOf property filters was never set. Returning null..."); return null; } return this.filters.getValue(); } /** * Trigger conditions for the policy. If there are multiple trigger conditions, all of them will be considered during the operation. */ @javax.validation.constraints.Size(min = 1, max = 4) @JsonProperty("triggerConditions") public List triggerConditions = null; /** * Impact Types for the associated resulting alert. */ @javax.validation.constraints.Size(min = 0, max = 8) @JsonProperty("impactTypes") public List impactTypes = null; /** * Username of the user who created the policy. */ @JsonProperty("createdBy") public String createdBy = null; /** * Error if conflicting alert policies are found. */ @JsonProperty("isExpectedToErrorOnConflict") public Boolean isExpectedToErrorOnConflict = true; /** * List of IDs of the alert policies that should be overridden. */ @javax.validation.constraints.Size(min = 0, max = 100) @JsonProperty("policiesToOverride") public List policiesToOverride = null; /** * Waiting duration in seconds before triggering the alert, when the specified condition is met. */ @JsonProperty("triggerWaitPeriod") public Long triggerWaitPeriod = null; /** * List of alert policies that are related to the entities of the current policy. */ @javax.validation.constraints.Size(min = 0, max = 100) @JsonProperty("relatedPolicies") public List relatedPolicies = null; /** * Entity type associated with the user-defined alert policy. Allowed values are vm, node and cluster. */ @JsonProperty("entityType") public String entityType = null; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy