/*
1Backend

AI-native microservices platform.

API version: 0.8.2
Contact: sales@singulatron.com
*/

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

package openapi

import (
	"encoding/json"
	"bytes"
	"fmt"
)

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

// UserSvcPermit struct for UserSvcPermit
type UserSvcPermit struct {
	// App of the permit. Use `*` to match all apps, such as when bootstrapping in services.
	AppId string `json:"appId"`
	CreatedAt string `json:"createdAt"`
	DeletedAt *string `json:"deletedAt,omitempty"`
	Id string `json:"id"`
	InternalId *string `json:"internalId,omitempty"`
	Permission string `json:"permission"`
	// Role IDs that have been permited the specified permission.  Originally, permits were designed for slugs to facilitate service-to-service calls. Due to their convenience—especially with CLI and infrastructure-as-code support—they were later extended to roles.
	Roles []string `json:"roles,omitempty"`
	// Slugs that have been permited the specified permission.
	Slugs []string `json:"slugs,omitempty"`
	UpdatedAt string `json:"updatedAt"`
}

type _UserSvcPermit UserSvcPermit

// NewUserSvcPermit instantiates a new UserSvcPermit 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 NewUserSvcPermit(appId string, createdAt string, id string, permission string, updatedAt string) *UserSvcPermit {
	this := UserSvcPermit{}
	this.AppId = appId
	this.CreatedAt = createdAt
	this.Id = id
	this.Permission = permission
	this.UpdatedAt = updatedAt
	return &this
}

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

// GetAppId returns the AppId field value
func (o *UserSvcPermit) GetAppId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.AppId
}

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

// SetAppId sets field value
func (o *UserSvcPermit) SetAppId(v string) {
	o.AppId = v
}

// GetCreatedAt returns the CreatedAt field value
func (o *UserSvcPermit) GetCreatedAt() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.CreatedAt
}

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

// SetCreatedAt sets field value
func (o *UserSvcPermit) SetCreatedAt(v string) {
	o.CreatedAt = v
}

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

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

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

	return false
}

// SetDeletedAt gets a reference to the given string and assigns it to the DeletedAt field.
func (o *UserSvcPermit) SetDeletedAt(v string) {
	o.DeletedAt = &v
}

// GetId returns the Id field value
func (o *UserSvcPermit) GetId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Id
}

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

// SetId sets field value
func (o *UserSvcPermit) SetId(v string) {
	o.Id = v
}

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

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

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

	return false
}

// SetInternalId gets a reference to the given string and assigns it to the InternalId field.
func (o *UserSvcPermit) SetInternalId(v string) {
	o.InternalId = &v
}

// GetPermission returns the Permission field value
func (o *UserSvcPermit) GetPermission() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Permission
}

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

// SetPermission sets field value
func (o *UserSvcPermit) SetPermission(v string) {
	o.Permission = v
}

// GetRoles returns the Roles field value if set, zero value otherwise.
func (o *UserSvcPermit) GetRoles() []string {
	if o == nil || IsNil(o.Roles) {
		var ret []string
		return ret
	}
	return o.Roles
}

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

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

	return false
}

// SetRoles gets a reference to the given []string and assigns it to the Roles field.
func (o *UserSvcPermit) SetRoles(v []string) {
	o.Roles = v
}

// GetSlugs returns the Slugs field value if set, zero value otherwise.
func (o *UserSvcPermit) GetSlugs() []string {
	if o == nil || IsNil(o.Slugs) {
		var ret []string
		return ret
	}
	return o.Slugs
}

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

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

	return false
}

// SetSlugs gets a reference to the given []string and assigns it to the Slugs field.
func (o *UserSvcPermit) SetSlugs(v []string) {
	o.Slugs = v
}

// GetUpdatedAt returns the UpdatedAt field value
func (o *UserSvcPermit) GetUpdatedAt() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.UpdatedAt
}

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

// SetUpdatedAt sets field value
func (o *UserSvcPermit) SetUpdatedAt(v string) {
	o.UpdatedAt = v
}

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

func (o UserSvcPermit) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["appId"] = o.AppId
	toSerialize["createdAt"] = o.CreatedAt
	if !IsNil(o.DeletedAt) {
		toSerialize["deletedAt"] = o.DeletedAt
	}
	toSerialize["id"] = o.Id
	if !IsNil(o.InternalId) {
		toSerialize["internalId"] = o.InternalId
	}
	toSerialize["permission"] = o.Permission
	if !IsNil(o.Roles) {
		toSerialize["roles"] = o.Roles
	}
	if !IsNil(o.Slugs) {
		toSerialize["slugs"] = o.Slugs
	}
	toSerialize["updatedAt"] = o.UpdatedAt
	return toSerialize, nil
}

func (o *UserSvcPermit) 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{
		"appId",
		"createdAt",
		"id",
		"permission",
		"updatedAt",
	}

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

	varUserSvcPermit := _UserSvcPermit{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varUserSvcPermit)

	if err != nil {
		return err
	}

	*o = UserSvcPermit(varUserSvcPermit)

	return err
}

type NullableUserSvcPermit struct {
	value *UserSvcPermit
	isSet bool
}

func (v NullableUserSvcPermit) Get() *UserSvcPermit {
	return v.value
}

func (v *NullableUserSvcPermit) Set(val *UserSvcPermit) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUserSvcPermit(val *UserSvcPermit) *NullableUserSvcPermit {
	return &NullableUserSvcPermit{value: val, isSet: true}
}

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

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


