/*
authentik

Making authentication simple.

API version: 2026.5.0-rc1
Contact: hello@goauthentik.io
*/

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

package api

import (
	"encoding/json"
	"fmt"
)

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

// Provider Provider Serializer
type Provider struct {
	Pk   int32  `json:"pk"`
	Name string `json:"name"`
	// Flow used for authentication when the associated application is accessed by an un-authenticated user.
	AuthenticationFlow NullableString `json:"authentication_flow,omitempty"`
	// Flow used when authorizing this provider.
	AuthorizationFlow string `json:"authorization_flow"`
	// Flow used ending the session from a provider.
	InvalidationFlow string   `json:"invalidation_flow"`
	PropertyMappings []string `json:"property_mappings,omitempty"`
	// Get object component so that we know how to edit the object
	Component string `json:"component"`
	// Internal application name, used in URLs.
	AssignedApplicationSlug NullableString `json:"assigned_application_slug"`
	// Application's display Name.
	AssignedApplicationName NullableString `json:"assigned_application_name"`
	// Internal application name, used in URLs.
	AssignedBackchannelApplicationSlug NullableString `json:"assigned_backchannel_application_slug"`
	// Application's display Name.
	AssignedBackchannelApplicationName NullableString `json:"assigned_backchannel_application_name"`
	// Return object's verbose_name
	VerboseName string `json:"verbose_name"`
	// Return object's plural verbose_name
	VerboseNamePlural string `json:"verbose_name_plural"`
	// Return internal model name
	MetaModelName        string `json:"meta_model_name"`
	AdditionalProperties map[string]interface{}
}

type _Provider Provider

// NewProvider instantiates a new Provider 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 NewProvider(pk int32, name string, authorizationFlow string, invalidationFlow string, component string, assignedApplicationSlug NullableString, assignedApplicationName NullableString, assignedBackchannelApplicationSlug NullableString, assignedBackchannelApplicationName NullableString, verboseName string, verboseNamePlural string, metaModelName string) *Provider {
	this := Provider{}
	this.Pk = pk
	this.Name = name
	this.AuthorizationFlow = authorizationFlow
	this.InvalidationFlow = invalidationFlow
	this.Component = component
	this.AssignedApplicationSlug = assignedApplicationSlug
	this.AssignedApplicationName = assignedApplicationName
	this.AssignedBackchannelApplicationSlug = assignedBackchannelApplicationSlug
	this.AssignedBackchannelApplicationName = assignedBackchannelApplicationName
	this.VerboseName = verboseName
	this.VerboseNamePlural = verboseNamePlural
	this.MetaModelName = metaModelName
	return &this
}

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

// GetPk returns the Pk field value
func (o *Provider) GetPk() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.Pk
}

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

// SetPk sets field value
func (o *Provider) SetPk(v int32) {
	o.Pk = v
}

// GetName returns the Name field value
func (o *Provider) GetName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Name
}

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

// SetName sets field value
func (o *Provider) SetName(v string) {
	o.Name = v
}

// GetAuthenticationFlow returns the AuthenticationFlow field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *Provider) GetAuthenticationFlow() string {
	if o == nil || IsNil(o.AuthenticationFlow.Get()) {
		var ret string
		return ret
	}
	return *o.AuthenticationFlow.Get()
}

// GetAuthenticationFlowOk returns a tuple with the AuthenticationFlow field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Provider) GetAuthenticationFlowOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.AuthenticationFlow.Get(), o.AuthenticationFlow.IsSet()
}

// HasAuthenticationFlow returns a boolean if a field has been set.
func (o *Provider) HasAuthenticationFlow() bool {
	if o != nil && o.AuthenticationFlow.IsSet() {
		return true
	}

	return false
}

// SetAuthenticationFlow gets a reference to the given NullableString and assigns it to the AuthenticationFlow field.
func (o *Provider) SetAuthenticationFlow(v string) {
	o.AuthenticationFlow.Set(&v)
}

