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

// StorageSettings Per tenant storage settings.
type StorageSettings struct {
	// The storage provider type 'azure' Blob storage or AWS 's3' (defaults to s3).
	Type *string `json:"type,omitempty"`
	// AWS region (S3 only: required).
	Region *string `json:"region,omitempty"`
	// S3 Bucket (Azure: container) name.
	Bucket string `json:"bucket"`
	// Bucket/container endpoint URI.
	Uri *string `json:"uri,omitempty"`
	// Public Endpoint URI for presigning URLs (S3 only).
	ExternalUri *string `json:"external_uri,omitempty"`
	// Access key identifier (Azure: account name).
	Key string `json:"key"`
	// Secret access key (Azure: access key).
	Secret string `json:"secret"`
	// AWS S3 session token (S3 only).
	Token *string `json:"token,omitempty"`
	// Force S3 path-style instead of virtual-hosted style (S3 only).
	ForcePathStyle *bool `json:"force_path_style,omitempty"`
	// Enable S3 Transfer acceleration (S3 only).
	UseAccelerate *bool `json:"use_accelerate,omitempty"`
	// Shared access key connection string (Azure only).
	ConnectionString *string `json:"connection_string,omitempty"`
	// Alias for 'bucket' (Azure only).
	ContainerName *string `json:"container_name,omitempty"`
	// Alias for 'key' (Azure only).
	AccountName *string `json:"account_name,omitempty"`
	// Alias for 'secret' (Azure only).
	AccountKey *string `json:"account_key,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _StorageSettings StorageSettings

// NewStorageSettings instantiates a new StorageSettings 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 NewStorageSettings(bucket string, key string, secret string) *StorageSettings {
	this := StorageSettings{}
	this.Bucket = bucket
	this.Key = key
	this.Secret = secret
	return &this
}

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

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

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

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

	return false
}

// SetType gets a reference to the given string and assigns it to the Type field.
func (o *StorageSettings) SetType(v string) {
	o.Type = &v
}

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

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

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

	return false
}

// SetRegion gets a reference to the given string and assigns it to the Region field.
func (o *StorageSettings) SetRegion(v string) {
	o.Region = &v
}

// GetBucket returns the Bucket field value
func (o *StorageSettings) GetBucket() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Bucket
}

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

// SetBucket sets field value
func (o *StorageSettings) SetBucket(v string) {
	o.Bucket = v
}

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

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

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

	return false
}

// SetUri gets a reference to the given string and assigns it to the Uri field.
func (o *StorageSettings) SetUri(v string) {
	o.Uri = &v
}

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

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

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

	return false
}

// SetExternalUri gets a reference to the given string and assigns it to the ExternalUri field.
func (o *StorageSettings) SetExternalUri(v string) {
	o.ExternalUri = &v
}

// GetKey returns the Key field value
func (o *StorageSettings) GetKey() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Key
}

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

// SetKey sets field value
func (o *StorageSettings) SetKey(v string) {
	o.Key = v
}

// GetSecret returns the Secret field value
func (o *StorageSettings) GetSecret() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Secret
}

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

// SetSecret sets field value
func (o *StorageSettings) SetSecret(v string) {
	o.Secret = v
}

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

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

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

	return false
}

// SetToken gets a reference to the given string and assigns it to the Token field.
func (o *StorageSettings) SetToken(v string) {
	o.Token = &v
}

// GetForcePathStyle returns the ForcePathStyle field value if set, zero value otherwise.
func (o *StorageSettings) GetForcePathStyle() bool {
	if o == nil || IsNil(o.ForcePathStyle) {
		var ret bool
		return ret
	}
	return *o.ForcePathStyle
}

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

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

	return false
}

// SetForcePathStyle gets a reference to the given bool and assigns it to the ForcePathStyle field.
func (o *StorageSettings) SetForcePathStyle(v bool) {
	o.ForcePathStyle = &v
}

// GetUseAccelerate returns the UseAccelerate field value if set, zero value otherwise.
func (o *StorageSettings) GetUseAccelerate() bool {
	if o == nil || IsNil(o.UseAccelerate) {
		var ret bool
		return ret
	}
	return *o.UseAccelerate
}

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

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

	return false
}

// SetUseAccelerate gets a reference to the given bool and assigns it to the UseAccelerate field.
func (o *StorageSettings) SetUseAccelerate(v bool) {
	o.UseAccelerate = &v
}

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

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

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

	return false
}

// SetConnectionString gets a reference to the given string and assigns it to the ConnectionString field.
func (o *StorageSettings) SetConnectionString(v string) {
	o.ConnectionString = &v
}

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

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

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

	return false
}

// SetContainerName gets a reference to the given string and assigns it to the ContainerName field.
func (o *StorageSettings) SetContainerName(v string) {
	o.ContainerName = &v
}

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

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

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

	return false
}

// SetAccountName gets a reference to the given string and assigns it to the AccountName field.
func (o *StorageSettings) SetAccountName(v string) {
	o.AccountName = &v
}

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

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

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

	return false
}

// SetAccountKey gets a reference to the given string and assigns it to the AccountKey field.
func (o *StorageSettings) SetAccountKey(v string) {
	o.AccountKey = &v
}

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

func (o StorageSettings) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Type) {
		toSerialize["type"] = o.Type
	}
	if !IsNil(o.Region) {
		toSerialize["region"] = o.Region
	}
	toSerialize["bucket"] = o.Bucket
	if !IsNil(o.Uri) {
		toSerialize["uri"] = o.Uri
	}
	if !IsNil(o.ExternalUri) {
		toSerialize["external_uri"] = o.ExternalUri
	}
	toSerialize["key"] = o.Key
	toSerialize["secret"] = o.Secret
	if !IsNil(o.Token) {
		toSerialize["token"] = o.Token
	}
	if !IsNil(o.ForcePathStyle) {
		toSerialize["force_path_style"] = o.ForcePathStyle
	}
	if !IsNil(o.UseAccelerate) {
		toSerialize["use_accelerate"] = o.UseAccelerate
	}
	if !IsNil(o.ConnectionString) {
		toSerialize["connection_string"] = o.ConnectionString
	}
	if !IsNil(o.ContainerName) {
		toSerialize["container_name"] = o.ContainerName
	}
	if !IsNil(o.AccountName) {
		toSerialize["account_name"] = o.AccountName
	}
	if !IsNil(o.AccountKey) {
		toSerialize["account_key"] = o.AccountKey
	}

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

	return toSerialize, nil
}

func (o *StorageSettings) 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{
		"bucket",
		"key",
		"secret",
	}

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

	varStorageSettings := _StorageSettings{}

	err = json.Unmarshal(data, &varStorageSettings)

	if err != nil {
		return err
	}

	*o = StorageSettings(varStorageSettings)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "type")
		delete(additionalProperties, "region")
		delete(additionalProperties, "bucket")
		delete(additionalProperties, "uri")
		delete(additionalProperties, "external_uri")
		delete(additionalProperties, "key")
		delete(additionalProperties, "secret")
		delete(additionalProperties, "token")
		delete(additionalProperties, "force_path_style")
		delete(additionalProperties, "use_accelerate")
		delete(additionalProperties, "connection_string")
		delete(additionalProperties, "container_name")
		delete(additionalProperties, "account_name")
		delete(additionalProperties, "account_key")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableStorageSettings struct {
	value *StorageSettings
	isSet bool
}

func (v NullableStorageSettings) Get() *StorageSettings {
	return v.value
}

func (v *NullableStorageSettings) Set(val *StorageSettings) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableStorageSettings(val *StorageSettings) *NullableStorageSettings {
	return &NullableStorageSettings{value: val, isSet: true}
}

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

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


