Files
sdk/model_problem_details.go

304 lines
7.3 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 ProblemDetails type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ProblemDetails{}
// ProblemDetails An RFC 9457 problem document.
type ProblemDetails struct {
// A stable token a client can branch on, when the refusal names one.
Code *string `json:"code,omitempty"`
// What was refused, for a person to read.
Detail string `json:"detail"`
// The HTTP status.
Status int64 `json:"status"`
// The status's reason phrase.
Title *string `json:"title,omitempty"`
// about:blank
Type string `json:"type"`
AdditionalProperties map[string]interface{}
}
type _ProblemDetails ProblemDetails
// NewProblemDetails instantiates a new ProblemDetails 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 NewProblemDetails(detail string, status int64, type_ string) *ProblemDetails {
this := ProblemDetails{}
this.Detail = detail
this.Status = status
this.Type = type_
return &this
}
// NewProblemDetailsWithDefaults instantiates a new ProblemDetails 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 NewProblemDetailsWithDefaults() *ProblemDetails {
this := ProblemDetails{}
return &this
}
// GetCode returns the Code field value if set, zero value otherwise.
func (o *ProblemDetails) GetCode() string {
if o == nil || IsNil(o.Code) {
var ret string
return ret
}
return *o.Code
}
// GetCodeOk returns a tuple with the Code field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ProblemDetails) GetCodeOk() (*string, bool) {
if o == nil || IsNil(o.Code) {
return nil, false
}
return o.Code, true
}
// HasCode returns a boolean if a field has been set.
func (o *ProblemDetails) HasCode() bool {
if o != nil && !IsNil(o.Code) {
return true
}
return false
}
// SetCode gets a reference to the given string and assigns it to the Code field.
func (o *ProblemDetails) SetCode(v string) {
o.Code = &v
}
// GetDetail returns the Detail field value
func (o *ProblemDetails) GetDetail() string {
if o == nil {
var ret string
return ret
}
return o.Detail
}
// GetDetailOk returns a tuple with the Detail field value
// and a boolean to check if the value has been set.
func (o *ProblemDetails) GetDetailOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Detail, true
}
// SetDetail sets field value
func (o *ProblemDetails) SetDetail(v string) {
o.Detail = v
}
// GetStatus returns the Status field value
func (o *ProblemDetails) GetStatus() int64 {
if o == nil {
var ret int64
return ret
}
return o.Status
}
// GetStatusOk returns a tuple with the Status field value
// and a boolean to check if the value has been set.
func (o *ProblemDetails) GetStatusOk() (*int64, bool) {
if o == nil {
return nil, false
}
return &o.Status, true
}
// SetStatus sets field value
func (o *ProblemDetails) SetStatus(v int64) {
o.Status = v
}
// GetTitle returns the Title field value if set, zero value otherwise.
func (o *ProblemDetails) GetTitle() string {
if o == nil || IsNil(o.Title) {
var ret string
return ret
}
return *o.Title
}
// GetTitleOk returns a tuple with the Title field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ProblemDetails) GetTitleOk() (*string, bool) {
if o == nil || IsNil(o.Title) {
return nil, false
}
return o.Title, true
}
// HasTitle returns a boolean if a field has been set.
func (o *ProblemDetails) HasTitle() bool {
if o != nil && !IsNil(o.Title) {
return true
}
return false
}
// SetTitle gets a reference to the given string and assigns it to the Title field.
func (o *ProblemDetails) SetTitle(v string) {
o.Title = &v
}
// GetType returns the Type field value
func (o *ProblemDetails) GetType() string {
if o == nil {
var ret string
return ret
}
return o.Type
}
// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *ProblemDetails) GetTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Type, true
}
// SetType sets field value
func (o *ProblemDetails) SetType(v string) {
o.Type = v
}
func (o ProblemDetails) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ProblemDetails) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Code) {
toSerialize["code"] = o.Code
}
toSerialize["detail"] = o.Detail
toSerialize["status"] = o.Status
if !IsNil(o.Title) {
toSerialize["title"] = o.Title
}
toSerialize["type"] = o.Type
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil
}
func (o *ProblemDetails) 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{
"detail",
"status",
"type",
}
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)
}
}
varProblemDetails := _ProblemDetails{}
err = json.Unmarshal(data, &varProblemDetails)
if err != nil {
return err
}
*o = ProblemDetails(varProblemDetails)
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(data, &additionalProperties); err == nil {
delete(additionalProperties, "code")
delete(additionalProperties, "detail")
delete(additionalProperties, "status")
delete(additionalProperties, "title")
delete(additionalProperties, "type")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableProblemDetails struct {
value *ProblemDetails
isSet bool
}
func (v NullableProblemDetails) Get() *ProblemDetails {
return v.value
}
func (v *NullableProblemDetails) Set(val *ProblemDetails) {
v.value = val
v.isSet = true
}
func (v NullableProblemDetails) IsSet() bool {
return v.isSet
}
func (v *NullableProblemDetails) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableProblemDetails(val *ProblemDetails) *NullableProblemDetails {
return &NullableProblemDetails{value: val, isSet: true}
}
func (v NullableProblemDetails) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableProblemDetails) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}