Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .generator/src/generator/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def simple_type(schema, render_nullable=False, render_new=False):
"date": "time.Time" if not nullable else f"{nullable_prefix}Time",
"date-time": "time.Time" if not nullable else f"{nullable_prefix}Time",
"binary": "_io.Reader",
"uuid": "uuid.UUID" if not nullable else f"{nullable_prefix}String",
"uuid": "uuid.UUID" if not nullable else f"{nullable_prefix}UUID",
}.get(type_format, "string" if not nullable else f"{nullable_prefix}String")
if type_name == "boolean":
return "bool" if not nullable else f"{nullable_prefix}Bool"
Expand Down
44 changes: 44 additions & 0 deletions .generator/src/generator/templates/utils.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,50 @@ func PtrTime(v time.Time) *time.Time { return &v }
// PtrUUID is helper routine that returns a pointer to given UUID value.
func PtrUUID(v uuid.UUID) *uuid.UUID { return &v }

// NullableUUID is a struct to hold a nullable UUID value.
type NullableUUID struct {
value *uuid.UUID
isSet bool
}

// Get returns the value associated with the nullable UUID.
func (v NullableUUID) Get() *uuid.UUID {
return v.value
}

// Set sets the value associated with the nullable UUID.
func (v *NullableUUID) Set(val *uuid.UUID) {
v.value = val
v.isSet = true
}

// IsSet returns true if the value has been set.
func (v NullableUUID) IsSet() bool {
return v.isSet
}

// Unset resets fields of the nullable UUID.
func (v *NullableUUID) Unset() {
v.value = nil
v.isSet = false
}

// NewNullableUUID instantiates a new nullable UUID.
func NewNullableUUID(val *uuid.UUID) *NullableUUID {
return &NullableUUID{value: val, isSet: true}
}

// MarshalJSON serializes the associated value.
func (v NullableUUID) MarshalJSON() ([]byte, error) {
return Marshal(v.value)
}

// UnmarshalJSON deserializes to the associated value.
func (v *NullableUUID) UnmarshalJSON(src []byte) error {
v.isSet = true
return Unmarshal(src, &v.value)
}

// PaginationResult pagination item helper struct
type PaginationResult[T any] struct {
Item T
Expand Down
44 changes: 44 additions & 0 deletions api/datadog/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,50 @@ func PtrTime(v time.Time) *time.Time { return &v }
// PtrUUID is helper routine that returns a pointer to given UUID value.
func PtrUUID(v uuid.UUID) *uuid.UUID { return &v }

// NullableUUID is a struct to hold a nullable UUID value.
type NullableUUID struct {
value *uuid.UUID
isSet bool
}

// Get returns the value associated with the nullable UUID.
func (v NullableUUID) Get() *uuid.UUID {
return v.value
}

// Set sets the value associated with the nullable UUID.
func (v *NullableUUID) Set(val *uuid.UUID) {
v.value = val
v.isSet = true
}

// IsSet returns true if the value has been set.
func (v NullableUUID) IsSet() bool {
return v.isSet
}

// Unset resets fields of the nullable UUID.
func (v *NullableUUID) Unset() {
v.value = nil
v.isSet = false
}

// NewNullableUUID instantiates a new nullable UUID.
func NewNullableUUID(val *uuid.UUID) *NullableUUID {
return &NullableUUID{value: val, isSet: true}
}

// MarshalJSON serializes the associated value.
func (v NullableUUID) MarshalJSON() ([]byte, error) {
return Marshal(v.value)
}

// UnmarshalJSON deserializes to the associated value.
func (v *NullableUUID) UnmarshalJSON(src []byte) error {
v.isSet = true
return Unmarshal(src, &v.value)
}

// PaginationResult pagination item helper struct
type PaginationResult[T any] struct {
Item T
Expand Down
Loading