/*
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"
	"time"
	"fmt"
)

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

// ArtifactLink URL for artifact file download.
type ArtifactLink struct {
	Uri string `json:"uri"`
	Expire time.Time `json:"expire"`
	AdditionalProperties map[string]interface{}
}

type _ArtifactLink ArtifactLink

// NewArtifactLink instantiates a new ArtifactLink 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 NewArtifactLink(uri string, expire time.Time) *ArtifactLink {
	this := ArtifactLink{}
	this.Uri = uri
	this.Expire = expire
	return &this
}

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

// GetUri returns the Uri field value
func (o *ArtifactLink) GetUri() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Uri
}

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

// SetUri sets field value
func (o *ArtifactLink) SetUri(v string) {
	o.Uri = v
}

// GetExpire returns the Expire field value
func (o *ArtifactLink) GetExpire() time.Time {
	if o == nil {
		var ret time.Time
		return ret
	}

	return o.Expire
}

// GetExpireOk returns a tuple with the Expire field value
// and a boolean to check if the value has been set.
func (o *ArtifactLink) GetExpireOk() (*time.Time, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Expire, true
}

// SetExpire sets field value
func (o *ArtifactLink) SetExpire(v time.Time) {
	o.Expire = v
}

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

func (o ArtifactLink) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["uri"] = o.Uri
	toSerialize["expire"] = o.Expire

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

	return toSerialize, nil
}

func (o *ArtifactLink) 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{
		"uri",
		"expire",
	}

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

	varArtifactLink := _ArtifactLink{}

	err = json.Unmarshal(data, &varArtifactLink)

	if err != nil {
		return err
	}

	*o = ArtifactLink(varArtifactLink)

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

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

	return err
}

type NullableArtifactLink struct {
	value *ArtifactLink
	isSet bool
}

func (v NullableArtifactLink) Get() *ArtifactLink {
	return v.value
}

func (v *NullableArtifactLink) Set(val *ArtifactLink) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableArtifactLink(val *ArtifactLink) *NullableArtifactLink {
	return &NullableArtifactLink{value: val, isSet: true}
}

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

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


