mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
535 lines
17 KiB
Go
535 lines
17 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// checks if the GatewayPolicy type satisfies the MappedNullable interface at compile time
|
|
var _ MappedNullable = &GatewayPolicy{}
|
|
|
|
// GatewayPolicy struct for GatewayPolicy
|
|
type GatewayPolicy struct {
|
|
// CachePaths overrides CacheTTLSec per path PREFIX (key \"/v1/models\" → seconds). The longest matching prefix wins.
|
|
CachePaths map[string]int64 `json:"cache_paths,omitempty"`
|
|
// CacheTTLSec is the org's default edge-cache TTL for its responses, in seconds; 0 means no caching. Unset inherits the platform default.
|
|
CacheTtlSec *int64 `json:"cache_ttl_sec,omitempty"`
|
|
// CORSOrigins is the PLATFORM-scope CORS allowlist EdgeCORS admits: an exact origin, a bare host, or a \"*.host\" wildcard. Writable only by a SuperAdmin — CORS is evaluated before identity, so it has no tenant to scope to.
|
|
CorsOrigins []string `json:"cors_origins,omitempty"`
|
|
// Methods is the allowlist of HTTP methods the edge accepts for this org. Empty means all are accepted.
|
|
Methods []string `json:"methods,omitempty"`
|
|
// Mode is the abuse gate's posture for THIS scope: \"shadow\" scores traffic and records the verdict without acting on it, \"live\" enforces it. Unset means shadow. It is the one per-org field that does NOT inherit. Every other field here layers a platform default under the org's own value, which is right for a default: a tenant that sets no rate ceiling should get the platform's. Mode is not a default, it is an ARMING DECISION — it is what makes a statistical judgement start refusing real traffic — and inheriting it means arming one scope arms every tenant that never asked for it, without a write to their row and without anything in their config changing. So a tenant is live only if that tenant's OWN row says live, and the platform row's mode governs exactly one scope: the anonymous lane, which has no tenant of its own. It is also not self-service. Writing it requires SuperAdmin (see the /v1/gateway config op): the subject of an abuse control does not get to switch the control off.
|
|
Mode *string `json:"mode,omitempty"`
|
|
// OrgCap is the most this organization's ceiling may be, requests per minute. Unset, it is the platform's org_rpm, else 60,000. Only a SuperAdmin sets it: it is how the platform raises one organization above the default, and the organization a limit governs does not get to remove it. It does not inherit from the platform row. Read back, it is the cap in force.
|
|
OrgCap *int64 `json:"org_cap,omitempty"`
|
|
// OrgRPM is the org's OWN authenticated rate ceiling, requests per minute, as ScopeRateLimit enforces it across the deployment. An organization may lower it but never raise it past its cap (org_cap); unset, the org is held to its cap. On the platform row it is every organization's default cap, and it does not inherit into any organization's own row. Read back, it is the ceiling in force: the org's own, clipped to its cap.
|
|
OrgRpm *int64 `json:"org_rpm,omitempty"`
|
|
// PerIPRPM is the PLATFORM-scope flood cap: requests admitted per WindowSec from one client IP that presents no credential, or a credential that resolves to nobody. A request presenting a credential is held to ten times this from its address until the credential is checked; a validated caller is then held by its key and org ceilings instead. SuperAdmin-only, same reason.
|
|
PerIpRpm *int64 `json:"per_ip_rpm,omitempty"`
|
|
// UpdatedAt is the unix second this policy row was last written. Server-stamped; a client-supplied value is ignored.
|
|
UpdatedAt *int64 `json:"updated_at,omitempty"`
|
|
// UpdatedBy is the validated user id that wrote this policy row. Server-stamped; a client-supplied value is ignored.
|
|
UpdatedBy *string `json:"updated_by,omitempty"`
|
|
// WindowSec is the window PerIPRPM is counted over, in seconds. SuperAdmin-only.
|
|
WindowSec *int64 `json:"window_sec,omitempty"`
|
|
AdditionalProperties map[string]interface{}
|
|
}
|
|
|
|
type _GatewayPolicy GatewayPolicy
|
|
|
|
// NewGatewayPolicy instantiates a new GatewayPolicy 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 NewGatewayPolicy() *GatewayPolicy {
|
|
this := GatewayPolicy{}
|
|
return &this
|
|
}
|
|
|
|
// NewGatewayPolicyWithDefaults instantiates a new GatewayPolicy 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 NewGatewayPolicyWithDefaults() *GatewayPolicy {
|
|
this := GatewayPolicy{}
|
|
return &this
|
|
}
|
|
|
|
// GetCachePaths returns the CachePaths field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetCachePaths() map[string]int64 {
|
|
if o == nil || IsNil(o.CachePaths) {
|
|
var ret map[string]int64
|
|
return ret
|
|
}
|
|
return o.CachePaths
|
|
}
|
|
|
|
// GetCachePathsOk returns a tuple with the CachePaths field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetCachePathsOk() (map[string]int64, bool) {
|
|
if o == nil || IsNil(o.CachePaths) {
|
|
return map[string]int64{}, false
|
|
}
|
|
return o.CachePaths, true
|
|
}
|
|
|
|
// HasCachePaths returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasCachePaths() bool {
|
|
if o != nil && !IsNil(o.CachePaths) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetCachePaths gets a reference to the given map[string]int64 and assigns it to the CachePaths field.
|
|
func (o *GatewayPolicy) SetCachePaths(v map[string]int64) {
|
|
o.CachePaths = v
|
|
}
|
|
|
|
// GetCacheTtlSec returns the CacheTtlSec field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetCacheTtlSec() int64 {
|
|
if o == nil || IsNil(o.CacheTtlSec) {
|
|
var ret int64
|
|
return ret
|
|
}
|
|
return *o.CacheTtlSec
|
|
}
|
|
|
|
// GetCacheTtlSecOk returns a tuple with the CacheTtlSec field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetCacheTtlSecOk() (*int64, bool) {
|
|
if o == nil || IsNil(o.CacheTtlSec) {
|
|
return nil, false
|
|
}
|
|
return o.CacheTtlSec, true
|
|
}
|
|
|
|
// HasCacheTtlSec returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasCacheTtlSec() bool {
|
|
if o != nil && !IsNil(o.CacheTtlSec) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetCacheTtlSec gets a reference to the given int64 and assigns it to the CacheTtlSec field.
|
|
func (o *GatewayPolicy) SetCacheTtlSec(v int64) {
|
|
o.CacheTtlSec = &v
|
|
}
|
|
|
|
// GetCorsOrigins returns the CorsOrigins field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetCorsOrigins() []string {
|
|
if o == nil || IsNil(o.CorsOrigins) {
|
|
var ret []string
|
|
return ret
|
|
}
|
|
return o.CorsOrigins
|
|
}
|
|
|
|
// GetCorsOriginsOk returns a tuple with the CorsOrigins field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetCorsOriginsOk() ([]string, bool) {
|
|
if o == nil || IsNil(o.CorsOrigins) {
|
|
return nil, false
|
|
}
|
|
return o.CorsOrigins, true
|
|
}
|
|
|
|
// HasCorsOrigins returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasCorsOrigins() bool {
|
|
if o != nil && !IsNil(o.CorsOrigins) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetCorsOrigins gets a reference to the given []string and assigns it to the CorsOrigins field.
|
|
func (o *GatewayPolicy) SetCorsOrigins(v []string) {
|
|
o.CorsOrigins = v
|
|
}
|
|
|
|
// GetMethods returns the Methods field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetMethods() []string {
|
|
if o == nil || IsNil(o.Methods) {
|
|
var ret []string
|
|
return ret
|
|
}
|
|
return o.Methods
|
|
}
|
|
|
|
// GetMethodsOk returns a tuple with the Methods field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetMethodsOk() ([]string, bool) {
|
|
if o == nil || IsNil(o.Methods) {
|
|
return nil, false
|
|
}
|
|
return o.Methods, true
|
|
}
|
|
|
|
// HasMethods returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasMethods() bool {
|
|
if o != nil && !IsNil(o.Methods) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetMethods gets a reference to the given []string and assigns it to the Methods field.
|
|
func (o *GatewayPolicy) SetMethods(v []string) {
|
|
o.Methods = v
|
|
}
|
|
|
|
// GetMode returns the Mode field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetMode() string {
|
|
if o == nil || IsNil(o.Mode) {
|
|
var ret string
|
|
return ret
|
|
}
|
|
return *o.Mode
|
|
}
|
|
|
|
// GetModeOk returns a tuple with the Mode field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetModeOk() (*string, bool) {
|
|
if o == nil || IsNil(o.Mode) {
|
|
return nil, false
|
|
}
|
|
return o.Mode, true
|
|
}
|
|
|
|
// HasMode returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasMode() bool {
|
|
if o != nil && !IsNil(o.Mode) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetMode gets a reference to the given string and assigns it to the Mode field.
|
|
func (o *GatewayPolicy) SetMode(v string) {
|
|
o.Mode = &v
|
|
}
|
|
|
|
// GetOrgCap returns the OrgCap field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetOrgCap() int64 {
|
|
if o == nil || IsNil(o.OrgCap) {
|
|
var ret int64
|
|
return ret
|
|
}
|
|
return *o.OrgCap
|
|
}
|
|
|
|
// GetOrgCapOk returns a tuple with the OrgCap field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetOrgCapOk() (*int64, bool) {
|
|
if o == nil || IsNil(o.OrgCap) {
|
|
return nil, false
|
|
}
|
|
return o.OrgCap, true
|
|
}
|
|
|
|
// HasOrgCap returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasOrgCap() bool {
|
|
if o != nil && !IsNil(o.OrgCap) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetOrgCap gets a reference to the given int64 and assigns it to the OrgCap field.
|
|
func (o *GatewayPolicy) SetOrgCap(v int64) {
|
|
o.OrgCap = &v
|
|
}
|
|
|
|
// GetOrgRpm returns the OrgRpm field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetOrgRpm() int64 {
|
|
if o == nil || IsNil(o.OrgRpm) {
|
|
var ret int64
|
|
return ret
|
|
}
|
|
return *o.OrgRpm
|
|
}
|
|
|
|
// GetOrgRpmOk returns a tuple with the OrgRpm field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetOrgRpmOk() (*int64, bool) {
|
|
if o == nil || IsNil(o.OrgRpm) {
|
|
return nil, false
|
|
}
|
|
return o.OrgRpm, true
|
|
}
|
|
|
|
// HasOrgRpm returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasOrgRpm() bool {
|
|
if o != nil && !IsNil(o.OrgRpm) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetOrgRpm gets a reference to the given int64 and assigns it to the OrgRpm field.
|
|
func (o *GatewayPolicy) SetOrgRpm(v int64) {
|
|
o.OrgRpm = &v
|
|
}
|
|
|
|
// GetPerIpRpm returns the PerIpRpm field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetPerIpRpm() int64 {
|
|
if o == nil || IsNil(o.PerIpRpm) {
|
|
var ret int64
|
|
return ret
|
|
}
|
|
return *o.PerIpRpm
|
|
}
|
|
|
|
// GetPerIpRpmOk returns a tuple with the PerIpRpm field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetPerIpRpmOk() (*int64, bool) {
|
|
if o == nil || IsNil(o.PerIpRpm) {
|
|
return nil, false
|
|
}
|
|
return o.PerIpRpm, true
|
|
}
|
|
|
|
// HasPerIpRpm returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasPerIpRpm() bool {
|
|
if o != nil && !IsNil(o.PerIpRpm) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetPerIpRpm gets a reference to the given int64 and assigns it to the PerIpRpm field.
|
|
func (o *GatewayPolicy) SetPerIpRpm(v int64) {
|
|
o.PerIpRpm = &v
|
|
}
|
|
|
|
// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetUpdatedAt() int64 {
|
|
if o == nil || IsNil(o.UpdatedAt) {
|
|
var ret int64
|
|
return ret
|
|
}
|
|
return *o.UpdatedAt
|
|
}
|
|
|
|
// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetUpdatedAtOk() (*int64, bool) {
|
|
if o == nil || IsNil(o.UpdatedAt) {
|
|
return nil, false
|
|
}
|
|
return o.UpdatedAt, true
|
|
}
|
|
|
|
// HasUpdatedAt returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasUpdatedAt() bool {
|
|
if o != nil && !IsNil(o.UpdatedAt) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetUpdatedAt gets a reference to the given int64 and assigns it to the UpdatedAt field.
|
|
func (o *GatewayPolicy) SetUpdatedAt(v int64) {
|
|
o.UpdatedAt = &v
|
|
}
|
|
|
|
// GetUpdatedBy returns the UpdatedBy field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetUpdatedBy() string {
|
|
if o == nil || IsNil(o.UpdatedBy) {
|
|
var ret string
|
|
return ret
|
|
}
|
|
return *o.UpdatedBy
|
|
}
|
|
|
|
// GetUpdatedByOk returns a tuple with the UpdatedBy field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetUpdatedByOk() (*string, bool) {
|
|
if o == nil || IsNil(o.UpdatedBy) {
|
|
return nil, false
|
|
}
|
|
return o.UpdatedBy, true
|
|
}
|
|
|
|
// HasUpdatedBy returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasUpdatedBy() bool {
|
|
if o != nil && !IsNil(o.UpdatedBy) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetUpdatedBy gets a reference to the given string and assigns it to the UpdatedBy field.
|
|
func (o *GatewayPolicy) SetUpdatedBy(v string) {
|
|
o.UpdatedBy = &v
|
|
}
|
|
|
|
// GetWindowSec returns the WindowSec field value if set, zero value otherwise.
|
|
func (o *GatewayPolicy) GetWindowSec() int64 {
|
|
if o == nil || IsNil(o.WindowSec) {
|
|
var ret int64
|
|
return ret
|
|
}
|
|
return *o.WindowSec
|
|
}
|
|
|
|
// GetWindowSecOk returns a tuple with the WindowSec field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *GatewayPolicy) GetWindowSecOk() (*int64, bool) {
|
|
if o == nil || IsNil(o.WindowSec) {
|
|
return nil, false
|
|
}
|
|
return o.WindowSec, true
|
|
}
|
|
|
|
// HasWindowSec returns a boolean if a field has been set.
|
|
func (o *GatewayPolicy) HasWindowSec() bool {
|
|
if o != nil && !IsNil(o.WindowSec) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetWindowSec gets a reference to the given int64 and assigns it to the WindowSec field.
|
|
func (o *GatewayPolicy) SetWindowSec(v int64) {
|
|
o.WindowSec = &v
|
|
}
|
|
|
|
func (o GatewayPolicy) MarshalJSON() ([]byte, error) {
|
|
toSerialize, err := o.ToMap()
|
|
if err != nil {
|
|
return []byte{}, err
|
|
}
|
|
return json.Marshal(toSerialize)
|
|
}
|
|
|
|
func (o GatewayPolicy) ToMap() (map[string]interface{}, error) {
|
|
toSerialize := map[string]interface{}{}
|
|
if !IsNil(o.CachePaths) {
|
|
toSerialize["cache_paths"] = o.CachePaths
|
|
}
|
|
if !IsNil(o.CacheTtlSec) {
|
|
toSerialize["cache_ttl_sec"] = o.CacheTtlSec
|
|
}
|
|
if !IsNil(o.CorsOrigins) {
|
|
toSerialize["cors_origins"] = o.CorsOrigins
|
|
}
|
|
if !IsNil(o.Methods) {
|
|
toSerialize["methods"] = o.Methods
|
|
}
|
|
if !IsNil(o.Mode) {
|
|
toSerialize["mode"] = o.Mode
|
|
}
|
|
if !IsNil(o.OrgCap) {
|
|
toSerialize["org_cap"] = o.OrgCap
|
|
}
|
|
if !IsNil(o.OrgRpm) {
|
|
toSerialize["org_rpm"] = o.OrgRpm
|
|
}
|
|
if !IsNil(o.PerIpRpm) {
|
|
toSerialize["per_ip_rpm"] = o.PerIpRpm
|
|
}
|
|
if !IsNil(o.UpdatedAt) {
|
|
toSerialize["updated_at"] = o.UpdatedAt
|
|
}
|
|
if !IsNil(o.UpdatedBy) {
|
|
toSerialize["updated_by"] = o.UpdatedBy
|
|
}
|
|
if !IsNil(o.WindowSec) {
|
|
toSerialize["window_sec"] = o.WindowSec
|
|
}
|
|
|
|
for key, value := range o.AdditionalProperties {
|
|
toSerialize[key] = value
|
|
}
|
|
|
|
return toSerialize, nil
|
|
}
|
|
|
|
func (o *GatewayPolicy) UnmarshalJSON(data []byte) (err error) {
|
|
varGatewayPolicy := _GatewayPolicy{}
|
|
|
|
err = json.Unmarshal(data, &varGatewayPolicy)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*o = GatewayPolicy(varGatewayPolicy)
|
|
|
|
additionalProperties := make(map[string]interface{})
|
|
|
|
if err = json.Unmarshal(data, &additionalProperties); err == nil {
|
|
delete(additionalProperties, "cache_paths")
|
|
delete(additionalProperties, "cache_ttl_sec")
|
|
delete(additionalProperties, "cors_origins")
|
|
delete(additionalProperties, "methods")
|
|
delete(additionalProperties, "mode")
|
|
delete(additionalProperties, "org_cap")
|
|
delete(additionalProperties, "org_rpm")
|
|
delete(additionalProperties, "per_ip_rpm")
|
|
delete(additionalProperties, "updated_at")
|
|
delete(additionalProperties, "updated_by")
|
|
delete(additionalProperties, "window_sec")
|
|
o.AdditionalProperties = additionalProperties
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
type NullableGatewayPolicy struct {
|
|
value *GatewayPolicy
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableGatewayPolicy) Get() *GatewayPolicy {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableGatewayPolicy) Set(val *GatewayPolicy) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableGatewayPolicy) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableGatewayPolicy) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableGatewayPolicy(val *GatewayPolicy) *NullableGatewayPolicy {
|
|
return &NullableGatewayPolicy{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableGatewayPolicy) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableGatewayPolicy) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|