From 9bef0ec8f674a949083bb982a30b66f91707d02c Mon Sep 17 00:00:00 2001 From: Nicolas Lopes Date: Thu, 26 Sep 2024 11:56:37 -0300 Subject: [PATCH] feat(saml_connection): add field --- saml_connection.go | 1 + samlconnection/client.go | 8 +++++++- samlconnection/client_test.go | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/saml_connection.go b/saml_connection.go index aa1f12e..85bf242 100644 --- a/saml_connection.go +++ b/saml_connection.go @@ -7,6 +7,7 @@ type SAMLConnection struct { Name string `json:"name"` Domain string `json:"domain"` IdpEntityID *string `json:"idp_entity_id"` + OrganizationID *string `json:"organization_id"` IdpSsoURL *string `json:"idp_sso_url"` IdpCertificate *string `json:"idp_certificate"` IdpMetadataURL *string `json:"idp_metadata_url"` diff --git a/samlconnection/client.go b/samlconnection/client.go index d9b410f..9fcd7c0 100644 --- a/samlconnection/client.go +++ b/samlconnection/client.go @@ -33,7 +33,12 @@ type AttributeMappingParams struct { type CreateParams struct { clerk.APIParams - Name *string `json:"name,omitempty"` + Name *string `json:"name,omitempty"` + // OrganizationID is a nullable optional field. + // - If nil or unset, the backend will not take any action. + // - If an empty value (""), the backend will unset the organization_id. + // - If a valid ID is provided, the backend will update the organization_id. + OrganizationID *string `json:"organization_id,omitempty"` Domain *string `json:"domain,omitempty"` Provider *string `json:"provider,omitempty"` IdpEntityID *string `json:"idp_entity_id,omitempty"` @@ -70,6 +75,7 @@ type UpdateParams struct { Name *string `json:"name,omitempty"` Domain *string `json:"domain,omitempty"` IdpEntityID *string `json:"idp_entity_id,omitempty"` + OrganizationID *string `json:"organization_id,omitempty"` IdpSsoURL *string `json:"idp_sso_url,omitempty"` IdpCertificate *string `json:"idp_certificate,omitempty"` IdpMetadataURL *string `json:"idp_metadata_url,omitempty"` diff --git a/samlconnection/client_test.go b/samlconnection/client_test.go index 4f2b1cf..3435df6 100644 --- a/samlconnection/client_test.go +++ b/samlconnection/client_test.go @@ -103,7 +103,7 @@ func TestSAMLConnectionClientUpdate(t *testing.T) { config.HTTPClient = &http.Client{ Transport: &clerktest.RoundTripper{ T: t, - In: json.RawMessage(fmt.Sprintf(`{"name":"%s", "disable_additional_identifications": %t}`, name, disableAdditionalIdentifications)), + In: json.RawMessage(fmt.Sprintf(`{"name":"%s", "disable_additional_identifications": %t, "organization_id": ""}`, name, disableAdditionalIdentifications)), Out: json.RawMessage(fmt.Sprintf(`{"id":"%s","name":"%s","domain":"%s","provider":"%s","disable_additional_identifications": %t}`, id, name, domain, provider, disableAdditionalIdentifications)), Method: http.MethodPatch, Path: "/v1/saml_connections/" + id, @@ -113,6 +113,7 @@ func TestSAMLConnectionClientUpdate(t *testing.T) { samlConnection, err := client.Update(context.Background(), id, &UpdateParams{ Name: clerk.String(name), DisableAdditionalIdentifications: clerk.Bool(disableAdditionalIdentifications), + OrganizationID: clerk.String(""), }) require.NoError(t, err) require.Equal(t, id, samlConnection.ID)