diff --git a/CHANGELOG.md b/CHANGELOG.md index b78912bb..d3ab74fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- New api_oidc_config resource allows users to configure an external JWT signer for API tokens. +JWT API tokens are in [limited access](https://www.cockroachlabs.com/docs/v23.1/cockroachdb-feature-availability). + ## [1.1.0] - 2023-08-15 ### Added diff --git a/docs/resources/api_oidc_config.md b/docs/resources/api_oidc_config.md new file mode 100644 index 00000000..60ca611f --- /dev/null +++ b/docs/resources/api_oidc_config.md @@ -0,0 +1,30 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "cockroach_api_oidc_config Resource - terraform-provider-cockroach" +subcategory: "" +description: |- + Configuration to allow external OIDC providers to issue tokens for use with CC API. +--- + +# cockroach_api_oidc_config (Resource) + +Configuration to allow external OIDC providers to issue tokens for use with CC API. + + + + +## Schema + +### Required + +- `audience` (String) The audience that CC API should accept for this API OIDC Configuration. +- `claim` (String) The JWT claim that should be used as the user identifier. Defaults to the subject if an empty string is provided. +- `identity_map` (String) The mapping rules to convert token user identifiers into a new form. +- `issuer` (String) The issuer of tokens for the API OIDC Configuration. Usually this is a url. +- `jwks` (String) The JSON Web Key Set used to check the signature of the JWTs. + +### Read-Only + +- `id` (String) ID of the API OIDC Configuration. Required by Terraform. + + diff --git a/examples/resources/cockroach_api_oidc_config/cockroach_api_oidc_config.tf b/examples/resources/cockroach_api_oidc_config/cockroach_api_oidc_config.tf new file mode 100644 index 00000000..200e7b98 --- /dev/null +++ b/examples/resources/cockroach_api_oidc_config/cockroach_api_oidc_config.tf @@ -0,0 +1,7 @@ +resource "cockroach_api_oidc_config" "example" { + issuer = "https://accounts.google.com" + audience = "test_audience" + jwks = "{\"keys\":[{\"alg\":\"RS256\",\"e\":\"AQAB\",\"kid\":\"test_kid1\",\"kty\":\"RSA\",\"n\":\"09lq1lCEuteonwDJOhGTDak11ThplZuC9JEWQNdBnBSQwlkJQIE7A7nTBO0xTibcsh2HwYkC-N_Gs1jP4iwN3dRqnu5FwG2ct5mY8KLwJiHzToFC0MKenSFQCy0FviNtOnpiObcUlDvR2NDeNtMl_6SPzcQEt7GUTBBYZgoAxPmOgevki6ZNO6Y86xFqx3y6v8EPwW010AiC60r4AHGCTBhYF4uqmq5JH2UU4dDh9Udc-9LZxlSqPwJvnKDG2GjcnD8TsU3wjfEM_nRmx3dnXsrZUXYfNGtdv5dlHywf5AhkJmTavqcsJkgrNA-PNBghFMcCR816_kCIkCYWLWC5vQ\"}]}" + claim = "sub" + identity_map = "token_username cc_username \n /(.*) \\1@example.com" +} diff --git a/go.mod b/go.mod index e05ca025..f2e660b0 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/cockroachdb/terraform-provider-cockroach go 1.18 require ( - github.com/cockroachdb/cockroach-cloud-sdk-go v1.4.0 + github.com/cockroachdb/cockroach-cloud-sdk-go v1.5.0 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/hashicorp/go-retryablehttp v0.7.4 diff --git a/go.sum b/go.sum index 1373481f..bbbdcf67 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cockroachdb/cockroach-cloud-sdk-go v1.4.0 h1:VLXNL7oYG5ySlPWaUlucHdiFTCCSViVobrC1b9Tg5Mg= -github.com/cockroachdb/cockroach-cloud-sdk-go v1.4.0/go.mod h1:oG9ylbcVGOF7IbVAW2nx5F6ry9a2dZD1H9rd+qd4P60= +github.com/cockroachdb/cockroach-cloud-sdk-go v1.5.0 h1:lrCbcOaUIpehAa4IsZhPtbZwfM/6s9K/GvN24+wDPvM= +github.com/cockroachdb/cockroach-cloud-sdk-go v1.5.0/go.mod h1:oG9ylbcVGOF7IbVAW2nx5F6ry9a2dZD1H9rd+qd4P60= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -274,8 +274,6 @@ golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/provider/api_oidc_config.go b/internal/provider/api_oidc_config.go new file mode 100644 index 00000000..7dad1666 --- /dev/null +++ b/internal/provider/api_oidc_config.go @@ -0,0 +1,248 @@ +/* +Copyright 2023 The Cockroach Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package provider + +import ( + "context" + "fmt" + "github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "net/http" +) + +type apiOidcConfigResource struct { + provider *provider +} + +func (r *apiOidcConfigResource) Schema( + _ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse, +) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Configuration to allow external OIDC providers to issue tokens for use with CC API.", + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: "ID of the API OIDC Configuration.", + }, + "issuer": schema.StringAttribute{ + Required: true, + Description: "The issuer of tokens for the API OIDC Configuration. Usually this is a url.", + }, + "audience": schema.StringAttribute{ + Required: true, + Description: "The audience that CC API should accept for this API OIDC Configuration.", + }, + "jwks": schema.StringAttribute{ + Required: true, + Description: "The JSON Web Key Set used to check the signature of the JWTs.", + }, + "claim": schema.StringAttribute{ + Optional: true, + Computed: true, + Description: "The JWT claim that should be used as the user identifier. Defaults to the subject if an empty string is provided.", + }, + "identity_map": schema.StringAttribute{ + Optional: true, + Computed: true, + Description: "The mapping rules to convert token user identifiers into a new form.", + }, + }, + } +} + +func (r *apiOidcConfigResource) Metadata( + _ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse, +) { + resp.TypeName = req.ProviderTypeName + "_api_oidc_config" +} + +func (r *apiOidcConfigResource) Configure( + _ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse, +) { + if req.ProviderData == nil { + return + } + var ok bool + if r.provider, ok = req.ProviderData.(*provider); !ok { + resp.Diagnostics.AddError("Internal provider error", + fmt.Sprintf("Error in Configure: expected %T but got %T", provider{}, req.ProviderData)) + } +} + +func (r *apiOidcConfigResource) Create( + ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse, +) { + if r.provider == nil || !r.provider.configured { + addConfigureProviderErr(&resp.Diagnostics) + return + } + + var apiOIdcConfigSpec ApiOidcConfig + diags := req.Plan.Get(ctx, &apiOIdcConfigSpec) + resp.Diagnostics.Append(diags...) + + if resp.Diagnostics.HasError() { + return + } + + createRequest := &client.CreateApiOidcConfigRequest{ + Audience: apiOIdcConfigSpec.Audience.ValueString(), + Issuer: apiOIdcConfigSpec.Issuer.ValueString(), + Jwks: apiOIdcConfigSpec.Jwks.ValueString(), + Claim: apiOIdcConfigSpec.Claim.ValueStringPointer(), + IdentityMap: apiOIdcConfigSpec.IdentityMap.ValueStringPointer(), + } + + apiResp, _, err := r.provider.service.CreateApiOidcConfig(ctx, createRequest) + if err != nil { + resp.Diagnostics.AddError( + "Error creating API OIDC Config", + fmt.Sprintf("Could not create API OIDC Config: %s", formatAPIErrorMessage(err)), + ) + return + } + + loadApiOidcConfigToTerraformState(apiResp, &apiOIdcConfigSpec) + diags = resp.State.Set(ctx, apiOIdcConfigSpec) + resp.Diagnostics.Append(diags...) +} + +func (r *apiOidcConfigResource) Read( + ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse, +) { + if r.provider == nil || !r.provider.configured { + addConfigureProviderErr(&resp.Diagnostics) + return + } + + var state ApiOidcConfig + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + apiResp, httpResp, err := r.provider.service.GetApiOidcConfig(ctx, state.ID.ValueString()) + if err != nil { + if httpResp != nil && httpResp.StatusCode == http.StatusNotFound { + resp.Diagnostics.AddWarning( + "API OIDC Config not found", + "API OIDC Config not found. API OIDC Config will be removed from state.") + resp.State.RemoveResource(ctx) + } else { + resp.Diagnostics.AddError( + "Error getting API OIDC Config", + fmt.Sprintf("Unexpected error retrieving API OIDC Config: %s", formatAPIErrorMessage(err))) + } + return + } + + loadApiOidcConfigToTerraformState(apiResp, &state) + + diags = resp.State.Set(ctx, state) + resp.Diagnostics.Append(diags...) +} + +func (r *apiOidcConfigResource) Update( + ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse, +) { + var plan ApiOidcConfig + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + // Get current state + var state ApiOidcConfig + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + apiResp, _, err := r.provider.service.UpdateApiOidcConfig(ctx, plan.ID.ValueString(), &client.ApiOidcConfig1{ + Audience: plan.Audience.ValueString(), + Claim: plan.Claim.ValueStringPointer(), + IdentityMap: plan.IdentityMap.ValueStringPointer(), + Issuer: plan.Issuer.ValueString(), + Jwks: plan.Jwks.ValueString(), + }) + if err != nil { + resp.Diagnostics.AddError( + "Error update API OIDC Config", + fmt.Sprintf("Could not update API OIDC Config: %s", formatAPIErrorMessage(err)), + ) + return + } + + loadApiOidcConfigToTerraformState(apiResp, &state) + diags = resp.State.Set(ctx, state) + resp.Diagnostics.Append(diags...) +} + +func (r *apiOidcConfigResource) Delete( + ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse, +) { + var state ApiOidcConfig + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + _, _, err := r.provider.service.DeleteApiOidcConfig(ctx, state.ID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error deleting API OIDC Config", + fmt.Sprintf("Could not delete API OIDC Config: %s", formatAPIErrorMessage(err)), + ) + return + } + + // Remove resource from state + resp.State.RemoveResource(ctx) +} + +func (r *apiOidcConfigResource) ImportState( + ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, +) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +func NewApiOidcConfigResource() resource.Resource { + return &apiOidcConfigResource{} +} + +func loadApiOidcConfigToTerraformState( + apiOidcConfig *client.ApiOidcConfig, state *ApiOidcConfig, +) { + state.ID = types.StringValue(apiOidcConfig.Id) + state.Audience = types.StringValue(apiOidcConfig.Audience) + state.Issuer = types.StringValue(apiOidcConfig.Issuer) + state.Jwks = types.StringValue(apiOidcConfig.Jwks) + state.Claim = types.StringPointerValue(apiOidcConfig.Claim) + state.IdentityMap = types.StringPointerValue(apiOidcConfig.IdentityMap) +} diff --git a/internal/provider/api_oidc_config_test.go b/internal/provider/api_oidc_config_test.go new file mode 100644 index 00000000..3f481616 --- /dev/null +++ b/internal/provider/api_oidc_config_test.go @@ -0,0 +1,151 @@ +/* + Copyright 2023 The Cockroach Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package provider + +import ( + "context" + "fmt" + "github.com/google/uuid" + "os" + "testing" + + "github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client" + mock_client "github.com/cockroachdb/terraform-provider-cockroach/mock" + "github.com/golang/mock/gomock" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +// TestAccApiOIdcConfigResource attempts to create, check, and destroy +// a real API OIDC Config. It will be skipped if TF_ACC isn't set. +// In order to work the ApiOidcEnabled Feature Flag must be enabled and +// the test org must have Org SSO enabled (no need for SAML/OIDC). +func TestAccApiOIdcConfigResource(t *testing.T) { + t.Parallel() + issuer := fmt.Sprintf("issuer-%s", GenerateRandomString(4)) + audience := "audience" + jwks := "{}" + claim := "subject" + identityMap := "foo bar" + + testApiOidcConfigResource(t, issuer, audience, jwks, claim, identityMap, false) +} + +// TestIntegrationApiOIdcConfigResource attempts to create, check, and destroy +// an API OIDC Config, but uses a mocked API service. +func TestIntegrationApiOIdcConfigResource(t *testing.T) { + id := uuid.Must(uuid.NewUUID()) + if os.Getenv(CockroachAPIKey) == "" { + os.Setenv(CockroachAPIKey, "fake") + } + + ctrl := gomock.NewController(t) + s := mock_client.NewMockService(ctrl) + defer HookGlobal(&NewService, func(c *client.Client) client.Service { + return s + })() + issuer := "issuer" + audience := "audience" + claim := "claim" + jwks := "{}" + identityMap := "from to" + response := client.ApiOidcConfig{ + Id: id.String(), + Issuer: issuer, + Audience: audience, + Jwks: jwks, + Claim: &claim, + IdentityMap: &identityMap, + } + + s.EXPECT().GetApiOidcConfig(gomock.Any(), id.String()). + Return(&response, nil, nil).AnyTimes() + s.EXPECT().CreateApiOidcConfig(gomock.Any(), gomock.Any()). + Return(&response, nil, nil) + s.EXPECT().DeleteApiOidcConfig(gomock.Any(), id.String()). + Return(&response, nil, nil) + + testApiOidcConfigResource(t, issuer, audience, jwks, claim, identityMap, true) +} + +func testApiOidcConfigResource(t *testing.T, issuer, audience, jwks, claim, identityMap string, useMock bool) { + var ( + resourceNameTest = "cockroach_api_oidc_config.test" + ) + resource.Test(t, resource.TestCase{ + IsUnitTest: useMock, + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: getTestApiOidcConfig(issuer, audience, jwks, claim, identityMap), + Check: resource.ComposeTestCheckFunc( + testApiOidcConfig(resourceNameTest, issuer, audience, jwks, claim, identityMap), + resource.TestCheckResourceAttr(resourceNameTest, "issuer", issuer), + resource.TestCheckResourceAttr(resourceNameTest, "audience", audience), + resource.TestCheckResourceAttr(resourceNameTest, "jwks", jwks), + resource.TestCheckResourceAttr(resourceNameTest, "claim", claim), + resource.TestCheckResourceAttr(resourceNameTest, "identity_map", identityMap), + ), + }, + { + ResourceName: resourceNameTest, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testApiOidcConfig( + resourceName, issuer, audience, jwks, claim, identityMap string, +) resource.TestCheckFunc { + return func(s *terraform.State) error { + p := testAccProvider.(*provider) + p.service = NewService(cl) + + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("no ID is set") + } + + roleResp, _, err := p.service.GetApiOidcConfig(context.TODO(), rs.Primary.ID) + if err == nil { + if roleResp.Issuer == issuer && roleResp.Audience == audience && roleResp.Jwks == jwks && *roleResp.Claim == claim && *roleResp.IdentityMap == identityMap { + return nil + } + } + + return fmt.Errorf("API OIDC Config does not have correct values") + } +} + +func getTestApiOidcConfig(issuer, audience, jwks, claim, identityMap string) string { + return fmt.Sprintf(` +resource "cockroach_api_oidc_config" "test" { + issuer = "%s" + audience = "%s" + jwks = "%s" + claim = "%s" + identity_map = "%s" +} +`, issuer, audience, jwks, claim, identityMap) +} diff --git a/internal/provider/models.go b/internal/provider/models.go index 866594f9..2bca1bd1 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -271,6 +271,15 @@ type Folder struct { ParentId types.String `tfsdk:"parent_id"` } +type ApiOidcConfig struct { + ID types.String `tfsdk:"id"` + Issuer types.String `tfsdk:"issuer"` + Audience types.String `tfsdk:"audience"` + Jwks types.String `tfsdk:"jwks"` + Claim types.String `tfsdk:"claim"` + IdentityMap types.String `tfsdk:"identity_map"` +} + func (e *APIErrorMessage) String() string { return fmt.Sprintf("%v-%v", e.Code, e.Message) } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index c721f39d..07f8dddf 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -131,6 +131,7 @@ func (p *provider) Resources(_ context.Context) []func() resource.Resource { NewMaintenanceWindowResource, NewVersionDeferralResource, NewFolderResource, + NewApiOidcConfigResource, } } diff --git a/mock/service.go b/mock/service.go index 47df5d84..f85060ca 100644 --- a/mock/service.go +++ b/mock/service.go @@ -100,6 +100,22 @@ func (mr *MockServiceMockRecorder) AddUserToRole(arg0, arg1, arg2, arg3, arg4 in return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddUserToRole", reflect.TypeOf((*MockService)(nil).AddUserToRole), arg0, arg1, arg2, arg3, arg4) } +// CreateApiOidcConfig mocks base method. +func (m *MockService) CreateApiOidcConfig(arg0 context.Context, arg1 *client.CreateApiOidcConfigRequest) (*client.ApiOidcConfig, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateApiOidcConfig", arg0, arg1) + ret0, _ := ret[0].(*client.ApiOidcConfig) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// CreateApiOidcConfig indicates an expected call of CreateApiOidcConfig. +func (mr *MockServiceMockRecorder) CreateApiOidcConfig(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateApiOidcConfig", reflect.TypeOf((*MockService)(nil).CreateApiOidcConfig), arg0, arg1) +} + // CreateCluster mocks base method. func (m *MockService) CreateCluster(arg0 context.Context, arg1 *client.CreateClusterRequest) (*client.Cluster, *http.Response, error) { m.ctrl.T.Helper() @@ -228,6 +244,22 @@ func (mr *MockServiceMockRecorder) DeleteAllowlistEntry(arg0, arg1, arg2, arg3 i return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllowlistEntry", reflect.TypeOf((*MockService)(nil).DeleteAllowlistEntry), arg0, arg1, arg2, arg3) } +// DeleteApiOidcConfig mocks base method. +func (m *MockService) DeleteApiOidcConfig(arg0 context.Context, arg1 string) (*client.ApiOidcConfig, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteApiOidcConfig", arg0, arg1) + ret0, _ := ret[0].(*client.ApiOidcConfig) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// DeleteApiOidcConfig indicates an expected call of DeleteApiOidcConfig. +func (mr *MockServiceMockRecorder) DeleteApiOidcConfig(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteApiOidcConfig", reflect.TypeOf((*MockService)(nil).DeleteApiOidcConfig), arg0, arg1) +} + // DeleteClientCACert mocks base method. func (m *MockService) DeleteClientCACert(arg0 context.Context, arg1 string) (*client.ClientCACertInfo, *http.Response, error) { m.ctrl.T.Helper() @@ -545,6 +577,22 @@ func (mr *MockServiceMockRecorder) GetAllRolesForUser(arg0, arg1 interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllRolesForUser", reflect.TypeOf((*MockService)(nil).GetAllRolesForUser), arg0, arg1) } +// GetApiOidcConfig mocks base method. +func (m *MockService) GetApiOidcConfig(arg0 context.Context, arg1 string) (*client.ApiOidcConfig, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetApiOidcConfig", arg0, arg1) + ret0, _ := ret[0].(*client.ApiOidcConfig) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetApiOidcConfig indicates an expected call of GetApiOidcConfig. +func (mr *MockServiceMockRecorder) GetApiOidcConfig(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetApiOidcConfig", reflect.TypeOf((*MockService)(nil).GetApiOidcConfig), arg0, arg1) +} + // GetCMEKClusterInfo mocks base method. func (m *MockService) GetCMEKClusterInfo(arg0 context.Context, arg1 string) (*client.CMEKClusterInfo, *http.Response, error) { m.ctrl.T.Helper() @@ -993,6 +1041,22 @@ func (mr *MockServiceMockRecorder) ListAllowlistEntries(arg0, arg1, arg2 interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAllowlistEntries", reflect.TypeOf((*MockService)(nil).ListAllowlistEntries), arg0, arg1, arg2) } +// ListApiOidcConfig mocks base method. +func (m *MockService) ListApiOidcConfig(arg0 context.Context, arg1 *client.ListApiOidcConfigOptions) (*client.ListApiOidcConfigResponse, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListApiOidcConfig", arg0, arg1) + ret0, _ := ret[0].(*client.ListApiOidcConfigResponse) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListApiOidcConfig indicates an expected call of ListApiOidcConfig. +func (mr *MockServiceMockRecorder) ListApiOidcConfig(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListApiOidcConfig", reflect.TypeOf((*MockService)(nil).ListApiOidcConfig), arg0, arg1) +} + // ListAuditLogs mocks base method. func (m *MockService) ListAuditLogs(arg0 context.Context, arg1 *client.ListAuditLogsOptions) (*client.ListAuditLogsResponse, *http.Response, error) { m.ctrl.T.Helper() @@ -1328,6 +1392,22 @@ func (mr *MockServiceMockRecorder) UpdateAllowlistEntry(arg0, arg1, arg2, arg3, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateAllowlistEntry", reflect.TypeOf((*MockService)(nil).UpdateAllowlistEntry), arg0, arg1, arg2, arg3, arg4) } +// UpdateApiOidcConfig mocks base method. +func (m *MockService) UpdateApiOidcConfig(arg0 context.Context, arg1 string, arg2 *client.ApiOidcConfig1) (*client.ApiOidcConfig, *http.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateApiOidcConfig", arg0, arg1, arg2) + ret0, _ := ret[0].(*client.ApiOidcConfig) + ret1, _ := ret[1].(*http.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// UpdateApiOidcConfig indicates an expected call of UpdateApiOidcConfig. +func (mr *MockServiceMockRecorder) UpdateApiOidcConfig(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateApiOidcConfig", reflect.TypeOf((*MockService)(nil).UpdateApiOidcConfig), arg0, arg1, arg2) +} + // UpdateCMEKSpec mocks base method. func (m *MockService) UpdateCMEKSpec(arg0 context.Context, arg1 string, arg2 *client.CMEKClusterSpecification) (*client.CMEKClusterInfo, *http.Response, error) { m.ctrl.T.Helper() diff --git a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_any.go b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_any.go index ad1e6066..03daeaa0 100644 --- a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_any.go +++ b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_any.go @@ -18,7 +18,7 @@ package client -// Any `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } // or ... if (any.isSameTypeAs(Foo.getDefaultInstance())) { foo = any.unpack(Foo.getDefaultInstance()); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": , \"lastName\": } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" }. +// Any `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": , \"lastName\": } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" }. type Any struct { // A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. Type *string `json:"@type,omitempty"` diff --git a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_api_oidc_config.go b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_api_oidc_config.go new file mode 100644 index 00000000..7cf7a8e4 --- /dev/null +++ b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_api_oidc_config.go @@ -0,0 +1,138 @@ +// Copyright 2023 The Cockroach Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +// CockroachDB Cloud API +// API version: 2023-04-10 + +package client + +// ApiOidcConfig api_oidc_config contains information about an OIDC provider that can generate JWT tokens that can be used for authentication with the Cockroach Cloud API.. +type ApiOidcConfig struct { + Audience string `json:"audience"` + Claim *string `json:"claim,omitempty"` + Id string `json:"id"` + IdentityMap *string `json:"identity_map,omitempty"` + Issuer string `json:"issuer"` + Jwks string `json:"jwks"` +} + +// NewApiOidcConfig instantiates a new ApiOidcConfig object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewApiOidcConfig(audience string, id string, issuer string, jwks string) *ApiOidcConfig { + p := ApiOidcConfig{} + p.Audience = audience + p.Id = id + p.Issuer = issuer + p.Jwks = jwks + return &p +} + +// NewApiOidcConfigWithDefaults instantiates a new ApiOidcConfig object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewApiOidcConfigWithDefaults() *ApiOidcConfig { + p := ApiOidcConfig{} + return &p +} + +// GetAudience returns the Audience field value. +func (o *ApiOidcConfig) GetAudience() string { + if o == nil { + var ret string + return ret + } + + return o.Audience +} + +// SetAudience sets field value. +func (o *ApiOidcConfig) SetAudience(v string) { + o.Audience = v +} + +// GetClaim returns the Claim field value if set, zero value otherwise. +func (o *ApiOidcConfig) GetClaim() string { + if o == nil || o.Claim == nil { + var ret string + return ret + } + return *o.Claim +} + +// SetClaim gets a reference to the given string and assigns it to the Claim field. +func (o *ApiOidcConfig) SetClaim(v string) { + o.Claim = &v +} + +// GetId returns the Id field value. +func (o *ApiOidcConfig) GetId() string { + if o == nil { + var ret string + return ret + } + + return o.Id +} + +// SetId sets field value. +func (o *ApiOidcConfig) SetId(v string) { + o.Id = v +} + +// GetIdentityMap returns the IdentityMap field value if set, zero value otherwise. +func (o *ApiOidcConfig) GetIdentityMap() string { + if o == nil || o.IdentityMap == nil { + var ret string + return ret + } + return *o.IdentityMap +} + +// SetIdentityMap gets a reference to the given string and assigns it to the IdentityMap field. +func (o *ApiOidcConfig) SetIdentityMap(v string) { + o.IdentityMap = &v +} + +// GetIssuer returns the Issuer field value. +func (o *ApiOidcConfig) GetIssuer() string { + if o == nil { + var ret string + return ret + } + + return o.Issuer +} + +// SetIssuer sets field value. +func (o *ApiOidcConfig) SetIssuer(v string) { + o.Issuer = v +} + +// GetJwks returns the Jwks field value. +func (o *ApiOidcConfig) GetJwks() string { + if o == nil { + var ret string + return ret + } + + return o.Jwks +} + +// SetJwks sets field value. +func (o *ApiOidcConfig) SetJwks(v string) { + o.Jwks = v +} diff --git a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_api_oidc_config_1.go b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_api_oidc_config_1.go new file mode 100644 index 00000000..e74f24e3 --- /dev/null +++ b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_api_oidc_config_1.go @@ -0,0 +1,121 @@ +// Copyright 2023 The Cockroach Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +// CockroachDB Cloud API +// API version: 2023-04-10 + +package client + +// ApiOidcConfig1 api_oidc_config contains information about an OIDC provider that can generate JWT tokens that can be used for authentication with the Cockroach Cloud API.. +type ApiOidcConfig1 struct { + Audience string `json:"audience"` + Claim *string `json:"claim,omitempty"` + IdentityMap *string `json:"identity_map,omitempty"` + Issuer string `json:"issuer"` + Jwks string `json:"jwks"` +} + +// NewApiOidcConfig1 instantiates a new ApiOidcConfig1 object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewApiOidcConfig1(audience string, issuer string, jwks string) *ApiOidcConfig1 { + p := ApiOidcConfig1{} + p.Audience = audience + p.Issuer = issuer + p.Jwks = jwks + return &p +} + +// NewApiOidcConfig1WithDefaults instantiates a new ApiOidcConfig1 object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewApiOidcConfig1WithDefaults() *ApiOidcConfig1 { + p := ApiOidcConfig1{} + return &p +} + +// GetAudience returns the Audience field value. +func (o *ApiOidcConfig1) GetAudience() string { + if o == nil { + var ret string + return ret + } + + return o.Audience +} + +// SetAudience sets field value. +func (o *ApiOidcConfig1) SetAudience(v string) { + o.Audience = v +} + +// GetClaim returns the Claim field value if set, zero value otherwise. +func (o *ApiOidcConfig1) GetClaim() string { + if o == nil || o.Claim == nil { + var ret string + return ret + } + return *o.Claim +} + +// SetClaim gets a reference to the given string and assigns it to the Claim field. +func (o *ApiOidcConfig1) SetClaim(v string) { + o.Claim = &v +} + +// GetIdentityMap returns the IdentityMap field value if set, zero value otherwise. +func (o *ApiOidcConfig1) GetIdentityMap() string { + if o == nil || o.IdentityMap == nil { + var ret string + return ret + } + return *o.IdentityMap +} + +// SetIdentityMap gets a reference to the given string and assigns it to the IdentityMap field. +func (o *ApiOidcConfig1) SetIdentityMap(v string) { + o.IdentityMap = &v +} + +// GetIssuer returns the Issuer field value. +func (o *ApiOidcConfig1) GetIssuer() string { + if o == nil { + var ret string + return ret + } + + return o.Issuer +} + +// SetIssuer sets field value. +func (o *ApiOidcConfig1) SetIssuer(v string) { + o.Issuer = v +} + +// GetJwks returns the Jwks field value. +func (o *ApiOidcConfig1) GetJwks() string { + if o == nil { + var ret string + return ret + } + + return o.Jwks +} + +// SetJwks sets field value. +func (o *ApiOidcConfig1) SetJwks(v string) { + o.Jwks = v +} diff --git a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_create_api_oidc_config_request.go b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_create_api_oidc_config_request.go new file mode 100644 index 00000000..202f2758 --- /dev/null +++ b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_create_api_oidc_config_request.go @@ -0,0 +1,121 @@ +// Copyright 2023 The Cockroach Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +// CockroachDB Cloud API +// API version: 2023-04-10 + +package client + +// CreateApiOidcConfigRequest struct for CreateApiOidcConfigRequest. +type CreateApiOidcConfigRequest struct { + Audience string `json:"audience"` + Claim *string `json:"claim,omitempty"` + IdentityMap *string `json:"identity_map,omitempty"` + Issuer string `json:"issuer"` + Jwks string `json:"jwks"` +} + +// NewCreateApiOidcConfigRequest instantiates a new CreateApiOidcConfigRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateApiOidcConfigRequest(audience string, issuer string, jwks string) *CreateApiOidcConfigRequest { + p := CreateApiOidcConfigRequest{} + p.Audience = audience + p.Issuer = issuer + p.Jwks = jwks + return &p +} + +// NewCreateApiOidcConfigRequestWithDefaults instantiates a new CreateApiOidcConfigRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateApiOidcConfigRequestWithDefaults() *CreateApiOidcConfigRequest { + p := CreateApiOidcConfigRequest{} + return &p +} + +// GetAudience returns the Audience field value. +func (o *CreateApiOidcConfigRequest) GetAudience() string { + if o == nil { + var ret string + return ret + } + + return o.Audience +} + +// SetAudience sets field value. +func (o *CreateApiOidcConfigRequest) SetAudience(v string) { + o.Audience = v +} + +// GetClaim returns the Claim field value if set, zero value otherwise. +func (o *CreateApiOidcConfigRequest) GetClaim() string { + if o == nil || o.Claim == nil { + var ret string + return ret + } + return *o.Claim +} + +// SetClaim gets a reference to the given string and assigns it to the Claim field. +func (o *CreateApiOidcConfigRequest) SetClaim(v string) { + o.Claim = &v +} + +// GetIdentityMap returns the IdentityMap field value if set, zero value otherwise. +func (o *CreateApiOidcConfigRequest) GetIdentityMap() string { + if o == nil || o.IdentityMap == nil { + var ret string + return ret + } + return *o.IdentityMap +} + +// SetIdentityMap gets a reference to the given string and assigns it to the IdentityMap field. +func (o *CreateApiOidcConfigRequest) SetIdentityMap(v string) { + o.IdentityMap = &v +} + +// GetIssuer returns the Issuer field value. +func (o *CreateApiOidcConfigRequest) GetIssuer() string { + if o == nil { + var ret string + return ret + } + + return o.Issuer +} + +// SetIssuer sets field value. +func (o *CreateApiOidcConfigRequest) SetIssuer(v string) { + o.Issuer = v +} + +// GetJwks returns the Jwks field value. +func (o *CreateApiOidcConfigRequest) GetJwks() string { + if o == nil { + var ret string + return ret + } + + return o.Jwks +} + +// SetJwks sets field value. +func (o *CreateApiOidcConfigRequest) SetJwks(v string) { + o.Jwks = v +} diff --git a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_list_api_oidc_config_response.go b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_list_api_oidc_config_response.go new file mode 100644 index 00000000..91f1ed20 --- /dev/null +++ b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/model_list_api_oidc_config_response.go @@ -0,0 +1,62 @@ +// Copyright 2023 The Cockroach Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. +// CockroachDB Cloud API +// API version: 2023-04-10 + +package client + +// ListApiOidcConfigResponse list_api_oidc_config_response contains information about all the OIDC providers that can generate JWT tokens that can be used for authentication with the Cockroach Cloud API.. +type ListApiOidcConfigResponse struct { + ApiOidcConfigs *[]ApiOidcConfig `json:"api_oidc_configs,omitempty"` + Pagination *KeysetPaginationResponse `json:"pagination,omitempty"` +} + +// NewListApiOidcConfigResponse instantiates a new ListApiOidcConfigResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListApiOidcConfigResponse() *ListApiOidcConfigResponse { + p := ListApiOidcConfigResponse{} + return &p +} + +// GetApiOidcConfigs returns the ApiOidcConfigs field value if set, zero value otherwise. +func (o *ListApiOidcConfigResponse) GetApiOidcConfigs() []ApiOidcConfig { + if o == nil || o.ApiOidcConfigs == nil { + var ret []ApiOidcConfig + return ret + } + return *o.ApiOidcConfigs +} + +// SetApiOidcConfigs gets a reference to the given []ApiOidcConfig and assigns it to the ApiOidcConfigs field. +func (o *ListApiOidcConfigResponse) SetApiOidcConfigs(v []ApiOidcConfig) { + o.ApiOidcConfigs = &v +} + +// GetPagination returns the Pagination field value if set, zero value otherwise. +func (o *ListApiOidcConfigResponse) GetPagination() KeysetPaginationResponse { + if o == nil || o.Pagination == nil { + var ret KeysetPaginationResponse + return ret + } + return *o.Pagination +} + +// SetPagination gets a reference to the given KeysetPaginationResponse and assigns it to the Pagination field. +func (o *ListApiOidcConfigResponse) SetPagination(v KeysetPaginationResponse) { + o.Pagination = &v +} diff --git a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/service.go b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/service.go index 4b21008c..0138b1c7 100644 --- a/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/service.go +++ b/vendor/github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client/service.go @@ -61,8 +61,13 @@ type Service interface { EditDatabase2(ctx _context.Context, clusterId string, updateDatabaseRequest *UpdateDatabaseRequest) (*ApiDatabase, *_nethttp.Response, error) ListDatabases(ctx _context.Context, clusterId string, options *ListDatabasesOptions) (*ApiListDatabasesResponse, *_nethttp.Response, error) // Default + CreateApiOidcConfig(ctx _context.Context, createApiOidcConfigRequest *CreateApiOidcConfigRequest) (*ApiOidcConfig, *_nethttp.Response, error) + DeleteApiOidcConfig(ctx _context.Context, id string) (*ApiOidcConfig, *_nethttp.Response, error) + GetApiOidcConfig(ctx _context.Context, id string) (*ApiOidcConfig, *_nethttp.Response, error) GetClusterVersionDeferral(ctx _context.Context, clusterId string) (*ClusterVersionDeferral, *_nethttp.Response, error) + ListApiOidcConfig(ctx _context.Context, options *ListApiOidcConfigOptions) (*ListApiOidcConfigResponse, *_nethttp.Response, error) SetClusterVersionDeferral(ctx _context.Context, clusterId string, clusterVersionDeferral *ClusterVersionDeferral) (*ClusterVersionDeferral, *_nethttp.Response, error) + UpdateApiOidcConfig(ctx _context.Context, id string, apiOidcConfig1 *ApiOidcConfig1) (*ApiOidcConfig, *_nethttp.Response, error) // EgressRules AddEgressRule(ctx _context.Context, clusterId string, addEgressRuleRequest *AddEgressRuleRequest) (*AddEgressRuleResponse, *_nethttp.Response, error) DeleteEgressRule(ctx _context.Context, clusterId string, ruleId string, options *DeleteEgressRuleOptions) (*DeleteEgressRuleResponse, *_nethttp.Response, error) @@ -3703,6 +3708,409 @@ func (a *ServiceImpl) ListDatabases( return &localVarReturnValue, localVarHTTPResponse, nil } +// CreateApiOidcConfig executes the request. +func (a *ServiceImpl) CreateApiOidcConfig( + ctx _context.Context, createApiOidcConfigRequest *CreateApiOidcConfigRequest, +) (*ApiOidcConfig, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath := a.client.cfg.ServerURL + + localVarPath := localBasePath + "/api/v1/api_oidc" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if createApiOidcConfigRequest == nil { + return nil, nil, reportError("createApiOidcConfigRequest is required and must be specified") + } + + // Determine the Content-Type header. + localVarHTTPContentTypes := []string{"application/json"} + + // Set Content-Type header. + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // Determine the Accept header. + localVarHTTPHeaderAccepts := []string{"application/json"} + + // Set Accept header. + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // Body params. + localVarPostBody = createApiOidcConfigRequest + req, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return nil, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return nil, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := Error{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + + var localVarReturnValue ApiOidcConfig + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := Error{ + body: localVarBody, + error: err.Error(), + } + return &localVarReturnValue, localVarHTTPResponse, newErr + } + + return &localVarReturnValue, localVarHTTPResponse, nil +} + +// DeleteApiOidcConfig executes the request. +func (a *ServiceImpl) DeleteApiOidcConfig( + ctx _context.Context, id string, +) (*ApiOidcConfig, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath := a.client.cfg.ServerURL + + localVarPath := localBasePath + "/api/v1/api_oidc/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", _neturl.PathEscape(parameterToString(id, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // Determine the Content-Type header. + localVarHTTPContentTypes := []string{} + + // Set Content-Type header. + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // Determine the Accept header. + localVarHTTPHeaderAccepts := []string{"application/json"} + + // Set Accept header. + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return nil, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return nil, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := Error{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + + var localVarReturnValue ApiOidcConfig + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := Error{ + body: localVarBody, + error: err.Error(), + } + return &localVarReturnValue, localVarHTTPResponse, newErr + } + + return &localVarReturnValue, localVarHTTPResponse, nil +} + +// GetApiOidcConfig executes the request. +func (a *ServiceImpl) GetApiOidcConfig( + ctx _context.Context, id string, +) (*ApiOidcConfig, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath := a.client.cfg.ServerURL + + localVarPath := localBasePath + "/api/v1/api_oidc/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", _neturl.PathEscape(parameterToString(id, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // Determine the Content-Type header. + localVarHTTPContentTypes := []string{} + + // Set Content-Type header. + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // Determine the Accept header. + localVarHTTPHeaderAccepts := []string{"application/json"} + + // Set Accept header. + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return nil, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return nil, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := Error{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + + var localVarReturnValue ApiOidcConfig + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := Error{ + body: localVarBody, + error: err.Error(), + } + return &localVarReturnValue, localVarHTTPResponse, newErr + } + + return &localVarReturnValue, localVarHTTPResponse, nil +} + // GetClusterVersionDeferral executes the request. func (a *ServiceImpl) GetClusterVersionDeferral( ctx _context.Context, clusterId string, @@ -3717,13 +4125,169 @@ func (a *ServiceImpl) GetClusterVersionDeferral( localBasePath := a.client.cfg.ServerURL - localVarPath := localBasePath + "/api/v1/clusters/{cluster_id}/version-deferral" - localVarPath = strings.Replace(localVarPath, "{"+"cluster_id"+"}", _neturl.PathEscape(parameterToString(clusterId, "")), -1) + localVarPath := localBasePath + "/api/v1/clusters/{cluster_id}/version-deferral" + localVarPath = strings.Replace(localVarPath, "{"+"cluster_id"+"}", _neturl.PathEscape(parameterToString(clusterId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // Determine the Content-Type header. + localVarHTTPContentTypes := []string{} + + // Set Content-Type header. + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // Determine the Accept header. + localVarHTTPHeaderAccepts := []string{"application/json"} + + // Set Accept header. + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return nil, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return nil, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := Error{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + + var localVarReturnValue ClusterVersionDeferral + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := Error{ + body: localVarBody, + error: err.Error(), + } + return &localVarReturnValue, localVarHTTPResponse, newErr + } + + return &localVarReturnValue, localVarHTTPResponse, nil +} + +// ListApiOidcConfigOptions contains optional parameters for ListApiOidcConfig. +type ListApiOidcConfigOptions struct { + PaginationPage *string + + PaginationLimit *int32 + + PaginationAsOfTime *time.Time + + // - ASC: Sort in ascending order. This is the default unless otherwise specified. - DESC: Sort in descending order. + PaginationSortOrder *string +} + +// ListApiOidcConfig executes the request. +func (a *ServiceImpl) ListApiOidcConfig( + ctx _context.Context, options *ListApiOidcConfigOptions, +) (*ListApiOidcConfigResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath := a.client.cfg.ServerURL + + localVarPath := localBasePath + "/api/v1/api_oidc" localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} + if options.PaginationPage != nil { + localVarQueryParams.Add("pagination.page", parameterToString(*options.PaginationPage, "")) + } + if options.PaginationLimit != nil { + localVarQueryParams.Add("pagination.limit", parameterToString(*options.PaginationLimit, "")) + } + if options.PaginationAsOfTime != nil { + localVarQueryParams.Add("pagination.as_of_time", parameterToString(*options.PaginationAsOfTime, "")) + } + if options.PaginationSortOrder != nil { + localVarQueryParams.Add("pagination.sort_order", parameterToString(*options.PaginationSortOrder, "")) + } // Determine the Content-Type header. localVarHTTPContentTypes := []string{} @@ -3823,7 +4387,7 @@ func (a *ServiceImpl) GetClusterVersionDeferral( return nil, localVarHTTPResponse, newErr } - var localVarReturnValue ClusterVersionDeferral + var localVarReturnValue ListApiOidcConfigResponse err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { newErr := Error{ @@ -3974,6 +4538,144 @@ func (a *ServiceImpl) SetClusterVersionDeferral( return &localVarReturnValue, localVarHTTPResponse, nil } +// UpdateApiOidcConfig executes the request. +func (a *ServiceImpl) UpdateApiOidcConfig( + ctx _context.Context, id string, apiOidcConfig1 *ApiOidcConfig1, +) (*ApiOidcConfig, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath := a.client.cfg.ServerURL + + localVarPath := localBasePath + "/api/v1/api_oidc/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", _neturl.PathEscape(parameterToString(id, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if apiOidcConfig1 == nil { + return nil, nil, reportError("apiOidcConfig1 is required and must be specified") + } + + // Determine the Content-Type header. + localVarHTTPContentTypes := []string{"application/json"} + + // Set Content-Type header. + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // Determine the Accept header. + localVarHTTPHeaderAccepts := []string{"application/json"} + + // Set Accept header. + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // Body params. + localVarPostBody = apiOidcConfig1 + req, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return nil, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return nil, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := Error{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 401 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v interface{} + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + var v Status + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return nil, localVarHTTPResponse, newErr + } + newErr.model = v + return nil, localVarHTTPResponse, newErr + } + + var localVarReturnValue ApiOidcConfig + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := Error{ + body: localVarBody, + error: err.Error(), + } + return &localVarReturnValue, localVarHTTPResponse, newErr + } + + return &localVarReturnValue, localVarHTTPResponse, nil +} + // AddEgressRule executes the request. func (a *ServiceImpl) AddEgressRule( ctx _context.Context, clusterId string, addEgressRuleRequest *AddEgressRuleRequest, diff --git a/vendor/modules.txt b/vendor/modules.txt index 27afdd04..bae76028 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -19,7 +19,7 @@ github.com/armon/go-radix # github.com/bgentry/speakeasy v0.1.0 ## explicit github.com/bgentry/speakeasy -# github.com/cockroachdb/cockroach-cloud-sdk-go v1.4.0 +# github.com/cockroachdb/cockroach-cloud-sdk-go v1.5.0 ## explicit; go 1.17 github.com/cockroachdb/cockroach-cloud-sdk-go/pkg/client # github.com/davecgh/go-spew v1.1.1