/*
Mender API

Combined API specification for the features of the different Mender backend services, suitable for code generation applications 

API version: 1
Contact: support@mender.io
*/

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

package client

import (
	"encoding/json"
	"fmt"
)

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

// AuthRequest struct for AuthRequest
type AuthRequest struct {
	// Vendor-specific JSON representation of the device identity data (MACs, serial numbers, etc.).
	IdData string `json:"id_data"`
	// The device's public key (PEM encoding), generated by the device or pre-provisioned by the vendor. Currently supported public algorithms are: RSA, Ed25519 and ECDSA P-256. 
	Pubkey string `json:"pubkey"`
	// Tenant token.
	TenantToken *string `json:"tenant_token,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _AuthRequest AuthRequest

// NewAuthRequest instantiates a new AuthRequest 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 NewAuthRequest(idData string, pubkey string) *AuthRequest {
	this := AuthRequest{}
	this.IdData = idData
	this.Pubkey = pubkey
	return &this
}

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

// GetIdData returns the IdData field value
func (o *AuthRequest) GetIdData() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.IdData
}

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

// SetIdData sets field value
func (o *AuthRequest) SetIdData(v string) {
	o.IdData = v
}

// GetPubkey returns the Pubkey field value
func (o *AuthRequest) GetPubkey() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Pubkey
}

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

// SetPubkey sets field value
func (o *AuthRequest) SetPubkey(v string) {
	o.Pubkey = v
}

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

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

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

	return false
}

// SetTenantToken gets a reference to the given string and assigns it to the TenantToken field.
func (o *AuthRequest) SetTenantToken(v string) {
	o.TenantToken = &v
}

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

func (o AuthRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id_data"] = o.IdData
	toSerialize["pubkey"] = o.Pubkey
	if !IsNil(o.TenantToken) {
		toSerialize["tenant_token"] = o.TenantToken
	}

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

	return toSerialize, nil
}

func (o *AuthRequest) 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{
		"id_data",
		"pubkey",
	}

	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)
		}
	}

	varAuthRequest := _AuthRequest{}

	err = json.Unmarshal(data, &varAuthRequest)

	if err != nil {
		return err
	}

	*o = AuthRequest(varAuthRequest)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id_data")
		delete(additionalProperties, "pubkey")
		delete(additionalProperties, "tenant_token")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableAuthRequest struct {
	value *AuthRequest
	isSet bool
}

func (v NullableAuthRequest) Get() *AuthRequest {
	return v.value
}

func (v *NullableAuthRequest) Set(val *AuthRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableAuthRequest(val *AuthRequest) *NullableAuthRequest {
	return &NullableAuthRequest{value: val, isSet: true}
}

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

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


