Skip to content

Commit 598d6a6

Browse files
authored
Fix nullable - required UUID examples (#3634)
* change templates to use function to get pointers * regenerate code
1 parent c208b52 commit 598d6a6

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

.generator/src/generator/formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def reference_to_value(schema, value, print_nullable=True, **kwargs):
252252

253253
if type_name == "string":
254254
if type_format == "uuid":
255-
return f"&{value}"
255+
return f"datadog.PtrUUID({value})"
256256

257257
function_name = {
258258
"date": "Time",

.generator/src/generator/templates/utils.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"reflect"
99
"strings"
1010
"time"
11+
12+
"github.com/google/uuid"
1113
)
1214

1315
// PtrBool is a helper routine that returns a pointer to given boolean value.
@@ -34,6 +36,9 @@ func PtrString(v string) *string { return &v }
3436
// PtrTime is helper routine that returns a pointer to given Time value.
3537
func PtrTime(v time.Time) *time.Time { return &v }
3638

39+
// PtrUUID is helper routine that returns a pointer to given UUID value.
40+
func PtrUUID(v uuid.UUID) *uuid.UUID { return &v }
41+
3742
// PaginationResult pagination item helper struct
3843
type PaginationResult[T any] struct {
3944
Item T

api/datadog/utils.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"strings"
1313
"time"
1414
"unicode/utf8"
15+
16+
"github.com/google/uuid"
1517
)
1618

1719
// PtrBool is a helper routine that returns a pointer to given boolean value.
@@ -38,6 +40,9 @@ func PtrString(v string) *string { return &v }
3840
// PtrTime is helper routine that returns a pointer to given Time value.
3941
func PtrTime(v time.Time) *time.Time { return &v }
4042

43+
// PtrUUID is helper routine that returns a pointer to given UUID value.
44+
func PtrUUID(v uuid.UUID) *uuid.UUID { return &v }
45+
4146
// PaginationResult pagination item helper struct
4247
type PaginationResult[T any] struct {
4348
Item T

examples/v2/app-builder/UpdateApp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323
Name: datadog.PtrString("Updated Name"),
2424
RootInstanceName: datadog.PtrString("grid0"),
2525
},
26-
Id: &AppDataID,
26+
Id: datadog.PtrUUID(AppDataID),
2727
Type: datadogV2.APPDEFINITIONTYPE_APPDEFINITIONS,
2828
},
2929
}

0 commit comments

Comments
 (0)