model_metadata_object.go•5.38 kB
/*
Metoro API
API for managing Metoro environments, alerts, and dashboards.
API version: 1.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package model
import (
"bytes"
"encoding/json"
"fmt"
)
// checks if the MetadataObject type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &MetadataObject{}
// MetadataObject struct for MetadataObject
type MetadataObject struct {
// Name of the alert
Name string `json:"name"`
// Description of the alert with additional context
Description *string `json:"description,omitempty"`
// Unique identifier for the alert.
Id string `json:"id"`
}
type _MetadataObject MetadataObject
// NewMetadataObject instantiates a new MetadataObject 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 NewMetadataObject(name string, id string) *MetadataObject {
this := MetadataObject{}
this.Name = name
this.Id = id
return &this
}
// NewMetadataObjectWithDefaults instantiates a new MetadataObject 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 NewMetadataObjectWithDefaults() *MetadataObject {
this := MetadataObject{}
return &this
}
// GetName returns the Name field value
func (o *MetadataObject) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *MetadataObject) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *MetadataObject) SetName(v string) {
o.Name = v
}
// GetDescription returns the Description field value if set, zero value otherwise.
func (o *MetadataObject) GetDescription() string {
if o == nil || IsNil(o.Description) {
var ret string
return ret
}
return *o.Description
}
// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MetadataObject) GetDescriptionOk() (*string, bool) {
if o == nil || IsNil(o.Description) {
return nil, false
}
return o.Description, true
}
// HasDescription returns a boolean if a field has been set.
func (o *MetadataObject) HasDescription() bool {
if o != nil && !IsNil(o.Description) {
return true
}
return false
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *MetadataObject) SetDescription(v string) {
o.Description = &v
}
// GetId returns the Id field value
func (o *MetadataObject) 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 *MetadataObject) GetIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Id, true
}
// SetId sets field value
func (o *MetadataObject) SetId(v string) {
o.Id = v
}
func (o MetadataObject) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o MetadataObject) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["name"] = o.Name
if !IsNil(o.Description) {
toSerialize["description"] = o.Description
}
toSerialize["id"] = o.Id
return toSerialize, nil
}
func (o *MetadataObject) 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{
"name",
"id",
}
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)
}
}
varMetadataObject := _MetadataObject{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varMetadataObject)
if err != nil {
return err
}
*o = MetadataObject(varMetadataObject)
return err
}
type NullableMetadataObject struct {
value *MetadataObject
isSet bool
}
func (v NullableMetadataObject) Get() *MetadataObject {
return v.value
}
func (v *NullableMetadataObject) Set(val *MetadataObject) {
v.value = val
v.isSet = true
}
func (v NullableMetadataObject) IsSet() bool {
return v.isSet
}
func (v *NullableMetadataObject) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableMetadataObject(val *MetadataObject) *NullableMetadataObject {
return &NullableMetadataObject{value: val, isSet: true}
}
func (v NullableMetadataObject) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableMetadataObject) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}