mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
380 lines
11 KiB
Go
380 lines
11 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"
|
|
"fmt"
|
|
)
|
|
|
|
// checks if the ExperimentCreateBody type satisfies the MappedNullable interface at compile time
|
|
var _ MappedNullable = &ExperimentCreateBody{}
|
|
|
|
// ExperimentCreateBody struct for ExperimentCreateBody
|
|
type ExperimentCreateBody struct {
|
|
// ExposureEvent is the event that marks a subject as enrolled — the analysis denominator — defaulting to the SDK's $feature_flag_called marker.
|
|
ExposureEvent *string `json:"exposureEvent,omitempty"`
|
|
// FlagKey names the assignment flag this experiment writes, defaulting to exp_<id>. It must be a slug.
|
|
FlagKey *string `json:"flagKey,omitempty"`
|
|
// ID is the experiment's slug, claimed once per project. It must match [A-Za-z0-9][A-Za-z0-9._-]{0,127}.
|
|
Id string `json:"id"`
|
|
// MetricEvent is the event that counts as a conversion — the analysis numerator.
|
|
MetricEvent string `json:"metricEvent"`
|
|
// Name is free text for a reader; the id is what addresses the experiment.
|
|
Name *string `json:"name,omitempty"`
|
|
// SubjectKind is the unit assigned and measured: user (the default), org, session or audience.
|
|
SubjectKind *string `json:"subjectKind,omitempty"`
|
|
// Arms are the arms, at least two. Weights that are all zero become an even split; otherwise they must sum to 100, and at most one arm may be flagged control.
|
|
Variants []ExperimentArm `json:"variants"`
|
|
AdditionalProperties map[string]interface{}
|
|
}
|
|
|
|
type _ExperimentCreateBody ExperimentCreateBody
|
|
|
|
// NewExperimentCreateBody instantiates a new ExperimentCreateBody 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 NewExperimentCreateBody(id string, metricEvent string, variants []ExperimentArm) *ExperimentCreateBody {
|
|
this := ExperimentCreateBody{}
|
|
this.Id = id
|
|
this.MetricEvent = metricEvent
|
|
this.Variants = variants
|
|
return &this
|
|
}
|
|
|
|
// NewExperimentCreateBodyWithDefaults instantiates a new ExperimentCreateBody 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 NewExperimentCreateBodyWithDefaults() *ExperimentCreateBody {
|
|
this := ExperimentCreateBody{}
|
|
return &this
|
|
}
|
|
|
|
// GetExposureEvent returns the ExposureEvent field value if set, zero value otherwise.
|
|
func (o *ExperimentCreateBody) GetExposureEvent() string {
|
|
if o == nil || IsNil(o.ExposureEvent) {
|
|
var ret string
|
|
return ret
|
|
}
|
|
return *o.ExposureEvent
|
|
}
|
|
|
|
// GetExposureEventOk returns a tuple with the ExposureEvent field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *ExperimentCreateBody) GetExposureEventOk() (*string, bool) {
|
|
if o == nil || IsNil(o.ExposureEvent) {
|
|
return nil, false
|
|
}
|
|
return o.ExposureEvent, true
|
|
}
|
|
|
|
// HasExposureEvent returns a boolean if a field has been set.
|
|
func (o *ExperimentCreateBody) HasExposureEvent() bool {
|
|
if o != nil && !IsNil(o.ExposureEvent) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetExposureEvent gets a reference to the given string and assigns it to the ExposureEvent field.
|
|
func (o *ExperimentCreateBody) SetExposureEvent(v string) {
|
|
o.ExposureEvent = &v
|
|
}
|
|
|
|
// GetFlagKey returns the FlagKey field value if set, zero value otherwise.
|
|
func (o *ExperimentCreateBody) GetFlagKey() string {
|
|
if o == nil || IsNil(o.FlagKey) {
|
|
var ret string
|
|
return ret
|
|
}
|
|
return *o.FlagKey
|
|
}
|
|
|
|
// GetFlagKeyOk returns a tuple with the FlagKey field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *ExperimentCreateBody) GetFlagKeyOk() (*string, bool) {
|
|
if o == nil || IsNil(o.FlagKey) {
|
|
return nil, false
|
|
}
|
|
return o.FlagKey, true
|
|
}
|
|
|
|
// HasFlagKey returns a boolean if a field has been set.
|
|
func (o *ExperimentCreateBody) HasFlagKey() bool {
|
|
if o != nil && !IsNil(o.FlagKey) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetFlagKey gets a reference to the given string and assigns it to the FlagKey field.
|
|
func (o *ExperimentCreateBody) SetFlagKey(v string) {
|
|
o.FlagKey = &v
|
|
}
|
|
|
|
// GetId returns the Id field value
|
|
func (o *ExperimentCreateBody) 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 *ExperimentCreateBody) GetIdOk() (*string, bool) {
|
|
if o == nil {
|
|
return nil, false
|
|
}
|
|
return &o.Id, true
|
|
}
|
|
|
|
// SetId sets field value
|
|
func (o *ExperimentCreateBody) SetId(v string) {
|
|
o.Id = v
|
|
}
|
|
|
|
// GetMetricEvent returns the MetricEvent field value
|
|
func (o *ExperimentCreateBody) GetMetricEvent() string {
|
|
if o == nil {
|
|
var ret string
|
|
return ret
|
|
}
|
|
|
|
return o.MetricEvent
|
|
}
|
|
|
|
// GetMetricEventOk returns a tuple with the MetricEvent field value
|
|
// and a boolean to check if the value has been set.
|
|
func (o *ExperimentCreateBody) GetMetricEventOk() (*string, bool) {
|
|
if o == nil {
|
|
return nil, false
|
|
}
|
|
return &o.MetricEvent, true
|
|
}
|
|
|
|
// SetMetricEvent sets field value
|
|
func (o *ExperimentCreateBody) SetMetricEvent(v string) {
|
|
o.MetricEvent = v
|
|
}
|
|
|
|
// GetName returns the Name field value if set, zero value otherwise.
|
|
func (o *ExperimentCreateBody) GetName() string {
|
|
if o == nil || IsNil(o.Name) {
|
|
var ret string
|
|
return ret
|
|
}
|
|
return *o.Name
|
|
}
|
|
|
|
// GetNameOk returns a tuple with the Name field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *ExperimentCreateBody) GetNameOk() (*string, bool) {
|
|
if o == nil || IsNil(o.Name) {
|
|
return nil, false
|
|
}
|
|
return o.Name, true
|
|
}
|
|
|
|
// HasName returns a boolean if a field has been set.
|
|
func (o *ExperimentCreateBody) HasName() bool {
|
|
if o != nil && !IsNil(o.Name) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetName gets a reference to the given string and assigns it to the Name field.
|
|
func (o *ExperimentCreateBody) SetName(v string) {
|
|
o.Name = &v
|
|
}
|
|
|
|
// GetSubjectKind returns the SubjectKind field value if set, zero value otherwise.
|
|
func (o *ExperimentCreateBody) GetSubjectKind() string {
|
|
if o == nil || IsNil(o.SubjectKind) {
|
|
var ret string
|
|
return ret
|
|
}
|
|
return *o.SubjectKind
|
|
}
|
|
|
|
// GetSubjectKindOk returns a tuple with the SubjectKind field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *ExperimentCreateBody) GetSubjectKindOk() (*string, bool) {
|
|
if o == nil || IsNil(o.SubjectKind) {
|
|
return nil, false
|
|
}
|
|
return o.SubjectKind, true
|
|
}
|
|
|
|
// HasSubjectKind returns a boolean if a field has been set.
|
|
func (o *ExperimentCreateBody) HasSubjectKind() bool {
|
|
if o != nil && !IsNil(o.SubjectKind) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetSubjectKind gets a reference to the given string and assigns it to the SubjectKind field.
|
|
func (o *ExperimentCreateBody) SetSubjectKind(v string) {
|
|
o.SubjectKind = &v
|
|
}
|
|
|
|
// GetVariants returns the Variants field value
|
|
func (o *ExperimentCreateBody) GetVariants() []ExperimentArm {
|
|
if o == nil {
|
|
var ret []ExperimentArm
|
|
return ret
|
|
}
|
|
|
|
return o.Variants
|
|
}
|
|
|
|
// GetVariantsOk returns a tuple with the Variants field value
|
|
// and a boolean to check if the value has been set.
|
|
func (o *ExperimentCreateBody) GetVariantsOk() ([]ExperimentArm, bool) {
|
|
if o == nil {
|
|
return nil, false
|
|
}
|
|
return o.Variants, true
|
|
}
|
|
|
|
// SetVariants sets field value
|
|
func (o *ExperimentCreateBody) SetVariants(v []ExperimentArm) {
|
|
o.Variants = v
|
|
}
|
|
|
|
func (o ExperimentCreateBody) MarshalJSON() ([]byte, error) {
|
|
toSerialize, err := o.ToMap()
|
|
if err != nil {
|
|
return []byte{}, err
|
|
}
|
|
return json.Marshal(toSerialize)
|
|
}
|
|
|
|
func (o ExperimentCreateBody) ToMap() (map[string]interface{}, error) {
|
|
toSerialize := map[string]interface{}{}
|
|
if !IsNil(o.ExposureEvent) {
|
|
toSerialize["exposureEvent"] = o.ExposureEvent
|
|
}
|
|
if !IsNil(o.FlagKey) {
|
|
toSerialize["flagKey"] = o.FlagKey
|
|
}
|
|
toSerialize["id"] = o.Id
|
|
toSerialize["metricEvent"] = o.MetricEvent
|
|
if !IsNil(o.Name) {
|
|
toSerialize["name"] = o.Name
|
|
}
|
|
if !IsNil(o.SubjectKind) {
|
|
toSerialize["subjectKind"] = o.SubjectKind
|
|
}
|
|
toSerialize["variants"] = o.Variants
|
|
|
|
for key, value := range o.AdditionalProperties {
|
|
toSerialize[key] = value
|
|
}
|
|
|
|
return toSerialize, nil
|
|
}
|
|
|
|
func (o *ExperimentCreateBody) 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",
|
|
"metricEvent",
|
|
"variants",
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
varExperimentCreateBody := _ExperimentCreateBody{}
|
|
|
|
err = json.Unmarshal(data, &varExperimentCreateBody)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*o = ExperimentCreateBody(varExperimentCreateBody)
|
|
|
|
additionalProperties := make(map[string]interface{})
|
|
|
|
if err = json.Unmarshal(data, &additionalProperties); err == nil {
|
|
delete(additionalProperties, "exposureEvent")
|
|
delete(additionalProperties, "flagKey")
|
|
delete(additionalProperties, "id")
|
|
delete(additionalProperties, "metricEvent")
|
|
delete(additionalProperties, "name")
|
|
delete(additionalProperties, "subjectKind")
|
|
delete(additionalProperties, "variants")
|
|
o.AdditionalProperties = additionalProperties
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
type NullableExperimentCreateBody struct {
|
|
value *ExperimentCreateBody
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableExperimentCreateBody) Get() *ExperimentCreateBody {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableExperimentCreateBody) Set(val *ExperimentCreateBody) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableExperimentCreateBody) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableExperimentCreateBody) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableExperimentCreateBody(val *ExperimentCreateBody) *NullableExperimentCreateBody {
|
|
return &NullableExperimentCreateBody{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableExperimentCreateBody) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableExperimentCreateBody) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|