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

// ProxySvcRoute struct for ProxySvcRoute
type ProxySvcRoute struct {
	// Id is the routing key: host plus optional path prefix. Example:   \"x.com\"              -> root of the domain   \"x.com/path1\"        -> microfrontend at /path1   \"x.com/path1/path2\"  -> deeper microfrontend mounted at /path1/path2  Use case: multiple microfrontends served under the same host but separated by URL path segments. For example:   - Marketing site at x.com   - Dashboard at x.com/app   - Admin UI at x.com/app/admin  Lookup algorithm:   1. Take the request host and path (e.g. \"x.com/app/admin/users\").   2. Try to match the longest registered Id by progressively stripping      trailing path segments:         - x.com/app/admin/users   (no match)         - x.com/app/admin         (match -> admin UI)   3. If still no match, strip again:         - x.com/app               (match -> dashboard)   4. If still no match, fallback to host-only route:         - x.com                   (match -> marketing site)   5. If no host-only route exists, return 404.  This provides deterministic longest-prefix routing without regex or rule engines, keeping the model simple but enabling path-based microfrontend composition.
	Id string `json:"id"`
	Target string `json:"target"`
}

type _ProxySvcRoute ProxySvcRoute

// NewProxySvcRoute instantiates a new ProxySvcRoute 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 NewProxySvcRoute(id string, target string) *ProxySvcRoute {
	this := ProxySvcRoute{}
	this.Id = id
	this.Target = target
	return &this
}

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

// GetId returns the Id field value
func (o *ProxySvcRoute) 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 *ProxySvcRoute) GetIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Id, true
}

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

// GetTarget returns the Target field value
func (o *ProxySvcRoute) GetTarget() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Target
}

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

// SetTarget sets field value
func (o *ProxySvcRoute) SetTarget(v string) {
	o.Target = v
}

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

func (o ProxySvcRoute) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	toSerialize["target"] = o.Target
	return toSerialize, nil
}

func (o *ProxySvcRoute) 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{
		"id",
		"target",
	}

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

	varProxySvcRoute := _ProxySvcRoute{}

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

	if err != nil {
		return err
	}

	*o = ProxySvcRoute(varProxySvcRoute)

	return err
}

type NullableProxySvcRoute struct {
	value *ProxySvcRoute
	isSet bool
}

func (v NullableProxySvcRoute) Get() *ProxySvcRoute {
	return v.value
}

func (v *NullableProxySvcRoute) Set(val *ProxySvcRoute) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableProxySvcRoute(val *ProxySvcRoute) *NullableProxySvcRoute {
	return &NullableProxySvcRoute{value: val, isSet: true}
}

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

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


