From 04bcf1d2cbd36ad529508163c5b6028b2dbbc0ac Mon Sep 17 00:00:00 2001 From: Eden Date: Mon, 13 Jan 2025 14:37:46 -0500 Subject: [PATCH] us --- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../enum/dynamic-snippets/example0/snippet.go | 7 +- .../enum/dynamic-snippets/example1/snippet.go | 7 +- .../enum/dynamic-snippets/example2/snippet.go | 7 +- .../enum/dynamic-snippets/example3/snippet.go | 7 +- .../enum/dynamic-snippets/example4/snippet.go | 7 +- .../enum/dynamic-snippets/example5/snippet.go | 7 +- .../enum/dynamic-snippets/example6/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example10/snippet.go | 3 + .../dynamic-snippets/example11/snippet.go | 3 + .../dynamic-snippets/example12/snippet.go | 3 + .../dynamic-snippets/example13/snippet.go | 3 + .../dynamic-snippets/example14/snippet.go | 3 + .../dynamic-snippets/example15/snippet.go | 3 + .../dynamic-snippets/example16/snippet.go | 3 + .../dynamic-snippets/example17/snippet.go | 3 + .../dynamic-snippets/example18/snippet.go | 3 + .../dynamic-snippets/example2/snippet.go | 3 + .../dynamic-snippets/example3/snippet.go | 3 + .../dynamic-snippets/example4/snippet.go | 3 + .../dynamic-snippets/example5/snippet.go | 3 + .../dynamic-snippets/example6/snippet.go | 3 + .../dynamic-snippets/example7/snippet.go | 3 + .../dynamic-snippets/example8/snippet.go | 3 + .../dynamic-snippets/example9/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example10/snippet.go | 3 + .../dynamic-snippets/example11/snippet.go | 3 + .../dynamic-snippets/example12/snippet.go | 3 + .../dynamic-snippets/example13/snippet.go | 3 + .../dynamic-snippets/example14/snippet.go | 3 + .../dynamic-snippets/example15/snippet.go | 3 + .../dynamic-snippets/example16/snippet.go | 3 + .../dynamic-snippets/example17/snippet.go | 3 + .../dynamic-snippets/example18/snippet.go | 3 + .../dynamic-snippets/example2/snippet.go | 3 + .../dynamic-snippets/example3/snippet.go | 3 + .../dynamic-snippets/example4/snippet.go | 3 + .../dynamic-snippets/example5/snippet.go | 3 + .../dynamic-snippets/example6/snippet.go | 3 + .../dynamic-snippets/example7/snippet.go | 3 + .../dynamic-snippets/example8/snippet.go | 3 + .../dynamic-snippets/example9/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example10/snippet.go | 3 + .../dynamic-snippets/example11/snippet.go | 3 + .../dynamic-snippets/example12/snippet.go | 3 + .../dynamic-snippets/example13/snippet.go | 3 + .../dynamic-snippets/example14/snippet.go | 3 + .../dynamic-snippets/example15/snippet.go | 3 + .../dynamic-snippets/example16/snippet.go | 3 + .../dynamic-snippets/example17/snippet.go | 3 + .../dynamic-snippets/example18/snippet.go | 3 + .../dynamic-snippets/example2/snippet.go | 3 + .../dynamic-snippets/example3/snippet.go | 3 + .../dynamic-snippets/example4/snippet.go | 3 + .../dynamic-snippets/example5/snippet.go | 3 + .../dynamic-snippets/example6/snippet.go | 3 + .../dynamic-snippets/example7/snippet.go | 3 + .../dynamic-snippets/example8/snippet.go | 3 + .../dynamic-snippets/example9/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example4/snippet.go | 7 +- .../dynamic-snippets/example5/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example10/snippet.go | 7 +- .../dynamic-snippets/example11/snippet.go | 7 +- .../dynamic-snippets/example12/snippet.go | 7 +- .../dynamic-snippets/example13/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example4/snippet.go | 7 +- .../dynamic-snippets/example5/snippet.go | 7 +- .../dynamic-snippets/example6/snippet.go | 7 +- .../dynamic-snippets/example7/snippet.go | 7 +- .../dynamic-snippets/example8/snippet.go | 7 +- .../dynamic-snippets/example9/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../imdb/dynamic-snippets/example0/snippet.go | 3 + .../imdb/dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example4/snippet.go | 7 +- .../dynamic-snippets/example5/snippet.go | 7 +- .../dynamic-snippets/example6/snippet.go | 7 +- .../dynamic-snippets/example7/snippet.go | 7 +- .../dynamic-snippets/example8/snippet.go | 7 +- .../dynamic-snippets/example9/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../.github/workflows/ci.yml | 27 ++ .../.mock/definition/api.yml | 18 + .../.mock/definition/auth.yml | 43 ++ .../.mock/fern.config.json | 1 + .../.mock/generators.yml | 1 + .../oauth-client-credentials-custom/auth.go | 159 +++++++ .../auth/client.go | 106 +++++ .../client/client.go | 34 ++ .../client/client_test.go | 45 ++ .../core/api_error.go | 42 ++ .../core/http.go | 8 + .../core/request_option.go | 112 +++++ .../dynamic-snippets/example0/snippet.go | 28 ++ .../dynamic-snippets/example1/snippet.go | 27 ++ .../file_param.go | 41 ++ .../oauth-client-credentials-custom/go.mod | 9 + .../oauth-client-credentials-custom/go.sum | 14 + .../internal/caller.go | 238 +++++++++++ .../internal/caller_test.go | 391 ++++++++++++++++++ .../internal/error_decoder.go | 45 ++ .../internal/error_decoder_test.go | 55 +++ .../internal/extra_properties.go | 141 +++++++ .../internal/extra_properties_test.go | 228 ++++++++++ .../internal/http.go | 48 +++ .../internal/query.go | 231 +++++++++++ .../internal/query_test.go | 187 +++++++++ .../internal/retrier.go | 165 ++++++++ .../internal/retrier_test.go | 211 ++++++++++ .../internal/stringer.go | 13 + .../internal/time.go | 137 ++++++ .../option/request_option.go | 64 +++ .../pointer.go | 132 ++++++ .../snippet-templates.json | 0 .../snippet.json | 26 ++ .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example1/snippet.go | 3 + .../dynamic-snippets/example2/snippet.go | 3 + .../dynamic-snippets/example3/snippet.go | 3 + .../dynamic-snippets/example4/snippet.go | 3 + .../dynamic-snippets/example5/snippet.go | 3 + .../dynamic-snippets/example6/snippet.go | 3 + .../dynamic-snippets/example7/snippet.go | 3 + .../dynamic-snippets/example8/snippet.go | 3 + .../dynamic-snippets/example9/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example4/snippet.go | 7 +- .../dynamic-snippets/example5/snippet.go | 7 +- .../dynamic-snippets/example6/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example4/snippet.go | 7 +- .../dynamic-snippets/example5/snippet.go | 7 +- .../dynamic-snippets/example6/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example3/snippet.go | 7 +- .../dynamic-snippets/example4/snippet.go | 7 +- .../dynamic-snippets/example5/snippet.go | 7 +- .../dynamic-snippets/example6/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 3 + .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example2/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example1/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- .../dynamic-snippets/example0/snippet.go | 7 +- seed/go-sdk/version/.mock/definition/api.yml | 6 +- .../dynamic-snippets/example0/snippet.go | 7 +- 238 files changed, 3979 insertions(+), 115 deletions(-) create mode 100644 seed/go-sdk/oauth-client-credentials-custom/.github/workflows/ci.yml create mode 100644 seed/go-sdk/oauth-client-credentials-custom/.mock/definition/api.yml create mode 100644 seed/go-sdk/oauth-client-credentials-custom/.mock/definition/auth.yml create mode 100644 seed/go-sdk/oauth-client-credentials-custom/.mock/fern.config.json create mode 100644 seed/go-sdk/oauth-client-credentials-custom/.mock/generators.yml create mode 100644 seed/go-sdk/oauth-client-credentials-custom/auth.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/auth/client.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/client/client.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/client/client_test.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/core/api_error.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/core/http.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/core/request_option.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example0/snippet.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example1/snippet.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/file_param.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/go.mod create mode 100644 seed/go-sdk/oauth-client-credentials-custom/go.sum create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/caller.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/caller_test.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder_test.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties_test.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/http.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/query.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/query_test.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/retrier.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/retrier_test.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/stringer.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/internal/time.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/option/request_option.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/pointer.go create mode 100644 seed/go-sdk/oauth-client-credentials-custom/snippet-templates.json create mode 100644 seed/go-sdk/oauth-client-credentials-custom/snippet.json diff --git a/seed/go-sdk/alias/dynamic-snippets/example0/snippet.go b/seed/go-sdk/alias/dynamic-snippets/example0/snippet.go index 5d871380917..32fe2671922 100644 --- a/seed/go-sdk/alias/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/alias/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/alias/fern/client" + option "github.com/alias/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Get( context.TODO(), "typeId", diff --git a/seed/go-sdk/any-auth/dynamic-snippets/example0/snippet.go b/seed/go-sdk/any-auth/dynamic-snippets/example0/snippet.go index 0bb2dabcb35..6b62db74447 100644 --- a/seed/go-sdk/any-auth/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/any-auth/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/any-auth/dynamic-snippets/example1/snippet.go b/seed/go-sdk/any-auth/dynamic-snippets/example1/snippet.go index 00668c08c9e..f59422aeeb5 100644 --- a/seed/go-sdk/any-auth/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/any-auth/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/api-wide-base-path/dynamic-snippets/example0/snippet.go b/seed/go-sdk/api-wide-base-path/dynamic-snippets/example0/snippet.go index e0b93c87c92..ec6ea3a9635 100644 --- a/seed/go-sdk/api-wide-base-path/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/api-wide-base-path/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/api-wide-base-path/fern/client" + option "github.com/api-wide-base-path/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.Post( context.TODO(), "pathParam", diff --git a/seed/go-sdk/audiences/dynamic-snippets/example0/snippet.go b/seed/go-sdk/audiences/dynamic-snippets/example0/snippet.go index 1bae0d4da0f..f85b72693bd 100644 --- a/seed/go-sdk/audiences/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/audiences/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/audiences/fern/client" + option "github.com/audiences/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.FolderA.Service.GetDirectThread( context.TODO(), ) diff --git a/seed/go-sdk/audiences/dynamic-snippets/example1/snippet.go b/seed/go-sdk/audiences/dynamic-snippets/example1/snippet.go index a729478c269..0c01fa5932d 100644 --- a/seed/go-sdk/audiences/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/audiences/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/audiences/fern/client" + option "github.com/audiences/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.FolderD.Service.GetDirectThread( context.TODO(), ) diff --git a/seed/go-sdk/audiences/dynamic-snippets/example2/snippet.go b/seed/go-sdk/audiences/dynamic-snippets/example2/snippet.go index 3b6952c3be6..0c8cf36abb3 100644 --- a/seed/go-sdk/audiences/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/audiences/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/audiences/fern/client" + option "github.com/audiences/fern/option" context "context" fern "github.com/audiences/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Foo.Find( context.TODO(), &fern.FindRequest{ diff --git a/seed/go-sdk/auth-environment-variables/dynamic-snippets/example0/snippet.go b/seed/go-sdk/auth-environment-variables/dynamic-snippets/example0/snippet.go index 4d22a9d4d32..c4b796aae38 100644 --- a/seed/go-sdk/auth-environment-variables/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/auth-environment-variables/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithApiKey( "", ), diff --git a/seed/go-sdk/auth-environment-variables/dynamic-snippets/example1/snippet.go b/seed/go-sdk/auth-environment-variables/dynamic-snippets/example1/snippet.go index b80266f3f45..e7e02071a34 100644 --- a/seed/go-sdk/auth-environment-variables/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/auth-environment-variables/dynamic-snippets/example1/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithApiKey( "", ), diff --git a/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example0/snippet.go b/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example0/snippet.go index 98c2d0fff52..7cbad6626b6 100644 --- a/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithBasicAuth( "", "", diff --git a/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example1/snippet.go b/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example1/snippet.go index 29d2062876e..173e107f78f 100644 --- a/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/basic-auth-environment-variables/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithBasicAuth( "", "", diff --git a/seed/go-sdk/basic-auth/dynamic-snippets/example0/snippet.go b/seed/go-sdk/basic-auth/dynamic-snippets/example0/snippet.go index 2ecbd66dc77..a68621671be 100644 --- a/seed/go-sdk/basic-auth/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/basic-auth/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithBasicAuth( "", "", diff --git a/seed/go-sdk/basic-auth/dynamic-snippets/example1/snippet.go b/seed/go-sdk/basic-auth/dynamic-snippets/example1/snippet.go index 72a69e1c5ed..013279b8fdb 100644 --- a/seed/go-sdk/basic-auth/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/basic-auth/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithBasicAuth( "", "", diff --git a/seed/go-sdk/bearer-token-environment-variable/dynamic-snippets/example0/snippet.go b/seed/go-sdk/bearer-token-environment-variable/dynamic-snippets/example0/snippet.go index b4820ab9213..1577f5449c5 100644 --- a/seed/go-sdk/bearer-token-environment-variable/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/bearer-token-environment-variable/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithApiKey( "", ), diff --git a/seed/go-sdk/cross-package-type-names/dynamic-snippets/example0/snippet.go b/seed/go-sdk/cross-package-type-names/dynamic-snippets/example0/snippet.go index f7d8a764aaf..0e6c7a5c0d7 100644 --- a/seed/go-sdk/cross-package-type-names/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/cross-package-type-names/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/cross-package-type-names/fern/client" + option "github.com/cross-package-type-names/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.FolderA.Service.GetDirectThread( context.TODO(), ) diff --git a/seed/go-sdk/cross-package-type-names/dynamic-snippets/example1/snippet.go b/seed/go-sdk/cross-package-type-names/dynamic-snippets/example1/snippet.go index f7d8a764aaf..0e6c7a5c0d7 100644 --- a/seed/go-sdk/cross-package-type-names/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/cross-package-type-names/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/cross-package-type-names/fern/client" + option "github.com/cross-package-type-names/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.FolderA.Service.GetDirectThread( context.TODO(), ) diff --git a/seed/go-sdk/cross-package-type-names/dynamic-snippets/example2/snippet.go b/seed/go-sdk/cross-package-type-names/dynamic-snippets/example2/snippet.go index bdefa236c96..cfed6cc7d86 100644 --- a/seed/go-sdk/cross-package-type-names/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/cross-package-type-names/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/cross-package-type-names/fern/client" + option "github.com/cross-package-type-names/fern/option" context "context" fern "github.com/cross-package-type-names/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Foo.Find( context.TODO(), &fern.FindRequest{ diff --git a/seed/go-sdk/custom-auth/dynamic-snippets/example0/snippet.go b/seed/go-sdk/custom-auth/dynamic-snippets/example0/snippet.go index 517043ae2e8..1de750a7767 100644 --- a/seed/go-sdk/custom-auth/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/custom-auth/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithCustomAuthScheme( "", ), diff --git a/seed/go-sdk/custom-auth/dynamic-snippets/example1/snippet.go b/seed/go-sdk/custom-auth/dynamic-snippets/example1/snippet.go index cbaba37cc96..92021781cfb 100644 --- a/seed/go-sdk/custom-auth/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/custom-auth/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithCustomAuthScheme( "", ), diff --git a/seed/go-sdk/enum/dynamic-snippets/example0/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example0/snippet.go index 4b0c86eda42..36897c1bd9c 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.InlinedRequest.Send( context.TODO(), &fern.SendEnumInlinedRequest{ diff --git a/seed/go-sdk/enum/dynamic-snippets/example1/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example1/snippet.go index 0bfc6d02c11..04dfb2f95ce 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.InlinedRequest.Send( context.TODO(), &fern.SendEnumInlinedRequest{ diff --git a/seed/go-sdk/enum/dynamic-snippets/example2/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example2/snippet.go index 83c8fcd5d09..3893879e353 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.PathParam.Send( context.TODO(), fern.OperandGreaterThan, diff --git a/seed/go-sdk/enum/dynamic-snippets/example3/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example3/snippet.go index 83c8fcd5d09..3893879e353 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example3/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.PathParam.Send( context.TODO(), fern.OperandGreaterThan, diff --git a/seed/go-sdk/enum/dynamic-snippets/example4/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example4/snippet.go index c69cb290ab4..35e9d385771 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example4/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.QueryParam.Send( context.TODO(), &fern.SendEnumAsQueryParamRequest{ diff --git a/seed/go-sdk/enum/dynamic-snippets/example5/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example5/snippet.go index 61335784846..3716f381cae 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example5/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.QueryParam.Send( context.TODO(), &fern.SendEnumAsQueryParamRequest{ diff --git a/seed/go-sdk/enum/dynamic-snippets/example6/snippet.go b/seed/go-sdk/enum/dynamic-snippets/example6/snippet.go index 16842ff0453..12e003c326e 100644 --- a/seed/go-sdk/enum/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/enum/dynamic-snippets/example6/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/enum/fern/client" + option "github.com/enum/fern/option" context "context" fern "github.com/enum/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.QueryParam.SendList( context.TODO(), &fern.SendEnumListAsQueryParamRequest{ diff --git a/seed/go-sdk/error-property/dynamic-snippets/example0/snippet.go b/seed/go-sdk/error-property/dynamic-snippets/example0/snippet.go index 1be31092bca..9fbffe86f38 100644 --- a/seed/go-sdk/error-property/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/error-property/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/error-property/fern/client" + option "github.com/error-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.PropertyBasedError.ThrowError( context.TODO(), ) diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example0/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example0/snippet.go index bc816172b55..643bffb8ef3 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example1/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example1/snippet.go index 460fdc4c77a..22a295f8f44 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example10/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example10/snippet.go index c9240e62f9e..73987a8277e 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example10/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example10/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example11/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example11/snippet.go index c9240e62f9e..73987a8277e 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example11/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example11/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example12/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example12/snippet.go index d345c94569a..8a7db2b0205 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example12/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example12/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example13/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example13/snippet.go index 4aca3169f72..626e88affc1 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example13/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example13/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example14/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example14/snippet.go index b4a9f9083a9..f3e1b83bfa2 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example14/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example14/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example15/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example15/snippet.go index 3e00f783dc2..bdcd7801217 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example15/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example15/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example16/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example16/snippet.go index 3eb00274c89..005f33a6337 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example16/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example16/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example17/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example17/snippet.go index 00dfcb36374..6159d94a0df 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example17/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example17/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example18/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example18/snippet.go index e774f360e42..8c986de005e 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example18/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example18/snippet.go @@ -11,6 +11,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example2/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example2/snippet.go index 11fe0a28aae..e75f1b73c87 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example2/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example3/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example3/snippet.go index 0fd85645a0e..3605df636ab 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example3/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example4/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example4/snippet.go index b8f79eea5c2..8661ab56c92 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example4/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example5/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example5/snippet.go index 460544b0f72..9e7641cbbff 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example5/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example6/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example6/snippet.go index ec8382ae623..4822f7bbb2e 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example6/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example7/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example7/snippet.go index 3d56a0923c0..492ef4b624a 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example7/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example7/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example8/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example8/snippet.go index f2caf690c60..5d8863eac7a 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example8/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example8/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example9/snippet.go b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example9/snippet.go index 6e122ddbbc8..0a08d523e79 100644 --- a/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example9/snippet.go +++ b/seed/go-sdk/examples/always-send-required-properties/dynamic-snippets/example9/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example0/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example0/snippet.go index 33c87862e87..c8398c9edd4 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example1/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example1/snippet.go index 642128d2680..674e893308d 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example10/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example10/snippet.go index 5e03b4b1012..8341a830296 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example10/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example10/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example11/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example11/snippet.go index 5e03b4b1012..8341a830296 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example11/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example11/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example12/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example12/snippet.go index 4c34c4d8dfc..92a067e5a66 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example12/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example12/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example13/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example13/snippet.go index 87d7a3f264d..652bdae43dd 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example13/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example13/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example14/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example14/snippet.go index ba60d1c903c..30c2921b7f3 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example14/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example14/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example15/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example15/snippet.go index 3c0baa82963..bc277593afb 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example15/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example15/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example16/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example16/snippet.go index 3f4f658cde4..4191f5cb167 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example16/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example16/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example17/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example17/snippet.go index fd42b4f6a1c..ac461030560 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example17/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example17/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example18/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example18/snippet.go index 50001f0bbf0..454d307d253 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example18/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example18/snippet.go @@ -11,6 +11,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example2/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example2/snippet.go index 4804e0fcc17..e44dcb6aed3 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example2/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example3/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example3/snippet.go index 5a7241d8ef8..f2650604792 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example3/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example4/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example4/snippet.go index 02f83545fa8..65420da2232 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example4/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example5/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example5/snippet.go index 05611cb140a..a2695ccb015 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example5/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example6/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example6/snippet.go index 7ca0b066340..869c9cca8e8 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example6/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example7/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example7/snippet.go index 2df73941e1c..b9f98157c76 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example7/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example7/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example8/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example8/snippet.go index aef38b1d7b8..0d69a82ea6e 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example8/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example8/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example9/snippet.go b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example9/snippet.go index 9cd5700e23c..7814dcccedb 100644 --- a/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example9/snippet.go +++ b/seed/go-sdk/examples/exported-client-name/dynamic-snippets/example9/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewAcmeClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example0/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example0/snippet.go index bc816172b55..643bffb8ef3 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example1/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example1/snippet.go index 460fdc4c77a..22a295f8f44 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example10/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example10/snippet.go index c9240e62f9e..73987a8277e 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example10/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example10/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example11/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example11/snippet.go index c9240e62f9e..73987a8277e 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example11/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example11/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example12/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example12/snippet.go index d345c94569a..8a7db2b0205 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example12/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example12/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example13/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example13/snippet.go index 4aca3169f72..626e88affc1 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example13/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example13/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example14/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example14/snippet.go index b4a9f9083a9..f3e1b83bfa2 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example14/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example14/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example15/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example15/snippet.go index 3e00f783dc2..bdcd7801217 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example15/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example15/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example16/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example16/snippet.go index 3eb00274c89..005f33a6337 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example16/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example16/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example17/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example17/snippet.go index 00dfcb36374..6159d94a0df 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example17/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example17/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example18/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example18/snippet.go index e774f360e42..8c986de005e 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example18/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example18/snippet.go @@ -11,6 +11,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example2/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example2/snippet.go index 11fe0a28aae..e75f1b73c87 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example2/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example3/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example3/snippet.go index 0fd85645a0e..3605df636ab 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example3/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example4/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example4/snippet.go index b8f79eea5c2..8661ab56c92 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example4/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example5/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example5/snippet.go index 460544b0f72..9e7641cbbff 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example5/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example6/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example6/snippet.go index ec8382ae623..4822f7bbb2e 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example6/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example7/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example7/snippet.go index 3d56a0923c0..492ef4b624a 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example7/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example7/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example8/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example8/snippet.go index f2caf690c60..5d8863eac7a 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example8/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example8/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example9/snippet.go b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example9/snippet.go index 6e122ddbbc8..0a08d523e79 100644 --- a/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example9/snippet.go +++ b/seed/go-sdk/examples/no-custom-config/dynamic-snippets/example9/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/extends/dynamic-snippets/example0/snippet.go b/seed/go-sdk/extends/dynamic-snippets/example0/snippet.go index 0d76fbed152..6c0446c0c06 100644 --- a/seed/go-sdk/extends/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/extends/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/extends/fern/client" + option "github.com/extends/fern/option" context "context" fern "github.com/extends/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.ExtendedInlineRequestBody( context.TODO(), &fern.Inlined{ diff --git a/seed/go-sdk/extra-properties/dynamic-snippets/example0/snippet.go b/seed/go-sdk/extra-properties/dynamic-snippets/example0/snippet.go index 4ebf5daa353..11a823e824d 100644 --- a/seed/go-sdk/extra-properties/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/extra-properties/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/extra-properties/fern/client" + option "github.com/extra-properties/fern/option" context "context" fern "github.com/extra-properties/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.CreateUser( context.TODO(), &fern.CreateUserRequest{ diff --git a/seed/go-sdk/folders/dynamic-snippets/example0/snippet.go b/seed/go-sdk/folders/dynamic-snippets/example0/snippet.go index 60eee184b9d..6dd8c7a5962 100644 --- a/seed/go-sdk/folders/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/folders/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/folders/fern/client" + option "github.com/folders/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Foo( context.TODO(), ) diff --git a/seed/go-sdk/folders/dynamic-snippets/example1/snippet.go b/seed/go-sdk/folders/dynamic-snippets/example1/snippet.go index 60eee184b9d..6dd8c7a5962 100644 --- a/seed/go-sdk/folders/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/folders/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/folders/fern/client" + option "github.com/folders/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Foo( context.TODO(), ) diff --git a/seed/go-sdk/folders/dynamic-snippets/example2/snippet.go b/seed/go-sdk/folders/dynamic-snippets/example2/snippet.go index 60eee184b9d..6dd8c7a5962 100644 --- a/seed/go-sdk/folders/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/folders/dynamic-snippets/example2/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/folders/fern/client" + option "github.com/folders/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Foo( context.TODO(), ) diff --git a/seed/go-sdk/folders/dynamic-snippets/example3/snippet.go b/seed/go-sdk/folders/dynamic-snippets/example3/snippet.go index 60eee184b9d..6dd8c7a5962 100644 --- a/seed/go-sdk/folders/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/folders/dynamic-snippets/example3/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/folders/fern/client" + option "github.com/folders/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Foo( context.TODO(), ) diff --git a/seed/go-sdk/folders/dynamic-snippets/example4/snippet.go b/seed/go-sdk/folders/dynamic-snippets/example4/snippet.go index cba75330a73..bc93c485e75 100644 --- a/seed/go-sdk/folders/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/folders/dynamic-snippets/example4/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/folders/fern/client" + option "github.com/folders/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Folder.Service.Endpoint( context.TODO(), ) diff --git a/seed/go-sdk/folders/dynamic-snippets/example5/snippet.go b/seed/go-sdk/folders/dynamic-snippets/example5/snippet.go index b484fdb7980..eb2d4274a49 100644 --- a/seed/go-sdk/folders/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/folders/dynamic-snippets/example5/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/folders/fern/client" + option "github.com/folders/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Folder.Service.UnknownRequest( context.TODO(), map[string]interface{}{ diff --git a/seed/go-sdk/go-content-type/dynamic-snippets/example0/snippet.go b/seed/go-sdk/go-content-type/dynamic-snippets/example0/snippet.go index 743c8619e2e..a2d6ab8d06a 100644 --- a/seed/go-sdk/go-content-type/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/go-content-type/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example0/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example0/snippet.go index 79f9e7be997..5fa29da1760 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Upload( context.TODO(), &fern.UploadRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example1/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example1/snippet.go index fcb02e89261..8d2d79f051c 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Upload( context.TODO(), &fern.UploadRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example10/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example10/snippet.go index 238ba15826d..9a8839575ce 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example10/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example10/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Query( context.TODO(), &fern.QueryRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example11/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example11/snippet.go index 0b18781d36f..242c6a1f8f0 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example11/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example11/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Query( context.TODO(), &fern.QueryRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example12/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example12/snippet.go index 505f7aad44b..7d7ca2270e5 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example12/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example12/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Update( context.TODO(), &fern.UpdateRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example13/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example13/snippet.go index 60b7abb6f5d..eb38c3f0974 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example13/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example13/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Update( context.TODO(), &fern.UpdateRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example2/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example2/snippet.go index b25c652a645..a378a377c9d 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Delete( context.TODO(), &fern.DeleteRequest{}, diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example3/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example3/snippet.go index 3dea14255ef..731c99d4a66 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example3/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Delete( context.TODO(), &fern.DeleteRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example4/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example4/snippet.go index 353e659ba4c..3ec9a1f080c 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example4/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Describe( context.TODO(), &fern.DescribeRequest{}, diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example5/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example5/snippet.go index a354b54b846..efd28fef337 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example5/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Describe( context.TODO(), &fern.DescribeRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example6/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example6/snippet.go index 4c87525c2c0..52b9e7b5556 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example6/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Fetch( context.TODO(), &fern.FetchRequest{}, diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example7/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example7/snippet.go index 121d5619871..07bdf804e7c 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example7/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example7/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.Fetch( context.TODO(), &fern.FetchRequest{ diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example8/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example8/snippet.go index 14650a0c793..8fc341d3f98 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example8/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example8/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.List( context.TODO(), &fern.ListRequest{}, diff --git a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example9/snippet.go b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example9/snippet.go index 4d3b68c7168..727ea1884e8 100644 --- a/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example9/snippet.go +++ b/seed/go-sdk/grpc-proto-exhaustive/dynamic-snippets/example9/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto-exhaustive/fern/client" + option "github.com/grpc-proto-exhaustive/fern/option" context "context" fern "github.com/grpc-proto-exhaustive/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dataservice.List( context.TODO(), &fern.ListRequest{ diff --git a/seed/go-sdk/grpc-proto/dynamic-snippets/example0/snippet.go b/seed/go-sdk/grpc-proto/dynamic-snippets/example0/snippet.go index 26989ae3b9e..5ddf70f01c1 100644 --- a/seed/go-sdk/grpc-proto/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/grpc-proto/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto/fern/client" + option "github.com/grpc-proto/fern/option" context "context" fern "github.com/grpc-proto/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Userservice.Create( context.TODO(), &fern.CreateRequest{}, diff --git a/seed/go-sdk/grpc-proto/dynamic-snippets/example1/snippet.go b/seed/go-sdk/grpc-proto/dynamic-snippets/example1/snippet.go index fdcc85798cf..f3171502755 100644 --- a/seed/go-sdk/grpc-proto/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/grpc-proto/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/grpc-proto/fern/client" + option "github.com/grpc-proto/fern/option" context "context" fern "github.com/grpc-proto/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Userservice.Create( context.TODO(), &fern.CreateRequest{ diff --git a/seed/go-sdk/idempotency-headers/dynamic-snippets/example0/snippet.go b/seed/go-sdk/idempotency-headers/dynamic-snippets/example0/snippet.go index fdff8ceaf4e..20f587e24d6 100644 --- a/seed/go-sdk/idempotency-headers/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/idempotency-headers/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/idempotency-headers/dynamic-snippets/example1/snippet.go b/seed/go-sdk/idempotency-headers/dynamic-snippets/example1/snippet.go index 742f588794c..aef3a43da1c 100644 --- a/seed/go-sdk/idempotency-headers/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/idempotency-headers/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/imdb/dynamic-snippets/example0/snippet.go b/seed/go-sdk/imdb/dynamic-snippets/example0/snippet.go index 6cfad8af2d7..6012041e207 100644 --- a/seed/go-sdk/imdb/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/imdb/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/imdb/dynamic-snippets/example1/snippet.go b/seed/go-sdk/imdb/dynamic-snippets/example1/snippet.go index ee115af9d6f..b1f78603251 100644 --- a/seed/go-sdk/imdb/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/imdb/dynamic-snippets/example1/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/license/dynamic-snippets/example0/snippet.go b/seed/go-sdk/license/dynamic-snippets/example0/snippet.go index 2fc52a3e67f..77592c5f890 100644 --- a/seed/go-sdk/license/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/license/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/license/fern/client" + option "github.com/license/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Get( context.TODO(), ) diff --git a/seed/go-sdk/literal/dynamic-snippets/example0/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example0/snippet.go index 3c043424036..810e35c55e8 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Headers.Send( context.TODO(), &fern.SendLiteralsInHeadersRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example1/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example1/snippet.go index 2fcd5b35672..9082d575e4a 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Headers.Send( context.TODO(), &fern.SendLiteralsInHeadersRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example2/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example2/snippet.go index a9af77f5b91..08b9c541378 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Inlined.Send( context.TODO(), &fern.SendLiteralsInlinedRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example3/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example3/snippet.go index d2c2a188db1..9f89f872529 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example3/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Inlined.Send( context.TODO(), &fern.SendLiteralsInlinedRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example4/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example4/snippet.go index 8ca76fd1bbf..87aae06d601 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example4/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Path.Send( context.TODO(), ) diff --git a/seed/go-sdk/literal/dynamic-snippets/example5/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example5/snippet.go index 8ca76fd1bbf..87aae06d601 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example5/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Path.Send( context.TODO(), ) diff --git a/seed/go-sdk/literal/dynamic-snippets/example6/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example6/snippet.go index a4be35e7655..a6b74985272 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example6/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Query.Send( context.TODO(), &fern.SendLiteralsInQueryRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example7/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example7/snippet.go index b8594971bc2..aaaf1d64b91 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example7/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example7/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Query.Send( context.TODO(), &fern.SendLiteralsInQueryRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example8/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example8/snippet.go index eb7eb499f79..c35ab837936 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example8/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example8/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Reference.Send( context.TODO(), &fern.SendRequest{ diff --git a/seed/go-sdk/literal/dynamic-snippets/example9/snippet.go b/seed/go-sdk/literal/dynamic-snippets/example9/snippet.go index 9de3402a8fc..1bc03075ef8 100644 --- a/seed/go-sdk/literal/dynamic-snippets/example9/snippet.go +++ b/seed/go-sdk/literal/dynamic-snippets/example9/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/literal/fern/client" + option "github.com/literal/fern/option" context "context" fern "github.com/literal/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Reference.Send( context.TODO(), &fern.SendRequest{ diff --git a/seed/go-sdk/mixed-case/dynamic-snippets/example0/snippet.go b/seed/go-sdk/mixed-case/dynamic-snippets/example0/snippet.go index e0600890ad9..0367e7e119f 100644 --- a/seed/go-sdk/mixed-case/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/mixed-case/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/mixed-case/fern/client" + option "github.com/mixed-case/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetResource( context.TODO(), "rsc-xyz", diff --git a/seed/go-sdk/mixed-case/dynamic-snippets/example1/snippet.go b/seed/go-sdk/mixed-case/dynamic-snippets/example1/snippet.go index 172abea808f..690adad7c84 100644 --- a/seed/go-sdk/mixed-case/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/mixed-case/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/mixed-case/fern/client" + option "github.com/mixed-case/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetResource( context.TODO(), "ResourceID", diff --git a/seed/go-sdk/mixed-case/dynamic-snippets/example2/snippet.go b/seed/go-sdk/mixed-case/dynamic-snippets/example2/snippet.go index b4b9481d105..99ef91aa163 100644 --- a/seed/go-sdk/mixed-case/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/mixed-case/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/mixed-case/fern/client" + option "github.com/mixed-case/fern/option" context "context" fern "github.com/mixed-case/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.ListResources( context.TODO(), &fern.ListResourcesRequest{ diff --git a/seed/go-sdk/mixed-case/dynamic-snippets/example3/snippet.go b/seed/go-sdk/mixed-case/dynamic-snippets/example3/snippet.go index cfcd0c7c093..02a8488753b 100644 --- a/seed/go-sdk/mixed-case/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/mixed-case/dynamic-snippets/example3/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/mixed-case/fern/client" + option "github.com/mixed-case/fern/option" context "context" fern "github.com/mixed-case/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.ListResources( context.TODO(), &fern.ListResourcesRequest{ diff --git a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example0/snippet.go b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example0/snippet.go index ebecb08d4a2..f123319458e 100644 --- a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/mixed-file-directory/fern/client" + option "github.com/mixed-file-directory/fern/option" context "context" fern "github.com/mixed-file-directory/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organization.Create( context.TODO(), &fern.CreateOrganizationRequest{ diff --git a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example1/snippet.go b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example1/snippet.go index 061ae70eb77..3ad5c752f46 100644 --- a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/mixed-file-directory/fern/client" + option "github.com/mixed-file-directory/fern/option" context "context" fern "github.com/mixed-file-directory/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.List( context.TODO(), &fern.ListUsersRequest{ diff --git a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example2/snippet.go b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example2/snippet.go index 5677df41fed..d09ab2fef54 100644 --- a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example2/snippet.go @@ -2,13 +2,18 @@ package example import ( client "github.com/mixed-file-directory/fern/client" + option "github.com/mixed-file-directory/fern/option" context "context" user "github.com/mixed-file-directory/fern/user" fern "github.com/mixed-file-directory/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.Events.ListEvents( context.TODO(), &user.ListUserEventsRequest{ diff --git a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example3/snippet.go b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example3/snippet.go index 60806f24212..394ae143613 100644 --- a/seed/go-sdk/mixed-file-directory/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/mixed-file-directory/dynamic-snippets/example3/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/mixed-file-directory/fern/client" + option "github.com/mixed-file-directory/fern/option" context "context" events "github.com/mixed-file-directory/fern/user/events" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.Events.Metadata.GetMetadata( context.TODO(), &events.GetEventMetadataRequest{ diff --git a/seed/go-sdk/multi-line-docs/dynamic-snippets/example0/snippet.go b/seed/go-sdk/multi-line-docs/dynamic-snippets/example0/snippet.go index 093b9a63753..dd26cee34f7 100644 --- a/seed/go-sdk/multi-line-docs/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/multi-line-docs/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/multi-line-docs/fern/client" + option "github.com/multi-line-docs/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.GetUser( context.TODO(), "userId", diff --git a/seed/go-sdk/multi-line-docs/dynamic-snippets/example1/snippet.go b/seed/go-sdk/multi-line-docs/dynamic-snippets/example1/snippet.go index ac600eb7b85..77e313fe50c 100644 --- a/seed/go-sdk/multi-line-docs/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/multi-line-docs/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/multi-line-docs/fern/client" + option "github.com/multi-line-docs/fern/option" context "context" fern "github.com/multi-line-docs/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.CreateUser( context.TODO(), &fern.CreateUserRequest{ diff --git a/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example0/snippet.go b/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example0/snippet.go index 41cc90a7c27..be66371dd5f 100644 --- a/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example1/snippet.go b/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example1/snippet.go index f4b700c7489..1dedb8ea633 100644 --- a/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/multi-url-environment-no-default/dynamic-snippets/example1/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/multi-url-environment/dynamic-snippets/example0/snippet.go b/seed/go-sdk/multi-url-environment/dynamic-snippets/example0/snippet.go index c6c04c5b7e0..a9103b28d30 100644 --- a/seed/go-sdk/multi-url-environment/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/multi-url-environment/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/multi-url-environment/dynamic-snippets/example1/snippet.go b/seed/go-sdk/multi-url-environment/dynamic-snippets/example1/snippet.go index 46a5c4e8465..a331c778ea2 100644 --- a/seed/go-sdk/multi-url-environment/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/multi-url-environment/dynamic-snippets/example1/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/no-environment/dynamic-snippets/example0/snippet.go b/seed/go-sdk/no-environment/dynamic-snippets/example0/snippet.go index 469014929a8..9d869166811 100644 --- a/seed/go-sdk/no-environment/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/no-environment/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/oauth-client-credentials-custom/.github/workflows/ci.yml b/seed/go-sdk/oauth-client-credentials-custom/.github/workflows/ci.yml new file mode 100644 index 00000000000..d4c0a5dcd95 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Compile + run: go build ./... + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up go + uses: actions/setup-go@v4 + + - name: Test + run: go test ./... diff --git a/seed/go-sdk/oauth-client-credentials-custom/.mock/definition/api.yml b/seed/go-sdk/oauth-client-credentials-custom/.mock/definition/api.yml new file mode 100644 index 00000000000..bf67efadce7 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/.mock/definition/api.yml @@ -0,0 +1,18 @@ +name: oauth-client-credentials +imports: + auth: auth.yml + +auth: OAuthScheme +auth-schemes: + OAuthScheme: + scheme: oauth + type: client-credentials + get-token: + endpoint: auth.getTokenWithClientCredentials + request-properties: + client-id: $request.cid + client-secret: $request.csr + scopes: $request.scp + response-properties: + access-token: $response.access_token + expires-in: $response.expires_in \ No newline at end of file diff --git a/seed/go-sdk/oauth-client-credentials-custom/.mock/definition/auth.yml b/seed/go-sdk/oauth-client-credentials-custom/.mock/definition/auth.yml new file mode 100644 index 00000000000..d9e4d868a5a --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/.mock/definition/auth.yml @@ -0,0 +1,43 @@ +types: + TokenResponse: + docs: | + An OAuth token response. + properties: + access_token: string + expires_in: integer + refresh_token: optional + +service: + auth: false + base-path: / + endpoints: + getTokenWithClientCredentials: + path: /token + method: POST + request: + name: GetTokenRequest + body: + properties: + cid: string + csr: string + scp: string + entity_id: string + audience: literal<"https://api.example.com"> + grant_type: literal<"client_credentials"> + scope: optional + response: TokenResponse + + refreshToken: + path: /token + method: POST + request: + name: RefreshTokenRequest + body: + properties: + client_id: string + client_secret: string + refresh_token: string + audience: literal<"https://api.example.com"> + grant_type: literal<"refresh_token"> + scope: optional + response: TokenResponse \ No newline at end of file diff --git a/seed/go-sdk/oauth-client-credentials-custom/.mock/fern.config.json b/seed/go-sdk/oauth-client-credentials-custom/.mock/fern.config.json new file mode 100644 index 00000000000..4c8e54ac313 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/.mock/fern.config.json @@ -0,0 +1 @@ +{"organization": "fern-test", "version": "*"} \ No newline at end of file diff --git a/seed/go-sdk/oauth-client-credentials-custom/.mock/generators.yml b/seed/go-sdk/oauth-client-credentials-custom/.mock/generators.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/.mock/generators.yml @@ -0,0 +1 @@ +{} diff --git a/seed/go-sdk/oauth-client-credentials-custom/auth.go b/seed/go-sdk/oauth-client-credentials-custom/auth.go new file mode 100644 index 00000000000..a873f2ed66e --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/auth.go @@ -0,0 +1,159 @@ +// This file was auto-generated by Fern from our API Definition. + +package oauthclientcredentials + +import ( + json "encoding/json" + fmt "fmt" + internal "github.com/oauth-client-credentials-custom/fern/internal" +) + +type GetTokenRequest struct { + Cid string `json:"cid" url:"-"` + Csr string `json:"csr" url:"-"` + Scp string `json:"scp" url:"-"` + EntityId string `json:"entity_id" url:"-"` + Scope *string `json:"scope,omitempty" url:"-"` + audience string + grantType string +} + +func (g *GetTokenRequest) Audience() string { + return g.audience +} + +func (g *GetTokenRequest) GrantType() string { + return g.grantType +} + +func (g *GetTokenRequest) UnmarshalJSON(data []byte) error { + type unmarshaler GetTokenRequest + var body unmarshaler + if err := json.Unmarshal(data, &body); err != nil { + return err + } + *g = GetTokenRequest(body) + g.audience = "https://api.example.com" + g.grantType = "client_credentials" + return nil +} + +func (g *GetTokenRequest) MarshalJSON() ([]byte, error) { + type embed GetTokenRequest + var marshaler = struct { + embed + Audience string `json:"audience"` + GrantType string `json:"grant_type"` + }{ + embed: embed(*g), + Audience: "https://api.example.com", + GrantType: "client_credentials", + } + return json.Marshal(marshaler) +} + +type RefreshTokenRequest struct { + ClientId string `json:"client_id" url:"-"` + ClientSecret string `json:"client_secret" url:"-"` + RefreshToken string `json:"refresh_token" url:"-"` + Scope *string `json:"scope,omitempty" url:"-"` + audience string + grantType string +} + +func (r *RefreshTokenRequest) Audience() string { + return r.audience +} + +func (r *RefreshTokenRequest) GrantType() string { + return r.grantType +} + +func (r *RefreshTokenRequest) UnmarshalJSON(data []byte) error { + type unmarshaler RefreshTokenRequest + var body unmarshaler + if err := json.Unmarshal(data, &body); err != nil { + return err + } + *r = RefreshTokenRequest(body) + r.audience = "https://api.example.com" + r.grantType = "refresh_token" + return nil +} + +func (r *RefreshTokenRequest) MarshalJSON() ([]byte, error) { + type embed RefreshTokenRequest + var marshaler = struct { + embed + Audience string `json:"audience"` + GrantType string `json:"grant_type"` + }{ + embed: embed(*r), + Audience: "https://api.example.com", + GrantType: "refresh_token", + } + return json.Marshal(marshaler) +} + +// An OAuth token response. +type TokenResponse struct { + AccessToken string `json:"access_token" url:"access_token"` + ExpiresIn int `json:"expires_in" url:"expires_in"` + RefreshToken *string `json:"refresh_token,omitempty" url:"refresh_token,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (t *TokenResponse) GetAccessToken() string { + if t == nil { + return "" + } + return t.AccessToken +} + +func (t *TokenResponse) GetExpiresIn() int { + if t == nil { + return 0 + } + return t.ExpiresIn +} + +func (t *TokenResponse) GetRefreshToken() *string { + if t == nil { + return nil + } + return t.RefreshToken +} + +func (t *TokenResponse) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *TokenResponse) UnmarshalJSON(data []byte) error { + type unmarshaler TokenResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = TokenResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + t.rawJSON = json.RawMessage(data) + return nil +} + +func (t *TokenResponse) String() string { + if len(t.rawJSON) > 0 { + if value, err := internal.StringifyJSON(t.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/auth/client.go b/seed/go-sdk/oauth-client-credentials-custom/auth/client.go new file mode 100644 index 00000000000..1373cf7dd09 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/auth/client.go @@ -0,0 +1,106 @@ +// This file was auto-generated by Fern from our API Definition. + +package auth + +import ( + context "context" + fern "github.com/oauth-client-credentials-custom/fern" + core "github.com/oauth-client-credentials-custom/fern/core" + internal "github.com/oauth-client-credentials-custom/fern/internal" + option "github.com/oauth-client-credentials-custom/fern/option" + http "net/http" +) + +type Client struct { + baseURL string + caller *internal.Caller + header http.Header +} + +func NewClient(opts ...option.RequestOption) *Client { + options := core.NewRequestOptions(opts...) + return &Client{ + baseURL: options.BaseURL, + caller: internal.NewCaller( + &internal.CallerParams{ + Client: options.HTTPClient, + MaxAttempts: options.MaxAttempts, + }, + ), + header: options.ToHeader(), + } +} + +func (c *Client) GetTokenWithClientCredentials( + ctx context.Context, + request *fern.GetTokenRequest, + opts ...option.RequestOption, +) (*fern.TokenResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "", + ) + endpointURL := baseURL + "/token" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + var response *fern.TokenResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} + +func (c *Client) RefreshToken( + ctx context.Context, + request *fern.RefreshTokenRequest, + opts ...option.RequestOption, +) (*fern.TokenResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "", + ) + endpointURL := baseURL + "/token" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + + var response *fern.TokenResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + }, + ); err != nil { + return nil, err + } + return response, nil +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/client/client.go b/seed/go-sdk/oauth-client-credentials-custom/client/client.go new file mode 100644 index 00000000000..b19d24aa605 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/client/client.go @@ -0,0 +1,34 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + auth "github.com/oauth-client-credentials-custom/fern/auth" + core "github.com/oauth-client-credentials-custom/fern/core" + internal "github.com/oauth-client-credentials-custom/fern/internal" + option "github.com/oauth-client-credentials-custom/fern/option" + http "net/http" +) + +type Client struct { + baseURL string + caller *internal.Caller + header http.Header + + Auth *auth.Client +} + +func NewClient(opts ...option.RequestOption) *Client { + options := core.NewRequestOptions(opts...) + return &Client{ + baseURL: options.BaseURL, + caller: internal.NewCaller( + &internal.CallerParams{ + Client: options.HTTPClient, + MaxAttempts: options.MaxAttempts, + }, + ), + header: options.ToHeader(), + Auth: auth.NewClient(opts...), + } +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/client/client_test.go b/seed/go-sdk/oauth-client-credentials-custom/client/client_test.go new file mode 100644 index 00000000000..89672d78b67 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/client/client_test.go @@ -0,0 +1,45 @@ +// This file was auto-generated by Fern from our API Definition. + +package client + +import ( + option "github.com/oauth-client-credentials-custom/fern/option" + assert "github.com/stretchr/testify/assert" + http "net/http" + testing "testing" + time "time" +) + +func TestNewClient(t *testing.T) { + t.Run("default", func(t *testing.T) { + c := NewClient() + assert.Empty(t, c.baseURL) + }) + + t.Run("base url", func(t *testing.T) { + c := NewClient( + option.WithBaseURL("test.co"), + ) + assert.Equal(t, "test.co", c.baseURL) + }) + + t.Run("http client", func(t *testing.T) { + httpClient := &http.Client{ + Timeout: 5 * time.Second, + } + c := NewClient( + option.WithHTTPClient(httpClient), + ) + assert.Empty(t, c.baseURL) + }) + + t.Run("http header", func(t *testing.T) { + header := make(http.Header) + header.Set("X-API-Tenancy", "test") + c := NewClient( + option.WithHTTPHeader(header), + ) + assert.Empty(t, c.baseURL) + assert.Equal(t, "test", c.header.Get("X-API-Tenancy")) + }) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/core/api_error.go b/seed/go-sdk/oauth-client-credentials-custom/core/api_error.go new file mode 100644 index 00000000000..dc4190ca1cd --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/core/api_error.go @@ -0,0 +1,42 @@ +package core + +import "fmt" + +// APIError is a lightweight wrapper around the standard error +// interface that preserves the status code from the RPC, if any. +type APIError struct { + err error + + StatusCode int `json:"-"` +} + +// NewAPIError constructs a new API error. +func NewAPIError(statusCode int, err error) *APIError { + return &APIError{ + err: err, + StatusCode: statusCode, + } +} + +// Unwrap returns the underlying error. This also makes the error compatible +// with errors.As and errors.Is. +func (a *APIError) Unwrap() error { + if a == nil { + return nil + } + return a.err +} + +// Error returns the API error's message. +func (a *APIError) Error() string { + if a == nil || (a.err == nil && a.StatusCode == 0) { + return "" + } + if a.err == nil { + return fmt.Sprintf("%d", a.StatusCode) + } + if a.StatusCode == 0 { + return a.err.Error() + } + return fmt.Sprintf("%d: %s", a.StatusCode, a.err.Error()) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/core/http.go b/seed/go-sdk/oauth-client-credentials-custom/core/http.go new file mode 100644 index 00000000000..b553350b84e --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/core/http.go @@ -0,0 +1,8 @@ +package core + +import "net/http" + +// HTTPClient is an interface for a subset of the *http.Client. +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/core/request_option.go b/seed/go-sdk/oauth-client-credentials-custom/core/request_option.go new file mode 100644 index 00000000000..f46e59ea806 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/core/request_option.go @@ -0,0 +1,112 @@ +// This file was auto-generated by Fern from our API Definition. + +package core + +import ( + http "net/http" + url "net/url" +) + +// RequestOption adapts the behavior of the client or an individual request. +type RequestOption interface { + applyRequestOptions(*RequestOptions) +} + +// RequestOptions defines all of the possible request options. +// +// This type is primarily used by the generated code and is not meant +// to be used directly; use the option package instead. +type RequestOptions struct { + BaseURL string + HTTPClient HTTPClient + HTTPHeader http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values + MaxAttempts uint +} + +// NewRequestOptions returns a new *RequestOptions value. +// +// This function is primarily used by the generated code and is not meant +// to be used directly; use RequestOption instead. +func NewRequestOptions(opts ...RequestOption) *RequestOptions { + options := &RequestOptions{ + HTTPHeader: make(http.Header), + BodyProperties: make(map[string]interface{}), + QueryParameters: make(url.Values), + } + for _, opt := range opts { + opt.applyRequestOptions(options) + } + return options +} + +// ToHeader maps the configured request options into a http.Header used +// for the request(s). +func (r *RequestOptions) ToHeader() http.Header { + header := r.cloneHeader() + return header +} + +func (r *RequestOptions) cloneHeader() http.Header { + headers := r.HTTPHeader.Clone() + headers.Set("X-Fern-Language", "Go") + headers.Set("X-Fern-SDK-Name", "github.com/oauth-client-credentials-custom/fern") + headers.Set("X-Fern-SDK-Version", "0.0.1") + headers.Set("User-Agent", "github.com/oauth-client-credentials-custom/fern/0.0.1") + return headers +} + +// BaseURLOption implements the RequestOption interface. +type BaseURLOption struct { + BaseURL string +} + +func (b *BaseURLOption) applyRequestOptions(opts *RequestOptions) { + opts.BaseURL = b.BaseURL +} + +// HTTPClientOption implements the RequestOption interface. +type HTTPClientOption struct { + HTTPClient HTTPClient +} + +func (h *HTTPClientOption) applyRequestOptions(opts *RequestOptions) { + opts.HTTPClient = h.HTTPClient +} + +// HTTPHeaderOption implements the RequestOption interface. +type HTTPHeaderOption struct { + HTTPHeader http.Header +} + +func (h *HTTPHeaderOption) applyRequestOptions(opts *RequestOptions) { + opts.HTTPHeader = h.HTTPHeader +} + +// BodyPropertiesOption implements the RequestOption interface. +type BodyPropertiesOption struct { + BodyProperties map[string]interface{} +} + +func (b *BodyPropertiesOption) applyRequestOptions(opts *RequestOptions) { + opts.BodyProperties = b.BodyProperties +} + +// QueryParametersOption implements the RequestOption interface. +type QueryParametersOption struct { + QueryParameters url.Values +} + +func (q *QueryParametersOption) applyRequestOptions(opts *RequestOptions) { + opts.QueryParameters = q.QueryParameters +} + +// MaxAttemptsOption implements the RequestOption interface. +type MaxAttemptsOption struct { + MaxAttempts uint +} + +func (m *MaxAttemptsOption) applyRequestOptions(opts *RequestOptions) { + opts.MaxAttempts = m.MaxAttempts +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example0/snippet.go b/seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example0/snippet.go new file mode 100644 index 00000000000..cd63420ef66 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example0/snippet.go @@ -0,0 +1,28 @@ +package example + +import ( + client "github.com/oauth-client-credentials-custom/fern/client" + option "github.com/oauth-client-credentials-custom/fern/option" + context "context" + fern "github.com/oauth-client-credentials-custom/fern" +) + +func do() () { + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) + client.Auth.GetTokenWithClientCredentials( + context.TODO(), + &fern.GetTokenRequest{ + Cid: "cid", + Csr: "csr", + Scp: "scp", + EntityId: "entity_id", + Scope: fern.String( + "scope", + ), + }, + ) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example1/snippet.go b/seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example1/snippet.go new file mode 100644 index 00000000000..51cbecaec13 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/dynamic-snippets/example1/snippet.go @@ -0,0 +1,27 @@ +package example + +import ( + client "github.com/oauth-client-credentials-custom/fern/client" + option "github.com/oauth-client-credentials-custom/fern/option" + context "context" + fern "github.com/oauth-client-credentials-custom/fern" +) + +func do() () { + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) + client.Auth.RefreshToken( + context.TODO(), + &fern.RefreshTokenRequest{ + ClientId: "client_id", + ClientSecret: "client_secret", + RefreshToken: "refresh_token", + Scope: fern.String( + "scope", + ), + }, + ) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/file_param.go b/seed/go-sdk/oauth-client-credentials-custom/file_param.go new file mode 100644 index 00000000000..ea4cbbddd57 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/file_param.go @@ -0,0 +1,41 @@ +package oauthclientcredentials + +import ( + "io" +) + +// FileParam is a file type suitable for multipart/form-data uploads. +type FileParam struct { + io.Reader + filename string + contentType string +} + +// FileParamOption adapts the behavior of the FileParam. No options are +// implemented yet, but this interface allows for future extensibility. +type FileParamOption interface { + apply() +} + +// NewFileParam returns a *FileParam type suitable for multipart/form-data uploads. All file +// upload endpoints accept a simple io.Reader, which is usually created by opening a file +// via os.Open. +// +// However, some endpoints require additional metadata about the file such as a specific +// Content-Type or custom filename. FileParam makes it easier to create the correct type +// signature for these endpoints. +func NewFileParam( + reader io.Reader, + filename string, + contentType string, + opts ...FileParamOption, +) *FileParam { + return &FileParam{ + Reader: reader, + filename: filename, + contentType: contentType, + } +} + +func (f *FileParam) Name() string { return f.filename } +func (f *FileParam) ContentType() string { return f.contentType } diff --git a/seed/go-sdk/oauth-client-credentials-custom/go.mod b/seed/go-sdk/oauth-client-credentials-custom/go.mod new file mode 100644 index 00000000000..bfb7c1b2c6a --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/go.mod @@ -0,0 +1,9 @@ +module github.com/oauth-client-credentials-custom/fern + +go 1.13 + +require ( + github.com/google/uuid v1.4.0 + github.com/stretchr/testify v1.7.0 + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/seed/go-sdk/oauth-client-credentials-custom/go.sum b/seed/go-sdk/oauth-client-credentials-custom/go.sum new file mode 100644 index 00000000000..b3766d4366b --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/caller.go b/seed/go-sdk/oauth-client-credentials-custom/internal/caller.go new file mode 100644 index 00000000000..83d6fd87c24 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/caller.go @@ -0,0 +1,238 @@ +package internal + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "reflect" + "strings" + + "github.com/oauth-client-credentials-custom/fern/core" +) + +const ( + // contentType specifies the JSON Content-Type header value. + contentType = "application/json" + contentTypeHeader = "Content-Type" +) + +// Caller calls APIs and deserializes their response, if any. +type Caller struct { + client core.HTTPClient + retrier *Retrier +} + +// CallerParams represents the parameters used to constrcut a new *Caller. +type CallerParams struct { + Client core.HTTPClient + MaxAttempts uint +} + +// NewCaller returns a new *Caller backed by the given parameters. +func NewCaller(params *CallerParams) *Caller { + var httpClient core.HTTPClient = http.DefaultClient + if params.Client != nil { + httpClient = params.Client + } + var retryOptions []RetryOption + if params.MaxAttempts > 0 { + retryOptions = append(retryOptions, WithMaxAttempts(params.MaxAttempts)) + } + return &Caller{ + client: httpClient, + retrier: NewRetrier(retryOptions...), + } +} + +// CallParams represents the parameters used to issue an API call. +type CallParams struct { + URL string + Method string + MaxAttempts uint + Headers http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values + Client core.HTTPClient + Request interface{} + Response interface{} + ResponseIsOptional bool + ErrorDecoder ErrorDecoder +} + +// Call issues an API call according to the given call parameters. +func (c *Caller) Call(ctx context.Context, params *CallParams) error { + url := buildURL(params.URL, params.QueryParameters) + req, err := newRequest( + ctx, + url, + params.Method, + params.Headers, + params.Request, + params.BodyProperties, + ) + if err != nil { + return err + } + + // If the call has been cancelled, don't issue the request. + if err := ctx.Err(); err != nil { + return err + } + + client := c.client + if params.Client != nil { + // Use the HTTP client scoped to the request. + client = params.Client + } + + var retryOptions []RetryOption + if params.MaxAttempts > 0 { + retryOptions = append(retryOptions, WithMaxAttempts(params.MaxAttempts)) + } + + resp, err := c.retrier.Run( + client.Do, + req, + params.ErrorDecoder, + retryOptions..., + ) + if err != nil { + return err + } + + // Close the response body after we're done. + defer resp.Body.Close() + + // Check if the call was cancelled before we return the error + // associated with the call and/or unmarshal the response data. + if err := ctx.Err(); err != nil { + return err + } + + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return decodeError(resp, params.ErrorDecoder) + } + + // Mutate the response parameter in-place. + if params.Response != nil { + if writer, ok := params.Response.(io.Writer); ok { + _, err = io.Copy(writer, resp.Body) + } else { + err = json.NewDecoder(resp.Body).Decode(params.Response) + } + if err != nil { + if err == io.EOF { + if params.ResponseIsOptional { + // The response is optional, so we should ignore the + // io.EOF error + return nil + } + return fmt.Errorf("expected a %T response, but the server responded with nothing", params.Response) + } + return err + } + } + + return nil +} + +// buildURL constructs the final URL by appending the given query parameters (if any). +func buildURL( + url string, + queryParameters url.Values, +) string { + if len(queryParameters) == 0 { + return url + } + if strings.ContainsRune(url, '?') { + url += "&" + } else { + url += "?" + } + url += queryParameters.Encode() + return url +} + +// newRequest returns a new *http.Request with all of the fields +// required to issue the call. +func newRequest( + ctx context.Context, + url string, + method string, + endpointHeaders http.Header, + request interface{}, + bodyProperties map[string]interface{}, +) (*http.Request, error) { + requestBody, err := newRequestBody(request, bodyProperties) + if err != nil { + return nil, err + } + req, err := http.NewRequestWithContext(ctx, method, url, requestBody) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + req.Header.Set(contentTypeHeader, contentType) + for name, values := range endpointHeaders { + req.Header[name] = values + } + return req, nil +} + +// newRequestBody returns a new io.Reader that represents the HTTP request body. +func newRequestBody(request interface{}, bodyProperties map[string]interface{}) (io.Reader, error) { + if isNil(request) { + if len(bodyProperties) == 0 { + return nil, nil + } + requestBytes, err := json.Marshal(bodyProperties) + if err != nil { + return nil, err + } + return bytes.NewReader(requestBytes), nil + } + if body, ok := request.(io.Reader); ok { + return body, nil + } + requestBytes, err := MarshalJSONWithExtraProperties(request, bodyProperties) + if err != nil { + return nil, err + } + return bytes.NewReader(requestBytes), nil +} + +// decodeError decodes the error from the given HTTP response. Note that +// it's the caller's responsibility to close the response body. +func decodeError(response *http.Response, errorDecoder ErrorDecoder) error { + if errorDecoder != nil { + // This endpoint has custom errors, so we'll + // attempt to unmarshal the error into a structured + // type based on the status code. + return errorDecoder(response.StatusCode, response.Body) + } + // This endpoint doesn't have any custom error + // types, so we just read the body as-is, and + // put it into a normal error. + bytes, err := io.ReadAll(response.Body) + if err != nil && err != io.EOF { + return err + } + if err == io.EOF { + // The error didn't have a response body, + // so all we can do is return an error + // with the status code. + return core.NewAPIError(response.StatusCode, nil) + } + return core.NewAPIError(response.StatusCode, errors.New(string(bytes))) +} + +// isNil is used to determine if the request value is equal to nil (i.e. an interface +// value that holds a nil concrete value is itself non-nil). +func isNil(value interface{}) bool { + return value == nil || reflect.ValueOf(value).IsNil() +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/caller_test.go b/seed/go-sdk/oauth-client-credentials-custom/internal/caller_test.go new file mode 100644 index 00000000000..c60a5cbcbc9 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/caller_test.go @@ -0,0 +1,391 @@ +package internal + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/http/httptest" + "net/url" + "strconv" + "testing" + + "github.com/oauth-client-credentials-custom/fern/core" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestCase represents a single test case. +type TestCase struct { + description string + + // Server-side assertions. + givePathSuffix string + giveMethod string + giveResponseIsOptional bool + giveHeader http.Header + giveErrorDecoder ErrorDecoder + giveRequest *Request + giveQueryParams url.Values + giveBodyProperties map[string]interface{} + + // Client-side assertions. + wantResponse *Response + wantError error +} + +// Request a simple request body. +type Request struct { + Id string `json:"id"` +} + +// Response a simple response body. +type Response struct { + Id string `json:"id"` + ExtraBodyProperties map[string]interface{} `json:"extraBodyProperties,omitempty"` + QueryParameters url.Values `json:"queryParameters,omitempty"` +} + +// NotFoundError represents a 404. +type NotFoundError struct { + *core.APIError + + Message string `json:"message"` +} + +func TestCall(t *testing.T) { + tests := []*TestCase{ + { + description: "GET success", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + }, + }, + { + description: "GET success with query", + givePathSuffix: "?limit=1", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "limit": []string{"1"}, + }, + }, + }, + { + description: "GET not found", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: &Request{ + Id: strconv.Itoa(http.StatusNotFound), + }, + giveErrorDecoder: newTestErrorDecoder(t), + wantError: &NotFoundError{ + APIError: core.NewAPIError( + http.StatusNotFound, + errors.New(`{"message":"ID \"404\" not found"}`), + ), + }, + }, + { + description: "POST empty body", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: nil, + wantError: core.NewAPIError( + http.StatusBadRequest, + errors.New("invalid request"), + ), + }, + { + description: "POST optional response", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + giveResponseIsOptional: true, + }, + { + description: "POST API error", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"fail"}, + }, + giveRequest: &Request{ + Id: strconv.Itoa(http.StatusInternalServerError), + }, + wantError: core.NewAPIError( + http.StatusInternalServerError, + errors.New("failed to process request"), + ), + }, + { + description: "POST extra properties", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: new(Request), + giveBodyProperties: map[string]interface{}{ + "key": "value", + }, + wantResponse: &Response{ + ExtraBodyProperties: map[string]interface{}{ + "key": "value", + }, + }, + }, + { + description: "GET extra query parameters", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveQueryParams: url.Values{ + "extra": []string{"true"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "extra": []string{"true"}, + }, + }, + }, + { + description: "GET merge extra query parameters", + givePathSuffix: "?limit=1", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + giveQueryParams: url.Values{ + "extra": []string{"true"}, + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "limit": []string{"1"}, + "extra": []string{"true"}, + }, + }, + }, + } + for _, test := range tests { + t.Run(test.description, func(t *testing.T) { + var ( + server = newTestServer(t, test) + client = server.Client() + ) + caller := NewCaller( + &CallerParams{ + Client: client, + }, + ) + var response *Response + err := caller.Call( + context.Background(), + &CallParams{ + URL: server.URL + test.givePathSuffix, + Method: test.giveMethod, + Headers: test.giveHeader, + BodyProperties: test.giveBodyProperties, + QueryParameters: test.giveQueryParams, + Request: test.giveRequest, + Response: &response, + ResponseIsOptional: test.giveResponseIsOptional, + ErrorDecoder: test.giveErrorDecoder, + }, + ) + if test.wantError != nil { + assert.EqualError(t, err, test.wantError.Error()) + return + } + require.NoError(t, err) + assert.Equal(t, test.wantResponse, response) + }) + } +} + +func TestMergeHeaders(t *testing.T) { + t.Run("both empty", func(t *testing.T) { + merged := MergeHeaders(make(http.Header), make(http.Header)) + assert.Empty(t, merged) + }) + + t.Run("empty left", func(t *testing.T) { + left := make(http.Header) + + right := make(http.Header) + right.Set("X-API-Version", "0.0.1") + + merged := MergeHeaders(left, right) + assert.Equal(t, "0.0.1", merged.Get("X-API-Version")) + }) + + t.Run("empty right", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Version", "0.0.1") + + right := make(http.Header) + + merged := MergeHeaders(left, right) + assert.Equal(t, "0.0.1", merged.Get("X-API-Version")) + }) + + t.Run("single value override", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Version", "0.0.0") + + right := make(http.Header) + right.Set("X-API-Version", "0.0.1") + + merged := MergeHeaders(left, right) + assert.Equal(t, []string{"0.0.1"}, merged.Values("X-API-Version")) + }) + + t.Run("multiple value override", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Versions", "0.0.0") + + right := make(http.Header) + right.Add("X-API-Versions", "0.0.1") + right.Add("X-API-Versions", "0.0.2") + + merged := MergeHeaders(left, right) + assert.Equal(t, []string{"0.0.1", "0.0.2"}, merged.Values("X-API-Versions")) + }) + + t.Run("disjoint merge", func(t *testing.T) { + left := make(http.Header) + left.Set("X-API-Tenancy", "test") + + right := make(http.Header) + right.Set("X-API-Version", "0.0.1") + + merged := MergeHeaders(left, right) + assert.Equal(t, []string{"test"}, merged.Values("X-API-Tenancy")) + assert.Equal(t, []string{"0.0.1"}, merged.Values("X-API-Version")) + }) +} + +// newTestServer returns a new *httptest.Server configured with the +// given test parameters. +func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { + return httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, tc.giveMethod, r.Method) + assert.Equal(t, contentType, r.Header.Get(contentTypeHeader)) + for header, value := range tc.giveHeader { + assert.Equal(t, value, r.Header.Values(header)) + } + + request := new(Request) + + bytes, err := io.ReadAll(r.Body) + if tc.giveRequest == nil { + require.Empty(t, bytes) + w.WriteHeader(http.StatusBadRequest) + _, err = w.Write([]byte("invalid request")) + require.NoError(t, err) + return + } + require.NoError(t, err) + require.NoError(t, json.Unmarshal(bytes, request)) + + switch request.Id { + case strconv.Itoa(http.StatusNotFound): + notFoundError := &NotFoundError{ + APIError: &core.APIError{ + StatusCode: http.StatusNotFound, + }, + Message: fmt.Sprintf("ID %q not found", request.Id), + } + bytes, err = json.Marshal(notFoundError) + require.NoError(t, err) + + w.WriteHeader(http.StatusNotFound) + _, err = w.Write(bytes) + require.NoError(t, err) + return + + case strconv.Itoa(http.StatusInternalServerError): + w.WriteHeader(http.StatusInternalServerError) + _, err = w.Write([]byte("failed to process request")) + require.NoError(t, err) + return + } + + if tc.giveResponseIsOptional { + w.WriteHeader(http.StatusOK) + return + } + + extraBodyProperties := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &extraBodyProperties)) + delete(extraBodyProperties, "id") + + response := &Response{ + Id: request.Id, + ExtraBodyProperties: extraBodyProperties, + QueryParameters: r.URL.Query(), + } + bytes, err = json.Marshal(response) + require.NoError(t, err) + + _, err = w.Write(bytes) + require.NoError(t, err) + }, + ), + ) +} + +// newTestErrorDecoder returns an error decoder suitable for tests. +func newTestErrorDecoder(t *testing.T) func(int, io.Reader) error { + return func(statusCode int, body io.Reader) error { + raw, err := io.ReadAll(body) + require.NoError(t, err) + + var ( + apiError = core.NewAPIError(statusCode, errors.New(string(raw))) + decoder = json.NewDecoder(bytes.NewReader(raw)) + ) + if statusCode == http.StatusNotFound { + value := new(NotFoundError) + value.APIError = apiError + require.NoError(t, decoder.Decode(value)) + + return value + } + return apiError + } +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder.go b/seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder.go new file mode 100644 index 00000000000..1d7c63d343d --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder.go @@ -0,0 +1,45 @@ +package internal + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + + "github.com/oauth-client-credentials-custom/fern/core" +) + +// ErrorDecoder decodes *http.Response errors and returns a +// typed API error (e.g. *core.APIError). +type ErrorDecoder func(statusCode int, body io.Reader) error + +// ErrorCodes maps HTTP status codes to error constructors. +type ErrorCodes map[int]func(*core.APIError) error + +// NewErrorDecoder returns a new ErrorDecoder backed by the given error codes. +func NewErrorDecoder(errorCodes ErrorCodes) ErrorDecoder { + return func(statusCode int, body io.Reader) error { + raw, err := io.ReadAll(body) + if err != nil { + return fmt.Errorf("failed to read error from response body: %w", err) + } + apiError := core.NewAPIError( + statusCode, + errors.New(string(raw)), + ) + newErrorFunc, ok := errorCodes[statusCode] + if !ok { + // This status code isn't recognized, so we return + // the API error as-is. + return apiError + } + customError := newErrorFunc(apiError) + if err := json.NewDecoder(bytes.NewReader(raw)).Decode(customError); err != nil { + // If we fail to decode the error, we return the + // API error as-is. + return apiError + } + return customError + } +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder_test.go b/seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder_test.go new file mode 100644 index 00000000000..da98866a2cf --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/error_decoder_test.go @@ -0,0 +1,55 @@ +package internal + +import ( + "bytes" + "errors" + "net/http" + "testing" + + "github.com/oauth-client-credentials-custom/fern/core" + "github.com/stretchr/testify/assert" +) + +func TestErrorDecoder(t *testing.T) { + decoder := NewErrorDecoder( + ErrorCodes{ + http.StatusNotFound: func(apiError *core.APIError) error { + return &NotFoundError{APIError: apiError} + }, + }) + + tests := []struct { + description string + giveStatusCode int + giveBody string + wantError error + }{ + { + description: "unrecognized status code", + giveStatusCode: http.StatusInternalServerError, + giveBody: "Internal Server Error", + wantError: core.NewAPIError(http.StatusInternalServerError, errors.New("Internal Server Error")), + }, + { + description: "not found with valid JSON", + giveStatusCode: http.StatusNotFound, + giveBody: `{"message": "Resource not found"}`, + wantError: &NotFoundError{ + APIError: core.NewAPIError(http.StatusNotFound, errors.New(`{"message": "Resource not found"}`)), + Message: "Resource not found", + }, + }, + { + description: "not found with invalid JSON", + giveStatusCode: http.StatusNotFound, + giveBody: `Resource not found`, + wantError: core.NewAPIError(http.StatusNotFound, errors.New("Resource not found")), + }, + } + + for _, tt := range tests { + t.Run(tt.description, func(t *testing.T) { + assert.Equal(t, tt.wantError, decoder(tt.giveStatusCode, bytes.NewReader([]byte(tt.giveBody)))) + }) + } +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties.go b/seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties.go new file mode 100644 index 00000000000..540c3fd89ee --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties.go @@ -0,0 +1,141 @@ +package internal + +import ( + "bytes" + "encoding/json" + "fmt" + "reflect" + "strings" +) + +// MarshalJSONWithExtraProperty marshals the given value to JSON, including the extra property. +func MarshalJSONWithExtraProperty(marshaler interface{}, key string, value interface{}) ([]byte, error) { + return MarshalJSONWithExtraProperties(marshaler, map[string]interface{}{key: value}) +} + +// MarshalJSONWithExtraProperties marshals the given value to JSON, including any extra properties. +func MarshalJSONWithExtraProperties(marshaler interface{}, extraProperties map[string]interface{}) ([]byte, error) { + bytes, err := json.Marshal(marshaler) + if err != nil { + return nil, err + } + if len(extraProperties) == 0 { + return bytes, nil + } + keys, err := getKeys(marshaler) + if err != nil { + return nil, err + } + for _, key := range keys { + if _, ok := extraProperties[key]; ok { + return nil, fmt.Errorf("cannot add extra property %q because it is already defined on the type", key) + } + } + extraBytes, err := json.Marshal(extraProperties) + if err != nil { + return nil, err + } + if isEmptyJSON(bytes) { + if isEmptyJSON(extraBytes) { + return bytes, nil + } + return extraBytes, nil + } + result := bytes[:len(bytes)-1] + result = append(result, ',') + result = append(result, extraBytes[1:len(extraBytes)-1]...) + result = append(result, '}') + return result, nil +} + +// ExtractExtraProperties extracts any extra properties from the given value. +func ExtractExtraProperties(bytes []byte, value interface{}, exclude ...string) (map[string]interface{}, error) { + val := reflect.ValueOf(value) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return nil, fmt.Errorf("value must be non-nil to extract extra properties") + } + val = val.Elem() + } + if err := json.Unmarshal(bytes, &value); err != nil { + return nil, err + } + var extraProperties map[string]interface{} + if err := json.Unmarshal(bytes, &extraProperties); err != nil { + return nil, err + } + for i := 0; i < val.Type().NumField(); i++ { + key := jsonKey(val.Type().Field(i)) + if key == "" || key == "-" { + continue + } + delete(extraProperties, key) + } + for _, key := range exclude { + delete(extraProperties, key) + } + if len(extraProperties) == 0 { + return nil, nil + } + return extraProperties, nil +} + +// getKeys returns the keys associated with the given value. The value must be a +// a struct or a map with string keys. +func getKeys(value interface{}) ([]string, error) { + val := reflect.ValueOf(value) + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + if !val.IsValid() { + return nil, nil + } + switch val.Kind() { + case reflect.Struct: + return getKeysForStructType(val.Type()), nil + case reflect.Map: + var keys []string + if val.Type().Key().Kind() != reflect.String { + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } + for _, key := range val.MapKeys() { + keys = append(keys, key.String()) + } + return keys, nil + default: + return nil, fmt.Errorf("cannot extract keys from %T; only structs and maps with string keys are supported", value) + } +} + +// getKeysForStructType returns all the keys associated with the given struct type, +// visiting embedded fields recursively. +func getKeysForStructType(structType reflect.Type) []string { + if structType.Kind() == reflect.Pointer { + structType = structType.Elem() + } + if structType.Kind() != reflect.Struct { + return nil + } + var keys []string + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + if field.Anonymous { + keys = append(keys, getKeysForStructType(field.Type)...) + continue + } + keys = append(keys, jsonKey(field)) + } + return keys +} + +// jsonKey returns the JSON key from the struct tag of the given field, +// excluding the omitempty flag (if any). +func jsonKey(field reflect.StructField) string { + return strings.TrimSuffix(field.Tag.Get("json"), ",omitempty") +} + +// isEmptyJSON returns true if the given data is empty, the empty JSON object, or +// an explicit null. +func isEmptyJSON(data []byte) bool { + return len(data) <= 2 || bytes.Equal(data, []byte("null")) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties_test.go b/seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties_test.go new file mode 100644 index 00000000000..aa2510ee512 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/extra_properties_test.go @@ -0,0 +1,228 @@ +package internal + +import ( + "encoding/json" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type testMarshaler struct { + Name string `json:"name"` + BirthDate time.Time `json:"birthDate"` + CreatedAt time.Time `json:"created_at"` +} + +func (t *testMarshaler) MarshalJSON() ([]byte, error) { + type embed testMarshaler + var marshaler = struct { + embed + BirthDate string `json:"birthDate"` + CreatedAt string `json:"created_at"` + }{ + embed: embed(*t), + BirthDate: t.BirthDate.Format("2006-01-02"), + CreatedAt: t.CreatedAt.Format(time.RFC3339), + } + return MarshalJSONWithExtraProperty(marshaler, "type", "test") +} + +func TestMarshalJSONWithExtraProperties(t *testing.T) { + tests := []struct { + desc string + giveMarshaler interface{} + giveExtraProperties map[string]interface{} + wantBytes []byte + wantError string + }{ + { + desc: "invalid type", + giveMarshaler: []string{"invalid"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from []string; only structs and maps with string keys are supported`, + }, + { + desc: "invalid key type", + giveMarshaler: map[int]interface{}{42: "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot extract keys from map[int]interface {}; only structs and maps with string keys are supported`, + }, + { + desc: "invalid map overwrite", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"key": "overwrite"}, + wantError: `cannot add extra property "key" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"birthDate": "2000-01-01"}, + wantError: `cannot add extra property "birthDate" because it is already defined on the type`, + }, + { + desc: "invalid struct overwrite embedded type", + giveMarshaler: new(testMarshaler), + giveExtraProperties: map[string]interface{}{"name": "bob"}, + wantError: `cannot add extra property "name" because it is already defined on the type`, + }, + { + desc: "nil", + giveMarshaler: nil, + giveExtraProperties: nil, + wantBytes: []byte(`null`), + }, + { + desc: "empty", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{}`), + }, + { + desc: "no extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "only extra properties", + giveMarshaler: map[string]interface{}{}, + giveExtraProperties: map[string]interface{}{"key": "value"}, + wantBytes: []byte(`{"key":"value"}`), + }, + { + desc: "single extra property", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"extra": "property"}, + wantBytes: []byte(`{"key":"value","extra":"property"}`), + }, + { + desc: "multiple extra properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{"one": 1, "two": 2}, + wantBytes: []byte(`{"key":"value","one":1,"two":2}`), + }, + { + desc: "nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","user":{"age":42,"name":"alice"}}`), + }, + { + desc: "multiple nested properties", + giveMarshaler: map[string]interface{}{"key": "value"}, + giveExtraProperties: map[string]interface{}{ + "metadata": map[string]interface{}{ + "ip": "127.0.0.1", + }, + "user": map[string]interface{}{ + "age": 42, + "name": "alice", + }, + }, + wantBytes: []byte(`{"key":"value","metadata":{"ip":"127.0.0.1"},"user":{"age":42,"name":"alice"}}`), + }, + { + desc: "custom marshaler", + giveMarshaler: &testMarshaler{ + Name: "alice", + BirthDate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), + CreatedAt: time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC), + }, + giveExtraProperties: map[string]interface{}{ + "extra": "property", + }, + wantBytes: []byte(`{"name":"alice","birthDate":"2000-01-01","created_at":"2024-01-01T00:00:00Z","type":"test","extra":"property"}`), + }, + } + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + bytes, err := MarshalJSONWithExtraProperties(tt.giveMarshaler, tt.giveExtraProperties) + if tt.wantError != "" { + require.EqualError(t, err, tt.wantError) + assert.Nil(t, tt.wantBytes) + return + } + require.NoError(t, err) + assert.Equal(t, tt.wantBytes, bytes) + + value := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &value)) + }) + } +} + +func TestExtractExtraProperties(t *testing.T) { + t.Run("none", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice"}`), value) + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) + + t.Run("non-nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("nil pointer", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value *user + _, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + assert.EqualError(t, err, "value must be non-nil to extract extra properties") + }) + + t.Run("non-zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("zero value", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + var value user + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value) + require.NoError(t, err) + assert.Equal(t, map[string]interface{}{"age": float64(42)}, extraProperties) + }) + + t.Run("exclude", func(t *testing.T) { + type user struct { + Name string `json:"name"` + } + value := &user{ + Name: "alice", + } + extraProperties, err := ExtractExtraProperties([]byte(`{"name": "alice", "age": 42}`), value, "age") + require.NoError(t, err) + assert.Nil(t, extraProperties) + }) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/http.go b/seed/go-sdk/oauth-client-credentials-custom/internal/http.go new file mode 100644 index 00000000000..768968bd621 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/http.go @@ -0,0 +1,48 @@ +package internal + +import ( + "fmt" + "net/http" + "net/url" +) + +// HTTPClient is an interface for a subset of the *http.Client. +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} + +// ResolveBaseURL resolves the base URL from the given arguments, +// preferring the first non-empty value. +func ResolveBaseURL(values ...string) string { + for _, value := range values { + if value != "" { + return value + } + } + return "" +} + +// EncodeURL encodes the given arguments into the URL, escaping +// values as needed. +func EncodeURL(urlFormat string, args ...interface{}) string { + escapedArgs := make([]interface{}, 0, len(args)) + for _, arg := range args { + escapedArgs = append(escapedArgs, url.PathEscape(fmt.Sprintf("%v", arg))) + } + return fmt.Sprintf(urlFormat, escapedArgs...) +} + +// MergeHeaders merges the given headers together, where the right +// takes precedence over the left. +func MergeHeaders(left, right http.Header) http.Header { + for key, values := range right { + if len(values) > 1 { + left[key] = values + continue + } + if value := right.Get(key); value != "" { + left.Set(key, value) + } + } + return left +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/query.go b/seed/go-sdk/oauth-client-credentials-custom/internal/query.go new file mode 100644 index 00000000000..6129e71ffe5 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/query.go @@ -0,0 +1,231 @@ +package internal + +import ( + "encoding/base64" + "fmt" + "net/url" + "reflect" + "strings" + "time" + + "github.com/google/uuid" +) + +var ( + bytesType = reflect.TypeOf([]byte{}) + queryEncoderType = reflect.TypeOf(new(QueryEncoder)).Elem() + timeType = reflect.TypeOf(time.Time{}) + uuidType = reflect.TypeOf(uuid.UUID{}) +) + +// QueryEncoder is an interface implemented by any type that wishes to encode +// itself into URL values in a non-standard way. +type QueryEncoder interface { + EncodeQueryValues(key string, v *url.Values) error +} + +// QueryValues encodes url.Values from request objects. +// +// Note: This type is inspired by Google's query encoding library, but +// supports far less customization and is tailored to fit this SDK's use case. +// +// Ref: https://github.com/google/go-querystring +func QueryValues(v interface{}) (url.Values, error) { + values := make(url.Values) + val := reflect.ValueOf(v) + for val.Kind() == reflect.Ptr { + if val.IsNil() { + return values, nil + } + val = val.Elem() + } + + if v == nil { + return values, nil + } + + if val.Kind() != reflect.Struct { + return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) + } + + err := reflectValue(values, val, "") + return values, err +} + +// reflectValue populates the values parameter from the struct fields in val. +// Embedded structs are followed recursively (using the rules defined in the +// Values function documentation) breadth-first. +func reflectValue(values url.Values, val reflect.Value, scope string) error { + typ := val.Type() + for i := 0; i < typ.NumField(); i++ { + sf := typ.Field(i) + if sf.PkgPath != "" && !sf.Anonymous { + // Skip unexported fields. + continue + } + + sv := val.Field(i) + tag := sf.Tag.Get("url") + if tag == "" || tag == "-" { + continue + } + + name, opts := parseTag(tag) + if name == "" { + name = sf.Name + } + + if scope != "" { + name = scope + "[" + name + "]" + } + + if opts.Contains("omitempty") && isEmptyValue(sv) { + continue + } + + if sv.Type().Implements(queryEncoderType) { + // If sv is a nil pointer and the custom encoder is defined on a non-pointer + // method receiver, set sv to the zero value of the underlying type + if !reflect.Indirect(sv).IsValid() && sv.Type().Elem().Implements(queryEncoderType) { + sv = reflect.New(sv.Type().Elem()) + } + + m := sv.Interface().(QueryEncoder) + if err := m.EncodeQueryValues(name, &values); err != nil { + return err + } + continue + } + + // Recursively dereference pointers, but stop at nil pointers. + for sv.Kind() == reflect.Ptr { + if sv.IsNil() { + break + } + sv = sv.Elem() + } + + if sv.Type() == uuidType || sv.Type() == bytesType || sv.Type() == timeType { + values.Add(name, valueString(sv, opts, sf)) + continue + } + + if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { + if sv.Len() == 0 { + // Skip if slice or array is empty. + continue + } + for i := 0; i < sv.Len(); i++ { + value := sv.Index(i) + if isStructPointer(value) && !value.IsNil() { + if err := reflectValue(values, value.Elem(), name); err != nil { + return err + } + } else { + values.Add(name, valueString(value, opts, sf)) + } + } + continue + } + + if sv.Kind() == reflect.Struct { + if err := reflectValue(values, sv, name); err != nil { + return err + } + continue + } + + values.Add(name, valueString(sv, opts, sf)) + } + + return nil +} + +// valueString returns the string representation of a value. +func valueString(v reflect.Value, opts tagOptions, sf reflect.StructField) string { + for v.Kind() == reflect.Ptr { + if v.IsNil() { + return "" + } + v = v.Elem() + } + + if v.Type() == timeType { + t := v.Interface().(time.Time) + if format := sf.Tag.Get("format"); format == "date" { + return t.Format("2006-01-02") + } + return t.Format(time.RFC3339) + } + + if v.Type() == uuidType { + u := v.Interface().(uuid.UUID) + return u.String() + } + + if v.Type() == bytesType { + b := v.Interface().([]byte) + return base64.StdEncoding.EncodeToString(b) + } + + return fmt.Sprint(v.Interface()) +} + +// isEmptyValue checks if a value should be considered empty for the purposes +// of omitting fields with the "omitempty" option. +func isEmptyValue(v reflect.Value) bool { + type zeroable interface { + IsZero() bool + } + + if !v.IsZero() { + if z, ok := v.Interface().(zeroable); ok { + return z.IsZero() + } + } + + switch v.Kind() { + case reflect.Array, reflect.Map, reflect.Slice, reflect.String: + return v.Len() == 0 + case reflect.Bool: + return !v.Bool() + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.Interface, reflect.Ptr: + return v.IsNil() + case reflect.Invalid, reflect.Complex64, reflect.Complex128, reflect.Chan, reflect.Func, reflect.Struct, reflect.UnsafePointer: + return false + } + + return false +} + +// isStructPointer returns true if the given reflect.Value is a pointer to a struct. +func isStructPointer(v reflect.Value) bool { + return v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct +} + +// tagOptions is the string following a comma in a struct field's "url" tag, or +// the empty string. It does not include the leading comma. +type tagOptions []string + +// parseTag splits a struct field's url tag into its name and comma-separated +// options. +func parseTag(tag string) (string, tagOptions) { + s := strings.Split(tag, ",") + return s[0], s[1:] +} + +// Contains checks whether the tagOptions contains the specified option. +func (o tagOptions) Contains(option string) bool { + for _, s := range o { + if s == option { + return true + } + } + return false +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/query_test.go b/seed/go-sdk/oauth-client-credentials-custom/internal/query_test.go new file mode 100644 index 00000000000..2e58ccadde1 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/query_test.go @@ -0,0 +1,187 @@ +package internal + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestQueryValues(t *testing.T) { + t.Run("empty optional", func(t *testing.T) { + type nested struct { + Value *string `json:"value,omitempty" url:"value,omitempty"` + } + type example struct { + Nested *nested `json:"nested,omitempty" url:"nested,omitempty"` + } + + values, err := QueryValues(&example{}) + require.NoError(t, err) + assert.Empty(t, values) + }) + + t.Run("empty required", func(t *testing.T) { + type nested struct { + Value *string `json:"value,omitempty" url:"value,omitempty"` + } + type example struct { + Required string `json:"required" url:"required"` + Nested *nested `json:"nested,omitempty" url:"nested,omitempty"` + } + + values, err := QueryValues(&example{}) + require.NoError(t, err) + assert.Equal(t, "required=", values.Encode()) + }) + + t.Run("allow multiple", func(t *testing.T) { + type example struct { + Values []string `json:"values" url:"values"` + } + + values, err := QueryValues( + &example{ + Values: []string{"foo", "bar", "baz"}, + }, + ) + require.NoError(t, err) + assert.Equal(t, "values=foo&values=bar&values=baz", values.Encode()) + }) + + t.Run("nested object", func(t *testing.T) { + type nested struct { + Value *string `json:"value,omitempty" url:"value,omitempty"` + } + type example struct { + Required string `json:"required" url:"required"` + Nested *nested `json:"nested,omitempty" url:"nested,omitempty"` + } + + nestedValue := "nestedValue" + values, err := QueryValues( + &example{ + Required: "requiredValue", + Nested: &nested{ + Value: &nestedValue, + }, + }, + ) + require.NoError(t, err) + assert.Equal(t, "nested%5Bvalue%5D=nestedValue&required=requiredValue", values.Encode()) + }) + + t.Run("url unspecified", func(t *testing.T) { + type example struct { + Required string `json:"required" url:"required"` + NotFound string `json:"notFound"` + } + + values, err := QueryValues( + &example{ + Required: "requiredValue", + NotFound: "notFound", + }, + ) + require.NoError(t, err) + assert.Equal(t, "required=requiredValue", values.Encode()) + }) + + t.Run("url ignored", func(t *testing.T) { + type example struct { + Required string `json:"required" url:"required"` + NotFound string `json:"notFound" url:"-"` + } + + values, err := QueryValues( + &example{ + Required: "requiredValue", + NotFound: "notFound", + }, + ) + require.NoError(t, err) + assert.Equal(t, "required=requiredValue", values.Encode()) + }) + + t.Run("datetime", func(t *testing.T) { + type example struct { + DateTime time.Time `json:"dateTime" url:"dateTime"` + } + + values, err := QueryValues( + &example{ + DateTime: time.Date(1994, 3, 16, 12, 34, 56, 0, time.UTC), + }, + ) + require.NoError(t, err) + assert.Equal(t, "dateTime=1994-03-16T12%3A34%3A56Z", values.Encode()) + }) + + t.Run("date", func(t *testing.T) { + type example struct { + Date time.Time `json:"date" url:"date" format:"date"` + } + + values, err := QueryValues( + &example{ + Date: time.Date(1994, 3, 16, 12, 34, 56, 0, time.UTC), + }, + ) + require.NoError(t, err) + assert.Equal(t, "date=1994-03-16", values.Encode()) + }) + + t.Run("optional time", func(t *testing.T) { + type example struct { + Date *time.Time `json:"date,omitempty" url:"date,omitempty" format:"date"` + } + + values, err := QueryValues( + &example{}, + ) + require.NoError(t, err) + assert.Empty(t, values.Encode()) + }) + + t.Run("omitempty with non-pointer zero value", func(t *testing.T) { + type enum string + + type example struct { + Enum enum `json:"enum,omitempty" url:"enum,omitempty"` + } + + values, err := QueryValues( + &example{}, + ) + require.NoError(t, err) + assert.Empty(t, values.Encode()) + }) + + t.Run("object array", func(t *testing.T) { + type object struct { + Key string `json:"key" url:"key"` + Value string `json:"value" url:"value"` + } + type example struct { + Objects []*object `json:"objects,omitempty" url:"objects,omitempty"` + } + + values, err := QueryValues( + &example{ + Objects: []*object{ + { + Key: "hello", + Value: "world", + }, + { + Key: "foo", + Value: "bar", + }, + }, + }, + ) + require.NoError(t, err) + assert.Equal(t, "objects%5Bkey%5D=hello&objects%5Bkey%5D=foo&objects%5Bvalue%5D=world&objects%5Bvalue%5D=bar", values.Encode()) + }) +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/retrier.go b/seed/go-sdk/oauth-client-credentials-custom/internal/retrier.go new file mode 100644 index 00000000000..6040147154b --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/retrier.go @@ -0,0 +1,165 @@ +package internal + +import ( + "crypto/rand" + "math/big" + "net/http" + "time" +) + +const ( + defaultRetryAttempts = 2 + minRetryDelay = 500 * time.Millisecond + maxRetryDelay = 5000 * time.Millisecond +) + +// RetryOption adapts the behavior the *Retrier. +type RetryOption func(*retryOptions) + +// RetryFunc is a retriable HTTP function call (i.e. *http.Client.Do). +type RetryFunc func(*http.Request) (*http.Response, error) + +// WithMaxAttempts configures the maximum number of attempts +// of the *Retrier. +func WithMaxAttempts(attempts uint) RetryOption { + return func(opts *retryOptions) { + opts.attempts = attempts + } +} + +// Retrier retries failed requests a configurable number of times with an +// exponential back-off between each retry. +type Retrier struct { + attempts uint +} + +// NewRetrier constructs a new *Retrier with the given options, if any. +func NewRetrier(opts ...RetryOption) *Retrier { + options := new(retryOptions) + for _, opt := range opts { + opt(options) + } + attempts := uint(defaultRetryAttempts) + if options.attempts > 0 { + attempts = options.attempts + } + return &Retrier{ + attempts: attempts, + } +} + +// Run issues the request and, upon failure, retries the request if possible. +// +// The request will be retried as long as the request is deemed retriable and the +// number of retry attempts has not grown larger than the configured retry limit. +func (r *Retrier) Run( + fn RetryFunc, + request *http.Request, + errorDecoder ErrorDecoder, + opts ...RetryOption, +) (*http.Response, error) { + options := new(retryOptions) + for _, opt := range opts { + opt(options) + } + maxRetryAttempts := r.attempts + if options.attempts > 0 { + maxRetryAttempts = options.attempts + } + var ( + retryAttempt uint + previousError error + ) + return r.run( + fn, + request, + errorDecoder, + maxRetryAttempts, + retryAttempt, + previousError, + ) +} + +func (r *Retrier) run( + fn RetryFunc, + request *http.Request, + errorDecoder ErrorDecoder, + maxRetryAttempts uint, + retryAttempt uint, + previousError error, +) (*http.Response, error) { + if retryAttempt >= maxRetryAttempts { + return nil, previousError + } + + // If the call has been cancelled, don't issue the request. + if err := request.Context().Err(); err != nil { + return nil, err + } + + response, err := fn(request) + if err != nil { + return nil, err + } + + if r.shouldRetry(response) { + defer response.Body.Close() + + delay, err := r.retryDelay(retryAttempt) + if err != nil { + return nil, err + } + + time.Sleep(delay) + + return r.run( + fn, + request, + errorDecoder, + maxRetryAttempts, + retryAttempt+1, + decodeError(response, errorDecoder), + ) + } + + return response, nil +} + +// shouldRetry returns true if the request should be retried based on the given +// response status code. +func (r *Retrier) shouldRetry(response *http.Response) bool { + return response.StatusCode == http.StatusTooManyRequests || + response.StatusCode == http.StatusRequestTimeout || + response.StatusCode >= http.StatusInternalServerError +} + +// retryDelay calculates the delay time in milliseconds based on the retry attempt. +func (r *Retrier) retryDelay(retryAttempt uint) (time.Duration, error) { + // Apply exponential backoff. + delay := minRetryDelay + minRetryDelay*time.Duration(retryAttempt*retryAttempt) + + // Do not allow the number to exceed maxRetryDelay. + if delay > maxRetryDelay { + delay = maxRetryDelay + } + + // Apply some itter by randomizing the value in the range of 75%-100%. + max := big.NewInt(int64(delay / 4)) + jitter, err := rand.Int(rand.Reader, max) + if err != nil { + return 0, err + } + + delay -= time.Duration(jitter.Int64()) + + // Never sleep less than the base sleep seconds. + if delay < minRetryDelay { + delay = minRetryDelay + } + + return delay, nil +} + +type retryOptions struct { + attempts uint +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/retrier_test.go b/seed/go-sdk/oauth-client-credentials-custom/internal/retrier_test.go new file mode 100644 index 00000000000..9b9d743a3bd --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/retrier_test.go @@ -0,0 +1,211 @@ +package internal + +import ( + "context" + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/oauth-client-credentials-custom/fern/core" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type RetryTestCase struct { + description string + + giveAttempts uint + giveStatusCodes []int + giveResponse *Response + + wantResponse *Response + wantError *core.APIError +} + +func TestRetrier(t *testing.T) { + tests := []*RetryTestCase{ + { + description: "retry request succeeds after multiple failures", + giveAttempts: 3, + giveStatusCodes: []int{ + http.StatusServiceUnavailable, + http.StatusServiceUnavailable, + http.StatusOK, + }, + giveResponse: &Response{ + Id: "1", + }, + wantResponse: &Response{ + Id: "1", + }, + }, + { + description: "retry request fails if MaxAttempts is exceeded", + giveAttempts: 3, + giveStatusCodes: []int{ + http.StatusRequestTimeout, + http.StatusRequestTimeout, + http.StatusRequestTimeout, + http.StatusOK, + }, + wantError: &core.APIError{ + StatusCode: http.StatusRequestTimeout, + }, + }, + { + description: "retry durations increase exponentially and stay within the min and max delay values", + giveAttempts: 4, + giveStatusCodes: []int{ + http.StatusServiceUnavailable, + http.StatusServiceUnavailable, + http.StatusServiceUnavailable, + http.StatusOK, + }, + }, + { + description: "retry does not occur on status code 404", + giveAttempts: 2, + giveStatusCodes: []int{http.StatusNotFound, http.StatusOK}, + wantError: &core.APIError{ + StatusCode: http.StatusNotFound, + }, + }, + { + description: "retries occur on status code 429", + giveAttempts: 2, + giveStatusCodes: []int{http.StatusTooManyRequests, http.StatusOK}, + }, + { + description: "retries occur on status code 408", + giveAttempts: 2, + giveStatusCodes: []int{http.StatusRequestTimeout, http.StatusOK}, + }, + { + description: "retries occur on status code 500", + giveAttempts: 2, + giveStatusCodes: []int{http.StatusInternalServerError, http.StatusOK}, + }, + } + + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + var ( + test = tc + server = newTestRetryServer(t, test) + client = server.Client() + ) + + t.Parallel() + + caller := NewCaller( + &CallerParams{ + Client: client, + }, + ) + + var response *Response + err := caller.Call( + context.Background(), + &CallParams{ + URL: server.URL, + Method: http.MethodGet, + Request: &Request{}, + Response: &response, + MaxAttempts: test.giveAttempts, + ResponseIsOptional: true, + }, + ) + + if test.wantError != nil { + require.IsType(t, err, &core.APIError{}) + expectedErrorCode := test.wantError.StatusCode + actualErrorCode := err.(*core.APIError).StatusCode + assert.Equal(t, expectedErrorCode, actualErrorCode) + return + } + + require.NoError(t, err) + assert.Equal(t, test.wantResponse, response) + }) + } +} + +// newTestRetryServer returns a new *httptest.Server configured with the +// given test parameters, suitable for testing retries. +func newTestRetryServer(t *testing.T, tc *RetryTestCase) *httptest.Server { + var index int + timestamps := make([]time.Time, 0, len(tc.giveStatusCodes)) + + return httptest.NewServer( + http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + timestamps = append(timestamps, time.Now()) + if index > 0 && index < len(expectedRetryDurations) { + // Ensure that the duration between retries increases exponentially, + // and that it is within the minimum and maximum retry delay values. + actualDuration := timestamps[index].Sub(timestamps[index-1]) + expectedDurationMin := expectedRetryDurations[index-1] * 75 / 100 + expectedDurationMax := expectedRetryDurations[index-1] * 125 / 100 + assert.True( + t, + actualDuration >= expectedDurationMin && actualDuration <= expectedDurationMax, + "expected duration to be in range [%v, %v], got %v", + expectedDurationMin, + expectedDurationMax, + actualDuration, + ) + assert.LessOrEqual( + t, + actualDuration, + maxRetryDelay, + "expected duration to be less than the maxRetryDelay (%v), got %v", + maxRetryDelay, + actualDuration, + ) + assert.GreaterOrEqual( + t, + actualDuration, + minRetryDelay, + "expected duration to be greater than the minRetryDelay (%v), got %v", + minRetryDelay, + actualDuration, + ) + } + + request := new(Request) + bytes, err := io.ReadAll(r.Body) + require.NoError(t, err) + require.NoError(t, json.Unmarshal(bytes, request)) + require.LessOrEqual(t, index, len(tc.giveStatusCodes)) + + statusCode := tc.giveStatusCodes[index] + w.WriteHeader(statusCode) + + if tc.giveResponse != nil && statusCode == http.StatusOK { + bytes, err = json.Marshal(tc.giveResponse) + require.NoError(t, err) + _, err = w.Write(bytes) + require.NoError(t, err) + } + + index++ + }, + ), + ) +} + +// expectedRetryDurations holds an array of calculated retry durations, +// where the index of the array should correspond to the retry attempt. +// +// Values are calculated based off of `minRetryDelay + minRetryDelay*i*i`, with +// a max and min value of 5000ms and 500ms respectively. +var expectedRetryDurations = []time.Duration{ + 500 * time.Millisecond, + 1000 * time.Millisecond, + 2500 * time.Millisecond, + 5000 * time.Millisecond, + 5000 * time.Millisecond, +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/stringer.go b/seed/go-sdk/oauth-client-credentials-custom/internal/stringer.go new file mode 100644 index 00000000000..312801851e0 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/stringer.go @@ -0,0 +1,13 @@ +package internal + +import "encoding/json" + +// StringifyJSON returns a pretty JSON string representation of +// the given value. +func StringifyJSON(value interface{}) (string, error) { + bytes, err := json.MarshalIndent(value, "", " ") + if err != nil { + return "", err + } + return string(bytes), nil +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/internal/time.go b/seed/go-sdk/oauth-client-credentials-custom/internal/time.go new file mode 100644 index 00000000000..ab0e269fade --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/internal/time.go @@ -0,0 +1,137 @@ +package internal + +import ( + "encoding/json" + "time" +) + +const dateFormat = "2006-01-02" + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date (e.g. 2006-01-02). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type Date struct { + t *time.Time +} + +// NewDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewDate(t time.Time) *Date { + return &Date{t: &t} +} + +// NewOptionalDate returns a new *Date. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDate(t *time.Time) *Date { + if t == nil { + return nil + } + return &Date{t: t} +} + +// Time returns the Date's underlying time, if any. If the +// date is nil, the zero value is returned. +func (d *Date) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the Date's underlying time.Time, if any. +func (d *Date) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *Date) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(dateFormat)) +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(dateFormat, raw) + if err != nil { + return err + } + + *d = Date{t: &parsedTime} + return nil +} + +// DateTime wraps time.Time and adapts its JSON representation +// to conform to a RFC3339 date-time (e.g. 2017-07-21T17:32:28Z). +// +// Ref: https://ijmacd.github.io/rfc3339-iso8601 +type DateTime struct { + t *time.Time +} + +// NewDateTime returns a new *DateTime. +func NewDateTime(t time.Time) *DateTime { + return &DateTime{t: &t} +} + +// NewOptionalDateTime returns a new *DateTime. If the given time.Time +// is nil, nil will be returned. +func NewOptionalDateTime(t *time.Time) *DateTime { + if t == nil { + return nil + } + return &DateTime{t: t} +} + +// Time returns the DateTime's underlying time, if any. If the +// date-time is nil, the zero value is returned. +func (d *DateTime) Time() time.Time { + if d == nil || d.t == nil { + return time.Time{} + } + return *d.t +} + +// TimePtr returns a pointer to the DateTime's underlying time.Time, if any. +func (d *DateTime) TimePtr() *time.Time { + if d == nil || d.t == nil { + return nil + } + if d.t.IsZero() { + return nil + } + return d.t +} + +func (d *DateTime) MarshalJSON() ([]byte, error) { + if d == nil || d.t == nil { + return nil, nil + } + return json.Marshal(d.t.Format(time.RFC3339)) +} + +func (d *DateTime) UnmarshalJSON(data []byte) error { + var raw string + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + + parsedTime, err := time.Parse(time.RFC3339, raw) + if err != nil { + return err + } + + *d = DateTime{t: &parsedTime} + return nil +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/option/request_option.go b/seed/go-sdk/oauth-client-credentials-custom/option/request_option.go new file mode 100644 index 00000000000..daff078fe01 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/option/request_option.go @@ -0,0 +1,64 @@ +// This file was auto-generated by Fern from our API Definition. + +package option + +import ( + core "github.com/oauth-client-credentials-custom/fern/core" + http "net/http" + url "net/url" +) + +// RequestOption adapts the behavior of an indivdual request. +type RequestOption = core.RequestOption + +// WithBaseURL sets the base URL, overriding the default +// environment, if any. +func WithBaseURL(baseURL string) *core.BaseURLOption { + return &core.BaseURLOption{ + BaseURL: baseURL, + } +} + +// WithHTTPClient uses the given HTTPClient to issue the request. +func WithHTTPClient(httpClient core.HTTPClient) *core.HTTPClientOption { + return &core.HTTPClientOption{ + HTTPClient: httpClient, + } +} + +// WithHTTPHeader adds the given http.Header to the request. +func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption { + return &core.HTTPHeaderOption{ + // Clone the headers so they can't be modified after the option call. + HTTPHeader: httpHeader.Clone(), + } +} + +// WithBodyProperties adds the given body properties to the request. +func WithBodyProperties(bodyProperties map[string]interface{}) *core.BodyPropertiesOption { + copiedBodyProperties := make(map[string]interface{}, len(bodyProperties)) + for key, value := range bodyProperties { + copiedBodyProperties[key] = value + } + return &core.BodyPropertiesOption{ + BodyProperties: copiedBodyProperties, + } +} + +// WithQueryParameters adds the given query parameters to the request. +func WithQueryParameters(queryParameters url.Values) *core.QueryParametersOption { + copiedQueryParameters := make(url.Values, len(queryParameters)) + for key, values := range queryParameters { + copiedQueryParameters[key] = values + } + return &core.QueryParametersOption{ + QueryParameters: copiedQueryParameters, + } +} + +// WithMaxAttempts configures the maximum number of retry attempts. +func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption { + return &core.MaxAttemptsOption{ + MaxAttempts: attempts, + } +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/pointer.go b/seed/go-sdk/oauth-client-credentials-custom/pointer.go new file mode 100644 index 00000000000..a1ed2387730 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/pointer.go @@ -0,0 +1,132 @@ +package oauthclientcredentials + +import ( + "time" + + "github.com/google/uuid" +) + +// Bool returns a pointer to the given bool value. +func Bool(b bool) *bool { + return &b +} + +// Byte returns a pointer to the given byte value. +func Byte(b byte) *byte { + return &b +} + +// Complex64 returns a pointer to the given complex64 value. +func Complex64(c complex64) *complex64 { + return &c +} + +// Complex128 returns a pointer to the given complex128 value. +func Complex128(c complex128) *complex128 { + return &c +} + +// Float32 returns a pointer to the given float32 value. +func Float32(f float32) *float32 { + return &f +} + +// Float64 returns a pointer to the given float64 value. +func Float64(f float64) *float64 { + return &f +} + +// Int returns a pointer to the given int value. +func Int(i int) *int { + return &i +} + +// Int8 returns a pointer to the given int8 value. +func Int8(i int8) *int8 { + return &i +} + +// Int16 returns a pointer to the given int16 value. +func Int16(i int16) *int16 { + return &i +} + +// Int32 returns a pointer to the given int32 value. +func Int32(i int32) *int32 { + return &i +} + +// Int64 returns a pointer to the given int64 value. +func Int64(i int64) *int64 { + return &i +} + +// Rune returns a pointer to the given rune value. +func Rune(r rune) *rune { + return &r +} + +// String returns a pointer to the given string value. +func String(s string) *string { + return &s +} + +// Uint returns a pointer to the given uint value. +func Uint(u uint) *uint { + return &u +} + +// Uint8 returns a pointer to the given uint8 value. +func Uint8(u uint8) *uint8 { + return &u +} + +// Uint16 returns a pointer to the given uint16 value. +func Uint16(u uint16) *uint16 { + return &u +} + +// Uint32 returns a pointer to the given uint32 value. +func Uint32(u uint32) *uint32 { + return &u +} + +// Uint64 returns a pointer to the given uint64 value. +func Uint64(u uint64) *uint64 { + return &u +} + +// Uintptr returns a pointer to the given uintptr value. +func Uintptr(u uintptr) *uintptr { + return &u +} + +// UUID returns a pointer to the given uuid.UUID value. +func UUID(u uuid.UUID) *uuid.UUID { + return &u +} + +// Time returns a pointer to the given time.Time value. +func Time(t time.Time) *time.Time { + return &t +} + +// MustParseDate attempts to parse the given string as a +// date time.Time, and panics upon failure. +func MustParseDate(date string) time.Time { + t, err := time.Parse("2006-01-02", date) + if err != nil { + panic(err) + } + return t +} + +// MustParseDateTime attempts to parse the given string as a +// datetime time.Time, and panics upon failure. +func MustParseDateTime(datetime string) time.Time { + t, err := time.Parse(time.RFC3339, datetime) + if err != nil { + panic(err) + } + return t +} diff --git a/seed/go-sdk/oauth-client-credentials-custom/snippet-templates.json b/seed/go-sdk/oauth-client-credentials-custom/snippet-templates.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/seed/go-sdk/oauth-client-credentials-custom/snippet.json b/seed/go-sdk/oauth-client-credentials-custom/snippet.json new file mode 100644 index 00000000000..a60fcddf7b7 --- /dev/null +++ b/seed/go-sdk/oauth-client-credentials-custom/snippet.json @@ -0,0 +1,26 @@ +{ + "endpoints": [ + { + "id": { + "path": "/token", + "method": "POST", + "identifier_override": "endpoint_auth.getTokenWithClientCredentials" + }, + "snippet": { + "type": "go", + "client": "import (\n\tcontext \"context\"\n\tfern \"github.com/oauth-client-credentials-custom/fern\"\n\tfernclient \"github.com/oauth-client-credentials-custom/fern/client\"\n)\n\nclient := fernclient.NewClient()\nresponse, err := client.Auth.GetTokenWithClientCredentials(\n\tcontext.TODO(),\n\t\u0026fern.GetTokenRequest{\n\t\tCid: \"cid\",\n\t\tCsr: \"csr\",\n\t\tScp: \"scp\",\n\t\tEntityId: \"entity_id\",\n\t},\n)\n" + } + }, + { + "id": { + "path": "/token", + "method": "POST", + "identifier_override": "endpoint_auth.refreshToken" + }, + "snippet": { + "type": "go", + "client": "import (\n\tcontext \"context\"\n\tfern \"github.com/oauth-client-credentials-custom/fern\"\n\tfernclient \"github.com/oauth-client-credentials-custom/fern/client\"\n)\n\nclient := fernclient.NewClient()\nresponse, err := client.Auth.RefreshToken(\n\tcontext.TODO(),\n\t\u0026fern.RefreshTokenRequest{\n\t\tClientId: \"client_id\",\n\t\tClientSecret: \"client_secret\",\n\t\tRefreshToken: \"refresh_token\",\n\t},\n)\n" + } + } + ] +} \ No newline at end of file diff --git a/seed/go-sdk/oauth-client-credentials-default/dynamic-snippets/example0/snippet.go b/seed/go-sdk/oauth-client-credentials-default/dynamic-snippets/example0/snippet.go index 88453fab829..cdf693687b6 100644 --- a/seed/go-sdk/oauth-client-credentials-default/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/oauth-client-credentials-default/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/oauth-client-credentials-default/fern/client" + option "github.com/oauth-client-credentials-default/fern/option" context "context" fern "github.com/oauth-client-credentials-default/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Auth.GetToken( context.TODO(), &fern.GetTokenRequest{ diff --git a/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example0/snippet.go b/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example0/snippet.go index 2a213d8427c..f185c26e480 100644 --- a/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/oauth-client-credentials-environment-variables/fern/client" + option "github.com/oauth-client-credentials-environment-variables/fern/option" context "context" fern "github.com/oauth-client-credentials-environment-variables/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Auth.GetTokenWithClientCredentials( context.TODO(), &fern.GetTokenRequest{ diff --git a/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example1/snippet.go b/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example1/snippet.go index 981830ae10e..8465bc28a69 100644 --- a/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/oauth-client-credentials-environment-variables/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/oauth-client-credentials-environment-variables/fern/client" + option "github.com/oauth-client-credentials-environment-variables/fern/option" context "context" fern "github.com/oauth-client-credentials-environment-variables/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Auth.RefreshToken( context.TODO(), &fern.RefreshTokenRequest{ diff --git a/seed/go-sdk/oauth-client-credentials-nested-root/dynamic-snippets/example0/snippet.go b/seed/go-sdk/oauth-client-credentials-nested-root/dynamic-snippets/example0/snippet.go index 0c260dc165d..7890209a129 100644 --- a/seed/go-sdk/oauth-client-credentials-nested-root/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/oauth-client-credentials-nested-root/dynamic-snippets/example0/snippet.go @@ -2,13 +2,18 @@ package example import ( client "github.com/oauth-client-credentials-nested-root/fern/client" + option "github.com/oauth-client-credentials-nested-root/fern/option" context "context" auth "github.com/oauth-client-credentials-nested-root/fern/auth" fern "github.com/oauth-client-credentials-nested-root/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Auth.GetToken( context.TODO(), &auth.GetTokenRequest{ diff --git a/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example0/snippet.go b/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example0/snippet.go index 3161bad51ef..7c2833ef147 100644 --- a/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/oauth-client-credentials/fern/client" + option "github.com/oauth-client-credentials/fern/option" context "context" fern "github.com/oauth-client-credentials/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Auth.GetTokenWithClientCredentials( context.TODO(), &fern.GetTokenRequest{ diff --git a/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example1/snippet.go b/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example1/snippet.go index 6748e3c6a34..ff4e3197633 100644 --- a/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/oauth-client-credentials/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/oauth-client-credentials/fern/client" + option "github.com/oauth-client-credentials/fern/option" context "context" fern "github.com/oauth-client-credentials/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Auth.RefreshToken( context.TODO(), &fern.RefreshTokenRequest{ diff --git a/seed/go-sdk/optional/dynamic-snippets/example0/snippet.go b/seed/go-sdk/optional/dynamic-snippets/example0/snippet.go index f77c81a6cc6..a0aaff86941 100644 --- a/seed/go-sdk/optional/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/optional/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/optional/fern/client" + option "github.com/optional/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Optional.SendOptionalBody( context.TODO(), map[string]interface{}{ diff --git a/seed/go-sdk/package-yml/dynamic-snippets/example0/snippet.go b/seed/go-sdk/package-yml/dynamic-snippets/example0/snippet.go index 514ffda2187..a0541df0933 100644 --- a/seed/go-sdk/package-yml/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/package-yml/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/package-yml/fern/client" + option "github.com/package-yml/fern/option" context "context" fern "github.com/package-yml/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Echo( context.TODO(), "id-ksfd9c1", diff --git a/seed/go-sdk/package-yml/dynamic-snippets/example1/snippet.go b/seed/go-sdk/package-yml/dynamic-snippets/example1/snippet.go index 0d2d4524608..ee4ae70c69b 100644 --- a/seed/go-sdk/package-yml/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/package-yml/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/package-yml/fern/client" + option "github.com/package-yml/fern/option" context "context" fern "github.com/package-yml/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Echo( context.TODO(), "id", diff --git a/seed/go-sdk/package-yml/dynamic-snippets/example2/snippet.go b/seed/go-sdk/package-yml/dynamic-snippets/example2/snippet.go index 58eb1523b13..df0b68b715f 100644 --- a/seed/go-sdk/package-yml/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/package-yml/dynamic-snippets/example2/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/package-yml/fern/client" + option "github.com/package-yml/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.Nop( context.TODO(), "id-a2ijs82", diff --git a/seed/go-sdk/package-yml/dynamic-snippets/example3/snippet.go b/seed/go-sdk/package-yml/dynamic-snippets/example3/snippet.go index f4a84db57c2..f988970018d 100644 --- a/seed/go-sdk/package-yml/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/package-yml/dynamic-snippets/example3/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/package-yml/fern/client" + option "github.com/package-yml/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.Nop( context.TODO(), "id", diff --git a/seed/go-sdk/pagination/dynamic-snippets/example0/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example0/snippet.go index aa0e183810e..26b026df1ff 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example0/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example1/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example1/snippet.go index 555b37ab15f..81d7234d31d 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example1/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example2/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example2/snippet.go index aa0e183810e..26b026df1ff 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example2/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example3/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example3/snippet.go index 638d45e5f98..7ded82a0be4 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example3/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example4/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example4/snippet.go index 60efe90728e..d60d1a147e5 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example4/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example5/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example5/snippet.go index 60efe90728e..d60d1a147e5 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example5/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example6/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example6/snippet.go index b79f8e00727..c8d45067a5a 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example6/snippet.go @@ -10,6 +10,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example7/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example7/snippet.go index b79f8e00727..c8d45067a5a 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example7/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example7/snippet.go @@ -10,6 +10,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example8/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example8/snippet.go index 96bcc5ff29d..6cca4f0f8a0 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example8/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example8/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/pagination/dynamic-snippets/example9/snippet.go b/seed/go-sdk/pagination/dynamic-snippets/example9/snippet.go index a58f15caaf0..64e2ca9fccc 100644 --- a/seed/go-sdk/pagination/dynamic-snippets/example9/snippet.go +++ b/seed/go-sdk/pagination/dynamic-snippets/example9/snippet.go @@ -9,6 +9,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example0/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example0/snippet.go index 0831069b917..0077ee8a268 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organizations.GetOrganization( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example1/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example1/snippet.go index f3f34b72717..4f04acb39e1 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" path "github.com/fern-api/path-parameters-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organizations.GetOrganizationUser( context.TODO(), &path.GetOrganizationUserRequest{ diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example2/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example2/snippet.go index 3f2b64fe060..710b4e9cf27 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" path "github.com/fern-api/path-parameters-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organizations.SearchOrganizations( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example3/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example3/snippet.go index 354fac200e6..cad365c44cb 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example3/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" path "github.com/fern-api/path-parameters-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.GetUser( context.TODO(), &path.GetUsersRequest{ diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example4/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example4/snippet.go index ec443943cbb..6fa9304a0fd 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example4/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" path "github.com/fern-api/path-parameters-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.CreateUser( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example5/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example5/snippet.go index 64816804053..d76b9a18f09 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example5/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" path "github.com/fern-api/path-parameters-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.UpdateUser( context.TODO(), &path.UpdateUserRequest{ diff --git a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example6/snippet.go b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example6/snippet.go index c53f301491f..4b0bab60107 100644 --- a/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/path-parameters/inline-path-parameters/dynamic-snippets/example6/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/path-parameters-go/client" + option "github.com/fern-api/path-parameters-go/option" context "context" path "github.com/fern-api/path-parameters-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.SearchUsers( context.TODO(), &path.SearchUsersRequest{ diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example0/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example0/snippet.go index 4d2b3399243..5b17bff3757 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organizations.GetOrganization( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example1/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example1/snippet.go index bcf236c9244..5a4ccf62201 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organizations.GetOrganizationUser( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example2/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example2/snippet.go index 2eb5bd01a4c..5cd820e4a63 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" fern "github.com/path-parameters/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Organizations.SearchOrganizations( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example3/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example3/snippet.go index 68df5b47acf..e7f3dce2997 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example3/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.GetUser( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example4/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example4/snippet.go index c7168dfe811..f8248a891fb 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example4/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" fern "github.com/path-parameters/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.CreateUser( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example5/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example5/snippet.go index 72489f6c2f5..0a4860626dc 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example5/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" fern "github.com/path-parameters/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.UpdateUser( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example6/snippet.go b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example6/snippet.go index 2d4475c7dd4..203f8cc0b45 100644 --- a/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/path-parameters/no-custom-config/dynamic-snippets/example6/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/path-parameters/fern/client" + option "github.com/path-parameters/fern/option" context "context" fern "github.com/path-parameters/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.SearchUsers( context.TODO(), "tenant_id", diff --git a/seed/go-sdk/plain-text/dynamic-snippets/example0/snippet.go b/seed/go-sdk/plain-text/dynamic-snippets/example0/snippet.go index c9f405a44a2..3a4ded150e6 100644 --- a/seed/go-sdk/plain-text/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/plain-text/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/plain-text/fern/client" + option "github.com/plain-text/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetText( context.TODO(), ) diff --git a/seed/go-sdk/response-property/dynamic-snippets/example0/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example0/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/response-property/dynamic-snippets/example1/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example1/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/response-property/dynamic-snippets/example2/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example2/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example2/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/response-property/dynamic-snippets/example3/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example3/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example3/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example3/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/response-property/dynamic-snippets/example4/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example4/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example4/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example4/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/response-property/dynamic-snippets/example5/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example5/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example5/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example5/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/response-property/dynamic-snippets/example6/snippet.go b/seed/go-sdk/response-property/dynamic-snippets/example6/snippet.go index 7580bd563a5..c6304988a18 100644 --- a/seed/go-sdk/response-property/dynamic-snippets/example6/snippet.go +++ b/seed/go-sdk/response-property/dynamic-snippets/example6/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/response-property/fern/client" + option "github.com/response-property/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.GetMovie( context.TODO(), "string", diff --git a/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example0/snippet.go b/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example0/snippet.go index 6f423da75d7..51a7bea7d31 100644 --- a/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/server-sent-event-examples/fern/client" + option "github.com/server-sent-event-examples/fern/option" context "context" fern "github.com/server-sent-event-examples/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Completions.Stream( context.TODO(), &fern.StreamCompletionRequest{ diff --git a/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example1/snippet.go b/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example1/snippet.go index 42b8c55c8a9..bda96c1c40e 100644 --- a/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/server-sent-event-examples/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/server-sent-event-examples/fern/client" + option "github.com/server-sent-event-examples/fern/option" context "context" fern "github.com/server-sent-event-examples/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Completions.Stream( context.TODO(), &fern.StreamCompletionRequest{ diff --git a/seed/go-sdk/server-sent-events/dynamic-snippets/example0/snippet.go b/seed/go-sdk/server-sent-events/dynamic-snippets/example0/snippet.go index ea720b2a8ab..b8729bf2d73 100644 --- a/seed/go-sdk/server-sent-events/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/server-sent-events/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/server-sent-events/fern/client" + option "github.com/server-sent-events/fern/option" context "context" fern "github.com/server-sent-events/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Completions.Stream( context.TODO(), &fern.StreamCompletionRequest{ diff --git a/seed/go-sdk/simple-fhir/dynamic-snippets/example0/snippet.go b/seed/go-sdk/simple-fhir/dynamic-snippets/example0/snippet.go index 0453c5b09b2..09a1e6f9814 100644 --- a/seed/go-sdk/simple-fhir/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/simple-fhir/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/simple-fhir/fern/client" + option "github.com/simple-fhir/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.GetAccount( context.TODO(), "account_id", diff --git a/seed/go-sdk/single-url-environment-default/dynamic-snippets/example0/snippet.go b/seed/go-sdk/single-url-environment-default/dynamic-snippets/example0/snippet.go index 3d21928dde6..c6bda3035d3 100644 --- a/seed/go-sdk/single-url-environment-default/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/single-url-environment-default/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/single-url-environment-no-default/dynamic-snippets/example0/snippet.go b/seed/go-sdk/single-url-environment-no-default/dynamic-snippets/example0/snippet.go index 944e3383748..1a4a1918060 100644 --- a/seed/go-sdk/single-url-environment-no-default/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/single-url-environment-no-default/dynamic-snippets/example0/snippet.go @@ -8,6 +8,9 @@ import ( func do() () { client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), option.WithToken( "", ), diff --git a/seed/go-sdk/streaming/dynamic-snippets/example0/snippet.go b/seed/go-sdk/streaming/dynamic-snippets/example0/snippet.go index 735bea142f7..d00ae2678a3 100644 --- a/seed/go-sdk/streaming/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/streaming/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/stream-go/v2/client" + option "github.com/fern-api/stream-go/v2/option" context "context" v2 "github.com/fern-api/stream-go/v2" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dummy.GenerateStream( context.TODO(), &v2.GenerateStreamRequest{ diff --git a/seed/go-sdk/streaming/dynamic-snippets/example1/snippet.go b/seed/go-sdk/streaming/dynamic-snippets/example1/snippet.go index 1ed60433624..b7cbc8ef753 100644 --- a/seed/go-sdk/streaming/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/streaming/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/stream-go/v2/client" + option "github.com/fern-api/stream-go/v2/option" context "context" v2 "github.com/fern-api/stream-go/v2" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dummy.Generate( context.TODO(), &v2.Generateequest{ diff --git a/seed/go-sdk/streaming/dynamic-snippets/example2/snippet.go b/seed/go-sdk/streaming/dynamic-snippets/example2/snippet.go index 751fd9f015a..0522002ebe0 100644 --- a/seed/go-sdk/streaming/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/streaming/dynamic-snippets/example2/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/stream-go/v2/client" + option "github.com/fern-api/stream-go/v2/option" context "context" v2 "github.com/fern-api/stream-go/v2" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Dummy.Generate( context.TODO(), &v2.Generateequest{ diff --git a/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example0/snippet.go b/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example0/snippet.go index 3847aba2274..2df49d2fca2 100644 --- a/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/undiscriminated-go/client" + option "github.com/fern-api/undiscriminated-go/option" context "context" undiscriminated "github.com/fern-api/undiscriminated-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Union.Get( context.TODO(), &undiscriminated.MyUnion{ diff --git a/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example1/snippet.go b/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example1/snippet.go index dc8e390878e..b398b3e1ea3 100644 --- a/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example1/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/fern-api/undiscriminated-go/client" + option "github.com/fern-api/undiscriminated-go/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Union.GetMetadata( context.TODO(), ) diff --git a/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example2/snippet.go b/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example2/snippet.go index dc8e390878e..b398b3e1ea3 100644 --- a/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example2/snippet.go +++ b/seed/go-sdk/undiscriminated-unions/dynamic-snippets/example2/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/fern-api/undiscriminated-go/client" + option "github.com/fern-api/undiscriminated-go/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Union.GetMetadata( context.TODO(), ) diff --git a/seed/go-sdk/unions/dynamic-snippets/example0/snippet.go b/seed/go-sdk/unions/dynamic-snippets/example0/snippet.go index 0fd806fa214..33fa09b61da 100644 --- a/seed/go-sdk/unions/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/unions/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/fern-api/unions-go/client" + option "github.com/fern-api/unions-go/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Union.Get( context.TODO(), "id", diff --git a/seed/go-sdk/unions/dynamic-snippets/example1/snippet.go b/seed/go-sdk/unions/dynamic-snippets/example1/snippet.go index bd882eb615f..ba730807807 100644 --- a/seed/go-sdk/unions/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/unions/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/fern-api/unions-go/client" + option "github.com/fern-api/unions-go/option" context "context" unions "github.com/fern-api/unions-go" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Union.Update( context.TODO(), &unions.Shape{ diff --git a/seed/go-sdk/unknown/dynamic-snippets/example0/snippet.go b/seed/go-sdk/unknown/dynamic-snippets/example0/snippet.go index 2b6a0d339e5..9d308fd8230 100644 --- a/seed/go-sdk/unknown/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/unknown/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/unknown/fern/client" + option "github.com/unknown/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Unknown.Post( context.TODO(), map[string]interface{}{ diff --git a/seed/go-sdk/unknown/dynamic-snippets/example1/snippet.go b/seed/go-sdk/unknown/dynamic-snippets/example1/snippet.go index dc342fa1d51..4c5b2eed3eb 100644 --- a/seed/go-sdk/unknown/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/unknown/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/unknown/fern/client" + option "github.com/unknown/fern/option" context "context" fern "github.com/unknown/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Unknown.PostObject( context.TODO(), &fern.MyObject{ diff --git a/seed/go-sdk/validation/dynamic-snippets/example0/snippet.go b/seed/go-sdk/validation/dynamic-snippets/example0/snippet.go index 45e5c39c653..5a2bf246669 100644 --- a/seed/go-sdk/validation/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/validation/dynamic-snippets/example0/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/validation/fern/client" + option "github.com/validation/fern/option" context "context" fern "github.com/validation/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Create( context.TODO(), &fern.CreateRequest{ diff --git a/seed/go-sdk/validation/dynamic-snippets/example1/snippet.go b/seed/go-sdk/validation/dynamic-snippets/example1/snippet.go index 5e6fac5a66a..32f109471b3 100644 --- a/seed/go-sdk/validation/dynamic-snippets/example1/snippet.go +++ b/seed/go-sdk/validation/dynamic-snippets/example1/snippet.go @@ -2,12 +2,17 @@ package example import ( client "github.com/validation/fern/client" + option "github.com/validation/fern/option" context "context" fern "github.com/validation/fern" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Get( context.TODO(), &fern.GetRequest{ diff --git a/seed/go-sdk/variables/dynamic-snippets/example0/snippet.go b/seed/go-sdk/variables/dynamic-snippets/example0/snippet.go index c283c467ec4..9ebfdbc766f 100644 --- a/seed/go-sdk/variables/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/variables/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/variables/fern/client" + option "github.com/variables/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.Service.Post( context.TODO(), "endpointParam", diff --git a/seed/go-sdk/version-no-default/dynamic-snippets/example0/snippet.go b/seed/go-sdk/version-no-default/dynamic-snippets/example0/snippet.go index 2e28280e275..0258c244c6d 100644 --- a/seed/go-sdk/version-no-default/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/version-no-default/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/version-no-default/fern/client" + option "github.com/version-no-default/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.GetUser( context.TODO(), "userId", diff --git a/seed/go-sdk/version/.mock/definition/api.yml b/seed/go-sdk/version/.mock/definition/api.yml index 8a52c2ad5e6..5b85d1c8086 100644 --- a/seed/go-sdk/version/.mock/definition/api.yml +++ b/seed/go-sdk/version/.mock/definition/api.yml @@ -3,6 +3,8 @@ version: header: X-API-Version default: "2.0.0" values: - - "1.0.0" - - "2.0.0" + - name: v1 + value: "1.0.0" + - name: v2 + value: "2.0.0" - "latest" \ No newline at end of file diff --git a/seed/go-sdk/version/dynamic-snippets/example0/snippet.go b/seed/go-sdk/version/dynamic-snippets/example0/snippet.go index 150dc927d14..6ca70f83102 100644 --- a/seed/go-sdk/version/dynamic-snippets/example0/snippet.go +++ b/seed/go-sdk/version/dynamic-snippets/example0/snippet.go @@ -2,11 +2,16 @@ package example import ( client "github.com/version/fern/client" + option "github.com/version/fern/option" context "context" ) func do() () { - client := client.NewClient() + client := client.NewClient( + option.WithBaseURL( + "https://api.fern.com", + ), + ) client.User.GetUser( context.TODO(), "userId",