// SetAuthenticationFlowNil sets the value for AuthenticationFlow to be an explicit nil
func (o *Provider) SetAuthenticationFlowNil() {
	o.AuthenticationFlow.Set(nil)
}

// UnsetAuthenticationFlow ensures that no value is present for AuthenticationFlow, not even an explicit nil
func (o *Provider) UnsetAuthenticationFlow() {
	o.AuthenticationFlow.Unset()
}

// GetAuthorizationFlow returns the AuthorizationFlow field value
func (o *Provider) GetAuthorizationFlow() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.AuthorizationFlow
}

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

// SetAuthorizationFlow sets field value
func (o *Provider) SetAuthorizationFlow(v string) {
	o.AuthorizationFlow = v
}

// GetInvalidationFlow returns the InvalidationFlow field value
func (o *Provider) GetInvalidationFlow() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.InvalidationFlow
}

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

// SetInvalidationFlow sets field value
func (o *Provider) SetInvalidationFlow(v string) {
	o.InvalidationFlow = v
}

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

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

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

	return false
}

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

// GetComponent returns the Component field value
func (o *Provider) GetComponent() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Component
}

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

// SetComponent sets field value
func (o *Provider) SetComponent(v string) {
	o.Component = v
}

// GetAssignedApplicationSlug returns the AssignedApplicationSlug field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Provider) GetAssignedApplicationSlug() string {
	if o == nil || o.AssignedApplicationSlug.Get() == nil {
		var ret string
		return ret
	}

	return *o.AssignedApplicationSlug.Get()
}

// GetAssignedApplicationSlugOk returns a tuple with the AssignedApplicationSlug field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Provider) GetAssignedApplicationSlugOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.AssignedApplicationSlug.Get(), o.AssignedApplicationSlug.IsSet()
}

// SetAssignedApplicationSlug sets field value
func (o *Provider) SetAssignedApplicationSlug(v string) {
	o.AssignedApplicationSlug.Set(&v)
}

// GetAssignedApplicationName returns the AssignedApplicationName field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Provider) GetAssignedApplicationName() string {
	if o == nil || o.AssignedApplicationName.Get() == nil {
		var ret string
		return ret
	}

	return *o.AssignedApplicationName.Get()
}

// GetAssignedApplicationNameOk returns a tuple with the AssignedApplicationName field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Provider) GetAssignedApplicationNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.AssignedApplicationName.Get(), o.AssignedApplicationName.IsSet()
}

// SetAssignedApplicationName sets field value
func (o *Provider) SetAssignedApplicationName(v string) {
	o.AssignedApplicationName.Set(&v)
}

// GetAssignedBackchannelApplicationSlug returns the AssignedBackchannelApplicationSlug field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Provider) GetAssignedBackchannelApplicationSlug() string {
	if o == nil || o.AssignedBackchannelApplicationSlug.Get() == nil {
		var ret string
		return ret
	}

	return *o.AssignedBackchannelApplicationSlug.Get()
}

// GetAssignedBackchannelApplicationSlugOk returns a tuple with the AssignedBackchannelApplicationSlug field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Provider) GetAssignedBackchannelApplicationSlugOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.AssignedBackchannelApplicationSlug.Get(), o.AssignedBackchannelApplicationSlug.IsSet()
}

// SetAssignedBackchannelApplicationSlug sets field value
func (o *Provider) SetAssignedBackchannelApplicationSlug(v string) {
	o.AssignedBackchannelApplicationSlug.Set(&v)
}

// GetAssignedBackchannelApplicationName returns the AssignedBackchannelApplicationName field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Provider) GetAssignedBackchannelApplicationName() string {
	if o == nil || o.AssignedBackchannelApplicationName.Get() == nil {
		var ret string
		return ret
	}

	return *o.AssignedBackchannelApplicationName.Get()
}

