Debian Codegraph @

scw/client_option.go

raw symbols SCIP
1 package scwscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/
2
3 import (
4 "net/httpscip-go gomod github.com/golang/go/src go1.17 `net/http`/"
5 "stringsscip-go gomod github.com/golang/go/src go1.17 strings/"
6
7 "github.com/scaleway/scaleway-sdk-go/errorsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/errors`/"
8 "github.com/scaleway/scaleway-sdk-go/internal/authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/"
9 "github.com/scaleway/scaleway-sdk-go/validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/"
10 )
11
12 // ClientOption is a function which applies options to a settings object.
13 type ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# func(*settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#)
14
15 // httpClient wraps the net/http Client Do method
16 type httpClientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/httpClient# interface {
17 Doscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/httpClient#Do.(*httpscip-go gomod github.com/golang/go/src go1.17 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.17 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.17 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.17 `net/http`/Response#, error)
18 }
19
20 // WithHTTPClient client option allows passing a custom http.Client which will be used for all requests.
21 func WithHTTPClientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithHTTPClient().(httpClient httpClientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/httpClient#) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
22 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
23 s.httpClientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#httpClient. = httpClient
24 }
25 }
26
27 // WithoutAuth client option sets the client token to an empty token.
28 func WithoutAuthscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithoutAuth().() ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
29 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
30 s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. = authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.NewNoAuthscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/NewNoAuth().()
31 }
32 }
33
34 // WithAuth client option sets the client access key and secret key.
35 func WithAuthscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithAuth().(accessKey, secretKey string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
36 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
37 s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. = authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.NewTokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/NewToken().(accessKey, secretKey)
38 }
39 }
40
41 // WithJWT client option sets the client session token.
42 func WithJWTscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithJWT().(token string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
43 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
44 s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. = authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.NewJWTscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/NewJWT().(token)
45 }
46 }
47
48 // WithAPIURL client option overrides the API URL of the Scaleway API to the given URL.
49 func WithAPIURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithAPIURL().(apiURL string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
50 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
51 s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL. = apiURL
52 }
53 }
54
55 // WithInsecure client option enables insecure transport on the client.
56 func WithInsecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithInsecure().() ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
57 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
58 s.insecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#insecure. = true
59 }
60 }
61
62 // WithUserAgent client option append a user agent to the default user agent of the SDK.
63 func WithUserAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithUserAgent().(ua string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
64 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
65 if s.userAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#userAgent. != "" && ua != "" {
66 s.userAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#userAgent. += " "
67 }
68 s.userAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#userAgent. += ua
69 }
70 }
71
72 // withDefaultUserAgent client option overrides the default user agent of the SDK.
73 func withDefaultUserAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/withDefaultUserAgent().(ua string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
74 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
75 s.userAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#userAgent. = ua
76 }
77 }
78
79 // WithProfile client option configures a client from the given profile.
80 func WithProfilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithProfile().(p *Profilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
81 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
82 accessKey := ""
83 if p.AccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#AccessKey. != nil {
84 accessKey = *p.AccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#AccessKey.
85 s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. = authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.NewAccessKeyOnlyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/NewAccessKeyOnly().(accessKey)
86 }
87
88 if p.SecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#SecretKey. != nil {
89 s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. = authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.NewTokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/NewToken().(accessKey, *p.SecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#SecretKey.)
90 }
91
92 if p.APIURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#APIURL. != nil {
93 s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL. = *p.APIURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#APIURL.
94 }
95
96 if p.Insecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#Insecure. != nil {
97 s.insecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#insecure. = *p.Insecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#Insecure.
98 }
99
100 if p.DefaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultOrganizationID. != nil {
101 organizationID := *p.DefaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultOrganizationID.
102 s.defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID. = &organizationID
103 }
104
105 if p.DefaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultProjectID. != nil {
106 projectID := *p.DefaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultProjectID.
107 s.defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID. = &projectID
108 }
109
110 if p.DefaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultRegion. != nil {
111 defaultRegion := Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#(*p.DefaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultRegion.)
112 s.defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion. = &defaultRegion
113 }
114
115 if p.DefaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultZone. != nil {
116 defaultZone := Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Zone#(*p.DefaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Profile#DefaultZone.)
117 s.defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone. = &defaultZone
118 }
119 }
120 }
121
122 // WithEnv client option configures a client from the environment variables.
123 func WithEnvscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithEnv().() ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
124 return WithProfilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithProfile().(LoadEnvProfilescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/LoadEnvProfile().())
125 }
126
127 // WithDefaultOrganizationID client option sets the client default organization ID.
128 //
129 // It will be used as the default value of the organization_id field in all requests made with this client.
130 func WithDefaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithDefaultOrganizationID().(organizationID string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
131 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
132 s.defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID. = &organizationID
133 }
134 }
135
136 // WithDefaultProjectID client option sets the client default project ID.
137 //
138 // It will be used as the default value of the projectID field in all requests made with this client.
139 func WithDefaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithDefaultProjectID().(projectID string) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
140 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
141 s.defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID. = &projectID
142 }
143 }
144
145 // WithDefaultRegion client option sets the client default region.
146 //
147 // It will be used as the default value of the region field in all requests made with this client.
148 func WithDefaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithDefaultRegion().(region Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
149 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
150 s.defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion. = &region
151 }
152 }
153
154 // WithDefaultZone client option sets the client default zone.
155 //
156 // It will be used as the default value of the zone field in all requests made with this client.
157 func WithDefaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithDefaultZone().(zone Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Zone#) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
158 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
159 s.defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone. = &zone
160 }
161 }
162
163 // WithDefaultPageSize client option overrides the default page size of the SDK.
164 //
165 // It will be used as the default value of the page_size field in all requests made with this client.
166 func WithDefaultPageSizescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/WithDefaultPageSize().(pageSize uint32) ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption# {
167 return func(s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) {
168 s.defaultPageSizescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultPageSize. = &pageSize
169 }
170 }
171
172 // settings hold the values of all client options
173 type settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings# struct {
174 apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL. string
175 tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.Authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Auth#
176 userAgentscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#userAgent. string
177 httpClientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#httpClient. httpClientscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/httpClient#
178 insecurescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#insecure. bool
179 defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID. *string
180 defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID. *string
181 defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion. *Regionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Region#
182 defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone. *Zonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/Zone#
183 defaultPageSizescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultPageSize. *uint32
184 }
185
186 func newSettingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/newSettings().() *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings# {
187 return &settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#{}
188 }
189
190 func (s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) applyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apply().(opts []ClientOptionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/ClientOption#) {
191 for _, opt := range opts {
192 opt(s)
193 }
194 }
195
196 func (s *settingsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#) validatescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#validate().() error {
197 // Auth.
198 if s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token. == nil {
199 // It should not happen, WithoutAuth option is used by default.
200 panic(errorsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/errors`/.Newscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/errors`/New().("no credential option provided"))
201 }
202 if token, isToken := s.tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#token..(*authscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/.Tokenscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#); isToken {
203 if token.AccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#AccessKey. == "" {
204 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("access key cannot be empty")
205 }
206 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsAccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsAccessKey().(token.AccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#AccessKey.) {
207 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid access key format '%s', expected SCWXXXXXXXXXXXXXXXXX format", token.AccessKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#AccessKey.)
208 }
209 if token.SecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#SecretKey. == "" {
210 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("secret key cannot be empty")
211 }
212 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsSecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsSecretKey().(token.SecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#SecretKey.) {
213 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid secret key format '%s', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", token.SecretKeyscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/internal/auth`/Token#SecretKey.)
214 }
215 }
216
217 // Default Organization ID.
218 if s.defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID. != nil {
219 if *s.defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID. == "" {
220 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("default organization ID cannot be empty")
221 }
222 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsOrganizationID().(*s.defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID.) {
223 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid organization ID format '%s', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", *s.defaultOrganizationIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultOrganizationID.)
224 }
225 }
226
227 // Default Project ID.
228 if s.defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID. != nil {
229 if *s.defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID. == "" {
230 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("default project ID cannot be empty")
231 }
232 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsProjectID().(*s.defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID.) {
233 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid project ID format '%s', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", *s.defaultProjectIDscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultProjectID.)
234 }
235 }
236
237 // Default Region.
238 if s.defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion. != nil {
239 if *s.defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion. == "" {
240 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("default region cannot be empty")
241 }
242 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsRegion().(string(*s.defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion.)) {
243 regions := []string(nil)
244 for _, r := range AllRegionsscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/AllRegions. {
245 regions = append(regions, string(r))
246 }
247 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid default region format '%s', available regions are: %s", *s.defaultRegionscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultRegion., stringsscip-go gomod github.com/golang/go/src go1.17 strings/.Joinscip-go gomod github.com/golang/go/src go1.17 strings/Join().(regions, ", "))
248 }
249 }
250
251 // Default Zone.
252 if s.defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone. != nil {
253 if *s.defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone. == "" {
254 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("default zone cannot be empty")
255 }
256 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsZone().(string(*s.defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone.)) {
257 zones := []string(nil)
258 for _, z := range AllZonesscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/AllZones. {
259 zones = append(zones, string(z))
260 }
261 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid default zone format '%s', available zones are: %s", *s.defaultZonescip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#defaultZone., stringsscip-go gomod github.com/golang/go/src go1.17 strings/.Joinscip-go gomod github.com/golang/go/src go1.17 strings/Join().(zones, ", "))
262 }
263 }
264
265 // API URL.
266 if !validationscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/.IsURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/validation`/IsURL().(s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL.) {
267 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid url %s", s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL.)
268 }
269 if s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL.[len(s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL.)-1:] == "/" {
270 return NewInvalidClientOptionErrorscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/NewInvalidClientOptionError().("invalid url %s it should not have a trailing slash", s.apiURLscip-go gomod github.com/scaleway/scaleway-sdk-go . `github.com/scaleway/scaleway-sdk-go/scw`/settings#apiURL.)
271 }
272
273 // TODO: check for max s.defaultPageSize
274
275 return nil
276 }