@@ -247,7 +247,7 @@ func (config *OIDCProviderConfigToUpdate) buildRequest() (nestedMap, error) {
247
247
248
248
// OIDCProviderConfigIterator is an iterator over OIDC provider configurations.
249
249
type OIDCProviderConfigIterator struct {
250
- client * providerConfigClient
250
+ client * baseClient
251
251
ctx context.Context
252
252
nextFunc func () error
253
253
pageInfo * iterator.PageInfo
@@ -538,7 +538,7 @@ func (config *SAMLProviderConfigToUpdate) buildRequest() (nestedMap, error) {
538
538
539
539
// SAMLProviderConfigIterator is an iterator over SAML provider configurations.
540
540
type SAMLProviderConfigIterator struct {
541
- client * providerConfigClient
541
+ client * baseClient
542
542
ctx context.Context
543
543
nextFunc func () error
544
544
pageInfo * iterator.PageInfo
@@ -595,36 +595,8 @@ func (it *SAMLProviderConfigIterator) fetch(pageSize int, pageToken string) (str
595
595
return result .NextPageToken , nil
596
596
}
597
597
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
-
626
598
// 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 ) {
628
600
if err := validateOIDCConfigID (id ); err != nil {
629
601
return nil , err
630
602
}
@@ -642,7 +614,7 @@ func (c *providerConfigClient) OIDCProviderConfig(ctx context.Context, id string
642
614
}
643
615
644
616
// 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 ) {
646
618
if config == nil {
647
619
return nil , errors .New ("config must not be nil" )
648
620
}
@@ -669,7 +641,7 @@ func (c *providerConfigClient) CreateOIDCProviderConfig(ctx context.Context, con
669
641
}
670
642
671
643
// 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 ) {
673
645
if err := validateOIDCConfigID (id ); err != nil {
674
646
return nil , err
675
647
}
@@ -704,7 +676,7 @@ func (c *providerConfigClient) UpdateOIDCProviderConfig(ctx context.Context, id
704
676
}
705
677
706
678
// 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 {
708
680
if err := validateOIDCConfigID (id ); err != nil {
709
681
return err
710
682
}
@@ -721,7 +693,7 @@ func (c *providerConfigClient) DeleteOIDCProviderConfig(ctx context.Context, id
721
693
//
722
694
// If nextPageToken is empty, the iterator will start at the beginning. Otherwise,
723
695
// 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 {
725
697
it := & OIDCProviderConfigIterator {
726
698
ctx : ctx ,
727
699
client : c ,
@@ -736,7 +708,7 @@ func (c *providerConfigClient) OIDCProviderConfigs(ctx context.Context, nextPage
736
708
}
737
709
738
710
// 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 ) {
740
712
if err := validateSAMLConfigID (id ); err != nil {
741
713
return nil , err
742
714
}
@@ -754,7 +726,7 @@ func (c *providerConfigClient) SAMLProviderConfig(ctx context.Context, id string
754
726
}
755
727
756
728
// 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 ) {
758
730
if config == nil {
759
731
return nil , errors .New ("config must not be nil" )
760
732
}
@@ -781,7 +753,7 @@ func (c *providerConfigClient) CreateSAMLProviderConfig(ctx context.Context, con
781
753
}
782
754
783
755
// 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 ) {
785
757
if err := validateSAMLConfigID (id ); err != nil {
786
758
return nil , err
787
759
}
@@ -816,7 +788,7 @@ func (c *providerConfigClient) UpdateSAMLProviderConfig(ctx context.Context, id
816
788
}
817
789
818
790
// 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 {
820
792
if err := validateSAMLConfigID (id ); err != nil {
821
793
return err
822
794
}
@@ -833,7 +805,7 @@ func (c *providerConfigClient) DeleteSAMLProviderConfig(ctx context.Context, id
833
805
//
834
806
// If nextPageToken is empty, the iterator will start at the beginning. Otherwise,
835
807
// 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 {
837
809
it := & SAMLProviderConfigIterator {
838
810
ctx : ctx ,
839
811
client : c ,
@@ -847,15 +819,17 @@ func (c *providerConfigClient) SAMLProviderConfigs(ctx context.Context, nextPage
847
819
return it
848
820
}
849
821
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
+
851
825
if c .projectID == "" {
852
826
return nil , errors .New ("project id not available" )
853
827
}
854
828
855
829
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 )
857
831
} 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 )
859
833
}
860
834
861
835
return c .httpClient .DoAndUnmarshal (ctx , req , v )
0 commit comments