@@ -247,7 +247,7 @@ func (config *OIDCProviderConfigToUpdate) buildRequest() (nestedMap, error) {
247247
248248// OIDCProviderConfigIterator is an iterator over OIDC provider configurations.
249249type OIDCProviderConfigIterator struct {
250- client * providerConfigClient
250+ client * baseClient
251251 ctx context.Context
252252 nextFunc func () error
253253 pageInfo * iterator.PageInfo
@@ -538,7 +538,7 @@ func (config *SAMLProviderConfigToUpdate) buildRequest() (nestedMap, error) {
538538
539539// SAMLProviderConfigIterator is an iterator over SAML provider configurations.
540540type SAMLProviderConfigIterator struct {
541- client * providerConfigClient
541+ client * baseClient
542542 ctx context.Context
543543 nextFunc func () error
544544 pageInfo * iterator.PageInfo
@@ -595,36 +595,8 @@ func (it *SAMLProviderConfigIterator) fetch(pageSize int, pageToken string) (str
595595 return result .NextPageToken , nil
596596}
597597
598- type providerConfigClient struct {
599- endpoint string
600- projectID string
601- tenantID string
602- httpClient * internal.HTTPClient
603- }
604-
605- func newProviderConfigClient (client * http.Client , conf * internal.AuthConfig ) * providerConfigClient {
606- hc := internal .WithDefaultRetryConfig (client )
607- hc .CreateErrFn = handleHTTPError
608- hc .SuccessFn = internal .HasSuccessStatus
609- hc .Opts = []internal.HTTPOption {
610- internal .WithHeader ("X-Client-Version" , fmt .Sprintf ("Go/Admin/%s" , conf .Version )),
611- }
612-
613- return & providerConfigClient {
614- endpoint : providerConfigEndpoint ,
615- projectID : conf .ProjectID ,
616- httpClient : hc ,
617- }
618- }
619-
620- func (c * providerConfigClient ) withTenantID (tenantID string ) * providerConfigClient {
621- copy := * c
622- copy .tenantID = tenantID
623- return & copy
624- }
625-
626598// OIDCProviderConfig returns the OIDCProviderConfig with the given ID.
627- func (c * providerConfigClient ) OIDCProviderConfig (ctx context.Context , id string ) (* OIDCProviderConfig , error ) {
599+ func (c * baseClient ) OIDCProviderConfig (ctx context.Context , id string ) (* OIDCProviderConfig , error ) {
628600 if err := validateOIDCConfigID (id ); err != nil {
629601 return nil , err
630602 }
@@ -642,7 +614,7 @@ func (c *providerConfigClient) OIDCProviderConfig(ctx context.Context, id string
642614}
643615
644616// CreateOIDCProviderConfig creates a new OIDC provider config from the given parameters.
645- func (c * providerConfigClient ) CreateOIDCProviderConfig (ctx context.Context , config * OIDCProviderConfigToCreate ) (* OIDCProviderConfig , error ) {
617+ func (c * baseClient ) CreateOIDCProviderConfig (ctx context.Context , config * OIDCProviderConfigToCreate ) (* OIDCProviderConfig , error ) {
646618 if config == nil {
647619 return nil , errors .New ("config must not be nil" )
648620 }
@@ -669,7 +641,7 @@ func (c *providerConfigClient) CreateOIDCProviderConfig(ctx context.Context, con
669641}
670642
671643// UpdateOIDCProviderConfig updates an existing OIDC provider config with the given parameters.
672- func (c * providerConfigClient ) UpdateOIDCProviderConfig (ctx context.Context , id string , config * OIDCProviderConfigToUpdate ) (* OIDCProviderConfig , error ) {
644+ func (c * baseClient ) UpdateOIDCProviderConfig (ctx context.Context , id string , config * OIDCProviderConfigToUpdate ) (* OIDCProviderConfig , error ) {
673645 if err := validateOIDCConfigID (id ); err != nil {
674646 return nil , err
675647 }
@@ -704,7 +676,7 @@ func (c *providerConfigClient) UpdateOIDCProviderConfig(ctx context.Context, id
704676}
705677
706678// DeleteOIDCProviderConfig deletes the OIDCProviderConfig with the given ID.
707- func (c * providerConfigClient ) DeleteOIDCProviderConfig (ctx context.Context , id string ) error {
679+ func (c * baseClient ) DeleteOIDCProviderConfig (ctx context.Context , id string ) error {
708680 if err := validateOIDCConfigID (id ); err != nil {
709681 return err
710682 }
@@ -721,7 +693,7 @@ func (c *providerConfigClient) DeleteOIDCProviderConfig(ctx context.Context, id
721693//
722694// If nextPageToken is empty, the iterator will start at the beginning. Otherwise,
723695// iterator starts after the token.
724- func (c * providerConfigClient ) OIDCProviderConfigs (ctx context.Context , nextPageToken string ) * OIDCProviderConfigIterator {
696+ func (c * baseClient ) OIDCProviderConfigs (ctx context.Context , nextPageToken string ) * OIDCProviderConfigIterator {
725697 it := & OIDCProviderConfigIterator {
726698 ctx : ctx ,
727699 client : c ,
@@ -736,7 +708,7 @@ func (c *providerConfigClient) OIDCProviderConfigs(ctx context.Context, nextPage
736708}
737709
738710// SAMLProviderConfig returns the SAMLProviderConfig with the given ID.
739- func (c * providerConfigClient ) SAMLProviderConfig (ctx context.Context , id string ) (* SAMLProviderConfig , error ) {
711+ func (c * baseClient ) SAMLProviderConfig (ctx context.Context , id string ) (* SAMLProviderConfig , error ) {
740712 if err := validateSAMLConfigID (id ); err != nil {
741713 return nil , err
742714 }
@@ -754,7 +726,7 @@ func (c *providerConfigClient) SAMLProviderConfig(ctx context.Context, id string
754726}
755727
756728// CreateSAMLProviderConfig creates a new SAML provider config from the given parameters.
757- func (c * providerConfigClient ) CreateSAMLProviderConfig (ctx context.Context , config * SAMLProviderConfigToCreate ) (* SAMLProviderConfig , error ) {
729+ func (c * baseClient ) CreateSAMLProviderConfig (ctx context.Context , config * SAMLProviderConfigToCreate ) (* SAMLProviderConfig , error ) {
758730 if config == nil {
759731 return nil , errors .New ("config must not be nil" )
760732 }
@@ -781,7 +753,7 @@ func (c *providerConfigClient) CreateSAMLProviderConfig(ctx context.Context, con
781753}
782754
783755// UpdateSAMLProviderConfig updates an existing SAML provider config with the given parameters.
784- func (c * providerConfigClient ) UpdateSAMLProviderConfig (ctx context.Context , id string , config * SAMLProviderConfigToUpdate ) (* SAMLProviderConfig , error ) {
756+ func (c * baseClient ) UpdateSAMLProviderConfig (ctx context.Context , id string , config * SAMLProviderConfigToUpdate ) (* SAMLProviderConfig , error ) {
785757 if err := validateSAMLConfigID (id ); err != nil {
786758 return nil , err
787759 }
@@ -816,7 +788,7 @@ func (c *providerConfigClient) UpdateSAMLProviderConfig(ctx context.Context, id
816788}
817789
818790// DeleteSAMLProviderConfig deletes the SAMLProviderConfig with the given ID.
819- func (c * providerConfigClient ) DeleteSAMLProviderConfig (ctx context.Context , id string ) error {
791+ func (c * baseClient ) DeleteSAMLProviderConfig (ctx context.Context , id string ) error {
820792 if err := validateSAMLConfigID (id ); err != nil {
821793 return err
822794 }
@@ -833,7 +805,7 @@ func (c *providerConfigClient) DeleteSAMLProviderConfig(ctx context.Context, id
833805//
834806// If nextPageToken is empty, the iterator will start at the beginning. Otherwise,
835807// iterator starts after the token.
836- func (c * providerConfigClient ) SAMLProviderConfigs (ctx context.Context , nextPageToken string ) * SAMLProviderConfigIterator {
808+ func (c * baseClient ) SAMLProviderConfigs (ctx context.Context , nextPageToken string ) * SAMLProviderConfigIterator {
837809 it := & SAMLProviderConfigIterator {
838810 ctx : ctx ,
839811 client : c ,
@@ -847,15 +819,17 @@ func (c *providerConfigClient) SAMLProviderConfigs(ctx context.Context, nextPage
847819 return it
848820}
849821
850- func (c * providerConfigClient ) makeRequest (ctx context.Context , req * internal.Request , v interface {}) (* internal.Response , error ) {
822+ func (c * baseClient ) makeRequest (
823+ ctx context.Context , req * internal.Request , v interface {}) (* internal.Response , error ) {
824+
851825 if c .projectID == "" {
852826 return nil , errors .New ("project id not available" )
853827 }
854828
855829 if c .tenantID != "" {
856- req .URL = fmt .Sprintf ("%s/projects/%s/tenants/%s%s" , c .endpoint , c .projectID , c .tenantID , req .URL )
830+ req .URL = fmt .Sprintf ("%s/projects/%s/tenants/%s%s" , c .providerConfigEndpoint , c .projectID , c .tenantID , req .URL )
857831 } else {
858- req .URL = fmt .Sprintf ("%s/projects/%s%s" , c .endpoint , c .projectID , req .URL )
832+ req .URL = fmt .Sprintf ("%s/projects/%s%s" , c .providerConfigEndpoint , c .projectID , req .URL )
859833 }
860834
861835 return c .httpClient .DoAndUnmarshal (ctx , req , v )
0 commit comments