@@ -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
531531func 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.
696692func 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.
740722func 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.
773746func (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,
11751148func (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{ }
12601221func 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.
13681325type GenericOpenAPIError struct {
13691326 body []byte
@@ -1416,7 +1373,7 @@ func tooManyRequests(resp *http.Response) bool {
14161373
14171374func 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-
14851432type 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
15271474func StringToAsciiBytes(s string) []byte {
0 commit comments