/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package apiclient

import (
	"encoding/json"
	"fmt"
)

// checks if the CreateDockerRegistry type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateDockerRegistry{}

// CreateDockerRegistry struct for CreateDockerRegistry
type CreateDockerRegistry struct {
	// Registry name
	Name string `json:"name"`
	// Registry URL
	Url string `json:"url"`
	// Registry username
	Username string `json:"username"`
	// Registry password
	Password string `json:"password"`
	// Registry project
	Project *string `json:"project,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _CreateDockerRegistry CreateDockerRegistry

// NewCreateDockerRegistry instantiates a new CreateDockerRegistry 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 NewCreateDockerRegistry(name string, url string, username string, password string) *CreateDockerRegistry {
	this := CreateDockerRegistry{}
	this.Name = name
	this.Url = url
	this.Username = username
	this.Password = password
	return &this
}

// NewCreateDockerRegistryWithDefaults instantiates a new CreateDockerRegistry 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 NewCreateDockerRegistryWithDefaults() *CreateDockerRegistry {
	this := CreateDockerRegistry{}
	return &this
}

// GetName returns the Name field value
func (o *CreateDockerRegistry) 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 *CreateDockerRegistry) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Name, true
}

// SetName sets field value
func (o *CreateDockerRegistry) SetName(v string) {
	o.Name = v
}

// GetUrl returns the Url field value
func (o *CreateDockerRegistry) GetUrl() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Url
}

// GetUrlOk returns a tuple with the Url field value
// and a boolean to check if the value has been set.
func (o *CreateDockerRegistry) GetUrlOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Url, true
}

// SetUrl sets field value
func (o *CreateDockerRegistry) SetUrl(v string) {
	o.Url = v
}

// GetUsername returns the Username field value
func (o *CreateDockerRegistry) GetUsername() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Username
}

// GetUsernameOk returns a tuple with the Username field value
// and a boolean to check if the value has been set.
func (o *CreateDockerRegistry) GetUsernameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Username, true
}

// SetUsername sets field value
func (o *CreateDockerRegistry) SetUsername(v string) {
	o.Username = v
}

// GetPassword returns the Password field value
func (o *CreateDockerRegistry) 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 *CreateDockerRegistry) GetPasswordOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Password, true
}

// SetPassword sets field value
func (o *CreateDockerRegistry) SetPassword(v string) {
	o.Password = v
}

// GetProject returns the Project field value if set, zero value otherwise.
func (o *CreateDockerRegistry) GetProject() string {
	if o == nil || IsNil(o.Project) {
		var ret string
		return ret
	}
	return *o.Project
}

// GetProjectOk returns a tuple with the Project field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateDockerRegistry) GetProjectOk() (*string, bool) {
	if o == nil || IsNil(o.Project) {
		return nil, false
	}
	return o.Project, true
}

// HasProject returns a boolean if a field has been set.
func (o *CreateDockerRegistry) HasProject() bool {
	if o != nil && !IsNil(o.Project) {
		return true
	}

	return false
}

// SetProject gets a reference to the given string and assigns it to the Project field.
func (o *CreateDockerRegistry) SetProject(v string) {
	o.Project = &v
}

func (o CreateDockerRegistry) MarshalJSON() ([]byte, error) {
	toSerialize,err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o CreateDockerRegistry) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name
	toSerialize["url"] = o.Url
	toSerialize["username"] = o.Username
	toSerialize["password"] = o.Password
	if !IsNil(o.Project) {
		toSerialize["project"] = o.Project
	}

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

func (o *CreateDockerRegistry) 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",
		"url",
		"username",
		"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)
		}
	}

	varCreateDockerRegistry := _CreateDockerRegistry{}

	err = json.Unmarshal(data, &varCreateDockerRegistry)

	if err != nil {
		return err
	}

	*o = CreateDockerRegistry(varCreateDockerRegistry)

	additionalProperties := make(map[string]interface{})

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "name")
		delete(additionalProperties, "url")
		delete(additionalProperties, "username")
		delete(additionalProperties, "password")
		delete(additionalProperties, "project")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableCreateDockerRegistry struct {
	value *CreateDockerRegistry
	isSet bool
}

func (v NullableCreateDockerRegistry) Get() *CreateDockerRegistry {
	return v.value
}

func (v *NullableCreateDockerRegistry) Set(val *CreateDockerRegistry) {
	v.value = val
	v.isSet = true
}

func (v NullableCreateDockerRegistry) IsSet() bool {
	return v.isSet
}

func (v *NullableCreateDockerRegistry) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableCreateDockerRegistry(val *CreateDockerRegistry) *NullableCreateDockerRegistry {
	return &NullableCreateDockerRegistry{value: val, isSet: true}
}

func (v NullableCreateDockerRegistry) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableCreateDockerRegistry) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}


