Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AllowProfilesOutsideOrganization for organizations #120

Merged
merged 4 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions pkg/organizations/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ type Organization struct {
// The Organization's name.
Name string `json:"name"`

// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`

// The Organization's Domains.
Domains []OrganizationDomain `json:"domains"`

Expand Down Expand Up @@ -109,23 +113,31 @@ type ListOrganizationsResponse struct {

// CreateOrganizationOpts contains the options to create an Organization.
type CreateOrganizationOpts struct {
// Domains of the Organization.
Domains []string `json:"domains"`

// Name of the Organization.
Name string `json:"name"`

// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`

// Domains of the Organization.
Domains []string `json:"domains"`
}

// UpdateOrganizationOpts contains the options to update an Organization.
type UpdateOrganizationOpts struct {
// Organization unique identifier.
Organization string

// Domains of the Organization.
Domains []string

// Name of the Organization.
Name string

// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
AllowProfilesOutsideOrganization bool

// Domains of the Organization.
Domains []string
}

// GetOrganization gets an Organization.
Expand Down Expand Up @@ -260,14 +272,18 @@ func (c *Client) UpdateOrganization(ctx context.Context, opts UpdateOrganization

// UpdateOrganizationChangeOpts contains the options to update an Organization minus the org ID
type UpdateOrganizationChangeOpts struct {
// Domains of the Organization.
Domains []string `json:"domains"`

// Name of the Organization.
Name string `json:"name"`

// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`

// Domains of the Organization.
Domains []string `json:"domains"`
}

update_opts := UpdateOrganizationChangeOpts{opts.Domains, opts.Name}
update_opts := UpdateOrganizationChangeOpts{opts.Name, opts.AllowProfilesOutsideOrganization, opts.Domains}

data, err := c.JSONEncode(update_opts)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/organizations/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestGetOrganization(t *testing.T) {
expected: Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -76,6 +77,7 @@ func getOrganizationTestHandler(w http.ResponseWriter, r *http.Request) {
body, err := json.Marshal(Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -119,6 +121,7 @@ func TestListOrganizations(t *testing.T) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -175,6 +178,7 @@ func listOrganizationsTestHandler(w http.ResponseWriter, r *http.Request) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -223,6 +227,7 @@ func TestCreateOrganization(t *testing.T) {
expected: Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -289,6 +294,7 @@ func createOrganizationTestHandler(w http.ResponseWriter, r *http.Request) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -332,6 +338,7 @@ func TestUpdateOrganization(t *testing.T) {
expected: Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -403,6 +410,7 @@ func updateOrganizationTestHandler(w http.ResponseWriter, r *http.Request) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down
4 changes: 4 additions & 0 deletions pkg/organizations/organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestOrganizationsGetOrganization(t *testing.T) {
expectedResponse := Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -53,6 +54,7 @@ func TestOrganizationsListOrganizations(t *testing.T) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -89,6 +91,7 @@ func TestOrganizationsCreateOrganization(t *testing.T) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down Expand Up @@ -120,6 +123,7 @@ func TestOrganizationsUpdateOrganization(t *testing.T) {
Organization{
ID: "organization_id",
Name: "Foo Corp",
AllowProfilesOutsideOrganization: false,
Domains: []OrganizationDomain{
OrganizationDomain{
ID: "organization_domain_id",
Expand Down