/*
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 AWSCredentials type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &AWSCredentials{}

// AWSCredentials AWS credentials in the form of access key id and secret access key, a region and a device policy name.
type AWSCredentials struct {
	// The credential type
	Type string `json:"type"`
	Aws AWSCredentialsAws `json:"aws"`
	AdditionalProperties map[string]interface{}
}

type _AWSCredentials AWSCredentials

// NewAWSCredentials instantiates a new AWSCredentials 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 NewAWSCredentials(type_ string, aws AWSCredentialsAws) *AWSCredentials {
	this := AWSCredentials{}
	this.Type = type_
	this.Aws = aws
	return &this
}

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

// GetType returns the Type field value
func (o *AWSCredentials) GetType() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Type
}

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

// SetType sets field value
func (o *AWSCredentials) SetType(v string) {
	o.Type = v
}

// GetAws returns the Aws field value
func (o *AWSCredentials) GetAws() AWSCredentialsAws {
	if o == nil {
		var ret AWSCredentialsAws
		return ret
	}

	return o.Aws
}

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

// SetAws sets field value
func (o *AWSCredentials) SetAws(v AWSCredentialsAws) {
	o.Aws = v
}

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

func (o AWSCredentials) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["type"] = o.Type
	toSerialize["aws"] = o.Aws

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

	return toSerialize, nil
}

func (o *AWSCredentials) 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{
		"type",
		"aws",
	}

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

	varAWSCredentials := _AWSCredentials{}

	err = json.Unmarshal(data, &varAWSCredentials)

	if err != nil {
		return err
	}

	*o = AWSCredentials(varAWSCredentials)

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

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

	return err
}

type NullableAWSCredentials struct {
	value *AWSCredentials
	isSet bool
}

func (v NullableAWSCredentials) Get() *AWSCredentials {
	return v.value
}

func (v *NullableAWSCredentials) Set(val *AWSCredentials) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableAWSCredentials(val *AWSCredentials) *NullableAWSCredentials {
	return &NullableAWSCredentials{value: val, isSet: true}
}

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

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


