Skip to content

Commit 9f92d03

Browse files
authored
feat: bump sdk with new openapi spec (#538)
1 parent b69bf6c commit 9f92d03

2,819 files changed

Lines changed: 471093 additions & 248705 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.generator/config.yaml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
generatorName: go
22
templateDir: ./.generator/templates
3-
outputDir: ./okta/v5
3+
outputDir: ./okta/v6
44
gitUserId: okta
55
gitRepoId: okta-sdk-golang
6-
versionName: v5
6+
versionName: v6
7+
goVersion: "1.23.0"
8+
toolchainVersion: "go1.24.0"
79
additionalProperties:
810
enumClassPrefix: true
911
generateInterfaces: true
1012
packageName: okta
11-
packageVersion: 5.0.6
13+
packageVersion: 6.0.0
1214
useOneOfDiscriminatorLookup: true
1315
disallowAdditionalPropertiesIfNotPresent: false
1416
files:
1517
asset/logo.png: {}
16-
api_application_test.go: {}
17-
api_factors_test.go: {}
18-
api_group_test.go: {}
19-
api_idp_test.go: {}
20-
api_policy_test.go: {}
21-
api_user_schema_test.go: {}
22-
api_user_test.go: {}
2318
cache_test.go: {}
2419
cache.go: {}
2520
configuration_test.go: {}
2621
gocache.go: {}
27-
main_test.go: {}
2822
noopcache.go: {}
29-
private_key_test.go: {}
3023
proxy_test.go: {}
31-
retry_logic_test.go: {}
32-
test_helpers.go: {}
3324
user_agent.go: {}

.generator/okta-management-APIs-oasv3-enum-inheritance.yaml

Lines changed: 0 additions & 39582 deletions
This file was deleted.

.generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml

Lines changed: 52070 additions & 20483 deletions
Large diffs are not rendered by default.

.generator/templates/api.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package {{packageName}}
55
import (
66
"bytes"
77
"context"
8-
"io/ioutil"
8+
"io"
99
"net/http"
1010
"net/url"
1111
"time"
@@ -279,7 +279,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
279279
}
280280
{{/required}}
281281
if {{paramName}}LocalVarFile != nil {
282-
fbs, _ := ioutil.ReadAll({{paramName}}LocalVarFile)
282+
fbs, _ := io.ReadAll({{paramName}}LocalVarFile)
283283
{{paramName}}LocalVarFileBytes = fbs
284284
{{paramName}}LocalVarFileName = {{paramName}}LocalVarFile.Name()
285285
{{paramName}}LocalVarFile.Close()
@@ -363,9 +363,9 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
363363
return {{#returnType}}localVarReturnValue, {{/returnType}}localAPIResponse, &GenericOpenAPIError{error: err.Error()}
364364
}
365365

366-
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
366+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
367367
localVarHTTPResponse.Body.Close()
368-
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
368+
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
369369
if err != nil {
370370
{{#returnType}}
371371
localAPIResponse = newAPIResponse(localVarHTTPResponse, a.client, {{#returnType}}localVarReturnValue{{/returnType}})
@@ -454,7 +454,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
454454
{{/returnType}}
455455
return {{#returnType}}localVarReturnValue, {{/returnType}}localAPIResponse, newErr
456456
}
457-
457+
458458
{{/returnType}}
459459
{{#returnType}}
460460
localAPIResponse = newAPIResponse(localVarHTTPResponse, a.client, {{#returnType}}localVarReturnValue{{/returnType}})
@@ -465,4 +465,4 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
465465
return {{#returnType}}localVarReturnValue, {{/returnType}}localAPIResponse, nil
466466
}
467467
{{/operation}}
468-
{{/operations}}
468+
{{/operations}}

.generator/templates/cache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package okta
22

33
import (
44
"bytes"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
)
88

@@ -23,12 +23,12 @@ func CreateCacheKey(req *http.Request) string {
2323

2424
func CopyResponse(resp *http.Response) *http.Response {
2525
c := *resp
26-
respBody, err := ioutil.ReadAll(resp.Body)
26+
respBody, err := io.ReadAll(resp.Body)
2727
if err != nil {
2828
return resp
2929
}
3030

31-
c.Body = ioutil.NopCloser(bytes.NewBuffer(respBody))
31+
c.Body = io.NopCloser(bytes.NewBuffer(respBody))
3232

3333
return &c
3434
}

.generator/templates/cache_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package okta
22

33
import (
44
"io"
5-
"io/ioutil"
65
"net/http"
76
"net/http/httptest"
87
"testing"
@@ -34,7 +33,7 @@ func Test_Item_Stored_Successful(t *testing.T) {
3433
assert.True(t, found, "item does not exist in cache")
3534
pulledFromCache := myCache.Get(cacheKey)
3635
assert.NotEqual(t, result, pulledFromCache, "Item pulled from cache was not a copy")
37-
cachedBody, _ := ioutil.ReadAll(pulledFromCache.Body)
36+
cachedBody, _ := io.ReadAll(pulledFromCache.Body)
3837
assert.Equal(t, toCache, string(cachedBody), "Item pulled from cache was not correct")
3938
}
4039

.generator/templates/client.mustache

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"errors"
1717
"fmt"
1818
"io"
19-
"io/ioutil"
2019
"log"
2120
"mime/multipart"
2221
"net/http"
@@ -28,12 +27,13 @@ import (
2827
"regexp"
2928
"strconv"
3029
"strings"
30+
"sync"
3131
"time"
3232
"unicode/utf8"
3333

3434
"github.com/cenkalti/backoff/v4"
35-
"github.com/go-jose/go-jose/v3"
36-
"github.com/go-jose/go-jose/v3/jwt"
35+
"github.com/go-jose/go-jose/v4"
36+
"github.com/go-jose/go-jose/v4/jwt"
3737
"golang.org/x/oauth2"
3838
{{#withAWSV4Signature}}
3939
awsv4 "github.com/aws/aws-sdk-go/aws/signer/v4"
@@ -525,7 +525,7 @@ func createClientAssertion(orgURL, clientID string, privateKeySinger jose.Signer
525525
ID: uuid.New().String(),
526526
}
527527
jwtBuilder := jwt.Signed(privateKeySinger).Claims(claims)
528-
return jwtBuilder.CompactSerialize()
528+
return jwtBuilder.Serialize()
529529
}
530530

531531
func getAccessTokenForPrivateKey(httpClient *http.Client, orgURL, clientAssertion, userAgent string, scopes []string, maxRetries int32, maxBackoff int64, clientID string, signer jose.Signer) (*RequestAccessToken, string, *rsa.PrivateKey, error) {
@@ -688,10 +688,6 @@ func NewAPIClient(cfg *Configuration) *APIClient {
688688
return c
689689
}
690690

691-
func atoi(in string) (int, error) {
692-
return strconv.Atoi(in)
693-
}
694-
695691
// selectHeaderContentType select a content type from the available list.
696692
func selectHeaderContentType(contentTypes []string) string {
697693
if len(contentTypes) == 0 {
@@ -722,20 +718,6 @@ func contains(haystack []string, needle string) bool {
722718
return false
723719
}
724720

725-
// Verify optional parameters are of the correct type.
726-
func typeCheckParameter(obj interface{}, expected string, name string) error {
727-
// Make sure there is an object.
728-
if obj == nil {
729-
return nil
730-
}
731-
732-
// Check the type is as expected.
733-
if reflect.TypeOf(obj).String() != expected {
734-
return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String())
735-
}
736-
return nil
737-
}
738-
739721
// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
740722
func parameterToString(obj interface{}, collectionFormat string) string {
741723
var delimiter string
@@ -760,15 +742,6 @@ func parameterToString(obj interface{}, collectionFormat string) string {
760742
return fmt.Sprintf("%v", obj)
761743
}
762744

763-
// helper for converting interface{} parameters to json strings
764-
func parameterToJson(obj interface{}) (string, error) {
765-
jsonBuf, err := json.Marshal(obj)
766-
if err != nil {
767-
return "", err
768-
}
769-
return string(jsonBuf), err
770-
}
771-
772745
// callAPI do the request.
773746
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
774747
if c.cfg.Debug {
@@ -1085,7 +1058,7 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err
10851058
return nil
10861059
}
10871060
if f, ok := v.(**os.File); ok {
1088-
*f, err = ioutil.TempFile("", "HttpClientFile")
1061+
*f, err = os.CreateTemp("", "HttpClientFile")
10891062
if err != nil {
10901063
return
10911064
}
@@ -1175,12 +1148,12 @@ func (c *APIClient) do(ctx context.Context, req *http.Request) (*http.Response,
11751148
func (c *APIClient) doWithRetries(ctx context.Context, req *http.Request) (*http.Response, error) {
11761149
var bodyReader func() io.ReadCloser
11771150
if req.Body != nil {
1178-
buf, err := ioutil.ReadAll(req.Body)
1151+
buf, err := io.ReadAll(req.Body)
11791152
if err != nil {
11801153
return nil, err
11811154
}
11821155
bodyReader = func() io.ReadCloser {
1183-
return ioutil.NopCloser(bytes.NewReader(buf))
1156+
return io.NopCloser(bytes.NewReader(buf))
11841157
}
11851158
}
11861159
var (
@@ -1244,18 +1217,6 @@ func addFile(w *multipart.Writer, fieldName, path string) error {
12441217
return err
12451218
}
12461219

1247-
// Prevent trying to import "fmt"
1248-
func reportError(format string, a ...interface{}) error {
1249-
return fmt.Errorf(format, a...)
1250-
}
1251-
1252-
// A wrapper for strict JSON decoding
1253-
func newStrictDecoder(data []byte) *json.Decoder {
1254-
dec := json.NewDecoder(bytes.NewBuffer(data))
1255-
dec.DisallowUnknownFields()
1256-
return dec
1257-
}
1258-
12591220
// Set request body from an interface{}
12601221
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
12611222
if bodyBuf == nil {
@@ -1360,10 +1321,6 @@ func CacheExpires(r *http.Response) time.Time {
13601321
return expires
13611322
}
13621323

1363-
func strlen(s string) int {
1364-
return utf8.RuneCountInString(s)
1365-
}
1366-
13671324
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
13681325
type GenericOpenAPIError struct {
13691326
body []byte
@@ -1416,7 +1373,7 @@ func tooManyRequests(resp *http.Response) bool {
14161373

14171374
func tryDrainBody(body io.ReadCloser) error {
14181375
defer body.Close()
1419-
_, err := io.Copy(ioutil.Discard, io.LimitReader(body, 4096))
1376+
_, err := io.Copy(io.Discard, io.LimitReader(body, 4096))
14201377
return err
14211378
}
14221379

@@ -1472,16 +1429,6 @@ func privateKeyToBytes(priv *rsa.PrivateKey) []byte {
14721429
return privBytes
14731430
}
14741431

1475-
func publicKeyToBytes(priv *rsa.PrivateKey) []byte {
1476-
privBytes := pem.EncodeToMemory(
1477-
&pem.Block{
1478-
Type: "RSA PUBLIC KEY",
1479-
Bytes: x509.MarshalPKCS1PublicKey(&priv.PublicKey),
1480-
},
1481-
)
1482-
return privBytes
1483-
}
1484-
14851432
type DpopClaims struct {
14861433
HTTPMethod string `json:"htm,omitempty"`
14871434
HTTPURI string `json:"htu,omitempty"`
@@ -1521,7 +1468,7 @@ func generateDpopJWT(privateKey *rsa.PrivateKey, httpMethod, URL, nonce, accessT
15211468
dpopClaims.AccessToken = base64.RawURLEncoding.EncodeToString(h.Sum(nil))
15221469
}
15231470
jwtBuilder := jwt.Signed(rsaSigner).Claims(dpopClaims)
1524-
return jwtBuilder.CompactSerialize()
1471+
return jwtBuilder.Serialize()
15251472
}
15261473

15271474
func StringToAsciiBytes(s string) []byte {

.generator/templates/configuration.mustache

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"errors"
77
"fmt"
8-
"io/ioutil"
98
"net/http"
109
"net/url"
1110
"os"
@@ -16,7 +15,7 @@ import (
1615
"strings"
1716
"syscall"
1817

19-
"github.com/go-jose/go-jose/v3"
18+
"github.com/go-jose/go-jose/v4"
2019
"github.com/kelseyhightower/envconfig"
2120
"gopkg.in/yaml.v3"
2221
)
@@ -288,7 +287,7 @@ func NewConfiguration(conf ...ConfigSetter) (*Configuration, error) {
288287
}
289288

290289
func readConfigFromFile(location string, c Configuration) (*Configuration, error) {
291-
yamlConfig, err := ioutil.ReadFile(location)
290+
yamlConfig, err := os.ReadFile(location)
292291
if err != nil {
293292
return nil, err
294293
}
@@ -591,7 +590,7 @@ func WithEncryptionType(etype string) ConfigSetter {
591590
func WithPrivateKey(privateKey string) ConfigSetter {
592591
return func(c *Configuration) {
593592
if fileExists(privateKey) {
594-
content, err := ioutil.ReadFile(privateKey)
593+
content, err := os.ReadFile(privateKey)
595594
if err != nil {
596595
fmt.Printf("failed to read from provided private key file path: %v", err)
597596
}
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}/{{versionName}}
22

3-
go 1.20
3+
go {{goVersion}}
4+
5+
toolchain {{toolchainVersion}}
46

57
require (
68
{{#withAWSV4Signature}}
79
github.com/aws/aws-sdk-go v1.34.14
810
{{/withAWSV4Signature}}
911
github.com/cenkalti/backoff/v4 v4.1.3
10-
github.com/go-jose/go-jose/v3 v3.0.3
11-
github.com/jarcoal/httpmock v1.2.0
12+
github.com/go-jose/go-jose/v4 v4.1.3
1213
github.com/kelseyhightower/envconfig v1.4.0
1314
github.com/lestrrat-go/jwx v1.2.29
1415
github.com/patrickmn/go-cache v0.0.0-20180815053127-5633e0862627
@@ -21,7 +22,8 @@ require (
2122
github.com/davecgh/go-spew v1.1.1 // indirect
2223
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
2324
github.com/goccy/go-json v0.10.2 // indirect
24-
github.com/golang/protobuf v1.4.2 // indirect
25+
github.com/golang/protobuf v1.5.0 // indirect
26+
github.com/google/go-cmp v0.5.9 // indirect
2527
github.com/google/uuid v1.6.0
2628
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
2729
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
@@ -30,8 +32,8 @@ require (
3032
github.com/lestrrat-go/option v1.0.1 // indirect
3133
github.com/pkg/errors v0.9.1 // indirect
3234
github.com/pmezard/go-difflib v1.0.0 // indirect
33-
golang.org/x/crypto v0.21.0 // indirect
34-
golang.org/x/net v0.21.0 // indirect
35+
golang.org/x/crypto v0.36.0 // indirect
36+
golang.org/x/net v0.38.0 // indirect
3537
google.golang.org/appengine v1.6.6 // indirect
36-
google.golang.org/protobuf v1.25.0 // indirect
37-
)
38+
google.golang.org/protobuf v1.33.0 // indirect
39+
)

0 commit comments

Comments
 (0)