/*
 * IONOS Object Storage API for contract-owned buckets
 *
 * ## Overview The IONOS Object Storage API for contract-owned buckets is a REST-based API that allows developers and applications to interact directly with IONOS' scalable storage solution, leveraging the S3 protocol for object storage operations. Its design ensures seamless compatibility with existing tools and libraries tailored for S3 systems.  ### API References - [S3 API Reference for contract-owned buckets](https://api.ionos.com/docs/s3-contract-owned-buckets/v2/) ### User documentation [IONOS Object Storage User Guide](https://docs.ionos.com/cloud/managed-services/s3-object-storage) * [Documentation on user-owned and contract-owned buckets](https://docs.ionos.com/cloud/managed-services/s3-object-storage/concepts/buckets) * [Documentation on S3 API Compatibility](https://docs.ionos.com/cloud/managed-services/s3-object-storage/concepts/s3-api-compatibility) * [S3 Tools](https://docs.ionos.com/cloud/managed-services/s3-object-storage/s3-tools)  ## Endpoints for contract-owned buckets | Location | Region Name | Bucket Type | Endpoint | | --- | --- | --- | --- | | **Berlin, Germany** | **eu-central-3** | Contract-owned | `https://s3.eu-central-3.ionoscloud.com` |  ## Changelog - 30.05.2024 Initial version
 *
 * API version: 2.0.2
 * Contact: support@cloud.ionos.com
 */

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

package ionoscloud

import (
	"encoding/json"
)

import "encoding/xml"

// RoutingRuleCondition A container for describing a condition that must be met for the specified redirect to apply. For example, 1. If request is for pages in the `/docs` folder, redirect to the `/documents` folder. 2. If request results in HTTP error 4xx, redirect request to another host where you might process the error.
type RoutingRuleCondition struct {
	XMLName xml.Name `xml:"Condition"`
	// The HTTP error code when the redirect is applied. In the event of an error, if the error code equals this value, then the specified redirect is applied. Required when parent element `Condition` is specified and sibling `KeyPrefixEquals` is not specified. If both are specified, then both must be true for the redirect to be applied.
	HttpErrorCodeReturnedEquals *string `json:"HttpErrorCodeReturnedEquals,omitempty" xml:"HttpErrorCodeReturnedEquals"`
	// <p>The object key name prefix when the redirect is applied. For example, to redirect requests for `ExamplePage.html`, the key prefix will be `ExamplePage.html`. To redirect request for all pages with the prefix `docs/`, the key prefix will be `/docs`, which identifies all objects in the `docs/` folder. Required when the parent element `Condition` is specified and sibling `HttpErrorCodeReturnedEquals` is not specified. If both conditions are specified, both must be true for the redirect to be applied.</p> <important> <p>Replacement must be made for object keys containing special characters (such as carriage returns) when using XML requests.</p> </important>
	KeyPrefixEquals *string `json:"KeyPrefixEquals,omitempty" xml:"KeyPrefixEquals"`
}

// NewRoutingRuleCondition instantiates a new RoutingRuleCondition 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 NewRoutingRuleCondition() *RoutingRuleCondition {
	this := RoutingRuleCondition{}

	return &this
}

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

// GetHttpErrorCodeReturnedEquals returns the HttpErrorCodeReturnedEquals field value
// If the value is explicit nil, the zero value for string will be returned
func (o *RoutingRuleCondition) GetHttpErrorCodeReturnedEquals() *string {
	if o == nil {
		return nil
	}

	return o.HttpErrorCodeReturnedEquals

}

// GetHttpErrorCodeReturnedEqualsOk returns a tuple with the HttpErrorCodeReturnedEquals 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 *RoutingRuleCondition) GetHttpErrorCodeReturnedEqualsOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.HttpErrorCodeReturnedEquals, true
}

// SetHttpErrorCodeReturnedEquals sets field value
func (o *RoutingRuleCondition) SetHttpErrorCodeReturnedEquals(v string) {

	o.HttpErrorCodeReturnedEquals = &v

}

// HasHttpErrorCodeReturnedEquals returns a boolean if a field has been set.
func (o *RoutingRuleCondition) HasHttpErrorCodeReturnedEquals() bool {
	if o != nil && o.HttpErrorCodeReturnedEquals != nil {
		return true
	}

	return false
}

// GetKeyPrefixEquals returns the KeyPrefixEquals field value
// If the value is explicit nil, the zero value for string will be returned
func (o *RoutingRuleCondition) GetKeyPrefixEquals() *string {
	if o == nil {
		return nil
	}

	return o.KeyPrefixEquals

}

// GetKeyPrefixEqualsOk returns a tuple with the KeyPrefixEquals 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 *RoutingRuleCondition) GetKeyPrefixEqualsOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.KeyPrefixEquals, true
}

// SetKeyPrefixEquals sets field value
func (o *RoutingRuleCondition) SetKeyPrefixEquals(v string) {

	o.KeyPrefixEquals = &v

}

// HasKeyPrefixEquals returns a boolean if a field has been set.
func (o *RoutingRuleCondition) HasKeyPrefixEquals() bool {
	if o != nil && o.KeyPrefixEquals != nil {
		return true
	}

	return false
}

func (o RoutingRuleCondition) MarshalJSON() ([]byte, error) {
	toSerialize := map[string]interface{}{}
	if o.HttpErrorCodeReturnedEquals != nil {
		toSerialize["HttpErrorCodeReturnedEquals"] = o.HttpErrorCodeReturnedEquals
	}

	if o.KeyPrefixEquals != nil {
		toSerialize["KeyPrefixEquals"] = o.KeyPrefixEquals
	}

	return json.Marshal(toSerialize)
}

type NullableRoutingRuleCondition struct {
	value *RoutingRuleCondition
	isSet bool
}

func (v NullableRoutingRuleCondition) Get() *RoutingRuleCondition {
	return v.value
}

func (v *NullableRoutingRuleCondition) Set(val *RoutingRuleCondition) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableRoutingRuleCondition(val *RoutingRuleCondition) *NullableRoutingRuleCondition {
	return &NullableRoutingRuleCondition{value: val, isSet: true}
}

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

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