// GetAssignedBackchannelApplicationNameOk returns a tuple with the AssignedBackchannelApplicationName field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Provider) GetAssignedBackchannelApplicationNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.AssignedBackchannelApplicationName.Get(), o.AssignedBackchannelApplicationName.IsSet()
}

// SetAssignedBackchannelApplicationName sets field value
func (o *Provider) SetAssignedBackchannelApplicationName(v string) {
	o.AssignedBackchannelApplicationName.Set(&v)
}

// GetVerboseName returns the VerboseName field value
func (o *Provider) GetVerboseName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.VerboseName
}

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

// SetVerboseName sets field value
func (o *Provider) SetVerboseName(v string) {
	o.VerboseName = v
}

// GetVerboseNamePlural returns the VerboseNamePlural field value
func (o *Provider) GetVerboseNamePlural() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.VerboseNamePlural
}

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

// SetVerboseNamePlural sets field value
func (o *Provider) SetVerboseNamePlural(v string) {
	o.VerboseNamePlural = v
}

// GetMetaModelName returns the MetaModelName field value
func (o *Provider) GetMetaModelName() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.MetaModelName
}

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

// SetMetaModelName sets field value
func (o *Provider) SetMetaModelName(v string) {
	o.MetaModelName = v
}

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

func (o Provider) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["pk"] = o.Pk
	toSerialize["name"] = o.Name
	if o.AuthenticationFlow.IsSet() {
		toSerialize["authentication_flow"] = o.AuthenticationFlow.Get()
	}
	toSerialize["authorization_flow"] = o.AuthorizationFlow
	toSerialize["invalidation_flow"] = o.InvalidationFlow
	if !IsNil(o.PropertyMappings) {
		toSerialize["property_mappings"] = o.PropertyMappings
	}
	toSerialize["component"] = o.Component
	toSerialize["assigned_application_slug"] = o.AssignedApplicationSlug.Get()
	toSerialize["assigned_application_name"] = o.AssignedApplicationName.Get()
	toSerialize["assigned_backchannel_application_slug"] = o.AssignedBackchannelApplicationSlug.Get()
	toSerialize["assigned_backchannel_application_name"] = o.AssignedBackchannelApplicationName.Get()
	toSerialize["verbose_name"] = o.VerboseName
	toSerialize["verbose_name_plural"] = o.VerboseNamePlural
	toSerialize["meta_model_name"] = o.MetaModelName

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

	return toSerialize, nil
}

func (o *Provider) 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{
		"pk",
		"name",
		"authorization_flow",
		"invalidation_flow",
		"component",
		"assigned_application_slug",
		"assigned_application_name",
		"assigned_backchannel_application_slug",
		"assigned_backchannel_application_name",
		"verbose_name",
		"verbose_name_plural",
		"meta_model_name",
	}

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

	varProvider := _Provider{}

	err = json.Unmarshal(data, &varProvider)

	if err != nil {
		return err
	}

	*o = Provider(varProvider)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "pk")
		delete(additionalProperties, "name")
		delete(additionalProperties, "authentication_flow")
		delete(additionalProperties, "authorization_flow")
		delete(additionalProperties, "invalidation_flow")
		delete(additionalProperties, "property_mappings")
		delete(additionalProperties, "component")
		delete(additionalProperties, "assigned_application_slug")
		delete(additionalProperties, "assigned_application_name")
		delete(additionalProperties, "assigned_backchannel_application_slug")
		delete(additionalProperties, "assigned_backchannel_application_name")
		delete(additionalProperties, "verbose_name")
		delete(additionalProperties, "verbose_name_plural")
		delete(additionalProperties, "meta_model_name")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableProvider struct {
	value *Provider
	isSet bool
}

func (v NullableProvider) Get() *Provider {
	return v.value
}

func (v *NullableProvider) Set(val *Provider) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableProvider(val *Provider) *NullableProvider {
	return &NullableProvider{value: val, isSet: true}
}

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

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