Files
portal/openapi/model_user_create.go
2026-06-22 11:38:29 +02:00

273 lines
6.4 KiB
Go

/*
FastAPI
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 0.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package openapi
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the UserCreate type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &UserCreate{}
// UserCreate struct for UserCreate
type UserCreate struct {
Name string `json:"name"`
Email NullableString `json:"email,omitempty"`
IsAdmin *bool `json:"is_admin,omitempty"`
Password string `json:"password"`
}
type _UserCreate UserCreate
// NewUserCreate instantiates a new UserCreate 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 NewUserCreate(name string, password string) *UserCreate {
this := UserCreate{}
this.Name = name
var isAdmin bool = false
this.IsAdmin = &isAdmin
this.Password = password
return &this
}
// NewUserCreateWithDefaults instantiates a new UserCreate 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 NewUserCreateWithDefaults() *UserCreate {
this := UserCreate{}
var isAdmin bool = false
this.IsAdmin = &isAdmin
return &this
}
// GetName returns the Name field value
func (o *UserCreate) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *UserCreate) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *UserCreate) SetName(v string) {
o.Name = v
}
// GetEmail returns the Email field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *UserCreate) GetEmail() string {
if o == nil || IsNil(o.Email.Get()) {
var ret string
return ret
}
return *o.Email.Get()
}
// GetEmailOk returns a tuple with the Email field value if set, nil otherwise
// 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 *UserCreate) GetEmailOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Email.Get(), o.Email.IsSet()
}
// HasEmail returns a boolean if a field has been set.
func (o *UserCreate) HasEmail() bool {
if o != nil && o.Email.IsSet() {
return true
}
return false
}
// SetEmail gets a reference to the given NullableString and assigns it to the Email field.
func (o *UserCreate) SetEmail(v string) {
o.Email.Set(&v)
}
// SetEmailNil sets the value for Email to be an explicit nil
func (o *UserCreate) SetEmailNil() {
o.Email.Set(nil)
}
// UnsetEmail ensures that no value is present for Email, not even an explicit nil
func (o *UserCreate) UnsetEmail() {
o.Email.Unset()
}
// GetIsAdmin returns the IsAdmin field value if set, zero value otherwise.
func (o *UserCreate) GetIsAdmin() bool {
if o == nil || IsNil(o.IsAdmin) {
var ret bool
return ret
}
return *o.IsAdmin
}
// GetIsAdminOk returns a tuple with the IsAdmin field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserCreate) GetIsAdminOk() (*bool, bool) {
if o == nil || IsNil(o.IsAdmin) {
return nil, false
}
return o.IsAdmin, true
}
// HasIsAdmin returns a boolean if a field has been set.
func (o *UserCreate) HasIsAdmin() bool {
if o != nil && !IsNil(o.IsAdmin) {
return true
}
return false
}
// SetIsAdmin gets a reference to the given bool and assigns it to the IsAdmin field.
func (o *UserCreate) SetIsAdmin(v bool) {
o.IsAdmin = &v
}
// GetPassword returns the Password field value
func (o *UserCreate) GetPassword() string {
if o == nil {
var ret string
return ret
}
return o.Password
}
// GetPasswordOk returns a tuple with the Password field value
// and a boolean to check if the value has been set.
func (o *UserCreate) GetPasswordOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Password, true
}
// SetPassword sets field value
func (o *UserCreate) SetPassword(v string) {
o.Password = v
}
func (o UserCreate) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o UserCreate) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["name"] = o.Name
if o.Email.IsSet() {
toSerialize["email"] = o.Email.Get()
}
if !IsNil(o.IsAdmin) {
toSerialize["is_admin"] = o.IsAdmin
}
toSerialize["password"] = o.Password
return toSerialize, nil
}
func (o *UserCreate) 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{
"name",
"password",
}
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)
}
}
varUserCreate := _UserCreate{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varUserCreate)
if err != nil {
return err
}
*o = UserCreate(varUserCreate)
return err
}
type NullableUserCreate struct {
value *UserCreate
isSet bool
}
func (v NullableUserCreate) Get() *UserCreate {
return v.value
}
func (v *NullableUserCreate) Set(val *UserCreate) {
v.value = val
v.isSet = true
}
func (v NullableUserCreate) IsSet() bool {
return v.isSet
}
func (v *NullableUserCreate) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableUserCreate(val *UserCreate) *NullableUserCreate {
return &NullableUserCreate{value: val, isSet: true}
}
func (v NullableUserCreate) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableUserCreate) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}