/* CDN API API used to create and manage your CDN distributions. API version: 1beta2.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package cdnbeta import ( "encoding/json" "fmt" "time" ) // checks if the Distribution type satisfies the MappedNullable interface at compile time var _ MappedNullable = &Distribution{} /* types and functions for config */ // isModel type DistributionGetConfigAttributeType = *Config type DistributionGetConfigArgType = Config type DistributionGetConfigRetType = Config func getDistributionGetConfigAttributeTypeOk(arg DistributionGetConfigAttributeType) (ret DistributionGetConfigRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetConfigAttributeType(arg *DistributionGetConfigAttributeType, val DistributionGetConfigRetType) { *arg = &val } /* types and functions for createdAt */ // isDateTime type DistributionGetCreatedAtAttributeType = *time.Time type DistributionGetCreatedAtArgType = time.Time type DistributionGetCreatedAtRetType = time.Time func getDistributionGetCreatedAtAttributeTypeOk(arg DistributionGetCreatedAtAttributeType) (ret DistributionGetCreatedAtRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetCreatedAtAttributeType(arg *DistributionGetCreatedAtAttributeType, val DistributionGetCreatedAtRetType) { *arg = &val } /* types and functions for domains */ // isArray type DistributionGetDomainsAttributeType = *[]Domain type DistributionGetDomainsArgType = []Domain type DistributionGetDomainsRetType = []Domain func getDistributionGetDomainsAttributeTypeOk(arg DistributionGetDomainsAttributeType) (ret DistributionGetDomainsRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetDomainsAttributeType(arg *DistributionGetDomainsAttributeType, val DistributionGetDomainsRetType) { *arg = &val } /* types and functions for errors */ // isArray type DistributionGetErrorsAttributeType = *[]StatusError type DistributionGetErrorsArgType = []StatusError type DistributionGetErrorsRetType = []StatusError func getDistributionGetErrorsAttributeTypeOk(arg DistributionGetErrorsAttributeType) (ret DistributionGetErrorsRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetErrorsAttributeType(arg *DistributionGetErrorsAttributeType, val DistributionGetErrorsRetType) { *arg = &val } /* types and functions for id */ // isNotNullableString type DistributionGetIdAttributeType = *string func getDistributionGetIdAttributeTypeOk(arg DistributionGetIdAttributeType) (ret DistributionGetIdRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetIdAttributeType(arg *DistributionGetIdAttributeType, val DistributionGetIdRetType) { *arg = &val } type DistributionGetIdArgType = string type DistributionGetIdRetType = string /* types and functions for projectId */ // isNotNullableString type DistributionGetProjectIdAttributeType = *string func getDistributionGetProjectIdAttributeTypeOk(arg DistributionGetProjectIdAttributeType) (ret DistributionGetProjectIdRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetProjectIdAttributeType(arg *DistributionGetProjectIdAttributeType, val DistributionGetProjectIdRetType) { *arg = &val } type DistributionGetProjectIdArgType = string type DistributionGetProjectIdRetType = string /* types and functions for status */ // isEnum // DistributionStatus - `CREATING`: The distribution was just created. All the relevant resources are created in the background. Once fully reconciled, this switches to `ACTIVE`. If there are any issues, the status changes to `ERROR`. You can look at the `errors` array to get more infos. - `ACTIVE`: The usual state. The desired configuration is synced, there are no errors - `UPDATING`: The state when there is a discrepancy between the desired and actual configuration state. This occurs right after an update. Will switch to `ACTIVE` or `ERROR`, depending on if synchronizing succeeds or not. - `DELETING`: The state right after a delete request was received. The distribution will stay in this status until all resources have been successfully removed, or until we encounter an `ERROR` state. **NOTE:** You can keep fetching the distribution while it is deleting. After successful deletion, trying to get a distribution will return a 404 Not Found response - `ERROR`: The error state. Look at the `errors` array for more info. // value type for enums type DistributionStatus string // List of Status const ( DISTRIBUTIONSTATUS_CREATING DistributionStatus = "CREATING" DISTRIBUTIONSTATUS_ACTIVE DistributionStatus = "ACTIVE" DISTRIBUTIONSTATUS_UPDATING DistributionStatus = "UPDATING" DISTRIBUTIONSTATUS_DELETING DistributionStatus = "DELETING" DISTRIBUTIONSTATUS_ERROR DistributionStatus = "ERROR" ) // All allowed values of Distribution enum var AllowedDistributionStatusEnumValues = []DistributionStatus{ "CREATING", "ACTIVE", "UPDATING", "DELETING", "ERROR", } func (v *DistributionStatus) UnmarshalJSON(src []byte) error { // use a type alias to prevent infinite recursion during unmarshal, // see https://biscuit.ninja/posts/go-avoid-an-infitine-loop-with-custom-json-unmarshallers type TmpJson DistributionStatus var value TmpJson err := json.Unmarshal(src, &value) if err != nil { return err } // Allow unmarshalling zero value for testing purposes var zeroValue TmpJson if value == zeroValue { return nil } enumTypeValue := DistributionStatus(value) for _, existing := range AllowedDistributionStatusEnumValues { if existing == enumTypeValue { *v = enumTypeValue return nil } } return fmt.Errorf("%+v is not a valid Distribution", value) } // NewDistributionStatusFromValue returns a pointer to a valid DistributionStatus // for the value passed as argument, or an error if the value passed is not allowed by the enum func NewDistributionStatusFromValue(v DistributionStatus) (*DistributionStatus, error) { ev := DistributionStatus(v) if ev.IsValid() { return &ev, nil } else { return nil, fmt.Errorf("invalid value '%v' for DistributionStatus: valid values are %v", v, AllowedDistributionStatusEnumValues) } } // IsValid return true if the value is valid for the enum, false otherwise func (v DistributionStatus) IsValid() bool { for _, existing := range AllowedDistributionStatusEnumValues { if existing == v { return true } } return false } // Ptr returns reference to StatusStatus value func (v DistributionStatus) Ptr() *DistributionStatus { return &v } type NullableDistributionStatus struct { value *DistributionStatus isSet bool } func (v NullableDistributionStatus) Get() *DistributionStatus { return v.value } func (v *NullableDistributionStatus) Set(val *DistributionStatus) { v.value = val v.isSet = true } func (v NullableDistributionStatus) IsSet() bool { return v.isSet } func (v *NullableDistributionStatus) Unset() { v.value = nil v.isSet = false } func NewNullableDistributionStatus(val *DistributionStatus) *NullableDistributionStatus { return &NullableDistributionStatus{value: val, isSet: true} } func (v NullableDistributionStatus) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableDistributionStatus) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } type DistributionGetStatusAttributeType = *DistributionStatus type DistributionGetStatusArgType = DistributionStatus type DistributionGetStatusRetType = DistributionStatus func getDistributionGetStatusAttributeTypeOk(arg DistributionGetStatusAttributeType) (ret DistributionGetStatusRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetStatusAttributeType(arg *DistributionGetStatusAttributeType, val DistributionGetStatusRetType) { *arg = &val } /* types and functions for updatedAt */ // isDateTime type DistributionGetUpdatedAtAttributeType = *time.Time type DistributionGetUpdatedAtArgType = time.Time type DistributionGetUpdatedAtRetType = time.Time func getDistributionGetUpdatedAtAttributeTypeOk(arg DistributionGetUpdatedAtAttributeType) (ret DistributionGetUpdatedAtRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetUpdatedAtAttributeType(arg *DistributionGetUpdatedAtAttributeType, val DistributionGetUpdatedAtRetType) { *arg = &val } /* types and functions for waf */ // isModel type DistributionGetWafAttributeType = *DistributionWaf type DistributionGetWafArgType = DistributionWaf type DistributionGetWafRetType = DistributionWaf func getDistributionGetWafAttributeTypeOk(arg DistributionGetWafAttributeType) (ret DistributionGetWafRetType, ok bool) { if arg == nil { return ret, false } return *arg, true } func setDistributionGetWafAttributeType(arg *DistributionGetWafAttributeType, val DistributionGetWafRetType) { *arg = &val } // Distribution struct for Distribution type Distribution struct { // REQUIRED Config DistributionGetConfigAttributeType `json:"config" required:"true"` // RFC3339 string defining when the distribution was created // REQUIRED CreatedAt DistributionGetCreatedAtAttributeType `json:"createdAt" required:"true"` // REQUIRED Domains DistributionGetDomainsAttributeType `json:"domains" required:"true"` // This object may be present if, and only if the distribution has encountered an error state. Errors DistributionGetErrorsAttributeType `json:"errors,omitempty"` // REQUIRED Id DistributionGetIdAttributeType `json:"id" required:"true"` // REQUIRED ProjectId DistributionGetProjectIdAttributeType `json:"projectId" required:"true"` // - `CREATING`: The distribution was just created. All the relevant resources are created in the background. Once fully reconciled, this switches to `ACTIVE`. If there are any issues, the status changes to `ERROR`. You can look at the `errors` array to get more infos. - `ACTIVE`: The usual state. The desired configuration is synced, there are no errors - `UPDATING`: The state when there is a discrepancy between the desired and actual configuration state. This occurs right after an update. Will switch to `ACTIVE` or `ERROR`, depending on if synchronizing succeeds or not. - `DELETING`: The state right after a delete request was received. The distribution will stay in this status until all resources have been successfully removed, or until we encounter an `ERROR` state. **NOTE:** You can keep fetching the distribution while it is deleting. After successful deletion, trying to get a distribution will return a 404 Not Found response - `ERROR`: The error state. Look at the `errors` array for more info. // REQUIRED Status DistributionGetStatusAttributeType `json:"status" required:"true"` // RFC3339 string which returns the last time the distribution configuration was modified. // REQUIRED UpdatedAt DistributionGetUpdatedAtAttributeType `json:"updatedAt" required:"true"` Waf DistributionGetWafAttributeType `json:"waf,omitempty"` } type _Distribution Distribution // NewDistribution instantiates a new Distribution object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed func NewDistribution(config DistributionGetConfigArgType, createdAt DistributionGetCreatedAtArgType, domains DistributionGetDomainsArgType, id DistributionGetIdArgType, projectId DistributionGetProjectIdArgType, status DistributionGetStatusArgType, updatedAt DistributionGetUpdatedAtArgType) *Distribution { this := Distribution{} setDistributionGetConfigAttributeType(&this.Config, config) setDistributionGetCreatedAtAttributeType(&this.CreatedAt, createdAt) setDistributionGetDomainsAttributeType(&this.Domains, domains) setDistributionGetIdAttributeType(&this.Id, id) setDistributionGetProjectIdAttributeType(&this.ProjectId, projectId) setDistributionGetStatusAttributeType(&this.Status, status) setDistributionGetUpdatedAtAttributeType(&this.UpdatedAt, updatedAt) return &this } // NewDistributionWithDefaults instantiates a new Distribution object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set func NewDistributionWithDefaults() *Distribution { this := Distribution{} return &this } // GetConfig returns the Config field value func (o *Distribution) GetConfig() (ret DistributionGetConfigRetType) { ret, _ = o.GetConfigOk() return ret } // GetConfigOk returns a tuple with the Config field value // and a boolean to check if the value has been set. func (o *Distribution) GetConfigOk() (ret DistributionGetConfigRetType, ok bool) { return getDistributionGetConfigAttributeTypeOk(o.Config) } // SetConfig sets field value func (o *Distribution) SetConfig(v DistributionGetConfigRetType) { setDistributionGetConfigAttributeType(&o.Config, v) } // GetCreatedAt returns the CreatedAt field value func (o *Distribution) GetCreatedAt() (ret DistributionGetCreatedAtRetType) { ret, _ = o.GetCreatedAtOk() return ret } // GetCreatedAtOk returns a tuple with the CreatedAt field value // and a boolean to check if the value has been set. func (o *Distribution) GetCreatedAtOk() (ret DistributionGetCreatedAtRetType, ok bool) { return getDistributionGetCreatedAtAttributeTypeOk(o.CreatedAt) } // SetCreatedAt sets field value func (o *Distribution) SetCreatedAt(v DistributionGetCreatedAtRetType) { setDistributionGetCreatedAtAttributeType(&o.CreatedAt, v) } // GetDomains returns the Domains field value func (o *Distribution) GetDomains() (ret DistributionGetDomainsRetType) { ret, _ = o.GetDomainsOk() return ret } // GetDomainsOk returns a tuple with the Domains field value // and a boolean to check if the value has been set. func (o *Distribution) GetDomainsOk() (ret DistributionGetDomainsRetType, ok bool) { return getDistributionGetDomainsAttributeTypeOk(o.Domains) } // SetDomains sets field value func (o *Distribution) SetDomains(v DistributionGetDomainsRetType) { setDistributionGetDomainsAttributeType(&o.Domains, v) } // GetErrors returns the Errors field value if set, zero value otherwise. func (o *Distribution) GetErrors() (res DistributionGetErrorsRetType) { res, _ = o.GetErrorsOk() return } // GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Distribution) GetErrorsOk() (ret DistributionGetErrorsRetType, ok bool) { return getDistributionGetErrorsAttributeTypeOk(o.Errors) } // HasErrors returns a boolean if a field has been set. func (o *Distribution) HasErrors() bool { _, ok := o.GetErrorsOk() return ok } // SetErrors gets a reference to the given []StatusError and assigns it to the Errors field. func (o *Distribution) SetErrors(v DistributionGetErrorsRetType) { setDistributionGetErrorsAttributeType(&o.Errors, v) } // GetId returns the Id field value func (o *Distribution) GetId() (ret DistributionGetIdRetType) { ret, _ = o.GetIdOk() return ret } // GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *Distribution) GetIdOk() (ret DistributionGetIdRetType, ok bool) { return getDistributionGetIdAttributeTypeOk(o.Id) } // SetId sets field value func (o *Distribution) SetId(v DistributionGetIdRetType) { setDistributionGetIdAttributeType(&o.Id, v) } // GetProjectId returns the ProjectId field value func (o *Distribution) GetProjectId() (ret DistributionGetProjectIdRetType) { ret, _ = o.GetProjectIdOk() return ret } // GetProjectIdOk returns a tuple with the ProjectId field value // and a boolean to check if the value has been set. func (o *Distribution) GetProjectIdOk() (ret DistributionGetProjectIdRetType, ok bool) { return getDistributionGetProjectIdAttributeTypeOk(o.ProjectId) } // SetProjectId sets field value func (o *Distribution) SetProjectId(v DistributionGetProjectIdRetType) { setDistributionGetProjectIdAttributeType(&o.ProjectId, v) } // GetStatus returns the Status field value func (o *Distribution) GetStatus() (ret DistributionGetStatusRetType) { ret, _ = o.GetStatusOk() return ret } // GetStatusOk returns a tuple with the Status field value // and a boolean to check if the value has been set. func (o *Distribution) GetStatusOk() (ret DistributionGetStatusRetType, ok bool) { return getDistributionGetStatusAttributeTypeOk(o.Status) } // SetStatus sets field value func (o *Distribution) SetStatus(v DistributionGetStatusRetType) { setDistributionGetStatusAttributeType(&o.Status, v) } // GetUpdatedAt returns the UpdatedAt field value func (o *Distribution) GetUpdatedAt() (ret DistributionGetUpdatedAtRetType) { ret, _ = o.GetUpdatedAtOk() return ret } // GetUpdatedAtOk returns a tuple with the UpdatedAt field value // and a boolean to check if the value has been set. func (o *Distribution) GetUpdatedAtOk() (ret DistributionGetUpdatedAtRetType, ok bool) { return getDistributionGetUpdatedAtAttributeTypeOk(o.UpdatedAt) } // SetUpdatedAt sets field value func (o *Distribution) SetUpdatedAt(v DistributionGetUpdatedAtRetType) { setDistributionGetUpdatedAtAttributeType(&o.UpdatedAt, v) } // GetWaf returns the Waf field value if set, zero value otherwise. func (o *Distribution) GetWaf() (res DistributionGetWafRetType) { res, _ = o.GetWafOk() return } // GetWafOk returns a tuple with the Waf field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Distribution) GetWafOk() (ret DistributionGetWafRetType, ok bool) { return getDistributionGetWafAttributeTypeOk(o.Waf) } // HasWaf returns a boolean if a field has been set. func (o *Distribution) HasWaf() bool { _, ok := o.GetWafOk() return ok } // SetWaf gets a reference to the given DistributionWaf and assigns it to the Waf field. func (o *Distribution) SetWaf(v DistributionGetWafRetType) { setDistributionGetWafAttributeType(&o.Waf, v) } func (o Distribution) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if val, ok := getDistributionGetConfigAttributeTypeOk(o.Config); ok { toSerialize["Config"] = val } if val, ok := getDistributionGetCreatedAtAttributeTypeOk(o.CreatedAt); ok { toSerialize["CreatedAt"] = val } if val, ok := getDistributionGetDomainsAttributeTypeOk(o.Domains); ok { toSerialize["Domains"] = val } if val, ok := getDistributionGetErrorsAttributeTypeOk(o.Errors); ok { toSerialize["Errors"] = val } if val, ok := getDistributionGetIdAttributeTypeOk(o.Id); ok { toSerialize["Id"] = val } if val, ok := getDistributionGetProjectIdAttributeTypeOk(o.ProjectId); ok { toSerialize["ProjectId"] = val } if val, ok := getDistributionGetStatusAttributeTypeOk(o.Status); ok { toSerialize["Status"] = val } if val, ok := getDistributionGetUpdatedAtAttributeTypeOk(o.UpdatedAt); ok { toSerialize["UpdatedAt"] = val } if val, ok := getDistributionGetWafAttributeTypeOk(o.Waf); ok { toSerialize["Waf"] = val } return toSerialize, nil } type NullableDistribution struct { value *Distribution isSet bool } func (v NullableDistribution) Get() *Distribution { return v.value } func (v *NullableDistribution) Set(val *Distribution) { v.value = val v.isSet = true } func (v NullableDistribution) IsSet() bool { return v.isSet } func (v *NullableDistribution) Unset() { v.value = nil v.isSet = false } func NewNullableDistribution(val *Distribution) *NullableDistribution { return &NullableDistribution{value: val, isSet: true} } func (v NullableDistribution) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableDistribution) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }