/* authentik Making authentication simple. API version: 2026.5.0-rc1 Contact: hello@goauthentik.io */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package api import ( "encoding/json" "fmt" "time" ) // checks if the DeviceChallenge type satisfies the MappedNullable interface at compile time var _ MappedNullable = &DeviceChallenge{} // DeviceChallenge Single device challenge type DeviceChallenge struct { DeviceClass DeviceClassesEnum `json:"device_class"` DeviceUid string `json:"device_uid"` Challenge map[string]interface{} `json:"challenge"` LastUsed NullableTime `json:"last_used"` AdditionalProperties map[string]interface{} } type _DeviceChallenge DeviceChallenge // NewDeviceChallenge instantiates a new DeviceChallenge 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 NewDeviceChallenge(deviceClass DeviceClassesEnum, deviceUid string, challenge map[string]interface{}, lastUsed NullableTime) *DeviceChallenge { this := DeviceChallenge{} this.DeviceClass = deviceClass this.DeviceUid = deviceUid this.Challenge = challenge this.LastUsed = lastUsed return &this } // NewDeviceChallengeWithDefaults instantiates a new DeviceChallenge 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 NewDeviceChallengeWithDefaults() *DeviceChallenge { this := DeviceChallenge{} return &this } // GetDeviceClass returns the DeviceClass field value func (o *DeviceChallenge) GetDeviceClass() DeviceClassesEnum { if o == nil { var ret DeviceClassesEnum return ret } return o.DeviceClass } // GetDeviceClassOk returns a tuple with the DeviceClass field value // and a boolean to check if the value has been set. func (o *DeviceChallenge) GetDeviceClassOk() (*DeviceClassesEnum, bool) { if o == nil { return nil, false } return &o.DeviceClass, true } // SetDeviceClass sets field value func (o *DeviceChallenge) SetDeviceClass(v DeviceClassesEnum) { o.DeviceClass = v } // GetDeviceUid returns the DeviceUid field value func (o *DeviceChallenge) GetDeviceUid() string { if o == nil { var ret string return ret } return o.DeviceUid } // GetDeviceUidOk returns a tuple with the DeviceUid field value // and a boolean to check if the value has been set. func (o *DeviceChallenge) GetDeviceUidOk() (*string, bool) { if o == nil { return nil, false } return &o.DeviceUid, true } // SetDeviceUid sets field value func (o *DeviceChallenge) SetDeviceUid(v string) { o.DeviceUid = v } // GetChallenge returns the Challenge field value func (o *DeviceChallenge) GetChallenge() map[string]interface{} { if o == nil { var ret map[string]interface{} return ret } return o.Challenge } // GetChallengeOk returns a tuple with the Challenge field value // and a boolean to check if the value has been set. func (o *DeviceChallenge) GetChallengeOk() (map[string]interface{}, bool) { if o == nil { return map[string]interface{}{}, false } return o.Challenge, true } // SetChallenge sets field value func (o *DeviceChallenge) SetChallenge(v map[string]interface{}) { o.Challenge = v } // GetLastUsed returns the LastUsed field value // If the value is explicit nil, the zero value for time.Time will be returned func (o *DeviceChallenge) GetLastUsed() time.Time { if o == nil || o.LastUsed.Get() == nil { var ret time.Time return ret } return *o.LastUsed.Get() } // GetLastUsedOk returns a tuple with the LastUsed field value // and a boolean to check if the value has been set. // NOTE: If the value is an explicit nil, `nil, true` will be returned func (o *DeviceChallenge) GetLastUsedOk() (*time.Time, bool) { if o == nil { return nil, false } return o.LastUsed.Get(), o.LastUsed.IsSet() } // SetLastUsed sets field value func (o *DeviceChallenge) SetLastUsed(v time.Time) { o.LastUsed.Set(&v) } func (o DeviceChallenge) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { return []byte{}, err } return json.Marshal(toSerialize) } func (o DeviceChallenge) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["device_class"] = o.DeviceClass toSerialize["device_uid"] = o.DeviceUid toSerialize["challenge"] = o.Challenge toSerialize["last_used"] = o.LastUsed.Get() for key, value := range o.AdditionalProperties { toSerialize[key] = value } return toSerialize, nil } func (o *DeviceChallenge) UnmarshalJSON(data []byte) (err error) { // This validates that all required properties are included in the JSON object // by unmarshalling the object into a generic map with string keys and checking // that every required field exists as a key in the generic map. requiredProperties := []string{ "device_class", "device_uid", "challenge", "last_used", } allProperties := make(map[string]interface{}) err = json.Unmarshal(data, &allProperties) if err != nil { return err } for _, requiredProperty := range requiredProperties { if _, exists := allProperties[requiredProperty]; !exists { return fmt.Errorf("no value given for required property %v", requiredProperty) } } varDeviceChallenge := _DeviceChallenge{} err = json.Unmarshal(data, &varDeviceChallenge) if err != nil { return err } *o = DeviceChallenge(varDeviceChallenge) additionalProperties := make(map[string]interface{}) if err = json.Unmarshal(data, &additionalProperties); err == nil { delete(additionalProperties, "device_class") delete(additionalProperties, "device_uid") delete(additionalProperties, "challenge") delete(additionalProperties, "last_used") o.AdditionalProperties = additionalProperties } return err } type NullableDeviceChallenge struct { value *DeviceChallenge isSet bool } func (v NullableDeviceChallenge) Get() *DeviceChallenge { return v.value } func (v *NullableDeviceChallenge) Set(val *DeviceChallenge) { v.value = val v.isSet = true } func (v NullableDeviceChallenge) IsSet() bool { return v.isSet } func (v *NullableDeviceChallenge) Unset() { v.value = nil v.isSet = false } func NewNullableDeviceChallenge(val *DeviceChallenge) *NullableDeviceChallenge { return &NullableDeviceChallenge{value: val, isSet: true} } func (v NullableDeviceChallenge) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableDeviceChallenge) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }