From 3b1dce6219ff5c3f5f9353aac6848fce9367e634 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Tue, 26 Sep 2023 18:39:02 +1000 Subject: [PATCH 01/22] Initial commit --- .../organizations/organizationById.graphql | 60 +++++++++++++ api/lagoon/client/client.go | 2 +- api/lagoon/client/lgraphql/lgraphql.go | 25 ++++++ api/lagoon/client/organizations.go | 24 +++++ api/lagoon/organizations.go | 20 +++++ api/schema/organization.go | 88 +++++++++++++++++++ 6 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 api/lagoon/client/_lgraphql/organizations/organizationById.graphql create mode 100644 api/lagoon/client/organizations.go create mode 100644 api/lagoon/organizations.go create mode 100644 api/schema/organization.go diff --git a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql new file mode 100644 index 0000000..7b02fcd --- /dev/null +++ b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql @@ -0,0 +1,60 @@ +query ( + $id: Int!) { + organizationById( + organization: $id) { + id + name + description + quotaProject + friendlyName + quotaGroup + quotaNotification + deployTargets { + id + name + friendlyName + cloudProvider + cloudRegion + } + owners { + id + firstName + lastName + email + owner + } + projects { + id + name + } + groups { + id + name + type + } + notifications { + ... on NotificationSlack { + __typename + webhook + name + channel + } + ... on NotificationRocketChat { + __typename + webhook + name + channel + } + ... on NotificationEmail { + __typename + emailAddress + name + } + ... on NotificationMicrosoftTeams { + __typename + webhook + name + } + } + } + } diff --git a/api/lagoon/client/client.go b/api/lagoon/client/client.go index e593c1a..2559971 100644 --- a/api/lagoon/client/client.go +++ b/api/lagoon/client/client.go @@ -1,4 +1,4 @@ -//go:generate go-bindata -pkg lgraphql -o lgraphql/lgraphql.go -nometadata _lgraphql/ _lgraphql/deployments/ _lgraphql/deploytargets/ _lgraphql/deploytargetconfigs/ _lgraphql/projects/ _lgraphql/environments/ _lgraphql/tasks/ _lgraphql/usergroups/ +//go:generate go-bindata -pkg lgraphql -o lgraphql/lgraphql.go -nometadata _lgraphql/ _lgraphql/deployments/ _lgraphql/deploytargets/ _lgraphql/deploytargetconfigs/ _lgraphql/projects/ _lgraphql/environments/ _lgraphql/tasks/ _lgraphql/usergroups/ _lgraphql/organizations/ // Package client implements the interfaces required by the parent lagoon // package. diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index b4dcdf9..2718aa0 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -63,6 +63,7 @@ // _lgraphql/usergroups/userBySSHFingerprint.graphql // _lgraphql/usergroups/userBySSHKey.graphql // _lgraphql/usergroups/userCanSSHToEnvironment.graphql +// _lgraphql/organizations/organizationById.graphql package lgraphql import ( @@ -1399,6 +1400,26 @@ func _lgraphqlUsergroupsUsercansshtoenvironmentGraphql() (*asset, error) { return a, nil } +var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x91\x41\x6e\xf2\x40\x0c\x85\xf7\x9c\xc2\xbf\xf4\x2f\xe8\x86\x03\xb0\x6b\xab\xaa\x62\x51\x84\x28\x7b\xe4\xce\x38\xc1\x25\x8c\x83\x67\x52\x94\x56\xb9\x7b\x95\x34\x90\x49\x54\xa0\x52\xa5\x6e\xa2\xc9\x93\xfd\x3e\xfb\x79\x5f\x90\x96\x30\x1e\x01\xfc\x67\x3b\x85\x99\x0b\xff\x6e\xe0\x63\x04\x00\x20\x9a\xa2\xe3\x77\x0c\x2c\xee\xae\x9c\xd9\x71\xa3\xf6\xf5\x69\xdd\x76\x6c\x00\x60\xdb\x3e\x1c\xee\xa8\x7d\x5a\xf2\x46\x39\xaf\xab\x5b\x65\x5f\x48\xc0\x85\xca\x2b\x99\xd0\x4a\x89\x32\x39\x9b\x95\xf3\xae\xaf\xa9\x7a\x54\x29\xf2\x58\x98\x4b\xe0\x84\x0d\x46\x76\x96\xf2\x4c\xca\x15\x6a\x4a\xc1\x9f\x46\x89\x86\xe9\x8d\xf3\x2d\x0b\xc0\x64\x52\xd8\x85\xca\x1b\x5b\xd2\xbe\xba\xa4\xb4\x83\x55\xc7\x10\x0e\x8e\xf4\x0c\x2d\x61\xf5\xa1\xe7\x9e\xe1\x40\xa0\x1d\x72\x76\xfa\x6b\xcc\x06\x80\xfc\x2b\x9f\xeb\x0b\x1d\x1b\xd2\x3a\xaa\x9f\xec\x1f\xca\x7c\xd8\xeb\xa2\x54\x63\x8b\xc9\x64\x02\xe2\x20\x0e\xfd\x39\x43\xb3\x8d\x4a\x00\xd6\xeb\xda\xb1\x87\x00\x38\xd0\xcb\x46\x64\x1b\x29\x83\x02\xb3\x41\xe7\xa8\xcb\xa0\xba\x04\x5d\x8a\xd9\x52\xb8\xdf\x60\xf8\x6b\xf2\x43\x7d\xa8\xeb\xd0\xe6\x9e\xb7\xd6\x2a\x79\x7f\x8e\x7c\x91\xf3\xc4\x46\xc5\x4b\x12\x56\x84\x3b\xff\xeb\x2d\xab\xde\x81\xeb\x6f\x35\xfa\x0c\x00\x00\xff\xff\x6f\xd3\x0f\x5b\xeb\x03\x00\x00") + +func _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlOrganizationsOrganizationbyidGraphql, + "_lgraphql/organizations/organizationById.graphql", + ) +} + +func _lgraphqlOrganizationsOrganizationbyidGraphql() (*asset, error) { + bytes, err := _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/organizations/organizationById.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + // Asset loads and returns the asset for the given name. // It returns an error if the asset could not be found or // could not be loaded. @@ -1514,6 +1535,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/userBySSHFingerprint.graphql": _lgraphqlUsergroupsUserbysshfingerprintGraphql, "_lgraphql/usergroups/userBySSHKey.graphql": _lgraphqlUsergroupsUserbysshkeyGraphql, "_lgraphql/usergroups/userCanSSHToEnvironment.graphql": _lgraphqlUsergroupsUsercansshtoenvironmentGraphql, + "_lgraphql/organizations/organizationById.graphql": _lgraphqlOrganizationsOrganizationbyidGraphql, } // AssetDir returns the file names below a certain @@ -1602,6 +1624,9 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "lagoonSchema.graphql": &bintree{_lgraphqlLagoonschemaGraphql, map[string]*bintree{}}, "lagoonVersion.graphql": &bintree{_lgraphqlLagoonversionGraphql, map[string]*bintree{}}, + "organizations": &bintree{nil, map[string]*bintree{ + "organizationById.graphql": &bintree{_lgraphqlOrganizationsOrganizationbyidGraphql, map[string]*bintree{}}, + }}, "projects": &bintree{nil, map[string]*bintree{ "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, "minimalProjectByName.graphql": &bintree{_lgraphqlProjectsMinimalprojectbynameGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/organizations.go b/api/lagoon/client/organizations.go new file mode 100644 index 0000000..b9e4e34 --- /dev/null +++ b/api/lagoon/client/organizations.go @@ -0,0 +1,24 @@ +package client + +import ( + "context" + "github.com/uselagoon/machinery/api/schema" +) + +// OrganizationByID queries the Lagoon API for an organization by its ID, and +// unmarshals the response into organization. +func (c *Client) OrganizationByID(ctx context.Context, id int, organization *schema.Organization) error { + req, err := c.newRequest("_lgraphql/organizations/organizationById.graphql", + map[string]interface{}{ + "id": id, + }) + if err != nil { + return err + } + + return c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationById"` + }{ + Response: organization, + }) +} diff --git a/api/lagoon/organizations.go b/api/lagoon/organizations.go new file mode 100644 index 0000000..f30b2ba --- /dev/null +++ b/api/lagoon/organizations.go @@ -0,0 +1,20 @@ +// Package lagoon implements high-level functions for interacting with the +// Lagoon API. +package lagoon + +import ( + "context" + + "github.com/uselagoon/machinery/api/schema" +) + +// Projects interface contains methods for getting info on projects. +type Organizations interface { + OrganizationByID(ctx context.Context, id int, organization *schema.Organization) error +} + +// GetOrganizationByID gets info of an organization in lagoon that matches the provided ID. +func GetOrganizationByID(ctx context.Context, id int, o Organizations) (*schema.Organization, error) { + organization := schema.Organization{} + return &organization, o.OrganizationByID(ctx, id, &organization) +} diff --git a/api/schema/organization.go b/api/schema/organization.go new file mode 100644 index 0000000..e920ef0 --- /dev/null +++ b/api/schema/organization.go @@ -0,0 +1,88 @@ +package schema + +// Organization is based on the Lagoon API type. +type Organization struct { + AddOrganizationInput + DeployTarget []DeployTarget `json:"openshift,omitempty"` + Projects []OrgProject `json:"projects,omitempty"` + Environments []OrgEnvironment `json:"environments,omitempty"` + Groups []*Groups `json:"groups,omitempty"` + Owners []OrgUser `json:"owners,omitempty"` + Notifications *Notifications `json:"notifications,omitempty"` +} + +type AddOrganizationInput struct { + ID uint `json:"id,omitempty"` + Name string `json:"name"` + FriendlyName string `json:"friendlyName"` + Description string `json:"description,omitempty"` + QuotaProject uint `json:"quotaProject"` + QuotaGroup uint `json:"quotaGroup,omitempty"` + QuotaNotification uint `json:"quotaNotification,omitempty"` + QuotaEnvironment uint `json:"quotaEnvironment,omitempty"` + QuotaRoute uint `json:"quotaRoute"` +} + +type OrgProject struct { + ID uint `json:"id,omitempty"` + Name string `json:"nameOrgProject,omitempty"` + Organization uint `json:"organization,omitempty"` + Groups *Groups `json:"groups,omitempty"` + Notifications []OrganizationNotification `json:"notifications,omitempty"` +} + +type OrgEnvironment struct { + ID uint `json:"id,omitempty"` + Name string `json:"name,omitempty"` + ProjectID uint `json:"project,omitempty"` + DeployType DeployType `json:"deployType,omitempty"` + DeployHeadRef string `json:"deployHeadRef,omitempty"` + DeployTitle string `json:"deployTitle,omitempty"` + EnvironmentType EnvType `json:"environmentType,omitempty"` + OpenshiftProjectName string `json:"openshiftProjectName,omitempty"` + AutoIdle uint `json:"autoIdle,omitempty"` + KubernetesNamespacePattern *string `json:"kubernetesNamespacePattern,omitempty"` + Updated string `json:"updated,omitempty"` + Created string `json:"created,omitempty"` + Deleted string `json:"deleted,omitempty"` + Route string `json:"route,omitempty"` + Routes string `json:"routes,omitempty"` + Services []EnvironmentService `json:"services,omitempty"` + DeployTarget DeployTarget `json:"openshift,omitempty"` + Kubernetes *uint `json:"kubernetes,omitempty"` +} + +type OrganizationNotification struct { + Name string `json:"name"` + Type NotificationType `json:"type"` +} + +type OrgUser struct { + ID string `json:"id,omitempty"` + Email string `json:"email,omitempty"` + FirstName string `json:"firstName,omitempty"` + LastName string `json:"lastName,omitempty"` + Comment string `json:"comment,omitempty"` + Owner bool `json:"owner,omitempty"` + GroupRoles []GroupRoles `json:"groupRoles,omitempty"` +} + +type DeleteOrganizationInput struct { + ID uint `json:"id"` +} + +type UpdateOrganizationPatchInput struct { + Name string `json:"name,omitempty"` + FriendlyName string `json:"friendlyName,omitempty"` + Description string `json:"description,omitempty"` + QuotaProject uint `json:"quotaProject,omitempty"` + QuotaGroup uint `json:"quotaGroup,omitempty"` + QuotaNotification uint `json:"quotaNotification,omitempty"` + QuotaEnvironment uint `json:"quotaEnvironment,omitempty"` + QuotaRoute uint `json:"quotaRoute,omitempty"` +} + +type UpdateOrganizationInput struct { + ID uint `json:"id"` + Patch UpdateOrganizationPatchInput `json:"patch"` +} From 1f8406d8b2e8d197476947829fdfaa0d6f4cc67d Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 27 Sep 2023 12:15:48 +1000 Subject: [PATCH 02/22] Basic add organization functionality --- .../organizations/addOrganization.graphql | 9 ++++++++ api/lagoon/client/lgraphql/lgraphql.go | 23 +++++++++++++++++++ api/lagoon/client/mutation.go | 2 +- api/lagoon/client/organizations.go | 15 ++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 api/lagoon/client/_lgraphql/organizations/addOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql b/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql new file mode 100644 index 0000000..5813ed8 --- /dev/null +++ b/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql @@ -0,0 +1,9 @@ +mutation ( + $name: String!,) { + addOrganization(input: { + name: $name, + }) { + id + name + } +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index 2718aa0..b11e953 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -63,6 +63,7 @@ // _lgraphql/usergroups/userBySSHFingerprint.graphql // _lgraphql/usergroups/userBySSHKey.graphql // _lgraphql/usergroups/userCanSSHToEnvironment.graphql +// _lgraphql/organizations/addOrganization.graphql // _lgraphql/organizations/organizationById.graphql package lgraphql @@ -1400,6 +1401,26 @@ func _lgraphqlUsergroupsUsercansshtoenvironmentGraphql() (*asset, error) { return a, nil } +var __lgraphqlOrganizationsAddorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\x4b\xcc\x4d\xb5\x52\x08\x2e\x29\xca\xcc\x4b\x57\xd4\xd1\x54\xa8\xe6\x52\x50\x48\x4c\x49\xf1\x2f\x4a\x4f\xcc\xcb\xac\x02\x2b\xd4\xc8\xcc\x2b\x28\x2d\xb1\x02\x4b\x29\x28\x40\x34\x80\xf5\xe9\x70\x29\x28\xd4\x6a\x42\xc5\x33\x53\xe0\xd2\x20\x61\xae\x5a\x2e\x40\x00\x00\x00\xff\xff\x66\x6b\xa4\x95\x69\x00\x00\x00") + +func _lgraphqlOrganizationsAddorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlOrganizationsAddorganizationGraphql, + "_lgraphql/organizations/addOrganization.graphql", + ) +} + +func _lgraphqlOrganizationsAddorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlOrganizationsAddorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/organizations/addOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x91\x41\x6e\xf2\x40\x0c\x85\xf7\x9c\xc2\xbf\xf4\x2f\xe8\x86\x03\xb0\x6b\xab\xaa\x62\x51\x84\x28\x7b\xe4\xce\x38\xc1\x25\x8c\x83\x67\x52\x94\x56\xb9\x7b\x95\x34\x90\x49\x54\xa0\x52\xa5\x6e\xa2\xc9\x93\xfd\x3e\xfb\x79\x5f\x90\x96\x30\x1e\x01\xfc\x67\x3b\x85\x99\x0b\xff\x6e\xe0\x63\x04\x00\x20\x9a\xa2\xe3\x77\x0c\x2c\xee\xae\x9c\xd9\x71\xa3\xf6\xf5\x69\xdd\x76\x6c\x00\x60\xdb\x3e\x1c\xee\xa8\x7d\x5a\xf2\x46\x39\xaf\xab\x5b\x65\x5f\x48\xc0\x85\xca\x2b\x99\xd0\x4a\x89\x32\x39\x9b\x95\xf3\xae\xaf\xa9\x7a\x54\x29\xf2\x58\x98\x4b\xe0\x84\x0d\x46\x76\x96\xf2\x4c\xca\x15\x6a\x4a\xc1\x9f\x46\x89\x86\xe9\x8d\xf3\x2d\x0b\xc0\x64\x52\xd8\x85\xca\x1b\x5b\xd2\xbe\xba\xa4\xb4\x83\x55\xc7\x10\x0e\x8e\xf4\x0c\x2d\x61\xf5\xa1\xe7\x9e\xe1\x40\xa0\x1d\x72\x76\xfa\x6b\xcc\x06\x80\xfc\x2b\x9f\xeb\x0b\x1d\x1b\xd2\x3a\xaa\x9f\xec\x1f\xca\x7c\xd8\xeb\xa2\x54\x63\x8b\xc9\x64\x02\xe2\x20\x0e\xfd\x39\x43\xb3\x8d\x4a\x00\xd6\xeb\xda\xb1\x87\x00\x38\xd0\xcb\x46\x64\x1b\x29\x83\x02\xb3\x41\xe7\xa8\xcb\xa0\xba\x04\x5d\x8a\xd9\x52\xb8\xdf\x60\xf8\x6b\xf2\x43\x7d\xa8\xeb\xd0\xe6\x9e\xb7\xd6\x2a\x79\x7f\x8e\x7c\x91\xf3\xc4\x46\xc5\x4b\x12\x56\x84\x3b\xff\xeb\x2d\xab\xde\x81\xeb\x6f\x35\xfa\x0c\x00\x00\xff\xff\x6f\xd3\x0f\x5b\xeb\x03\x00\x00") func _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() ([]byte, error) { @@ -1535,6 +1556,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/userBySSHFingerprint.graphql": _lgraphqlUsergroupsUserbysshfingerprintGraphql, "_lgraphql/usergroups/userBySSHKey.graphql": _lgraphqlUsergroupsUserbysshkeyGraphql, "_lgraphql/usergroups/userCanSSHToEnvironment.graphql": _lgraphqlUsergroupsUsercansshtoenvironmentGraphql, + "_lgraphql/organizations/addOrganization.graphql": _lgraphqlOrganizationsAddorganizationGraphql, "_lgraphql/organizations/organizationById.graphql": _lgraphqlOrganizationsOrganizationbyidGraphql, } @@ -1625,6 +1647,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "lagoonSchema.graphql": &bintree{_lgraphqlLagoonschemaGraphql, map[string]*bintree{}}, "lagoonVersion.graphql": &bintree{_lgraphqlLagoonversionGraphql, map[string]*bintree{}}, "organizations": &bintree{nil, map[string]*bintree{ + "addOrganization.graphql": &bintree{_lgraphqlOrganizationsAddorganizationGraphql, map[string]*bintree{}}, "organizationById.graphql": &bintree{_lgraphqlOrganizationsOrganizationbyidGraphql, map[string]*bintree{}}, }}, "projects": &bintree{nil, map[string]*bintree{ diff --git a/api/lagoon/client/mutation.go b/api/lagoon/client/mutation.go index 17d2cdb..5f6b37c 100644 --- a/api/lagoon/client/mutation.go +++ b/api/lagoon/client/mutation.go @@ -9,7 +9,7 @@ import ( "github.com/uselagoon/machinery/api/schema" ) -var duplicate = regexp.MustCompile("^graphql: Duplicate entry ") +var duplicate = regexp.MustCompile("(?s).*graphql.*Duplicate entry.* ") // wrapErr wraps a response error with a lagoon.ErrExist type if the response // is due to an object already existing diff --git a/api/lagoon/client/organizations.go b/api/lagoon/client/organizations.go index b9e4e34..c9844d3 100644 --- a/api/lagoon/client/organizations.go +++ b/api/lagoon/client/organizations.go @@ -22,3 +22,18 @@ func (c *Client) OrganizationByID(ctx context.Context, id int, organization *sch Response: organization, }) } + +// AddOrganization adds an organization. +func (c *Client) AddOrganization( + ctx context.Context, in *schema.AddOrganizationInput, org *schema.Organization) error { + req, err := c.newRequest("_lgraphql/organizations/addOrganization.graphql", in) + if err != nil { + return err + } + + return wrapErr(c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"addOrganization"` + }{ + Response: org, + })) +} From 7d6e8f399a89a0ddc0d6a39b590825fe537a2b66 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Thu, 28 Sep 2023 11:04:42 +1000 Subject: [PATCH 03/22] Delete Organization functionality --- .../organizations/deleteOrganization.graphql | 9 +++++++ api/lagoon/client/lgraphql/lgraphql.go | 27 +++++++++++++++++-- api/lagoon/client/organizations.go | 13 +++++++++ api/lagoon/organizations.go | 9 ++++++- 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/organizations/deleteOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/organizations/deleteOrganization.graphql b/api/lagoon/client/_lgraphql/organizations/deleteOrganization.graphql new file mode 100644 index 0000000..c8a17a1 --- /dev/null +++ b/api/lagoon/client/_lgraphql/organizations/deleteOrganization.graphql @@ -0,0 +1,9 @@ +mutation ( + $id: Int! +){ + deleteOrganization( + input: { + id: $id + } + ) +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index b11e953..aa892f1 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -64,6 +64,7 @@ // _lgraphql/usergroups/userBySSHKey.graphql // _lgraphql/usergroups/userCanSSHToEnvironment.graphql // _lgraphql/organizations/addOrganization.graphql +// _lgraphql/organizations/deleteOrganization.graphql // _lgraphql/organizations/organizationById.graphql package lgraphql @@ -1421,6 +1422,26 @@ func _lgraphqlOrganizationsAddorganizationGraphql() (*asset, error) { return a, nil } +var __lgraphqlOrganizationsDeleteorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xe4\xd2\xac\xe6\x52\x50\x48\x49\xcd\x49\x2d\x49\xf5\x2f\x4a\x4f\xcc\xcb\xac\x02\xab\x02\x29\x52\x50\xc8\xcc\x2b\x28\x2d\xb1\x52\xa8\x06\x73\x14\x14\x40\x9a\x54\x32\x53\xc0\xbc\x5a\x2e\x05\x05\x4d\xae\x5a\x2e\x40\x00\x00\x00\xff\xff\x54\xd8\xea\x66\x57\x00\x00\x00") + +func _lgraphqlOrganizationsDeleteorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlOrganizationsDeleteorganizationGraphql, + "_lgraphql/organizations/deleteOrganization.graphql", + ) +} + +func _lgraphqlOrganizationsDeleteorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlOrganizationsDeleteorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/organizations/deleteOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x91\x41\x6e\xf2\x40\x0c\x85\xf7\x9c\xc2\xbf\xf4\x2f\xe8\x86\x03\xb0\x6b\xab\xaa\x62\x51\x84\x28\x7b\xe4\xce\x38\xc1\x25\x8c\x83\x67\x52\x94\x56\xb9\x7b\x95\x34\x90\x49\x54\xa0\x52\xa5\x6e\xa2\xc9\x93\xfd\x3e\xfb\x79\x5f\x90\x96\x30\x1e\x01\xfc\x67\x3b\x85\x99\x0b\xff\x6e\xe0\x63\x04\x00\x20\x9a\xa2\xe3\x77\x0c\x2c\xee\xae\x9c\xd9\x71\xa3\xf6\xf5\x69\xdd\x76\x6c\x00\x60\xdb\x3e\x1c\xee\xa8\x7d\x5a\xf2\x46\x39\xaf\xab\x5b\x65\x5f\x48\xc0\x85\xca\x2b\x99\xd0\x4a\x89\x32\x39\x9b\x95\xf3\xae\xaf\xa9\x7a\x54\x29\xf2\x58\x98\x4b\xe0\x84\x0d\x46\x76\x96\xf2\x4c\xca\x15\x6a\x4a\xc1\x9f\x46\x89\x86\xe9\x8d\xf3\x2d\x0b\xc0\x64\x52\xd8\x85\xca\x1b\x5b\xd2\xbe\xba\xa4\xb4\x83\x55\xc7\x10\x0e\x8e\xf4\x0c\x2d\x61\xf5\xa1\xe7\x9e\xe1\x40\xa0\x1d\x72\x76\xfa\x6b\xcc\x06\x80\xfc\x2b\x9f\xeb\x0b\x1d\x1b\xd2\x3a\xaa\x9f\xec\x1f\xca\x7c\xd8\xeb\xa2\x54\x63\x8b\xc9\x64\x02\xe2\x20\x0e\xfd\x39\x43\xb3\x8d\x4a\x00\xd6\xeb\xda\xb1\x87\x00\x38\xd0\xcb\x46\x64\x1b\x29\x83\x02\xb3\x41\xe7\xa8\xcb\xa0\xba\x04\x5d\x8a\xd9\x52\xb8\xdf\x60\xf8\x6b\xf2\x43\x7d\xa8\xeb\xd0\xe6\x9e\xb7\xd6\x2a\x79\x7f\x8e\x7c\x91\xf3\xc4\x46\xc5\x4b\x12\x56\x84\x3b\xff\xeb\x2d\xab\xde\x81\xeb\x6f\x35\xfa\x0c\x00\x00\xff\xff\x6f\xd3\x0f\x5b\xeb\x03\x00\x00") func _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() ([]byte, error) { @@ -1557,6 +1578,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/userBySSHKey.graphql": _lgraphqlUsergroupsUserbysshkeyGraphql, "_lgraphql/usergroups/userCanSSHToEnvironment.graphql": _lgraphqlUsergroupsUsercansshtoenvironmentGraphql, "_lgraphql/organizations/addOrganization.graphql": _lgraphqlOrganizationsAddorganizationGraphql, + "_lgraphql/organizations/deleteOrganization.graphql": _lgraphqlOrganizationsDeleteorganizationGraphql, "_lgraphql/organizations/organizationById.graphql": _lgraphqlOrganizationsOrganizationbyidGraphql, } @@ -1647,8 +1669,9 @@ var _bintree = &bintree{nil, map[string]*bintree{ "lagoonSchema.graphql": &bintree{_lgraphqlLagoonschemaGraphql, map[string]*bintree{}}, "lagoonVersion.graphql": &bintree{_lgraphqlLagoonversionGraphql, map[string]*bintree{}}, "organizations": &bintree{nil, map[string]*bintree{ - "addOrganization.graphql": &bintree{_lgraphqlOrganizationsAddorganizationGraphql, map[string]*bintree{}}, - "organizationById.graphql": &bintree{_lgraphqlOrganizationsOrganizationbyidGraphql, map[string]*bintree{}}, + "addOrganization.graphql": &bintree{_lgraphqlOrganizationsAddorganizationGraphql, map[string]*bintree{}}, + "deleteOrganization.graphql": &bintree{_lgraphqlOrganizationsDeleteorganizationGraphql, map[string]*bintree{}}, + "organizationById.graphql": &bintree{_lgraphqlOrganizationsOrganizationbyidGraphql, map[string]*bintree{}}, }}, "projects": &bintree{nil, map[string]*bintree{ "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/organizations.go b/api/lagoon/client/organizations.go index c9844d3..6a504f7 100644 --- a/api/lagoon/client/organizations.go +++ b/api/lagoon/client/organizations.go @@ -37,3 +37,16 @@ func (c *Client) AddOrganization( Response: org, })) } + +// DeleteOrganization deletes an organization. +func (c *Client) DeleteOrg(ctx context.Context, + id int, out *schema.DeleteOrganizationInput) error { + req, err := c.newRequest("_lgraphql/organizations/deleteOrganization.graphql", + map[string]interface{}{ + "id": id, + }) + if err != nil { + return err + } + return c.client.Run(ctx, req, &out) +} diff --git a/api/lagoon/organizations.go b/api/lagoon/organizations.go index f30b2ba..fff2b1d 100644 --- a/api/lagoon/organizations.go +++ b/api/lagoon/organizations.go @@ -8,9 +8,10 @@ import ( "github.com/uselagoon/machinery/api/schema" ) -// Projects interface contains methods for getting info on projects. +// Organizations interface contains methods for getting info on projects. type Organizations interface { OrganizationByID(ctx context.Context, id int, organization *schema.Organization) error + DeleteOrg(ctx context.Context, id int, organization *schema.DeleteOrganizationInput) error } // GetOrganizationByID gets info of an organization in lagoon that matches the provided ID. @@ -18,3 +19,9 @@ func GetOrganizationByID(ctx context.Context, id int, o Organizations) (*schema. organization := schema.Organization{} return &organization, o.OrganizationByID(ctx, id, &organization) } + +// DeleteOrganization updates environment storage. +func DeleteOrganization(ctx context.Context, id int, o Organizations) (*schema.DeleteOrganizationInput, error) { + result := schema.DeleteOrganizationInput{} + return &result, o.DeleteOrg(ctx, id, &result) +} From eaa5a60c02b6f461640a0ede5395be507eefd8ed Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Thu, 28 Sep 2023 18:52:39 +1000 Subject: [PATCH 04/22] Included update Org --- .../organizations/organizationByName.graphql | 60 +++++++++++++++++++ .../organizations/updateOrganization.graphql | 13 ++++ api/lagoon/client/lgraphql/lgraphql.go | 46 ++++++++++++++ api/lagoon/client/organizations.go | 42 ++++++++++++- api/lagoon/organizations.go | 24 ++++++-- 5 files changed, 178 insertions(+), 7 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/organizations/organizationByName.graphql create mode 100644 api/lagoon/client/_lgraphql/organizations/updateOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql new file mode 100644 index 0000000..0a8c5c0 --- /dev/null +++ b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql @@ -0,0 +1,60 @@ +query ( + $name: String!) { + organizationByName( + organization: $name) { + id + name + description + quotaProject + friendlyName + quotaGroup + quotaNotification + deployTargets { + id + name + friendlyName + cloudProvider + cloudRegion + } + owners { + id + firstName + lastName + email + owner + } + projects { + id + name + } + groups { + id + name + type + } + notifications { + ... on NotificationSlack { + __typename + webhook + name + channel + } + ... on NotificationRocketChat { + __typename + webhook + name + channel + } + ... on NotificationEmail { + __typename + emailAddress + name + } + ... on NotificationMicrosoftTeams { + __typename + webhook + name + } + } + } +} diff --git a/api/lagoon/client/_lgraphql/organizations/updateOrganization.graphql b/api/lagoon/client/_lgraphql/organizations/updateOrganization.graphql new file mode 100644 index 0000000..f9de159 --- /dev/null +++ b/api/lagoon/client/_lgraphql/organizations/updateOrganization.graphql @@ -0,0 +1,13 @@ +mutation ( + $id: Int! + $patch: UpdateOrganizationPatchInput!){ + updateOrganization( + input: { + id: $id + patch: $patch + } + ){ + id + name + } +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index aa892f1..fc81a0b 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -66,6 +66,8 @@ // _lgraphql/organizations/addOrganization.graphql // _lgraphql/organizations/deleteOrganization.graphql // _lgraphql/organizations/organizationById.graphql +// _lgraphql/organizations/organizationByName.graphql +// _lgraphql/organizations/updateOrganization.graphql package lgraphql import ( @@ -1462,6 +1464,46 @@ func _lgraphqlOrganizationsOrganizationbyidGraphql() (*asset, error) { return a, nil } +var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x91\x31\x6e\xf3\x30\x0c\x85\x77\x9f\x82\x3f\xf0\x0f\xed\x92\x03\x64\x6b\x8b\xa2\x53\x83\x20\xc9\x1e\xb0\x12\xed\xb0\xb1\x45\x87\x92\x1b\xb8\x85\xef\x5e\x58\x4e\x1c\x05\x48\x3d\x74\xe8\x64\x91\x7e\xfc\x9e\x1e\x75\x68\x48\x5b\xb8\xcb\x00\xfe\x3b\xac\x68\x0e\xeb\xa0\xec\x8a\x7f\xf7\xf0\x95\x01\x88\x16\xe8\xf8\x13\x03\x8b\x7b\x6c\x17\x58\x51\xaf\xbc\xee\xcf\x87\xc9\x61\x00\x80\x6d\xfc\xf4\xad\x78\xb0\xe4\x8d\x72\xdd\x2b\x63\x7d\x68\x24\xe0\x52\xe5\x9d\x4c\x88\x8d\x5c\x99\x9c\x2d\x23\xfd\xa2\x78\x51\x69\xea\x4b\xb9\x90\xc0\x39\x1b\x1c\x31\x96\xea\x52\xda\x0d\x6a\x41\xc1\x9f\xac\x47\xf3\xc4\xfe\x06\x1f\xc0\x94\xd2\xd8\xa5\xca\x07\x5b\xd2\xb4\xb7\xa2\xe2\x6c\xd0\x0d\x41\x8f\x8e\xf4\x06\x3f\x67\xf5\x21\x21\x96\x78\x55\x52\x85\x5c\x9e\xce\x11\x91\x20\xeb\x21\xfb\xd4\xa5\x07\x61\xd1\xaf\x60\x3a\x5b\x68\xeb\x74\xc2\x25\x5b\xba\x0c\xce\x66\x33\x10\x07\xe9\x0a\xd7\x25\x9a\xfd\x28\x00\xd8\x6e\x7b\x52\x02\x06\x38\xd2\xdb\x4e\x64\x3f\xd6\x57\x3f\xcd\x0e\x9d\xa3\x73\xc2\xee\x67\xa3\x95\x98\x3d\x85\xa7\x1d\x86\xbf\x70\x7b\xee\xd7\x3e\x6d\x14\x5f\xe6\xc1\x5a\x25\xef\x6f\xb9\x4d\xd0\x5f\xd9\xa8\x78\xc9\xc3\x86\xb0\xf2\xbf\xce\xd3\x8d\x0f\xd6\x65\x5d\xf6\x1d\x00\x00\xff\xff\x62\x6a\xd4\x99\x80\x03\x00\x00") + +func _lgraphqlOrganizationsOrganizationbynameGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlOrganizationsOrganizationbynameGraphql, + "_lgraphql/organizations/organizationByName.graphql", + ) +} + +func _lgraphqlOrganizationsOrganizationbynameGraphql() (*asset, error) { + bytes, err := _lgraphqlOrganizationsOrganizationbynameGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/organizations/organizationByName.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var __lgraphqlOrganizationsUpdateorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x8d\x31\x0e\x02\x31\x0c\x04\x7b\xbf\x62\x4f\xba\x82\xfb\x42\x7e\x70\x15\x34\x3c\xc0\x22\x11\xb8\x88\x89\x90\xd3\x10\xe5\xef\xc8\x49\x3a\x3a\xaf\x77\x34\x9b\xab\xb1\xc9\x5b\x71\x21\x60\x97\x18\x70\xaa\x6d\x7e\x17\xb6\xc7\x2b\xe0\x5e\x22\x5b\xba\x7e\x9e\xac\xf2\x1d\xe8\xcd\x8b\x53\x4b\xb5\xed\x68\x04\xd4\x3f\xc2\x5d\x80\x38\x12\xd0\x46\x00\xdc\xbd\x4b\x5c\x69\xd9\xe7\xca\xf8\x75\x02\x8e\x09\x2f\x4a\x39\x27\xf2\xa2\xd3\x2f\x00\x00\xff\xff\x70\xcd\x28\x48\xa7\x00\x00\x00") + +func _lgraphqlOrganizationsUpdateorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlOrganizationsUpdateorganizationGraphql, + "_lgraphql/organizations/updateOrganization.graphql", + ) +} + +func _lgraphqlOrganizationsUpdateorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlOrganizationsUpdateorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/organizations/updateOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + // Asset loads and returns the asset for the given name. // It returns an error if the asset could not be found or // could not be loaded. @@ -1580,6 +1622,8 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/organizations/addOrganization.graphql": _lgraphqlOrganizationsAddorganizationGraphql, "_lgraphql/organizations/deleteOrganization.graphql": _lgraphqlOrganizationsDeleteorganizationGraphql, "_lgraphql/organizations/organizationById.graphql": _lgraphqlOrganizationsOrganizationbyidGraphql, + "_lgraphql/organizations/organizationByName.graphql": _lgraphqlOrganizationsOrganizationbynameGraphql, + "_lgraphql/organizations/updateOrganization.graphql": _lgraphqlOrganizationsUpdateorganizationGraphql, } // AssetDir returns the file names below a certain @@ -1672,6 +1716,8 @@ var _bintree = &bintree{nil, map[string]*bintree{ "addOrganization.graphql": &bintree{_lgraphqlOrganizationsAddorganizationGraphql, map[string]*bintree{}}, "deleteOrganization.graphql": &bintree{_lgraphqlOrganizationsDeleteorganizationGraphql, map[string]*bintree{}}, "organizationById.graphql": &bintree{_lgraphqlOrganizationsOrganizationbyidGraphql, map[string]*bintree{}}, + "organizationByName.graphql": &bintree{_lgraphqlOrganizationsOrganizationbynameGraphql, map[string]*bintree{}}, + "updateOrganization.graphql": &bintree{_lgraphqlOrganizationsUpdateorganizationGraphql, map[string]*bintree{}}, }}, "projects": &bintree{nil, map[string]*bintree{ "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/organizations.go b/api/lagoon/client/organizations.go index 6a504f7..895086e 100644 --- a/api/lagoon/client/organizations.go +++ b/api/lagoon/client/organizations.go @@ -7,7 +7,7 @@ import ( // OrganizationByID queries the Lagoon API for an organization by its ID, and // unmarshals the response into organization. -func (c *Client) OrganizationByID(ctx context.Context, id int, organization *schema.Organization) error { +func (c *Client) OrganizationByID(ctx context.Context, id uint, organization *schema.Organization) error { req, err := c.newRequest("_lgraphql/organizations/organizationById.graphql", map[string]interface{}{ "id": id, @@ -23,6 +23,24 @@ func (c *Client) OrganizationByID(ctx context.Context, id int, organization *sch }) } +// OrganizationByName queries the Lagoon API for an organization by its name, and +// unmarshals the response into organization. +func (c *Client) OrganizationByName(ctx context.Context, name string, organization *schema.Organization) error { + req, err := c.newRequest("_lgraphql/organizations/organizationByName.graphql", + map[string]interface{}{ + "name": name, + }) + if err != nil { + return err + } + + return c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationByName"` + }{ + Response: organization, + }) +} + // AddOrganization adds an organization. func (c *Client) AddOrganization( ctx context.Context, in *schema.AddOrganizationInput, org *schema.Organization) error { @@ -40,7 +58,7 @@ func (c *Client) AddOrganization( // DeleteOrganization deletes an organization. func (c *Client) DeleteOrg(ctx context.Context, - id int, out *schema.DeleteOrganizationInput) error { + id uint, out *schema.DeleteOrganizationInput) error { req, err := c.newRequest("_lgraphql/organizations/deleteOrganization.graphql", map[string]interface{}{ "id": id, @@ -50,3 +68,23 @@ func (c *Client) DeleteOrg(ctx context.Context, } return c.client.Run(ctx, req, &out) } + +// UpdateOrganization updates an organization. +func (c *Client) UpdateOrganization( + ctx context.Context, id uint, patch schema.UpdateOrganizationPatchInput, organization *schema.Organization) error { + + req, err := c.newRequest("_lgraphql/organizations/updateOrganization.graphql", + map[string]interface{}{ + "id": id, + "patch": patch, + }) + if err != nil { + return err + } + + return c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"updateOrganization"` + }{ + Response: organization, + }) +} diff --git a/api/lagoon/organizations.go b/api/lagoon/organizations.go index fff2b1d..15f950a 100644 --- a/api/lagoon/organizations.go +++ b/api/lagoon/organizations.go @@ -10,18 +10,32 @@ import ( // Organizations interface contains methods for getting info on projects. type Organizations interface { - OrganizationByID(ctx context.Context, id int, organization *schema.Organization) error - DeleteOrg(ctx context.Context, id int, organization *schema.DeleteOrganizationInput) error + OrganizationByID(ctx context.Context, id uint, organization *schema.Organization) error + OrganizationByName(ctx context.Context, name string, organization *schema.Organization) error + DeleteOrg(ctx context.Context, id uint, organization *schema.DeleteOrganizationInput) error + UpdateOrganization(ctx context.Context, id uint, patch schema.UpdateOrganizationPatchInput, result *schema.Organization) error } // GetOrganizationByID gets info of an organization in lagoon that matches the provided ID. -func GetOrganizationByID(ctx context.Context, id int, o Organizations) (*schema.Organization, error) { +func GetOrganizationByID(ctx context.Context, id uint, o Organizations) (*schema.Organization, error) { organization := schema.Organization{} return &organization, o.OrganizationByID(ctx, id, &organization) } -// DeleteOrganization updates environment storage. -func DeleteOrganization(ctx context.Context, id int, o Organizations) (*schema.DeleteOrganizationInput, error) { +// **Pending Merge** GetOrganizationByName gets info of an organization in lagoon that matches the provided name. +func GetOrganizationByName(ctx context.Context, name string, o Organizations) (*schema.Organization, error) { + organization := schema.Organization{} + return &organization, o.OrganizationByName(ctx, name, &organization) +} + +// DeleteOrganization deletes an organization. +func DeleteOrganization(ctx context.Context, id uint, o Organizations) (*schema.DeleteOrganizationInput, error) { result := schema.DeleteOrganizationInput{} return &result, o.DeleteOrg(ctx, id, &result) } + +// UpdateOrganization updates an organization. +func UpdateOrganization(ctx context.Context, id uint, patch schema.UpdateOrganizationPatchInput, o Organizations) (*schema.Organization, error) { + result := schema.Organization{} + return &result, o.UpdateOrganization(ctx, id, patch, &result) +} From de29ad78dc9ac2335a047ad9c44b7526eac616f6 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Tue, 3 Oct 2023 16:30:09 +1100 Subject: [PATCH 05/22] Updates mutations & queries --- .../organizations/addOrganization.graphql | 16 ++++- .../organizations/organizationById.graphql | 47 --------------- .../organizations/organizationByName.graphql | 59 ++----------------- api/lagoon/client/lgraphql/lgraphql.go | 6 +- api/schema/organization.go | 16 ++--- 5 files changed, 32 insertions(+), 112 deletions(-) diff --git a/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql b/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql index 5813ed8..85b8d69 100644 --- a/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql +++ b/api/lagoon/client/_lgraphql/organizations/addOrganization.graphql @@ -1,7 +1,21 @@ mutation ( - $name: String!,) { + $name: String!, + $friendlyName: String, + $description: String, + $quotaProject: Int, + $quotaGroup: Int, + $quotaNotification: Int, + $quotaEnvironment: Int, + $quotaRoute: Int,) { addOrganization(input: { name: $name, + friendlyName: $friendlyName, + description: $description, + quotaProject: $quotaProject, + quotaGroup: $quotaGroup, + quotaNotification: $quotaNotification, + quotaEnvironment: $quotaEnvironment, + quotaRoute: $quotaRoute, }) { id name diff --git a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql index 7b02fcd..94b9de7 100644 --- a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql +++ b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql @@ -9,52 +9,5 @@ query ( friendlyName quotaGroup quotaNotification - deployTargets { - id - name - friendlyName - cloudProvider - cloudRegion - } - owners { - id - firstName - lastName - email - owner - } - projects { - id - name - } - groups { - id - name - type - } - notifications { - ... on NotificationSlack { - __typename - webhook - name - channel - } - ... on NotificationRocketChat { - __typename - webhook - name - channel - } - ... on NotificationEmail { - __typename - emailAddress - name - } - ... on NotificationMicrosoftTeams { - __typename - webhook - name - } - } } } diff --git a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql index 0a8c5c0..3953ca2 100644 --- a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql +++ b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql @@ -1,60 +1,13 @@ query ( $name: String!) { - organizationByName( - organization: $name) { - id - name - description - quotaProject - friendlyName - quotaGroup - quotaNotification - deployTargets { + organizationByName( + organization: $name) { id name + description + quotaProject friendlyName - cloudProvider - cloudRegion + quotaGroup + quotaNotification } - owners { - id - firstName - lastName - email - owner - } - projects { - id - name - } - groups { - id - name - type - } - notifications { - ... on NotificationSlack { - __typename - webhook - name - channel - } - ... on NotificationRocketChat { - __typename - webhook - name - channel - } - ... on NotificationEmail { - __typename - emailAddress - name - } - ... on NotificationMicrosoftTeams { - __typename - webhook - name - } - } - } } diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index fc81a0b..55f69f7 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -1404,7 +1404,7 @@ func _lgraphqlUsergroupsUsercansshtoenvironmentGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsAddorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\x4b\xcc\x4d\xb5\x52\x08\x2e\x29\xca\xcc\x4b\x57\xd4\xd1\x54\xa8\xe6\x52\x50\x48\x4c\x49\xf1\x2f\x4a\x4f\xcc\xcb\xac\x02\x2b\xd4\xc8\xcc\x2b\x28\x2d\xb1\x02\x4b\x29\x28\x40\x34\x80\xf5\xe9\x70\x29\x28\xd4\x6a\x42\xc5\x33\x53\xe0\xd2\x20\x61\xae\x5a\x2e\x40\x00\x00\x00\xff\xff\x66\x6b\xa4\x95\x69\x00\x00\x00") +var __lgraphqlOrganizationsAddorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x90\xc1\x4a\xc5\x30\x10\x45\xf7\xf9\x8a\x11\x5c\xb4\xd0\x2f\xe8\x5e\xc4\x4d\x15\xfd\x82\xd0\xa4\x65\xc4\x4e\x6a\x9c\x08\xfa\xe8\xbf\x3f\x92\x94\xf7\x66\xda\xed\xbd\x77\x06\xce\x59\x12\x5b\xc6\x40\xd0\x18\x80\x47\xb2\x8b\xef\xe1\x83\x23\xd2\xfc\xd0\xe5\x64\x8a\xe8\xc9\x7d\xfd\x0d\xa2\x29\x85\xf3\x3f\x63\xc4\x35\xdf\xaa\xfc\x3b\x05\xb6\x6f\x31\x7c\xfa\x91\x7b\x78\x21\xbe\xa7\xcf\x31\xa4\xf5\x90\x0d\x81\x71\xc2\xd1\xd6\x3f\xaa\x7a\xa2\x5f\x8c\x81\x16\x4f\xc7\x47\xef\x21\xb1\xaf\x59\x0b\x17\x03\x60\x9d\x7b\x8d\xb3\x25\xfc\x2f\x8f\x1a\xa4\x35\x71\x5f\x2a\x80\x0a\x55\xd8\xba\x12\x68\x26\x85\x58\x07\x8a\x4d\x92\xd6\x5a\x23\x2a\x62\x31\xd8\x69\x05\xba\x28\x35\xf6\x59\x85\x98\x2a\x0d\x27\x33\x62\xb8\x5b\x11\x8a\x72\xb9\xb5\xbb\x06\x74\x37\x1b\x39\x36\x9b\xb9\x06\x00\x00\xff\xff\x80\x81\xe4\x11\xfc\x01\x00\x00") func _lgraphqlOrganizationsAddorganizationGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1444,7 +1444,7 @@ func _lgraphqlOrganizationsDeleteorganizationGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x91\x41\x6e\xf2\x40\x0c\x85\xf7\x9c\xc2\xbf\xf4\x2f\xe8\x86\x03\xb0\x6b\xab\xaa\x62\x51\x84\x28\x7b\xe4\xce\x38\xc1\x25\x8c\x83\x67\x52\x94\x56\xb9\x7b\x95\x34\x90\x49\x54\xa0\x52\xa5\x6e\xa2\xc9\x93\xfd\x3e\xfb\x79\x5f\x90\x96\x30\x1e\x01\xfc\x67\x3b\x85\x99\x0b\xff\x6e\xe0\x63\x04\x00\x20\x9a\xa2\xe3\x77\x0c\x2c\xee\xae\x9c\xd9\x71\xa3\xf6\xf5\x69\xdd\x76\x6c\x00\x60\xdb\x3e\x1c\xee\xa8\x7d\x5a\xf2\x46\x39\xaf\xab\x5b\x65\x5f\x48\xc0\x85\xca\x2b\x99\xd0\x4a\x89\x32\x39\x9b\x95\xf3\xae\xaf\xa9\x7a\x54\x29\xf2\x58\x98\x4b\xe0\x84\x0d\x46\x76\x96\xf2\x4c\xca\x15\x6a\x4a\xc1\x9f\x46\x89\x86\xe9\x8d\xf3\x2d\x0b\xc0\x64\x52\xd8\x85\xca\x1b\x5b\xd2\xbe\xba\xa4\xb4\x83\x55\xc7\x10\x0e\x8e\xf4\x0c\x2d\x61\xf5\xa1\xe7\x9e\xe1\x40\xa0\x1d\x72\x76\xfa\x6b\xcc\x06\x80\xfc\x2b\x9f\xeb\x0b\x1d\x1b\xd2\x3a\xaa\x9f\xec\x1f\xca\x7c\xd8\xeb\xa2\x54\x63\x8b\xc9\x64\x02\xe2\x20\x0e\xfd\x39\x43\xb3\x8d\x4a\x00\xd6\xeb\xda\xb1\x87\x00\x38\xd0\xcb\x46\x64\x1b\x29\x83\x02\xb3\x41\xe7\xa8\xcb\xa0\xba\x04\x5d\x8a\xd9\x52\xb8\xdf\x60\xf8\x6b\xf2\x43\x7d\xa8\xeb\xd0\xe6\x9e\xb7\xd6\x2a\x79\x7f\x8e\x7c\x91\xf3\xc4\x46\xc5\x4b\x12\x56\x84\x3b\xff\xeb\x2d\xab\xde\x81\xeb\x6f\x35\xfa\x0c\x00\x00\xff\xff\x6f\xd3\x0f\x5b\xeb\x03\x00\x00") +var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcc\x4d\x0a\xc2\x30\x10\x05\xe0\x7d\x4e\xf1\x04\x17\xf5\x0a\x5d\xba\x91\x6e\x8a\x57\x08\x49\x2a\x23\x3a\xd3\x8e\x93\x45\x14\xef\x2e\x29\xf1\x6f\x31\xf0\xf8\x78\x6f\x96\x9c\xb4\xa0\x73\xc0\x96\x62\x8f\x81\x6d\xb3\xc3\xc3\x01\x80\xe8\xc9\x33\xdd\xbd\x91\xf0\xbe\x0c\xb1\x5b\xf5\xdf\xfb\x3a\x7b\x0f\x00\x8a\x2d\xb0\xbf\xa6\x16\x63\xba\x05\xa5\xb9\xb6\x9b\x2c\x59\xcc\x1f\x55\xce\x29\x58\xa3\x49\x29\x71\xbc\x94\xf1\xbb\x5b\x5b\x07\x95\x3c\xff\xc2\x28\x46\x13\x05\xff\x79\xf7\x74\xf5\x5e\x01\x00\x00\xff\xff\xc2\xc4\x03\x71\xc7\x00\x00\x00") func _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1464,7 +1464,7 @@ func _lgraphqlOrganizationsOrganizationbyidGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x91\x31\x6e\xf3\x30\x0c\x85\x77\x9f\x82\x3f\xf0\x0f\xed\x92\x03\x64\x6b\x8b\xa2\x53\x83\x20\xc9\x1e\xb0\x12\xed\xb0\xb1\x45\x87\x92\x1b\xb8\x85\xef\x5e\x58\x4e\x1c\x05\x48\x3d\x74\xe8\x64\x91\x7e\xfc\x9e\x1e\x75\x68\x48\x5b\xb8\xcb\x00\xfe\x3b\xac\x68\x0e\xeb\xa0\xec\x8a\x7f\xf7\xf0\x95\x01\x88\x16\xe8\xf8\x13\x03\x8b\x7b\x6c\x17\x58\x51\xaf\xbc\xee\xcf\x87\xc9\x61\x00\x80\x6d\xfc\xf4\xad\x78\xb0\xe4\x8d\x72\xdd\x2b\x63\x7d\x68\x24\xe0\x52\xe5\x9d\x4c\x88\x8d\x5c\x99\x9c\x2d\x23\xfd\xa2\x78\x51\x69\xea\x4b\xb9\x90\xc0\x39\x1b\x1c\x31\x96\xea\x52\xda\x0d\x6a\x41\xc1\x9f\xac\x47\xf3\xc4\xfe\x06\x1f\xc0\x94\xd2\xd8\xa5\xca\x07\x5b\xd2\xb4\xb7\xa2\xe2\x6c\xd0\x0d\x41\x8f\x8e\xf4\x06\x3f\x67\xf5\x21\x21\x96\x78\x55\x52\x85\x5c\x9e\xce\x11\x91\x20\xeb\x21\xfb\xd4\xa5\x07\x61\xd1\xaf\x60\x3a\x5b\x68\xeb\x74\xc2\x25\x5b\xba\x0c\xce\x66\x33\x10\x07\xe9\x0a\xd7\x25\x9a\xfd\x28\x00\xd8\x6e\x7b\x52\x02\x06\x38\xd2\xdb\x4e\x64\x3f\xd6\x57\x3f\xcd\x0e\x9d\xa3\x73\xc2\xee\x67\xa3\x95\x98\x3d\x85\xa7\x1d\x86\xbf\x70\x7b\xee\xd7\x3e\x6d\x14\x5f\xe6\xc1\x5a\x25\xef\x6f\xb9\x4d\xd0\x5f\xd9\xa8\x78\xc9\xc3\x86\xb0\xf2\xbf\xce\xd3\x8d\x0f\xd6\x65\x5d\xf6\x1d\x00\x00\xff\xff\x62\x6a\xd4\x99\x80\x03\x00\x00") +var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcd\x41\x0e\x82\x30\x10\x05\xd0\x7d\x4f\xf1\x4d\x5c\xe0\x15\x58\xba\x71\x47\x4c\x3c\xc1\xa4\x1d\xc8\x18\xe9\xc0\xd8\x2e\xd0\x70\x77\x03\x56\x03\xbb\x9f\xd7\xff\x3b\x63\x66\x9b\x50\x39\xe0\x18\xa9\xe7\x1a\xb7\x64\x12\xbb\xc3\x09\x6f\x07\x00\x6a\x1d\x45\x79\x51\x12\x8d\xe7\xa9\xa1\x9e\xab\xd5\xf7\x2f\xf5\x77\xfd\x1b\x01\x12\x4a\x58\xb8\xc4\xc0\x4f\x6f\x32\x2c\xfd\x22\x63\xd6\x44\x57\xd3\x3b\xfb\x54\xa8\x35\xe1\x18\x1e\xeb\xa5\x6d\xeb\x62\x9a\x87\x2d\x34\x9a\xa4\x15\x4f\xff\xef\x66\x37\xbb\x4f\x00\x00\x00\xff\xff\x00\x73\x0a\xb4\xce\x00\x00\x00") func _lgraphqlOrganizationsOrganizationbynameGraphqlBytes() ([]byte, error) { return bindataRead( diff --git a/api/schema/organization.go b/api/schema/organization.go index e920ef0..0538768 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -72,14 +72,14 @@ type DeleteOrganizationInput struct { } type UpdateOrganizationPatchInput struct { - Name string `json:"name,omitempty"` - FriendlyName string `json:"friendlyName,omitempty"` - Description string `json:"description,omitempty"` - QuotaProject uint `json:"quotaProject,omitempty"` - QuotaGroup uint `json:"quotaGroup,omitempty"` - QuotaNotification uint `json:"quotaNotification,omitempty"` - QuotaEnvironment uint `json:"quotaEnvironment,omitempty"` - QuotaRoute uint `json:"quotaRoute,omitempty"` + Name *string `json:"name,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Description *string `json:"description,omitempty"` + QuotaProject *uint `json:"quotaProject,omitempty"` + QuotaGroup *uint `json:"quotaGroup,omitempty"` + QuotaNotification *uint `json:"quotaNotification,omitempty"` + QuotaEnvironment *uint `json:"quotaEnvironment,omitempty"` + QuotaRoute *uint `json:"quotaRoute,omitempty"` } type UpdateOrganizationInput struct { From 275f86c08ac5aaa0231acfce738c78dfe6a0d881 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 4 Oct 2023 18:54:48 +1100 Subject: [PATCH 06/22] First pass at groups & projects by org id --- .../projects/projectsByOrganizationId.graphql | 12 +++++ .../usergroups/groupsByOrganizationId.graphql | 12 +++++ api/lagoon/client/lgraphql/lgraphql.go | 46 +++++++++++++++++++ api/lagoon/client/projects.go | 34 ++++++++++++++ api/lagoon/client/usergroups.go | 33 +++++++++++++ api/lagoon/projects.go | 7 +++ api/lagoon/usergroups.go | 7 +++ api/schema/group.go | 7 ++- api/schema/organization.go | 5 +- 9 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql create mode 100644 api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql diff --git a/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql b/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql new file mode 100644 index 0000000..615c78e --- /dev/null +++ b/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql @@ -0,0 +1,12 @@ +query ( + $id: Int!) { + organizationById( + organization: $id) { + projects { + id + name + organization + groupCount + } + } +} diff --git a/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql b/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql new file mode 100644 index 0000000..ea697bb --- /dev/null +++ b/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql @@ -0,0 +1,12 @@ +query ( + $id: Int!) { + organizationById( + organization: $id) { + groups { + id + name + type + memberCount + } + } +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index 55f69f7..e1ed661 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -32,6 +32,7 @@ // _lgraphql/projects/projectByName.graphql // _lgraphql/projects/projectByNameMetadata.graphql // _lgraphql/projects/projectsByMetadata.graphql +// _lgraphql/projects/projectsByOrganizationId.graphql // _lgraphql/projects/removeProjectMetadataByKey.graphql // _lgraphql/projects/updateProject.graphql // _lgraphql/projects/updateProjectMetadata.graphql @@ -56,6 +57,7 @@ // _lgraphql/usergroups/addUserToGroup.graphql // _lgraphql/usergroups/allGroupMembers.graphql // _lgraphql/usergroups/allUsers.graphql +// _lgraphql/usergroups/groupsByOrganizationId.graphql // _lgraphql/usergroups/me.graphql // _lgraphql/usergroups/removeGroupsFromProject.graphql // _lgraphql/usergroups/removeUserFromGroup.graphql @@ -784,6 +786,26 @@ func _lgraphqlProjectsProjectsbymetadataGraphql() (*asset, error) { return a, nil } +var __lgraphqlProjectsProjectsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xd4\x54\xa8\xe6\x52\x50\xc8\x2f\x4a\x4f\xcc\xcb\xac\x4a\x2c\xc9\xcc\xcf\x73\xaa\xf4\x4c\x01\x29\x41\x15\xb5\x02\x69\x81\x28\x56\x50\x28\x28\xca\xcf\x4a\x4d\x2e\x29\x86\x72\x15\x14\x32\x53\xa0\x8c\xbc\xc4\xdc\x54\x28\x13\x59\x37\x54\x28\xbd\x28\xbf\xb4\xc0\x39\xbf\x34\xaf\x04\x2c\x50\xcb\x05\xc2\xb5\x5c\x80\x00\x00\x00\xff\xff\xaf\xfd\x66\x60\x97\x00\x00\x00") + +func _lgraphqlProjectsProjectsbyorganizationidGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlProjectsProjectsbyorganizationidGraphql, + "_lgraphql/projects/projectsByOrganizationId.graphql", + ) +} + +func _lgraphqlProjectsProjectsbyorganizationidGraphql() (*asset, error) { + bytes, err := _lgraphqlProjectsProjectsbyorganizationidGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/projects/projectsByOrganizationId.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlProjectsRemoveprojectmetadatabykeyGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\x84\xf0\xb2\x53\x2b\xad\x14\x82\x4b\x8a\x32\xf3\xd2\x15\x35\xab\xc1\x62\x45\xa9\xb9\xf9\x65\xa9\x01\x45\xf9\x59\xa9\xc9\x25\xbe\xa9\x25\x89\x29\x89\x25\x89\x4e\x95\xde\xa9\x95\x10\x13\x40\x20\x33\xaf\xa0\xb4\xc4\xaa\x1a\xce\x07\x8b\xa5\x58\x81\x4c\x47\x11\x03\x1b\x0f\xb2\x04\x2e\x5a\x0b\x66\x69\x22\xb4\x22\xe9\xc8\x4b\xcc\x4d\x85\x73\x72\xa1\x36\x73\x41\x74\xd5\x02\x02\x00\x00\xff\xff\xfc\x0e\xa7\xd1\xc8\x00\x00\x00") func _lgraphqlProjectsRemoveprojectmetadatabykeyGraphqlBytes() ([]byte, error) { @@ -1264,6 +1286,26 @@ func _lgraphqlUsergroupsAllusersGraphql() (*asset, error) { return a, nil } +var __lgraphqlUsergroupsGroupsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xd4\x54\xa8\xe6\x52\x50\xc8\x2f\x4a\x4f\xcc\xcb\xac\x4a\x2c\xc9\xcc\xcf\x73\xaa\xf4\x4c\x01\x29\x41\x15\xb5\x02\x69\x81\x28\x56\x50\x48\x2f\xca\x2f\x2d\x28\x86\x72\x14\x14\x32\x53\xa0\x8c\xbc\xc4\xdc\x54\x28\xb3\xa4\xb2\x00\xc6\xcc\x4d\xcd\x4d\x4a\x2d\x72\xce\x2f\xcd\x2b\x01\x8b\xd4\x72\x81\x70\x2d\x17\x20\x00\x00\xff\xff\xfe\xdb\x77\x76\x8e\x00\x00\x00") + +func _lgraphqlUsergroupsGroupsbyorganizationidGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlUsergroupsGroupsbyorganizationidGraphql, + "_lgraphql/usergroups/groupsByOrganizationId.graphql", + ) +} + +func _lgraphqlUsergroupsGroupsbyorganizationidGraphql() (*asset, error) { + bytes, err := _lgraphqlUsergroupsGroupsbyorganizationidGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/usergroups/groupsByOrganizationId.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlUsergroupsMeGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x8e\xb1\xae\x82\x21\x14\x83\xf7\xff\x29\x78\x9a\xbb\xdc\xc4\xc1\x18\x77\xa2\xf5\x97\x78\x0e\xe0\x01\x06\x62\x78\x77\x83\x31\x47\x02\x9d\xda\x6f\x68\xfb\x2c\x90\x6a\x5e\x9b\x31\xc6\x30\xbe\xa6\xcb\x5d\xd5\x82\xad\x23\x4d\x37\x27\x29\x1f\x2c\x43\x09\xd9\x09\x5c\x02\x33\x7c\xd6\x9c\xd2\xfd\x1f\x35\x0d\xed\xd3\x42\x97\x1f\x1b\xba\x1e\xa8\xa7\x1a\x17\x76\xb6\x54\x16\xf8\xe7\xfc\x0e\x89\xe2\x86\xd5\xcf\x13\x81\xcd\xf8\x0d\x35\x75\xbb\x84\x12\x8f\x81\x30\xdf\x5a\x7e\x48\x20\x4c\x05\x6d\x6b\xef\x00\x00\x00\xff\xff\x80\x58\xa8\xdd\x39\x01\x00\x00") func _lgraphqlUsergroupsMeGraphqlBytes() ([]byte, error) { @@ -1588,6 +1630,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/projects/projectByName.graphql": _lgraphqlProjectsProjectbynameGraphql, "_lgraphql/projects/projectByNameMetadata.graphql": _lgraphqlProjectsProjectbynamemetadataGraphql, "_lgraphql/projects/projectsByMetadata.graphql": _lgraphqlProjectsProjectsbymetadataGraphql, + "_lgraphql/projects/projectsByOrganizationId.graphql": _lgraphqlProjectsProjectsbyorganizationidGraphql, "_lgraphql/projects/removeProjectMetadataByKey.graphql": _lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, "_lgraphql/projects/updateProject.graphql": _lgraphqlProjectsUpdateprojectGraphql, "_lgraphql/projects/updateProjectMetadata.graphql": _lgraphqlProjectsUpdateprojectmetadataGraphql, @@ -1612,6 +1655,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/addUserToGroup.graphql": _lgraphqlUsergroupsAddusertogroupGraphql, "_lgraphql/usergroups/allGroupMembers.graphql": _lgraphqlUsergroupsAllgroupmembersGraphql, "_lgraphql/usergroups/allUsers.graphql": _lgraphqlUsergroupsAllusersGraphql, + "_lgraphql/usergroups/groupsByOrganizationId.graphql": _lgraphqlUsergroupsGroupsbyorganizationidGraphql, "_lgraphql/usergroups/me.graphql": _lgraphqlUsergroupsMeGraphql, "_lgraphql/usergroups/removeGroupsFromProject.graphql": _lgraphqlUsergroupsRemovegroupsfromprojectGraphql, "_lgraphql/usergroups/removeUserFromGroup.graphql": _lgraphqlUsergroupsRemoveuserfromgroupGraphql, @@ -1725,6 +1769,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "projectByName.graphql": &bintree{_lgraphqlProjectsProjectbynameGraphql, map[string]*bintree{}}, "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsProjectsbymetadataGraphql, map[string]*bintree{}}, + "projectsByOrganizationId.graphql": &bintree{_lgraphqlProjectsProjectsbyorganizationidGraphql, map[string]*bintree{}}, "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, "updateProject.graphql": &bintree{_lgraphqlProjectsUpdateprojectGraphql, map[string]*bintree{}}, "updateProjectMetadata.graphql": &bintree{_lgraphqlProjectsUpdateprojectmetadataGraphql, map[string]*bintree{}}, @@ -1744,6 +1789,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "addUserToGroup.graphql": &bintree{_lgraphqlUsergroupsAddusertogroupGraphql, map[string]*bintree{}}, "allGroupMembers.graphql": &bintree{_lgraphqlUsergroupsAllgroupmembersGraphql, map[string]*bintree{}}, "allUsers.graphql": &bintree{_lgraphqlUsergroupsAllusersGraphql, map[string]*bintree{}}, + "groupsByOrganizationId.graphql": &bintree{_lgraphqlUsergroupsGroupsbyorganizationidGraphql, map[string]*bintree{}}, "me.graphql": &bintree{_lgraphqlUsergroupsMeGraphql, map[string]*bintree{}}, "removeGroupsFromProject.graphql": &bintree{_lgraphqlUsergroupsRemovegroupsfromprojectGraphql, map[string]*bintree{}}, "removeUserFromGroup.graphql": &bintree{_lgraphqlUsergroupsRemoveuserfromgroupGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/projects.go b/api/lagoon/client/projects.go index 467d559..d736e20 100644 --- a/api/lagoon/client/projects.go +++ b/api/lagoon/client/projects.go @@ -2,6 +2,8 @@ package client import ( "context" + "encoding/json" + "fmt" "github.com/uselagoon/machinery/api/schema" ) @@ -161,3 +163,35 @@ func (c *Client) UpdateProject( Response: projects, }) } + +// ProjectsByOrganizationID queries the Lagoon API for projects by the given organization id +// and unmarshals the response into environment. +func (c *Client) ProjectsByOrganizationID(ctx context.Context, id uint, projects *[]schema.OrgProject) error { + + req, err := c.newRequest("_lgraphql/projects/projectsByOrganizationId.graphql", + map[string]interface{}{ + "id": id, + }) + if err != nil { + return err + } + + o := &schema.Organization{} + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationById"` + }{ + Response: o, + }) + if err != nil { + return err + } + if len(o.Projects) == 0 { + return fmt.Errorf("no associated projects found for organization %s", o.Name) + } + data, err := json.Marshal(o.Projects) + if err != nil { + return err + } + json.Unmarshal(data, projects) + return nil +} diff --git a/api/lagoon/client/usergroups.go b/api/lagoon/client/usergroups.go index 56d762f..2ffeae3 100644 --- a/api/lagoon/client/usergroups.go +++ b/api/lagoon/client/usergroups.go @@ -3,6 +3,7 @@ package client import ( "context" "encoding/json" + "fmt" "github.com/uselagoon/machinery/api/schema" ) @@ -218,3 +219,35 @@ func (c *Client) UserBySSHFingerprint( return c.client.Run(ctx, req, &user) } + +// GroupsByOrganizationID queries the Lagoon API for groups by the given organization id +// and unmarshals the response into environment. +func (c *Client) GroupsByOrganizationID(ctx context.Context, id uint, groups *[]schema.Group) error { + + req, err := c.newRequest("_lgraphql/usergroups/groupsByOrganizationId.graphql", + map[string]interface{}{ + "id": id, + }) + if err != nil { + return err + } + + o := &schema.Organization{} + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationById"` + }{ + Response: o, + }) + if err != nil { + return err + } + if len(o.Groups) == 0 { + return fmt.Errorf("no associated groups found for organization %s", o.Name) + } + data, err := json.Marshal(o.Groups) + if err != nil { + return err + } + json.Unmarshal(data, groups) + return nil +} diff --git a/api/lagoon/projects.go b/api/lagoon/projects.go index 6425054..221cea2 100644 --- a/api/lagoon/projects.go +++ b/api/lagoon/projects.go @@ -18,6 +18,7 @@ type Projects interface { NotificationsForProjectByName(ctx context.Context, name string, result *schema.Project) error UpdateProject(ctx context.Context, id int, patch schema.UpdateProjectPatchInput, project *schema.Project) error SSHEndpointsByProject(ctx context.Context, name string, project *schema.Project) error + ProjectsByOrganizationID(ctx context.Context, name uint, project *[]schema.OrgProject) error } // GetMinimalProjectByName gets info of projects in lagoon that have matching metadata. @@ -67,3 +68,9 @@ func GetSSHEndpointsByProject(ctx context.Context, name string, p Projects) (*sc project := schema.Project{} return &project, p.SSHEndpointsByProject(ctx, name, &project) } + +// GetProjectsByOrganizationID gets projects associated with an organization in lagoon via provided ID. +func GetProjectsByOrganizationID(ctx context.Context, id uint, o Projects) (*[]schema.OrgProject, error) { + project := []schema.OrgProject{} + return &project, o.ProjectsByOrganizationID(ctx, id, &project) +} diff --git a/api/lagoon/usergroups.go b/api/lagoon/usergroups.go index dfa4811..8d95f51 100644 --- a/api/lagoon/usergroups.go +++ b/api/lagoon/usergroups.go @@ -24,6 +24,7 @@ type UserGroups interface { UserCanSSHToEnvironment(context.Context, string, *schema.Environment) error UserBySSHKey(ctx context.Context, sshKey string, user *schema.User) error UserBySSHFingerprint(ctx context.Context, fingerprint string, user *schema.User) error + GroupsByOrganizationID(ctx context.Context, id uint, group *[]schema.Group) error } // Me gets info on the current user of lagoon. @@ -98,3 +99,9 @@ func UserBySSHFingerprint(ctx context.Context, fingerprint string, ug UserGroups user := schema.User{} return &user, ug.UserBySSHFingerprint(ctx, fingerprint, &user) } + +// GetGroupsByOrganizationID gets groups associated with an organization in lagoon via provided ID. +func GetGroupsByOrganizationID(ctx context.Context, id uint, ug UserGroups) (*[]schema.Group, error) { + group := []schema.Group{} + return &group, ug.GroupsByOrganizationID(ctx, id, &group) +} diff --git a/api/schema/group.go b/api/schema/group.go index 90984a8..2b580fa 100644 --- a/api/schema/group.go +++ b/api/schema/group.go @@ -25,8 +25,11 @@ type AddGroupInput struct { // Group provides for unmarshalling the groups contained with a Project. type Group struct { AddGroupInput - ID *uuid.UUID `json:"id,omitempty"` - Members []struct { + ID *uuid.UUID `json:"id,omitempty"` + Type string `json:"type,omitempty"` + Organization int `json:"organization,omitempty"` + MemberCount int `json:"memberCount,omitempty"` + Members []struct { User User `json:"user"` Role GroupRole `json:"role"` } `json:"members,omitempty"` diff --git a/api/schema/organization.go b/api/schema/organization.go index 0538768..5de9ccf 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -6,7 +6,7 @@ type Organization struct { DeployTarget []DeployTarget `json:"openshift,omitempty"` Projects []OrgProject `json:"projects,omitempty"` Environments []OrgEnvironment `json:"environments,omitempty"` - Groups []*Groups `json:"groups,omitempty"` + Groups []Group `json:"groups,omitempty"` Owners []OrgUser `json:"owners,omitempty"` Notifications *Notifications `json:"notifications,omitempty"` } @@ -25,8 +25,9 @@ type AddOrganizationInput struct { type OrgProject struct { ID uint `json:"id,omitempty"` - Name string `json:"nameOrgProject,omitempty"` + Name string `json:"name,omitempty"` Organization uint `json:"organization,omitempty"` + GroupCount uint `json:"groupCount,omitempty"` Groups *Groups `json:"groups,omitempty"` Notifications []OrganizationNotification `json:"notifications,omitempty"` } From c51d073ce8063ca393a399fd23086d27056687a9 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 6 Oct 2023 18:48:32 +1100 Subject: [PATCH 07/22] Add project to org --- .../organizations/organizationByName.graphql | 2 +- .../projects/addProjectToOrganization.graphql | 11 ++++++++ .../projects/minimalProjectByName.graphql | 1 + .../usergroups/addGroupToOrganization.graphql | 11 ++++++++ api/lagoon/client/lgraphql/lgraphql.go | 27 +++++++++++++++++-- api/lagoon/client/projects.go | 14 ++++++++++ api/schema/project.go | 8 ++++++ 7 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/projects/addProjectToOrganization.graphql create mode 100644 api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql index 3953ca2..738e7b3 100644 --- a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql +++ b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql @@ -1,7 +1,7 @@ query ( $name: String!) { organizationByName( - organization: $name) { + name: $name) { id name description diff --git a/api/lagoon/client/_lgraphql/projects/addProjectToOrganization.graphql b/api/lagoon/client/_lgraphql/projects/addProjectToOrganization.graphql new file mode 100644 index 0000000..4906d9a --- /dev/null +++ b/api/lagoon/client/_lgraphql/projects/addProjectToOrganization.graphql @@ -0,0 +1,11 @@ +mutation ( + $project: Int!, + $organization: Int!,){ + addProjectToOrganization(input: { + project: $project, + organization: $organization, + }) { + id + name + } +} diff --git a/api/lagoon/client/_lgraphql/projects/minimalProjectByName.graphql b/api/lagoon/client/_lgraphql/projects/minimalProjectByName.graphql index 71c2e83..509a1ab 100644 --- a/api/lagoon/client/_lgraphql/projects/minimalProjectByName.graphql +++ b/api/lagoon/client/_lgraphql/projects/minimalProjectByName.graphql @@ -12,6 +12,7 @@ query ( developmentEnvironmentsLimit gitUrl autoIdle + organization openshift{ id } diff --git a/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql b/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql new file mode 100644 index 0000000..45db7b5 --- /dev/null +++ b/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql @@ -0,0 +1,11 @@ +mutation ( + $name: String!, + $organization: Int,){ + addGroupToOrganization(input: { + name: $name, + organization: $organization, + }) { + id + name + } +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index e1ed661..c6b0b14 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -28,6 +28,7 @@ // _lgraphql/deploytargetconfigs/deployTargetConfigsByProjectId.graphql // _lgraphql/deploytargetconfigs/updateDeployTargetConfig.graphql // _lgraphql/projects/addProject.graphql +// _lgraphql/projects/addProjectToOrganization.graphql // _lgraphql/projects/minimalProjectByName.graphql // _lgraphql/projects/projectByName.graphql // _lgraphql/projects/projectByNameMetadata.graphql @@ -706,7 +707,27 @@ func _lgraphqlProjectsAddprojectGraphql() (*asset, error) { return a, nil } -var __lgraphqlProjectsMinimalprojectbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x8f\x41\x4a\xc6\x30\x10\x85\xf7\x39\xc5\x08\x2e\xea\x15\x5c\x0a\x2e\x04\x91\x82\x78\x80\xd8\x8c\xed\x48\x32\x49\x27\x93\x42\x91\xde\x5d\xda\x62\x52\x17\x7f\x36\x49\xbe\x37\x2f\x79\x6f\x2e\x28\x2b\x74\x06\xe0\x9e\x6d\xc0\x47\x78\x57\x21\x1e\xef\x1e\xe0\xc7\x00\x00\x24\x89\xdf\x38\xe8\xd3\xfa\x66\x03\x76\x07\x02\x38\x27\x0f\xc3\xdf\xdc\xbe\xc8\xd5\xe3\x2e\xd5\x8b\x2d\x1a\x5f\x9c\x6f\xe0\x53\x2c\x0f\x13\xe6\x0a\x52\xf1\x5e\x70\x2e\x98\xf5\x02\x25\xba\x32\x28\x45\x7e\xe6\x85\x24\x72\x40\xd6\xaa\xc6\x84\x9c\x27\xfa\xd2\xfe\x4c\xd8\x5b\x55\x14\xae\xba\xc3\x05\x7d\x4c\xbb\xe7\x62\xcf\xaf\x14\xa8\x3d\x32\x92\x7e\x88\xbf\x1d\xb4\x7e\xd2\x4a\xfe\xab\xb9\x99\xb6\x6f\xe6\x37\x00\x00\xff\xff\x43\xb8\x3d\x3c\x4c\x01\x00\x00") +var __lgraphqlProjectsAddprojecttoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x28\xca\xcf\x4a\x4d\x2e\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x89\xe4\x17\xa5\x27\xe6\x65\x56\x81\xd5\x40\x85\x35\xab\xb9\x14\x14\x12\x53\x52\x02\x20\x8a\x43\xf2\xfd\x91\xd4\x68\x64\xe6\x15\x94\x96\x58\x29\x80\xd4\x28\x28\xc0\xcd\x83\x99\xac\x03\x16\x46\x35\x14\xc5\x0e\x90\x82\x5a\x4d\xa8\xf6\xcc\x14\x30\x95\x97\x98\x9b\x0a\x12\xe6\xaa\xe5\x02\x04\x00\x00\xff\xff\x86\x33\xbc\xab\xaf\x00\x00\x00") + +func _lgraphqlProjectsAddprojecttoorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlProjectsAddprojecttoorganizationGraphql, + "_lgraphql/projects/addProjectToOrganization.graphql", + ) +} + +func _lgraphqlProjectsAddprojecttoorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlProjectsAddprojecttoorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/projects/addProjectToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var __lgraphqlProjectsMinimalprojectbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x8f\x41\x4a\x04\x31\x10\x45\xf7\x39\x45\x09\x2e\xc6\x2b\xb8\x14\x5c\x08\x22\x03\xe2\x01\x62\xa7\xec\x29\x49\xaa\x32\x95\xca\xc0\x28\x73\x77\x49\x37\x26\x2d\x32\xd9\x24\x79\xbf\x7e\xf2\xff\xb1\xa2\x9e\x61\xe7\x00\x6e\xd9\x27\xbc\x87\x57\x53\xe2\xf9\xe6\x0e\xbe\x1d\x00\x40\x56\xf9\xc4\xc9\x1e\xce\x2f\x3e\xe1\x6e\x41\x00\xeb\xe4\x62\xf8\x9d\x6b\x8b\x42\x3f\x36\xa9\x5f\x7c\x35\x79\x0a\x71\x80\x77\xf5\x3c\x1d\xb0\x74\x90\x6b\x8c\x8a\xc7\x8a\xc5\x36\x50\x25\xd4\xc9\x48\xf8\x91\x4f\xa4\xc2\x09\xd9\xba\x2a\x19\xb9\x1c\xe8\xc3\xf6\x6b\xc2\xbd\x37\x43\xe5\xae\x07\x3c\x61\x94\xdc\x3c\x1b\x7b\x79\xa6\x44\xe3\x91\x99\xec\x4d\xe3\xf5\xa0\xa2\xb3\x67\xfa\xf2\x2d\xc4\xff\x9f\x47\xf3\x3f\xdd\x2f\x6e\xec\x17\xf7\x13\x00\x00\xff\xff\x0b\xea\x82\x53\x61\x01\x00\x00") func _lgraphqlProjectsMinimalprojectbynameGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1506,7 +1527,7 @@ func _lgraphqlOrganizationsOrganizationbyidGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcd\x41\x0e\x82\x30\x10\x05\xd0\x7d\x4f\xf1\x4d\x5c\xe0\x15\x58\xba\x71\x47\x4c\x3c\xc1\xa4\x1d\xc8\x18\xe9\xc0\xd8\x2e\xd0\x70\x77\x03\x56\x03\xbb\x9f\xd7\xff\x3b\x63\x66\x9b\x50\x39\xe0\x18\xa9\xe7\x1a\xb7\x64\x12\xbb\xc3\x09\x6f\x07\x00\x6a\x1d\x45\x79\x51\x12\x8d\xe7\xa9\xa1\x9e\xab\xd5\xf7\x2f\xf5\x77\xfd\x1b\x01\x12\x4a\x58\xb8\xc4\xc0\x4f\x6f\x32\x2c\xfd\x22\x63\xd6\x44\x57\xd3\x3b\xfb\x54\xa8\x35\xe1\x18\x1e\xeb\xa5\x6d\xeb\x62\x9a\x87\x2d\x34\x9a\xa4\x15\x4f\xff\xef\x66\x37\xbb\x4f\x00\x00\x00\xff\xff\x00\x73\x0a\xb4\xce\x00\x00\x00") +var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8d\x31\x0e\xc2\x30\x0c\x45\xf7\x9c\xe2\x23\x31\x94\x2b\x30\xb2\xb0\x55\x48\x9c\xc0\x4a\xdc\xca\x88\xc6\xad\x49\x86\x82\x7a\x77\x44\x08\x28\x9b\xf5\xfc\xfc\xbc\x64\xb6\x15\x9d\x03\xf6\x91\x26\x3e\xe2\x9a\x4c\xe2\xb8\x3b\xe0\xe5\x00\x40\x6d\xa4\x28\x4f\x4a\xa2\xf1\xb4\xf6\x34\x71\x57\x38\xf0\xd5\xcb\xd5\x4f\x06\x24\x34\xdb\x3a\x06\x7e\x78\x93\xf9\x53\xa8\x64\xc9\x9a\xe8\x62\x7a\x63\x9f\x2a\x1a\x4c\x38\x86\x7b\xf9\xd0\x5a\x67\xd3\x3c\xb7\xa0\xd7\x24\x83\x78\xfa\xe7\x36\xb7\xb9\x77\x00\x00\x00\xff\xff\xea\x81\xe5\x19\xc6\x00\x00\x00") func _lgraphqlOrganizationsOrganizationbynameGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1626,6 +1647,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/deploytargetconfigs/deployTargetConfigsByProjectId.graphql": _lgraphqlDeploytargetconfigsDeploytargetconfigsbyprojectidGraphql, "_lgraphql/deploytargetconfigs/updateDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql, "_lgraphql/projects/addProject.graphql": _lgraphqlProjectsAddprojectGraphql, + "_lgraphql/projects/addProjectToOrganization.graphql": _lgraphqlProjectsAddprojecttoorganizationGraphql, "_lgraphql/projects/minimalProjectByName.graphql": _lgraphqlProjectsMinimalprojectbynameGraphql, "_lgraphql/projects/projectByName.graphql": _lgraphqlProjectsProjectbynameGraphql, "_lgraphql/projects/projectByNameMetadata.graphql": _lgraphqlProjectsProjectbynamemetadataGraphql, @@ -1765,6 +1787,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "projects": &bintree{nil, map[string]*bintree{ "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, + "addProjectToOrganization.graphql": &bintree{_lgraphqlProjectsAddprojecttoorganizationGraphql, map[string]*bintree{}}, "minimalProjectByName.graphql": &bintree{_lgraphqlProjectsMinimalprojectbynameGraphql, map[string]*bintree{}}, "projectByName.graphql": &bintree{_lgraphqlProjectsProjectbynameGraphql, map[string]*bintree{}}, "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/projects.go b/api/lagoon/client/projects.go index d736e20..fe05b55 100644 --- a/api/lagoon/client/projects.go +++ b/api/lagoon/client/projects.go @@ -195,3 +195,17 @@ func (c *Client) ProjectsByOrganizationID(ctx context.Context, id uint, projects json.Unmarshal(data, projects) return nil } + +// AddProjectToOrganization adds a project to an organization. +func (c *Client) AddProjectToOrganization( + ctx context.Context, in *schema.AddProjectToOrganizationInput, out *schema.Project) error { + req, err := c.newRequest("_lgraphql/projects/addProjectToOrganization.graphql", in) + if err != nil { + return err + } + return wrapErr(c.client.Run(ctx, req, &struct { + Response *schema.Project `json:"addProjectToOrganization"` + }{ + Response: out, + })) +} diff --git a/api/schema/project.go b/api/schema/project.go index e599e61..c02747e 100644 --- a/api/schema/project.go +++ b/api/schema/project.go @@ -32,6 +32,8 @@ type AddProjectInput struct { DevelopmentEnvironmentsLimit uint `json:"developmentEnvironmentsLimit,omitempty"` PrivateKey string `json:"privateKey,omitempty"` BuildImage string `json:"buildImage,omitempty"` + Organization uint `json:"organization"` + AddOrgOwner bool `json:"addOrgOwner,omitempty"` } // Project is the Lagoon API Project object. @@ -121,3 +123,9 @@ type UpdateProjectPatchInput struct { // `null` is valid graphql, use a pointer to allow `nil` to be empty BuildImage *null.String `json:"buildImage,omitempty"` } + +// AddProjectToOrganizationInput +type AddProjectToOrganizationInput struct { + Project uint `json:"project"` + Organization uint `json:"organization"` +} From 6d83d527417a3db8aad2456d062af6b8ae178468 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 11 Oct 2023 18:12:34 +1100 Subject: [PATCH 08/22] Updated group organization schema + various minor changes --- .../organizations/organizationById.graphql | 2 +- ... addExistingProjectToOrganization.graphql} | 0 .../_lgraphql/projects/addProject.graphql | 4 + .../projects/projectsByOrganizationId.graphql | 2 +- .../usergroups/addGroupToOrganization.graphql | 2 +- .../usergroups/groupsByOrganizationId.graphql | 3 +- api/lagoon/client/lgraphql/lgraphql.go | 81 ++++++++++++------- api/lagoon/client/projects.go | 26 +++--- api/lagoon/client/usergroups.go | 15 +++- api/lagoon/usergroups.go | 12 ++- api/schema/organization.go | 31 ++++++- api/schema/project.go | 2 +- 12 files changed, 127 insertions(+), 53 deletions(-) rename api/lagoon/client/_lgraphql/projects/{addProjectToOrganization.graphql => addExistingProjectToOrganization.graphql} (100%) diff --git a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql index 94b9de7..7ec3472 100644 --- a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql +++ b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql @@ -1,7 +1,7 @@ query ( $id: Int!) { organizationById( - organization: $id) { + id: $id) { id name description diff --git a/api/lagoon/client/_lgraphql/projects/addProjectToOrganization.graphql b/api/lagoon/client/_lgraphql/projects/addExistingProjectToOrganization.graphql similarity index 100% rename from api/lagoon/client/_lgraphql/projects/addProjectToOrganization.graphql rename to api/lagoon/client/_lgraphql/projects/addExistingProjectToOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/projects/addProject.graphql b/api/lagoon/client/_lgraphql/projects/addProject.graphql index 505123b..017a61e 100644 --- a/api/lagoon/client/_lgraphql/projects/addProject.graphql +++ b/api/lagoon/client/_lgraphql/projects/addProject.graphql @@ -1,5 +1,6 @@ mutation ( $name: String!, + $organization: Int, $gitUrl: String!, $subfolder: String, $openshift: Int!, @@ -10,9 +11,11 @@ mutation ( $autoIdle: Int, $storageCalc: Int, $developmentEnvironmentsLimit: Int, + $addOrgOwner: Boolean, $privateKey: String) { addProject(input: { name: $name, + organization: $organization, gitUrl: $gitUrl, subfolder: $subfolder, openshift: $openshift, @@ -23,6 +26,7 @@ mutation ( autoIdle: $autoIdle, storageCalc: $storageCalc, developmentEnvironmentsLimit: $developmentEnvironmentsLimit, + addOrgOwner: $addOrgOwner, privateKey: $privateKey }) { id diff --git a/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql b/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql index 615c78e..145a68b 100644 --- a/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql +++ b/api/lagoon/client/_lgraphql/projects/projectsByOrganizationId.graphql @@ -1,7 +1,7 @@ query ( $id: Int!) { organizationById( - organization: $id) { + id: $id) { projects { id name diff --git a/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql b/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql index 45db7b5..7299e75 100644 --- a/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql +++ b/api/lagoon/client/_lgraphql/usergroups/addGroupToOrganization.graphql @@ -1,6 +1,6 @@ mutation ( $name: String!, - $organization: Int,){ + $organization: Int!,){ addGroupToOrganization(input: { name: $name, organization: $organization, diff --git a/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql b/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql index ea697bb..8019f1f 100644 --- a/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql +++ b/api/lagoon/client/_lgraphql/usergroups/groupsByOrganizationId.graphql @@ -1,12 +1,13 @@ query ( $id: Int!) { organizationById( - organization: $id) { + id: $id) { groups { id name type memberCount + organization } } } diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index c6b0b14..a1e5257 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -27,8 +27,8 @@ // _lgraphql/deploytargetconfigs/deleteDeployTargetConfig.graphql // _lgraphql/deploytargetconfigs/deployTargetConfigsByProjectId.graphql // _lgraphql/deploytargetconfigs/updateDeployTargetConfig.graphql +// _lgraphql/projects/addExistingProjectToOrganization.graphql // _lgraphql/projects/addProject.graphql -// _lgraphql/projects/addProjectToOrganization.graphql // _lgraphql/projects/minimalProjectByName.graphql // _lgraphql/projects/projectByName.graphql // _lgraphql/projects/projectByNameMetadata.graphql @@ -52,6 +52,7 @@ // _lgraphql/tasks/updateTask.graphql // _lgraphql/tasks/uploadFilesForTask.graphql // _lgraphql/usergroups/addGroup.graphql +// _lgraphql/usergroups/addGroupToOrganization.graphql // _lgraphql/usergroups/addGroupsToProject.graphql // _lgraphql/usergroups/addSshKey.graphql // _lgraphql/usergroups/addUser.graphql @@ -687,42 +688,42 @@ func _lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql() (*asset, erro return a, nil } -var __lgraphqlProjectsAddprojectGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x91\x4b\x6a\xc3\x40\x0c\x86\xf7\x3e\x85\x02\x5d\x24\x90\x13\x78\x5b\xba\x08\xed\x22\x50\x7a\x80\x89\x47\x71\xa6\x8c\x35\xae\xac\x31\x94\xd2\xbb\x17\x3f\xe6\x95\x26\x59\x78\xf3\xff\x92\x2d\x7f\x5f\xe7\x45\x89\x71\x04\xdb\x0a\xe0\x89\x54\x87\x35\xbc\x0b\x1b\x6a\x37\xfb\x29\x69\x8d\x7c\xb0\x2d\xb3\xc1\x9f\xce\xce\x6a\xe4\x10\xcf\xa9\xeb\x91\x86\x8b\x39\x4b\x0d\x07\x92\x4d\x99\x1d\xd9\x7d\x62\x23\x47\x25\x82\x4c\xc5\xde\x89\x15\x35\x17\x1c\x8a\xb0\xf7\xd6\x32\x7e\x79\x1c\xe4\xaa\x60\xa7\x7d\x33\x5d\xfc\x42\xa3\x61\x47\x1d\x92\x94\xe7\x29\x2f\xee\xa0\x2d\xce\x77\x2c\x07\x8b\x63\xd5\xe2\xb3\xb2\x4d\x0a\x35\x8e\x68\x5d\x3f\xed\x67\xaf\x1a\xde\x4c\x67\x24\x4d\xf5\x6c\x46\x25\xf8\x8a\xdf\xe1\x23\x3b\xf8\xa9\x00\x00\x94\xd6\xeb\x5f\x6d\x0d\xf5\x5e\xea\x35\x07\x58\x28\xce\x30\xf7\x6b\x14\x30\xae\x3c\x43\x9c\x91\x4c\x54\x43\x99\x01\x4d\x20\xff\x95\xd7\x64\xef\x31\x0f\x8b\x09\x77\x24\x1f\xaa\x12\x7a\xe1\x20\x8e\xdc\xc6\x7f\x5b\x4b\x58\x4a\x42\xa2\x9b\x08\x20\x37\x93\x7b\x0a\x03\x8f\x2d\x3d\x94\x98\x6e\x4e\x0a\x33\x9f\x73\xfb\xbb\x8b\xd6\x8c\xce\xf4\x2d\x65\x35\x3d\x7f\x01\x00\x00\xff\xff\x70\x99\xe2\x23\x22\x03\x00\x00") +var __lgraphqlProjectsAddexistingprojecttoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x28\xca\xcf\x4a\x4d\x2e\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x89\xe4\x17\xa5\x27\xe6\x65\x56\x81\xd5\x40\x85\x35\xab\xb9\x14\x14\x12\x53\x52\x02\x20\x8a\x43\xf2\xfd\x91\xd4\x68\x64\xe6\x15\x94\x96\x58\x29\x80\xd4\x28\x28\xc0\xcd\x83\x99\xac\x03\x16\x46\x35\x14\xc5\x0e\x90\x82\x5a\x4d\xa8\xf6\xcc\x14\x30\x95\x97\x98\x9b\x0a\x12\xe6\xaa\xe5\x02\x04\x00\x00\xff\xff\x86\x33\xbc\xab\xaf\x00\x00\x00") -func _lgraphqlProjectsAddprojectGraphqlBytes() ([]byte, error) { +func _lgraphqlProjectsAddexistingprojecttoorganizationGraphqlBytes() ([]byte, error) { return bindataRead( - __lgraphqlProjectsAddprojectGraphql, - "_lgraphql/projects/addProject.graphql", + __lgraphqlProjectsAddexistingprojecttoorganizationGraphql, + "_lgraphql/projects/addExistingProjectToOrganization.graphql", ) } -func _lgraphqlProjectsAddprojectGraphql() (*asset, error) { - bytes, err := _lgraphqlProjectsAddprojectGraphqlBytes() +func _lgraphqlProjectsAddexistingprojecttoorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlProjectsAddexistingprojecttoorganizationGraphqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "_lgraphql/projects/addProject.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + info := bindataFileInfo{name: "_lgraphql/projects/addExistingProjectToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var __lgraphqlProjectsAddprojecttoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x28\xca\xcf\x4a\x4d\x2e\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x89\xe4\x17\xa5\x27\xe6\x65\x56\x81\xd5\x40\x85\x35\xab\xb9\x14\x14\x12\x53\x52\x02\x20\x8a\x43\xf2\xfd\x91\xd4\x68\x64\xe6\x15\x94\x96\x58\x29\x80\xd4\x28\x28\xc0\xcd\x83\x99\xac\x03\x16\x46\x35\x14\xc5\x0e\x90\x82\x5a\x4d\xa8\xf6\xcc\x14\x30\x95\x97\x98\x9b\x0a\x12\xe6\xaa\xe5\x02\x04\x00\x00\xff\xff\x86\x33\xbc\xab\xaf\x00\x00\x00") +var __lgraphqlProjectsAddprojectGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x92\xcf\x4e\xc3\x30\x0c\xc6\xef\x7b\x8a\x4c\xe2\xb0\x49\x7b\x82\x1d\x41\x1c\x26\x90\x36\x09\xf1\x00\x5e\xe3\x75\x41\xa9\x53\x1c\x67\x08\x10\xef\x8e\xda\x35\xff\xc6\xd8\xa1\x97\xcf\xdf\xd7\xd8\xfe\xb9\x0b\x02\x62\x1c\xa9\xc5\x4c\xa9\x3b\x82\x0e\xd7\xea\x45\xd8\x50\x3b\x5f\x0d\x8a\xe3\x16\xc8\x7c\x8d\x9e\xb5\xda\x90\x8c\x6a\x6b\xe4\x95\x6d\xed\xf4\x61\x7f\x70\x56\x23\x47\xf9\x9c\xef\x91\xfc\xd1\x1c\x64\x0c\xcf\x6b\x6d\xc7\xee\x0d\x1b\xd9\x81\x08\x32\x55\xb9\x3d\x03\x35\x47\xf4\x95\xd8\x07\x6b\x19\xdf\x03\x7a\xb9\x28\xb0\xd3\xa1\x19\x7a\x7c\xa4\x93\x61\x47\x1d\x92\xd4\xed\x41\x10\xb7\xd1\x16\xf3\x10\x5e\x1c\x43\x8b\x0f\x60\x9b\x2c\x6a\x3c\xa1\x75\xfd\x90\x2f\x7e\xe5\x9f\x4d\x67\x24\xbb\x40\xeb\x2d\xb7\xdb\x0f\x1a\xa6\xbd\x77\xce\x22\xd0\xd4\x88\x39\x81\xe0\x13\x7e\xc6\xd7\x97\xea\x7b\xa6\x94\x52\xa0\xf5\x34\xee\xc2\x50\x1f\x64\x3d\xe9\x4a\x9d\x97\x3e\xee\x7e\x35\x49\xf5\xd6\x2b\x08\xd1\x12\x11\x4c\x2c\xa2\x5c\x50\xc8\x44\xd2\x6f\x33\x8c\x0c\xe1\x4f\xf1\x92\xca\x7f\xbc\x62\x30\xa3\x4a\xd4\x62\xa9\x06\x56\xf1\x4b\x96\xeb\xe8\xae\x23\x8d\xa1\x0c\x33\x71\x4d\x0b\x28\xa9\x96\x8c\xa3\xe1\x36\xe1\x9b\x07\x90\x9e\x2f\xf1\x97\xc7\x90\x87\xca\x67\x50\xdc\xc4\x58\xfd\x59\x26\xf2\x46\x17\x27\x70\x2e\xce\x86\xef\x37\x00\x00\xff\xff\xc5\xe9\x48\x5a\x95\x03\x00\x00") -func _lgraphqlProjectsAddprojecttoorganizationGraphqlBytes() ([]byte, error) { +func _lgraphqlProjectsAddprojectGraphqlBytes() ([]byte, error) { return bindataRead( - __lgraphqlProjectsAddprojecttoorganizationGraphql, - "_lgraphql/projects/addProjectToOrganization.graphql", + __lgraphqlProjectsAddprojectGraphql, + "_lgraphql/projects/addProject.graphql", ) } -func _lgraphqlProjectsAddprojecttoorganizationGraphql() (*asset, error) { - bytes, err := _lgraphqlProjectsAddprojecttoorganizationGraphqlBytes() +func _lgraphqlProjectsAddprojectGraphql() (*asset, error) { + bytes, err := _lgraphqlProjectsAddprojectGraphqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "_lgraphql/projects/addProjectToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + info := bindataFileInfo{name: "_lgraphql/projects/addProject.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -807,7 +808,7 @@ func _lgraphqlProjectsProjectsbymetadataGraphql() (*asset, error) { return a, nil } -var __lgraphqlProjectsProjectsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xd4\x54\xa8\xe6\x52\x50\xc8\x2f\x4a\x4f\xcc\xcb\xac\x4a\x2c\xc9\xcc\xcf\x73\xaa\xf4\x4c\x01\x29\x41\x15\xb5\x02\x69\x81\x28\x56\x50\x28\x28\xca\xcf\x4a\x4d\x2e\x29\x86\x72\x15\x14\x32\x53\xa0\x8c\xbc\xc4\xdc\x54\x28\x13\x59\x37\x54\x28\xbd\x28\xbf\xb4\xc0\x39\xbf\x34\xaf\x04\x2c\x50\xcb\x05\xc2\xb5\x5c\x80\x00\x00\x00\xff\xff\xaf\xfd\x66\x60\x97\x00\x00\x00") +var __lgraphqlProjectsProjectsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xd4\x54\xa8\xe6\x52\x50\xc8\x2f\x4a\x4f\xcc\xcb\xac\x4a\x2c\xc9\xcc\xcf\x73\xaa\xf4\x4c\x01\x29\x51\x50\x00\xa9\x51\xc9\x4c\x81\x28\x51\x50\x28\x28\xca\xcf\x4a\x4d\x2e\x29\x86\x72\x41\xf2\x50\x46\x5e\x62\x6e\x2a\x94\x89\x6c\x12\x54\x28\xbd\x28\xbf\xb4\xc0\x39\xbf\x34\xaf\x04\x2c\x50\xcb\x05\xc2\xb5\x5c\x80\x00\x00\x00\xff\xff\xf8\x1b\xb1\x64\x8d\x00\x00\x00") func _lgraphqlProjectsProjectsbyorganizationidGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1187,6 +1188,26 @@ func _lgraphqlUsergroupsAddgroupGraphql() (*asset, error) { return a, nil } +var __lgraphqlUsergroupsAddgrouptoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\x4b\xcc\x4d\xb5\x52\x08\x2e\x29\xca\xcc\x4b\x57\xd4\x01\x89\xe4\x17\xa5\x27\xe6\x65\x56\x81\xd5\x58\x29\x78\xe6\x95\x28\xea\x68\x56\x73\x29\x28\x24\xa6\xa4\xb8\x17\xe5\x97\x16\x84\xe4\xfb\x23\xa9\xd0\xc8\xcc\x2b\x28\x2d\xb1\x52\x00\xa9\x50\x50\x80\x98\x06\x36\x54\x07\x2c\x80\x6a\x18\x8a\xd9\x20\x05\xb5\x9a\x50\x8d\x99\x29\x70\xfd\x20\x61\xae\x5a\x2e\x40\x00\x00\x00\xff\xff\x92\x85\xef\xa4\xa7\x00\x00\x00") + +func _lgraphqlUsergroupsAddgrouptoorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlUsergroupsAddgrouptoorganizationGraphql, + "_lgraphql/usergroups/addGroupToOrganization.graphql", + ) +} + +func _lgraphqlUsergroupsAddgrouptoorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlUsergroupsAddgrouptoorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/usergroups/addGroupToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlUsergroupsAddgroupstoprojectGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x28\xca\xcf\x4a\x4d\x2e\xb1\x52\x08\x80\x30\x3c\xf3\x0a\x4a\x4b\x14\x75\x40\x52\xe9\x45\xf9\xa5\x05\xc5\x56\x0a\xd1\xee\x20\x06\x44\x22\x56\x51\x53\xa1\x9a\x4b\x41\x41\x41\x21\x31\x25\x05\x2c\x5e\x1c\x92\x0f\xd5\xaa\x91\x09\x52\x62\x05\x95\x57\x50\x80\x1b\x0d\xb3\x04\x2a\x0e\x33\x17\x6a\x01\x58\xb4\x56\x13\xae\x2d\x33\x05\xca\xc8\x4b\xcc\x4d\x85\x48\x72\x81\x30\x20\x00\x00\xff\xff\x8b\x70\xd6\xd3\xb8\x00\x00\x00") func _lgraphqlUsergroupsAddgroupstoprojectGraphqlBytes() ([]byte, error) { @@ -1307,7 +1328,7 @@ func _lgraphqlUsergroupsAllusersGraphql() (*asset, error) { return a, nil } -var __lgraphqlUsergroupsGroupsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xd4\x54\xa8\xe6\x52\x50\xc8\x2f\x4a\x4f\xcc\xcb\xac\x4a\x2c\xc9\xcc\xcf\x73\xaa\xf4\x4c\x01\x29\x41\x15\xb5\x02\x69\x81\x28\x56\x50\x48\x2f\xca\x2f\x2d\x28\x86\x72\x14\x14\x32\x53\xa0\x8c\xbc\xc4\xdc\x54\x28\xb3\xa4\xb2\x00\xc6\xcc\x4d\xcd\x4d\x4a\x2d\x72\xce\x2f\xcd\x2b\x01\x8b\xd4\x72\x81\x70\x2d\x17\x20\x00\x00\xff\xff\xfe\xdb\x77\x76\x8e\x00\x00\x00") +var __lgraphqlUsergroupsGroupsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xd4\x54\xa8\xe6\x52\x50\xc8\x2f\x4a\x4f\xcc\xcb\xac\x4a\x2c\xc9\xcc\xcf\x73\xaa\xf4\x4c\x01\x29\x51\x50\x00\xa9\x51\xc9\x4c\x81\x28\x51\x50\x48\x2f\xca\x2f\x2d\x28\x86\x72\x40\xb2\x50\x46\x5e\x62\x6e\x2a\x94\x59\x52\x59\x00\x63\xe6\xa6\xe6\x26\xa5\x16\x39\xe7\x97\xe6\x95\x40\x45\x90\x2d\x01\x0b\xd5\x72\x81\x70\x2d\x17\x20\x00\x00\xff\xff\xed\x26\x0a\x8d\x97\x00\x00\x00") func _lgraphqlUsergroupsGroupsbyorganizationidGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1507,7 +1528,7 @@ func _lgraphqlOrganizationsDeleteorganizationGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcc\x4d\x0a\xc2\x30\x10\x05\xe0\x7d\x4e\xf1\x04\x17\xf5\x0a\x5d\xba\x91\x6e\x8a\x57\x08\x49\x2a\x23\x3a\xd3\x8e\x93\x45\x14\xef\x2e\x29\xf1\x6f\x31\xf0\xf8\x78\x6f\x96\x9c\xb4\xa0\x73\xc0\x96\x62\x8f\x81\x6d\xb3\xc3\xc3\x01\x80\xe8\xc9\x33\xdd\xbd\x91\xf0\xbe\x0c\xb1\x5b\xf5\xdf\xfb\x3a\x7b\x0f\x00\x8a\x2d\xb0\xbf\xa6\x16\x63\xba\x05\xa5\xb9\xb6\x9b\x2c\x59\xcc\x1f\x55\xce\x29\x58\xa3\x49\x29\x71\xbc\x94\xf1\xbb\x5b\x5b\x07\x95\x3c\xff\xc2\x28\x46\x13\x05\xff\x79\xf7\x74\xf5\x5e\x01\x00\x00\xff\xff\xc2\xc4\x03\x71\xc7\x00\x00\x00") +var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\xcc\x41\x0a\xc2\x30\x10\x05\xd0\x7d\x4e\xf1\x85\x2e\xea\x15\x5c\xba\x91\x6e\x8a\x57\x08\x49\x2a\x23\x3a\xd3\x8e\x93\x45\x14\xef\x2e\x29\x51\xbb\x18\xf8\x3c\xfe\x9f\x25\x27\x2d\xe8\x1d\xd0\x51\x3c\x60\x60\xdb\xed\xf1\x72\x00\x20\x7a\xf1\x4c\x4f\x6f\x24\x7c\x2c\x43\xec\x57\x05\x6a\xaf\xa3\xf8\xad\x55\x68\x81\xfd\x3d\xb5\x18\xd3\x23\x28\xcd\x75\xdb\x64\xc9\x62\xfe\xac\x72\x4d\xc1\x1a\x4d\x4a\x89\xe3\xad\x8c\xff\xdd\xda\x3a\xa9\xe4\x79\x0b\xa3\x18\x4d\x14\xfc\xef\xdd\xdb\xd5\xfb\x04\x00\x00\xff\xff\xd8\x99\xb0\xf5\xbd\x00\x00\x00") func _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1646,8 +1667,8 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/deploytargetconfigs/deleteDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsDeletedeploytargetconfigGraphql, "_lgraphql/deploytargetconfigs/deployTargetConfigsByProjectId.graphql": _lgraphqlDeploytargetconfigsDeploytargetconfigsbyprojectidGraphql, "_lgraphql/deploytargetconfigs/updateDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql, + "_lgraphql/projects/addExistingProjectToOrganization.graphql": _lgraphqlProjectsAddexistingprojecttoorganizationGraphql, "_lgraphql/projects/addProject.graphql": _lgraphqlProjectsAddprojectGraphql, - "_lgraphql/projects/addProjectToOrganization.graphql": _lgraphqlProjectsAddprojecttoorganizationGraphql, "_lgraphql/projects/minimalProjectByName.graphql": _lgraphqlProjectsMinimalprojectbynameGraphql, "_lgraphql/projects/projectByName.graphql": _lgraphqlProjectsProjectbynameGraphql, "_lgraphql/projects/projectByNameMetadata.graphql": _lgraphqlProjectsProjectbynamemetadataGraphql, @@ -1671,6 +1692,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/tasks/updateTask.graphql": _lgraphqlTasksUpdatetaskGraphql, "_lgraphql/tasks/uploadFilesForTask.graphql": _lgraphqlTasksUploadfilesfortaskGraphql, "_lgraphql/usergroups/addGroup.graphql": _lgraphqlUsergroupsAddgroupGraphql, + "_lgraphql/usergroups/addGroupToOrganization.graphql": _lgraphqlUsergroupsAddgrouptoorganizationGraphql, "_lgraphql/usergroups/addGroupsToProject.graphql": _lgraphqlUsergroupsAddgroupstoprojectGraphql, "_lgraphql/usergroups/addSshKey.graphql": _lgraphqlUsergroupsAddsshkeyGraphql, "_lgraphql/usergroups/addUser.graphql": _lgraphqlUsergroupsAdduserGraphql, @@ -1786,16 +1808,16 @@ var _bintree = &bintree{nil, map[string]*bintree{ "updateOrganization.graphql": &bintree{_lgraphqlOrganizationsUpdateorganizationGraphql, map[string]*bintree{}}, }}, "projects": &bintree{nil, map[string]*bintree{ - "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, - "addProjectToOrganization.graphql": &bintree{_lgraphqlProjectsAddprojecttoorganizationGraphql, map[string]*bintree{}}, - "minimalProjectByName.graphql": &bintree{_lgraphqlProjectsMinimalprojectbynameGraphql, map[string]*bintree{}}, - "projectByName.graphql": &bintree{_lgraphqlProjectsProjectbynameGraphql, map[string]*bintree{}}, - "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, - "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsProjectsbymetadataGraphql, map[string]*bintree{}}, - "projectsByOrganizationId.graphql": &bintree{_lgraphqlProjectsProjectsbyorganizationidGraphql, map[string]*bintree{}}, - "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, - "updateProject.graphql": &bintree{_lgraphqlProjectsUpdateprojectGraphql, map[string]*bintree{}}, - "updateProjectMetadata.graphql": &bintree{_lgraphqlProjectsUpdateprojectmetadataGraphql, map[string]*bintree{}}, + "addExistingProjectToOrganization.graphql": &bintree{_lgraphqlProjectsAddexistingprojecttoorganizationGraphql, map[string]*bintree{}}, + "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, + "minimalProjectByName.graphql": &bintree{_lgraphqlProjectsMinimalprojectbynameGraphql, map[string]*bintree{}}, + "projectByName.graphql": &bintree{_lgraphqlProjectsProjectbynameGraphql, map[string]*bintree{}}, + "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, + "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsProjectsbymetadataGraphql, map[string]*bintree{}}, + "projectsByOrganizationId.graphql": &bintree{_lgraphqlProjectsProjectsbyorganizationidGraphql, map[string]*bintree{}}, + "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, + "updateProject.graphql": &bintree{_lgraphqlProjectsUpdateprojectGraphql, map[string]*bintree{}}, + "updateProjectMetadata.graphql": &bintree{_lgraphqlProjectsUpdateprojectmetadataGraphql, map[string]*bintree{}}, }}, "sshEndpointsByProject.graphql": &bintree{_lgraphqlSshendpointsbyprojectGraphql, map[string]*bintree{}}, "taskByID.graphql": &bintree{_lgraphqlTaskbyidGraphql, map[string]*bintree{}}, @@ -1806,6 +1828,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "usergroups": &bintree{nil, map[string]*bintree{ "addGroup.graphql": &bintree{_lgraphqlUsergroupsAddgroupGraphql, map[string]*bintree{}}, + "addGroupToOrganization.graphql": &bintree{_lgraphqlUsergroupsAddgrouptoorganizationGraphql, map[string]*bintree{}}, "addGroupsToProject.graphql": &bintree{_lgraphqlUsergroupsAddgroupstoprojectGraphql, map[string]*bintree{}}, "addSshKey.graphql": &bintree{_lgraphqlUsergroupsAddsshkeyGraphql, map[string]*bintree{}}, "addUser.graphql": &bintree{_lgraphqlUsergroupsAdduserGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/projects.go b/api/lagoon/client/projects.go index fe05b55..c094909 100644 --- a/api/lagoon/client/projects.go +++ b/api/lagoon/client/projects.go @@ -196,16 +196,16 @@ func (c *Client) ProjectsByOrganizationID(ctx context.Context, id uint, projects return nil } -// AddProjectToOrganization adds a project to an organization. -func (c *Client) AddProjectToOrganization( - ctx context.Context, in *schema.AddProjectToOrganizationInput, out *schema.Project) error { - req, err := c.newRequest("_lgraphql/projects/addProjectToOrganization.graphql", in) - if err != nil { - return err - } - return wrapErr(c.client.Run(ctx, req, &struct { - Response *schema.Project `json:"addProjectToOrganization"` - }{ - Response: out, - })) -} +// TODO - AddExistingProjectToOrganization adds an existing project to an organization. +//func (c *Client) AddExistingProjectToOrganization( +// ctx context.Context, in *schema.AddProjectToOrganizationInput, out *schema.Project) error { +// req, err := c.newRequest("_lgraphql/projects/addExistingProjectToOrganization.graphql", in) +// if err != nil { +// return err +// } +// return wrapErr(c.client.Run(ctx, req, &struct { +// Response *schema.Project `json:"addProjectToOrganization"` +// }{ +// Response: out, +// })) +//} diff --git a/api/lagoon/client/usergroups.go b/api/lagoon/client/usergroups.go index 2ffeae3..bd63a86 100644 --- a/api/lagoon/client/usergroups.go +++ b/api/lagoon/client/usergroups.go @@ -222,7 +222,7 @@ func (c *Client) UserBySSHFingerprint( // GroupsByOrganizationID queries the Lagoon API for groups by the given organization id // and unmarshals the response into environment. -func (c *Client) GroupsByOrganizationID(ctx context.Context, id uint, groups *[]schema.Group) error { +func (c *Client) GroupsByOrganizationID(ctx context.Context, id uint, groups *[]schema.OrgGroup) error { req, err := c.newRequest("_lgraphql/usergroups/groupsByOrganizationId.graphql", map[string]interface{}{ @@ -251,3 +251,16 @@ func (c *Client) GroupsByOrganizationID(ctx context.Context, id uint, groups *[] json.Unmarshal(data, groups) return nil } + +// AddGroupToOrganization adds a Group to an Organization. +func (c *Client) AddGroupToOrganization(ctx context.Context, in *schema.AddGroupToOrganizationInput, out *schema.OrgGroup) error { + req, err := c.newRequest("_lgraphql/usergroups/addGroupToOrganization.graphql", in) + if err != nil { + return err + } + return c.client.Run(ctx, req, &struct { + Response *schema.OrgGroup `json:"addGroupToOrganization"` + }{ + Response: out, + }) +} diff --git a/api/lagoon/usergroups.go b/api/lagoon/usergroups.go index 8d95f51..caa1223 100644 --- a/api/lagoon/usergroups.go +++ b/api/lagoon/usergroups.go @@ -24,7 +24,8 @@ type UserGroups interface { UserCanSSHToEnvironment(context.Context, string, *schema.Environment) error UserBySSHKey(ctx context.Context, sshKey string, user *schema.User) error UserBySSHFingerprint(ctx context.Context, fingerprint string, user *schema.User) error - GroupsByOrganizationID(ctx context.Context, id uint, group *[]schema.Group) error + GroupsByOrganizationID(ctx context.Context, id uint, group *[]schema.OrgGroup) error + AddGroupToOrganization(ctx context.Context, in *schema.AddGroupToOrganizationInput, out *schema.OrgGroup) error } // Me gets info on the current user of lagoon. @@ -101,7 +102,12 @@ func UserBySSHFingerprint(ctx context.Context, fingerprint string, ug UserGroups } // GetGroupsByOrganizationID gets groups associated with an organization in lagoon via provided ID. -func GetGroupsByOrganizationID(ctx context.Context, id uint, ug UserGroups) (*[]schema.Group, error) { - group := []schema.Group{} +func GetGroupsByOrganizationID(ctx context.Context, id uint, ug UserGroups) (*[]schema.OrgGroup, error) { + group := []schema.OrgGroup{} return &group, ug.GroupsByOrganizationID(ctx, id, &group) } + +func AddGroupToOrganization(ctx context.Context, in *schema.AddGroupToOrganizationInput, ug UserGroups) (*schema.OrgGroup, error) { + group := schema.OrgGroup{} + return &group, ug.AddGroupToOrganization(ctx, in, &group) +} diff --git a/api/schema/organization.go b/api/schema/organization.go index 5de9ccf..9f32de3 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -1,12 +1,14 @@ package schema +import "github.com/google/uuid" + // Organization is based on the Lagoon API type. type Organization struct { AddOrganizationInput DeployTarget []DeployTarget `json:"openshift,omitempty"` Projects []OrgProject `json:"projects,omitempty"` Environments []OrgEnvironment `json:"environments,omitempty"` - Groups []Group `json:"groups,omitempty"` + Groups []OrgGroup `json:"groups,omitempty"` Owners []OrgUser `json:"owners,omitempty"` Notifications *Notifications `json:"notifications,omitempty"` } @@ -28,7 +30,7 @@ type OrgProject struct { Name string `json:"name,omitempty"` Organization uint `json:"organization,omitempty"` GroupCount uint `json:"groupCount,omitempty"` - Groups *Groups `json:"groups,omitempty"` + Groups *OrgGroups `json:"groups,omitempty"` Notifications []OrganizationNotification `json:"notifications,omitempty"` } @@ -53,6 +55,31 @@ type OrgEnvironment struct { Kubernetes *uint `json:"kubernetes,omitempty"` } +// AddGroupToOrganizationInput is based on the input to AddGroupToOrganization. +type AddGroupToOrganizationInput struct { + Name string `json:"name"` + Organization uint `json:"organization"` + ParentGroup *GroupInput `json:"parentGroup,omitempty"` + AddOrgOwner bool `json:"addOrgOwner,omitempty"` +} + +// OrgGroup provides for unmarshalling the groups contained with an Organization. +type OrgGroup struct { + AddGroupToOrganizationInput + ID *uuid.UUID `json:"id,omitempty"` + Type string `json:"type,omitempty"` + Members []struct { + User User `json:"user"` + Role GroupRole `json:"role"` + } `json:"members,omitempty"` + MemberCount int `json:"memberCount,omitempty"` + Projects []OrgProject `json:"projects,omitempty"` +} + +type OrgGroups struct { + OrgGroups []OrgGroup +} + type OrganizationNotification struct { Name string `json:"name"` Type NotificationType `json:"type"` diff --git a/api/schema/project.go b/api/schema/project.go index c02747e..1414506 100644 --- a/api/schema/project.go +++ b/api/schema/project.go @@ -32,7 +32,7 @@ type AddProjectInput struct { DevelopmentEnvironmentsLimit uint `json:"developmentEnvironmentsLimit,omitempty"` PrivateKey string `json:"privateKey,omitempty"` BuildImage string `json:"buildImage,omitempty"` - Organization uint `json:"organization"` + Organization uint `json:"organization,omitempty"` AddOrgOwner bool `json:"addOrgOwner,omitempty"` } From b9d9df834b25a3003c1a327337d2297c4b92793e Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 13 Oct 2023 17:55:39 +1100 Subject: [PATCH 09/22] Included queries for deploy targets & users --- .../deployTargetsByOrganizationId.graphql | 21 ++++ .../deployTargetsByOrganizationName.graphql | 21 ++++ .../usergroups/usersByOrganization.graphql | 12 +++ .../usersByOrganizationName.graphql | 14 +++ api/lagoon/client/deploytargets.go | 66 ++++++++++++ api/lagoon/client/lgraphql/lgraphql.go | 100 +++++++++++++++++- api/lagoon/client/projects.go | 2 +- api/lagoon/client/usergroups.go | 55 +++++++++- api/lagoon/deploytarget.go | 14 +++ api/lagoon/projects.go | 6 +- api/lagoon/usergroups.go | 16 ++- api/schema/organization.go | 2 +- 12 files changed, 317 insertions(+), 12 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql create mode 100644 api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql create mode 100644 api/lagoon/client/_lgraphql/usergroups/usersByOrganization.graphql create mode 100644 api/lagoon/client/_lgraphql/usergroups/usersByOrganizationName.graphql diff --git a/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql new file mode 100644 index 0000000..f7afc0a --- /dev/null +++ b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql @@ -0,0 +1,21 @@ +query ( + $id: Int!) { + organizationById( + id: $id) { + deployTargets { + id + name + created + consoleUrl + cloudRegion + cloudProvider + friendlyName + token + sshHost + sshPort + routerPattern + buildImage + monitoringConfig + } + } + } diff --git a/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql new file mode 100644 index 0000000..1933cb0 --- /dev/null +++ b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql @@ -0,0 +1,21 @@ +query ( + $name: String!) { + organizationByName( + name: $name) { + deployTargets { + id + name + created + consoleUrl + cloudRegion + cloudProvider + friendlyName + token + sshHost + sshPort + routerPattern + buildImage + monitoringConfig + } + } +} diff --git a/api/lagoon/client/_lgraphql/usergroups/usersByOrganization.graphql b/api/lagoon/client/_lgraphql/usergroups/usersByOrganization.graphql new file mode 100644 index 0000000..e628c77 --- /dev/null +++ b/api/lagoon/client/_lgraphql/usergroups/usersByOrganization.graphql @@ -0,0 +1,12 @@ +query ( + $id: Int!) { + usersByOrganization( + organization: $id) { + id + email + firstName + lastName + owner + comment + } +} diff --git a/api/lagoon/client/_lgraphql/usergroups/usersByOrganizationName.graphql b/api/lagoon/client/_lgraphql/usergroups/usersByOrganizationName.graphql new file mode 100644 index 0000000..3466435 --- /dev/null +++ b/api/lagoon/client/_lgraphql/usergroups/usersByOrganizationName.graphql @@ -0,0 +1,14 @@ +query ( + $name: String!) { + organizationByName( + name: $name) { + owners { + id + email + firstName + lastName + owner + comment + } + } +} diff --git a/api/lagoon/client/deploytargets.go b/api/lagoon/client/deploytargets.go index c85ba0a..f973c27 100644 --- a/api/lagoon/client/deploytargets.go +++ b/api/lagoon/client/deploytargets.go @@ -2,6 +2,8 @@ package client import ( "context" + "encoding/json" + "fmt" "github.com/uselagoon/machinery/api/schema" ) @@ -56,3 +58,67 @@ func (c *Client) DeleteDeployTarget(ctx context.Context, in *schema.DeleteDeploy return c.client.Run(ctx, req, &out) } + +// DeployTargetsByOrganizationId queries the Lagoon API for deploy targets by the given organization id +// and unmarshals the response into organization. +func (c *Client) DeployTargetsByOrganizationId(ctx context.Context, id uint, out *[]schema.DeployTarget) error { + + req, err := c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql", + map[string]interface{}{ + "id": id, + }) + if err != nil { + return err + } + + o := &schema.Organization{} + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationById"` + }{ + Response: o, + }) + if err != nil { + return err + } + if len(o.DeployTargets) == 0 { + return fmt.Errorf("no deploy targets found for organization %s", o.Name) + } + data, err := json.Marshal(o.DeployTargets) + if err != nil { + return err + } + json.Unmarshal(data, out) + return nil +} + +// DeployTargetsByOrganizationName queries the Lagoon API for deploy targets by the given organization name +// and unmarshals the response into organization. +func (c *Client) DeployTargetsByOrganizationName(ctx context.Context, name string, out *[]schema.DeployTarget) error { + + req, err := c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql", + map[string]interface{}{ + "name": name, + }) + if err != nil { + return err + } + + o := &schema.Organization{} + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationByName"` + }{ + Response: o, + }) + if err != nil { + return err + } + if len(o.DeployTargets) == 0 { + return fmt.Errorf("no deploy targets found for organization %s", o.Name) + } + data, err := json.Marshal(o.DeployTargets) + if err != nil { + return err + } + json.Unmarshal(data, out) + return nil +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index a1e5257..aff66f5 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -21,6 +21,8 @@ // _lgraphql/deployments/updateDeployment.graphql // _lgraphql/deploytargets/addDeployTarget.graphql // _lgraphql/deploytargets/deleteDeployTarget.graphql +// _lgraphql/deploytargets/deployTargetsByOrganizationId.graphql +// _lgraphql/deploytargets/deployTargetsByOrganizationName.graphql // _lgraphql/deploytargets/listDeployTargets.graphql // _lgraphql/deploytargets/updateDeployTarget.graphql // _lgraphql/deploytargetconfigs/addDeployTargetConfig.graphql @@ -67,6 +69,8 @@ // _lgraphql/usergroups/userBySSHFingerprint.graphql // _lgraphql/usergroups/userBySSHKey.graphql // _lgraphql/usergroups/userCanSSHToEnvironment.graphql +// _lgraphql/usergroups/usersByOrganization.graphql +// _lgraphql/usergroups/usersByOrganizationName.graphql // _lgraphql/organizations/addOrganization.graphql // _lgraphql/organizations/deleteOrganization.graphql // _lgraphql/organizations/organizationById.graphql @@ -568,6 +572,46 @@ func _lgraphqlDeploytargetsDeletedeploytargetGraphql() (*asset, error) { return a, nil } +var __lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8c\x31\x4e\x04\x31\x0c\x45\xfb\x39\x85\x91\xb6\x58\xae\x40\x09\x0d\xd3\xa0\x11\x82\x03\x84\xb5\x37\x58\x64\x6c\x70\x1c\xa4\x80\xb8\x3b\xda\x51\xac\xd9\x22\xd2\xff\x2f\xcf\xff\xab\x91\x75\x38\x4e\x00\x07\xc6\x3b\x98\xc5\x6f\x6e\xe1\x77\x02\x00\x50\xcb\x49\xf8\x27\x39\xab\xdc\xf7\x19\x8f\x1b\xbd\x58\x07\xc6\x90\x90\x3e\x8b\xf6\x97\x64\x99\xbc\x0e\x76\x91\x46\x90\xb4\xd2\x88\x27\xa3\xe4\x14\x1f\x27\x95\xaa\x85\x5e\xad\x04\x28\xda\xf0\x99\x32\xab\x5c\x93\xc5\xf4\x9b\x91\x6c\xb0\xb3\x31\x09\x96\xfe\xb4\xef\xba\x7e\x50\x9c\xd4\xfa\xfe\xa8\xd5\xf7\xb6\xa8\x45\x33\x6d\x4e\xb6\x24\x77\xb2\xf0\xdf\x1a\x17\x9c\xd7\x94\x63\x6c\x55\x61\x57\x63\xc9\x0f\x2a\x67\xce\x1b\xfe\x9b\xe2\xfd\x07\x00\x00\xff\xff\x1c\x62\x15\x17\x2e\x01\x00\x00") + +func _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql, + "_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql", + ) +} + +func _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql() (*asset, error) { + bytes, err := _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var __lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x90\xcd\x4e\x05\x21\x0c\x85\xf7\x3c\x45\x4d\x5c\x5c\x5f\xc1\xa5\x6e\x74\x63\x26\xfe\x3c\x40\xbd\xf4\x62\x23\xb4\x5a\x8a\xc9\x68\xe6\xdd\xcd\xcc\x28\xe8\x86\x70\xbe\x9e\x8f\x90\xbe\x37\xb2\x19\x0e\x01\xe0\x5c\xb0\xd0\x25\x3c\xb8\xb1\xa4\xb3\x0b\xf8\x0a\x00\x00\x6a\x09\x85\x3f\xd1\x59\xe5\x6a\xbe\xc3\x42\x87\x8d\x03\xec\xf5\xcd\xfa\x2d\x03\x44\x7a\xcb\x3a\x3f\xa2\x25\xf2\xda\x29\x00\xc7\x7e\x5d\x85\x1e\x8e\x46\xe8\x34\x86\x47\x95\xaa\x99\x9e\x2c\x0f\x94\xb5\xc5\x7b\x4a\xac\xf2\x9f\x4d\xa6\x1f\x1c\xc9\x3a\x3d\x19\x93\xc4\xbc\xfd\xb2\x43\xd7\x57\x1a\x62\xad\x2f\x37\x5a\xfd\x6f\x9e\xd4\x46\x36\x6d\x4e\x36\xa1\x3b\xd9\xb0\x9e\x1b\xe7\x78\x5b\x30\x8d\x67\x8b\x0a\xbb\xae\xab\xba\x56\x39\x71\xfa\x19\x2c\x61\x3f\x97\xf0\x1d\x00\x00\xff\xff\x35\x68\x51\x4c\x59\x01\x00\x00") + +func _lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql, + "_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql", + ) +} + +func _lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql() (*asset, error) { + bytes, err := _lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlDeploytargetsListdeploytargetsGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x44\x8c\x51\x4a\xc4\x40\x10\x44\xff\x73\x8a\x3e\x87\xbf\xfa\xa1\x08\x12\x44\x0f\x30\xc9\x54\xc6\xc6\x4e\xb7\xf6\xf4\x2c\x84\x25\x77\x5f\x36\x43\xd8\xaf\x7a\x55\x3c\xea\xbf\xc1\x37\xba\x0e\x44\xc2\x35\x5e\xf0\x27\xb6\x7d\x25\x2f\x88\xfa\x44\x49\xe4\xbd\x4d\x70\x45\xa0\xde\x1d\x22\xce\x47\x68\x5a\x71\xc0\xec\x48\x81\x3e\xce\xa6\xd5\x04\xdf\x2e\xbd\x8a\xb5\xfc\x89\xc2\xa6\x8f\x3e\xba\x5d\x38\xc3\x8f\x65\x71\x86\x66\xd9\x3e\xce\xb7\xb0\x5f\x74\xb9\xd6\x9f\x57\xab\x71\xf2\x68\xde\xd9\xad\x05\x7c\x4c\x11\xf0\x6e\x4e\x8d\x25\xbf\xad\xa9\xf4\x8b\xd5\x94\xc3\x9c\xb5\x3c\x9b\x2e\x5c\x06\xa2\x7d\xd8\x6f\x01\x00\x00\xff\xff\x7c\xcb\xe1\x0e\xe7\x00\x00\x00") func _lgraphqlDeploytargetsListdeploytargetsGraphqlBytes() ([]byte, error) { @@ -1488,6 +1532,46 @@ func _lgraphqlUsergroupsUsercansshtoenvironmentGraphql() (*asset, error) { return a, nil } +var __lgraphqlUsergroupsUsersbyorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8b\x41\x0a\xc2\x40\x0c\x45\xf7\x39\xc5\x17\x5c\xe8\x15\xba\x74\xe7\x46\xcf\x10\x6c\x94\x40\x27\x83\x99\x14\xa9\xd2\xbb\x4b\xd3\xcd\xac\xf2\x5e\x78\xff\x3d\x8b\x2f\x38\x11\x70\xd4\x71\xc0\xd5\xe2\x70\xc6\x8f\x80\xb9\x89\xb7\xcb\x72\xf7\x17\x9b\x7e\x39\xb4\xda\x56\x01\xb5\xfb\x0c\xdb\x6a\xef\x01\x1d\xf3\x48\x61\x9d\x92\x9e\xea\x2d\x6e\x5c\x24\x6d\xe2\x4e\xea\xc7\xc4\x93\x1e\xb5\x14\xb1\x20\x60\xa5\x95\xfe\x01\x00\x00\xff\xff\x56\xbe\xa2\x65\x8f\x00\x00\x00") + +func _lgraphqlUsergroupsUsersbyorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlUsergroupsUsersbyorganizationGraphql, + "_lgraphql/usergroups/usersByOrganization.graphql", + ) +} + +func _lgraphqlUsergroupsUsersbyorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlUsergroupsUsersbyorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/usergroups/usersByOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +var __lgraphqlUsergroupsUsersbyorganizationnameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8c\x31\x0a\x02\x41\x0c\x45\xfb\x39\xc5\x17\x2c\xf4\x0a\x96\x1e\xc0\xc6\x13\x04\x8d\x4b\x60\x93\xc1\x6c\x44\x56\xd9\xbb\xcb\xcc\xa4\xb1\x08\xbc\x07\x2f\xff\xf9\x62\x5f\x71\x28\xc0\xde\x48\xf9\x84\x6b\xb8\xd8\xb4\x3b\xe2\x5b\x80\xea\x13\x99\x7c\x28\xa4\xda\x79\xbd\x90\x72\x2b\x81\x91\xf6\x8f\x11\x02\xf5\x6d\xec\x4b\x0a\x20\xf7\x04\x56\x92\x39\xf9\x21\xbe\x44\x5b\x49\x9f\xe9\x4f\xfb\x44\xf2\xad\xaa\xb2\x45\xb7\xad\xb4\xdb\xca\x2f\x00\x00\xff\xff\x3b\xd8\x0c\x59\xac\x00\x00\x00") + +func _lgraphqlUsergroupsUsersbyorganizationnameGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlUsergroupsUsersbyorganizationnameGraphql, + "_lgraphql/usergroups/usersByOrganizationName.graphql", + ) +} + +func _lgraphqlUsergroupsUsersbyorganizationnameGraphql() (*asset, error) { + bytes, err := _lgraphqlUsergroupsUsersbyorganizationnameGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/usergroups/usersByOrganizationName.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlOrganizationsAddorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x90\xc1\x4a\xc5\x30\x10\x45\xf7\xf9\x8a\x11\x5c\xb4\xd0\x2f\xe8\x5e\xc4\x4d\x15\xfd\x82\xd0\xa4\x65\xc4\x4e\x6a\x9c\x08\xfa\xe8\xbf\x3f\x92\x94\xf7\x66\xda\xed\xbd\x77\x06\xce\x59\x12\x5b\xc6\x40\xd0\x18\x80\x47\xb2\x8b\xef\xe1\x83\x23\xd2\xfc\xd0\xe5\x64\x8a\xe8\xc9\x7d\xfd\x0d\xa2\x29\x85\xf3\x3f\x63\xc4\x35\xdf\xaa\xfc\x3b\x05\xb6\x6f\x31\x7c\xfa\x91\x7b\x78\x21\xbe\xa7\xcf\x31\xa4\xf5\x90\x0d\x81\x71\xc2\xd1\xd6\x3f\xaa\x7a\xa2\x5f\x8c\x81\x16\x4f\xc7\x47\xef\x21\xb1\xaf\x59\x0b\x17\x03\x60\x9d\x7b\x8d\xb3\x25\xfc\x2f\x8f\x1a\xa4\x35\x71\x5f\x2a\x80\x0a\x55\xd8\xba\x12\x68\x26\x85\x58\x07\x8a\x4d\x92\xd6\x5a\x23\x2a\x62\x31\xd8\x69\x05\xba\x28\x35\xf6\x59\x85\x98\x2a\x0d\x27\x33\x62\xb8\x5b\x11\x8a\x72\xb9\xb5\xbb\x06\x74\x37\x1b\x39\x36\x9b\xb9\x06\x00\x00\xff\xff\x80\x81\xe4\x11\xfc\x01\x00\x00") func _lgraphqlOrganizationsAddorganizationGraphqlBytes() ([]byte, error) { @@ -1661,6 +1745,8 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/deployments/updateDeployment.graphql": _lgraphqlDeploymentsUpdatedeploymentGraphql, "_lgraphql/deploytargets/addDeployTarget.graphql": _lgraphqlDeploytargetsAdddeploytargetGraphql, "_lgraphql/deploytargets/deleteDeployTarget.graphql": _lgraphqlDeploytargetsDeletedeploytargetGraphql, + "_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql": _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql, + "_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql": _lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql, "_lgraphql/deploytargets/listDeployTargets.graphql": _lgraphqlDeploytargetsListdeploytargetsGraphql, "_lgraphql/deploytargets/updateDeployTarget.graphql": _lgraphqlDeploytargetsUpdatedeploytargetGraphql, "_lgraphql/deploytargetconfigs/addDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsAdddeploytargetconfigGraphql, @@ -1707,6 +1793,8 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/userBySSHFingerprint.graphql": _lgraphqlUsergroupsUserbysshfingerprintGraphql, "_lgraphql/usergroups/userBySSHKey.graphql": _lgraphqlUsergroupsUserbysshkeyGraphql, "_lgraphql/usergroups/userCanSSHToEnvironment.graphql": _lgraphqlUsergroupsUsercansshtoenvironmentGraphql, + "_lgraphql/usergroups/usersByOrganization.graphql": _lgraphqlUsergroupsUsersbyorganizationGraphql, + "_lgraphql/usergroups/usersByOrganizationName.graphql": _lgraphqlUsergroupsUsersbyorganizationnameGraphql, "_lgraphql/organizations/addOrganization.graphql": _lgraphqlOrganizationsAddorganizationGraphql, "_lgraphql/organizations/deleteOrganization.graphql": _lgraphqlOrganizationsDeleteorganizationGraphql, "_lgraphql/organizations/organizationById.graphql": _lgraphqlOrganizationsOrganizationbyidGraphql, @@ -1780,10 +1868,12 @@ var _bintree = &bintree{nil, map[string]*bintree{ "updateDeployTargetConfig.graphql": &bintree{_lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql, map[string]*bintree{}}, }}, "deploytargets": &bintree{nil, map[string]*bintree{ - "addDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsAdddeploytargetGraphql, map[string]*bintree{}}, - "deleteDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsDeletedeploytargetGraphql, map[string]*bintree{}}, - "listDeployTargets.graphql": &bintree{_lgraphqlDeploytargetsListdeploytargetsGraphql, map[string]*bintree{}}, - "updateDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsUpdatedeploytargetGraphql, map[string]*bintree{}}, + "addDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsAdddeploytargetGraphql, map[string]*bintree{}}, + "deleteDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsDeletedeploytargetGraphql, map[string]*bintree{}}, + "deployTargetsByOrganizationId.graphql": &bintree{_lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql, map[string]*bintree{}}, + "deployTargetsByOrganizationName.graphql": &bintree{_lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql, map[string]*bintree{}}, + "listDeployTargets.graphql": &bintree{_lgraphqlDeploytargetsListdeploytargetsGraphql, map[string]*bintree{}}, + "updateDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsUpdatedeploytargetGraphql, map[string]*bintree{}}, }}, "environments": &bintree{nil, map[string]*bintree{ "addOrUpdateEnvironment.graphql": &bintree{_lgraphqlEnvironmentsAddorupdateenvironmentGraphql, map[string]*bintree{}}, @@ -1843,6 +1933,8 @@ var _bintree = &bintree{nil, map[string]*bintree{ "userBySSHFingerprint.graphql": &bintree{_lgraphqlUsergroupsUserbysshfingerprintGraphql, map[string]*bintree{}}, "userBySSHKey.graphql": &bintree{_lgraphqlUsergroupsUserbysshkeyGraphql, map[string]*bintree{}}, "userCanSSHToEnvironment.graphql": &bintree{_lgraphqlUsergroupsUsercansshtoenvironmentGraphql, map[string]*bintree{}}, + "usersByOrganization.graphql": &bintree{_lgraphqlUsergroupsUsersbyorganizationGraphql, map[string]*bintree{}}, + "usersByOrganizationName.graphql": &bintree{_lgraphqlUsergroupsUsersbyorganizationnameGraphql, map[string]*bintree{}}, }}, }}, }} diff --git a/api/lagoon/client/projects.go b/api/lagoon/client/projects.go index c094909..8c12dc0 100644 --- a/api/lagoon/client/projects.go +++ b/api/lagoon/client/projects.go @@ -165,7 +165,7 @@ func (c *Client) UpdateProject( } // ProjectsByOrganizationID queries the Lagoon API for projects by the given organization id -// and unmarshals the response into environment. +// and unmarshals the response into organization. func (c *Client) ProjectsByOrganizationID(ctx context.Context, id uint, projects *[]schema.OrgProject) error { req, err := c.newRequest("_lgraphql/projects/projectsByOrganizationId.graphql", diff --git a/api/lagoon/client/usergroups.go b/api/lagoon/client/usergroups.go index bd63a86..275450b 100644 --- a/api/lagoon/client/usergroups.go +++ b/api/lagoon/client/usergroups.go @@ -221,7 +221,7 @@ func (c *Client) UserBySSHFingerprint( } // GroupsByOrganizationID queries the Lagoon API for groups by the given organization id -// and unmarshals the response into environment. +// and unmarshals the response into organization. func (c *Client) GroupsByOrganizationID(ctx context.Context, id uint, groups *[]schema.OrgGroup) error { req, err := c.newRequest("_lgraphql/usergroups/groupsByOrganizationId.graphql", @@ -264,3 +264,56 @@ func (c *Client) AddGroupToOrganization(ctx context.Context, in *schema.AddGroup Response: out, }) } + +// UsersByOrganization queries the Lagoon API for users by the given organization id +// and unmarshals the response into organization. +func (c *Client) UsersByOrganization(ctx context.Context, id uint, users *[]schema.OrgUser) error { + + req, err := c.newRequest("_lgraphql/usergroups/usersByOrganization.graphql", + map[string]interface{}{ + "id": id, + }) + if err != nil { + return err + } + + return c.client.Run(ctx, req, &struct { + Response *[]schema.OrgUser `json:"usersByOrganization"` + }{ + Response: users, + }) +} + +// UsersByOrganizationName queries the Lagoon API for users by the given organization name +// and unmarshals the response into organization. +func (c *Client) UsersByOrganizationName(ctx context.Context, name string, users *[]schema.OrgUser) error { + + req, err := c.newRequest("_lgraphql/usergroups/usersByOrganizationName.graphql", + map[string]interface{}{ + "name": name, + }) + if err != nil { + return err + } + + o := &schema.Organization{} + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationByName"` + }{ + Response: o, + }) + if err != nil { + return err + } + dd, err := json.Marshal(o) + fmt.Println(string(dd)) + if len(o.Owners) == 0 { + return fmt.Errorf("no deploy targets found for organization %s", o.Name) + } + data, err := json.Marshal(o.Owners) + if err != nil { + return err + } + json.Unmarshal(data, users) + return nil +} diff --git a/api/lagoon/deploytarget.go b/api/lagoon/deploytarget.go index c215bc6..35a122e 100644 --- a/api/lagoon/deploytarget.go +++ b/api/lagoon/deploytarget.go @@ -11,6 +11,8 @@ type DeployTargets interface { UpdateDeployTarget(ctx context.Context, in *schema.UpdateDeployTargetInput, out *schema.UpdateDeployTargetResponse) error DeleteDeployTarget(ctx context.Context, in *schema.DeleteDeployTargetInput, out *schema.DeleteDeployTargetResponse) error ListDeployTargets(ctx context.Context, out *[]schema.DeployTarget) error + DeployTargetsByOrganizationId(ctx context.Context, id uint, out *[]schema.DeployTarget) error + DeployTargetsByOrganizationName(ctx context.Context, name string, out *[]schema.DeployTarget) error } func AddDeployTarget(ctx context.Context, in *schema.AddDeployTargetInput, out DeployTargets) (*schema.AddDeployTargetResponse, error) { @@ -33,3 +35,15 @@ func ListDeployTargets(ctx context.Context, out DeployTargets) (*[]schema.Deploy deploytargets := []schema.DeployTarget{} return &deploytargets, out.ListDeployTargets(ctx, &deploytargets) } + +// ListDeployTargetsByOrganizationId gets deploy targets associated with an organization in lagoon via provided ID. +func ListDeployTargetsByOrganizationId(ctx context.Context, id uint, d DeployTargets) (*[]schema.DeployTarget, error) { + deploytargets := []schema.DeployTarget{} + return &deploytargets, d.DeployTargetsByOrganizationId(ctx, id, &deploytargets) +} + +// ListDeployTargetsByOrganizationName gets deploy targets associated with an organization in lagoon via provided Name. +func ListDeployTargetsByOrganizationName(ctx context.Context, name string, d DeployTargets) (*[]schema.DeployTarget, error) { + deploytargets := []schema.DeployTarget{} + return &deploytargets, d.DeployTargetsByOrganizationName(ctx, name, &deploytargets) +} diff --git a/api/lagoon/projects.go b/api/lagoon/projects.go index 221cea2..48ff0de 100644 --- a/api/lagoon/projects.go +++ b/api/lagoon/projects.go @@ -69,8 +69,8 @@ func GetSSHEndpointsByProject(ctx context.Context, name string, p Projects) (*sc return &project, p.SSHEndpointsByProject(ctx, name, &project) } -// GetProjectsByOrganizationID gets projects associated with an organization in lagoon via provided ID. -func GetProjectsByOrganizationID(ctx context.Context, id uint, o Projects) (*[]schema.OrgProject, error) { +// ListProjectsByOrganizationID gets projects associated with an organization in lagoon via provided ID. +func ListProjectsByOrganizationID(ctx context.Context, id uint, p Projects) (*[]schema.OrgProject, error) { project := []schema.OrgProject{} - return &project, o.ProjectsByOrganizationID(ctx, id, &project) + return &project, p.ProjectsByOrganizationID(ctx, id, &project) } diff --git a/api/lagoon/usergroups.go b/api/lagoon/usergroups.go index caa1223..acb4dde 100644 --- a/api/lagoon/usergroups.go +++ b/api/lagoon/usergroups.go @@ -26,6 +26,8 @@ type UserGroups interface { UserBySSHFingerprint(ctx context.Context, fingerprint string, user *schema.User) error GroupsByOrganizationID(ctx context.Context, id uint, group *[]schema.OrgGroup) error AddGroupToOrganization(ctx context.Context, in *schema.AddGroupToOrganizationInput, out *schema.OrgGroup) error + UsersByOrganization(ctx context.Context, id uint, users *[]schema.OrgUser) error + UsersByOrganizationName(ctx context.Context, name string, users *[]schema.OrgUser) error } // Me gets info on the current user of lagoon. @@ -101,8 +103,8 @@ func UserBySSHFingerprint(ctx context.Context, fingerprint string, ug UserGroups return &user, ug.UserBySSHFingerprint(ctx, fingerprint, &user) } -// GetGroupsByOrganizationID gets groups associated with an organization in lagoon via provided ID. -func GetGroupsByOrganizationID(ctx context.Context, id uint, ug UserGroups) (*[]schema.OrgGroup, error) { +// ListGroupsByOrganizationID gets groups associated with an organization in lagoon via provided ID. +func ListGroupsByOrganizationID(ctx context.Context, id uint, ug UserGroups) (*[]schema.OrgGroup, error) { group := []schema.OrgGroup{} return &group, ug.GroupsByOrganizationID(ctx, id, &group) } @@ -111,3 +113,13 @@ func AddGroupToOrganization(ctx context.Context, in *schema.AddGroupToOrganizati group := schema.OrgGroup{} return &group, ug.AddGroupToOrganization(ctx, in, &group) } + +func UsersByOrganization(ctx context.Context, id uint, ug UserGroups) (*[]schema.OrgUser, error) { + user := []schema.OrgUser{} + return &user, ug.UsersByOrganization(ctx, id, &user) +} + +func UsersByOrganizationName(ctx context.Context, name string, ug UserGroups) (*[]schema.OrgUser, error) { + user := []schema.OrgUser{} + return &user, ug.UsersByOrganizationName(ctx, name, &user) +} diff --git a/api/schema/organization.go b/api/schema/organization.go index 9f32de3..39562e1 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -5,7 +5,7 @@ import "github.com/google/uuid" // Organization is based on the Lagoon API type. type Organization struct { AddOrganizationInput - DeployTarget []DeployTarget `json:"openshift,omitempty"` + DeployTargets []DeployTarget `json:"deployTargets,omitempty"` Projects []OrgProject `json:"projects,omitempty"` Environments []OrgEnvironment `json:"environments,omitempty"` Groups []OrgGroup `json:"groups,omitempty"` From 9e8151292e0c195f806ea96aaec56064d89f15c4 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Mon, 16 Oct 2023 09:54:16 +1100 Subject: [PATCH 10/22] Removed test println & comments --- api/lagoon/client/projects.go | 14 -------------- api/lagoon/client/usergroups.go | 6 ------ api/lagoon/organizations.go | 2 +- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/api/lagoon/client/projects.go b/api/lagoon/client/projects.go index 8c12dc0..cfe668f 100644 --- a/api/lagoon/client/projects.go +++ b/api/lagoon/client/projects.go @@ -195,17 +195,3 @@ func (c *Client) ProjectsByOrganizationID(ctx context.Context, id uint, projects json.Unmarshal(data, projects) return nil } - -// TODO - AddExistingProjectToOrganization adds an existing project to an organization. -//func (c *Client) AddExistingProjectToOrganization( -// ctx context.Context, in *schema.AddProjectToOrganizationInput, out *schema.Project) error { -// req, err := c.newRequest("_lgraphql/projects/addExistingProjectToOrganization.graphql", in) -// if err != nil { -// return err -// } -// return wrapErr(c.client.Run(ctx, req, &struct { -// Response *schema.Project `json:"addProjectToOrganization"` -// }{ -// Response: out, -// })) -//} diff --git a/api/lagoon/client/usergroups.go b/api/lagoon/client/usergroups.go index 275450b..f7bd865 100644 --- a/api/lagoon/client/usergroups.go +++ b/api/lagoon/client/usergroups.go @@ -266,7 +266,6 @@ func (c *Client) AddGroupToOrganization(ctx context.Context, in *schema.AddGroup } // UsersByOrganization queries the Lagoon API for users by the given organization id -// and unmarshals the response into organization. func (c *Client) UsersByOrganization(ctx context.Context, id uint, users *[]schema.OrgUser) error { req, err := c.newRequest("_lgraphql/usergroups/usersByOrganization.graphql", @@ -305,11 +304,6 @@ func (c *Client) UsersByOrganizationName(ctx context.Context, name string, users if err != nil { return err } - dd, err := json.Marshal(o) - fmt.Println(string(dd)) - if len(o.Owners) == 0 { - return fmt.Errorf("no deploy targets found for organization %s", o.Name) - } data, err := json.Marshal(o.Owners) if err != nil { return err diff --git a/api/lagoon/organizations.go b/api/lagoon/organizations.go index 15f950a..95bd89d 100644 --- a/api/lagoon/organizations.go +++ b/api/lagoon/organizations.go @@ -22,7 +22,7 @@ func GetOrganizationByID(ctx context.Context, id uint, o Organizations) (*schema return &organization, o.OrganizationByID(ctx, id, &organization) } -// **Pending Merge** GetOrganizationByName gets info of an organization in lagoon that matches the provided name. +// GetOrganizationByName gets info of an organization in lagoon that matches the provided name. func GetOrganizationByName(ctx context.Context, name string, o Organizations) (*schema.Organization, error) { organization := schema.Organization{} return &organization, o.OrganizationByName(ctx, name, &organization) From 4ea384607fc35eec17752cfd4a61e0ec95f7aaa8 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 20 Oct 2023 14:05:57 +1100 Subject: [PATCH 11/22] add & remove deploytarget --- .../addDeployTargetToOrganization.graphql | 11 ++ ...removeDeployTargetFromOrganization.graphql | 11 ++ .../removeProjectFromOrganization.graphql | 11 ++ .../usergroups/addUserToOrganization.graphql | 13 +++ api/lagoon/client/deploytargets.go | 26 +++++ api/lagoon/client/lgraphql/lgraphql.go | 104 +++++++++++++++++- api/lagoon/client/projects.go | 13 +++ api/lagoon/client/usergroups.go | 13 +++ api/lagoon/deploytarget.go | 14 +++ api/lagoon/projects.go | 7 ++ api/lagoon/usergroups.go | 3 + api/schema/deploytarget.go | 10 ++ api/schema/project.go | 4 +- api/schema/user.go | 11 ++ 14 files changed, 243 insertions(+), 8 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/deploytargets/addDeployTargetToOrganization.graphql create mode 100644 api/lagoon/client/_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql create mode 100644 api/lagoon/client/_lgraphql/projects/removeProjectFromOrganization.graphql create mode 100644 api/lagoon/client/_lgraphql/usergroups/addUserToOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/deploytargets/addDeployTargetToOrganization.graphql b/api/lagoon/client/_lgraphql/deploytargets/addDeployTargetToOrganization.graphql new file mode 100644 index 0000000..9f6d876 --- /dev/null +++ b/api/lagoon/client/_lgraphql/deploytargets/addDeployTargetToOrganization.graphql @@ -0,0 +1,11 @@ +mutation ( + $deployTarget: Int!, + $organization: Int!,){ + addDeployTargetToOrganization(input: { + deployTarget: $deployTarget, + organization: $organization, + }) { + id + name + } +} diff --git a/api/lagoon/client/_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql b/api/lagoon/client/_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql new file mode 100644 index 0000000..2d37062 --- /dev/null +++ b/api/lagoon/client/_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql @@ -0,0 +1,11 @@ +mutation ( + $deployTarget: Int!, + $organization: Int!,){ + removeDeployTargetFromOrganization(input: { + deployTarget: $deployTarget, + organization: $organization, + }) { + id + name + } +} diff --git a/api/lagoon/client/_lgraphql/projects/removeProjectFromOrganization.graphql b/api/lagoon/client/_lgraphql/projects/removeProjectFromOrganization.graphql new file mode 100644 index 0000000..69d9e8f --- /dev/null +++ b/api/lagoon/client/_lgraphql/projects/removeProjectFromOrganization.graphql @@ -0,0 +1,11 @@ +mutation ( + $project: Int!, + $organization: Int!,){ + removeProjectFromOrganization(input: { + project: $project, + organization: $organization, + }) { + id + name + } +} diff --git a/api/lagoon/client/_lgraphql/usergroups/addUserToOrganization.graphql b/api/lagoon/client/_lgraphql/usergroups/addUserToOrganization.graphql new file mode 100644 index 0000000..9d1b697 --- /dev/null +++ b/api/lagoon/client/_lgraphql/usergroups/addUserToOrganization.graphql @@ -0,0 +1,13 @@ +mutation ( + $user: UserInput!, + $organization: Int!, + $owner: Boolean) { + addUserToOrganization(input: { + user: $user + organization: $organization + owner: $owner + }) { + id + name + } + } diff --git a/api/lagoon/client/deploytargets.go b/api/lagoon/client/deploytargets.go index f973c27..5d1f1cc 100644 --- a/api/lagoon/client/deploytargets.go +++ b/api/lagoon/client/deploytargets.go @@ -122,3 +122,29 @@ func (c *Client) DeployTargetsByOrganizationName(ctx context.Context, name strin json.Unmarshal(data, out) return nil } + +// AddDeployTargetToOrganization adds an existing deploytarget to an organization. +func (c *Client) AddDeployTargetToOrganization(ctx context.Context, in *schema.AddDeployTargetToOrganizationInput, out *schema.AddDeployTargetResponse) error { + req, err := c.newRequest("_lgraphql/deploytargets/addDeployTargetToOrganization.graphql", in) + if err != nil { + return err + } + return c.client.Run(ctx, req, &struct { + Response *schema.AddDeployTargetResponse `json:"addDeployTargetToOrganization"` + }{ + Response: out, + }) +} + +// RemoveDeployTargetFromOrganization removes a deploytarget from an organization. +func (c *Client) RemoveDeployTargetFromOrganization(ctx context.Context, in *schema.RemoveDeployTargetFromOrganizationInput, out *schema.DeleteDeployTargetResponse) error { + req, err := c.newRequest("_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql", in) + if err != nil { + return err + } + return c.client.Run(ctx, req, &struct { + Response *schema.DeleteDeployTargetResponse `json:"removeDeployTargetFromOrganization"` + }{ + Response: out, + }) +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index aff66f5..9d03491 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -20,10 +20,12 @@ // _lgraphql/deployments/getDeploymentsForEnvironment.graphql // _lgraphql/deployments/updateDeployment.graphql // _lgraphql/deploytargets/addDeployTarget.graphql +// _lgraphql/deploytargets/addDeployTargetToOrganization.graphql // _lgraphql/deploytargets/deleteDeployTarget.graphql // _lgraphql/deploytargets/deployTargetsByOrganizationId.graphql // _lgraphql/deploytargets/deployTargetsByOrganizationName.graphql // _lgraphql/deploytargets/listDeployTargets.graphql +// _lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql // _lgraphql/deploytargets/updateDeployTarget.graphql // _lgraphql/deploytargetconfigs/addDeployTargetConfig.graphql // _lgraphql/deploytargetconfigs/deleteDeployTargetConfig.graphql @@ -36,6 +38,7 @@ // _lgraphql/projects/projectByNameMetadata.graphql // _lgraphql/projects/projectsByMetadata.graphql // _lgraphql/projects/projectsByOrganizationId.graphql +// _lgraphql/projects/removeProjectFromOrganization.graphql // _lgraphql/projects/removeProjectMetadataByKey.graphql // _lgraphql/projects/updateProject.graphql // _lgraphql/projects/updateProjectMetadata.graphql @@ -59,6 +62,7 @@ // _lgraphql/usergroups/addSshKey.graphql // _lgraphql/usergroups/addUser.graphql // _lgraphql/usergroups/addUserToGroup.graphql +// _lgraphql/usergroups/addUserToOrganization.graphql // _lgraphql/usergroups/allGroupMembers.graphql // _lgraphql/usergroups/allUsers.graphql // _lgraphql/usergroups/groupsByOrganizationId.graphql @@ -552,6 +556,26 @@ func _lgraphqlDeploytargetsAdddeploytargetGraphql() (*asset, error) { return a, nil } +var __lgraphqlDeploytargetsAdddeploytargettoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x49\x49\x2d\xc8\xc9\xaf\x0c\x49\x2c\x4a\x4f\x2d\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x09\xe7\x17\xa5\x27\xe6\x65\x56\x81\x15\x42\x85\x35\xab\xb9\x14\x14\x12\x53\x52\x5c\x90\x74\x84\xe4\xfb\x23\x29\xd4\xc8\xcc\x2b\x28\x2d\xb1\x52\x00\x29\x54\x50\x40\x35\x19\xc5\x22\x1d\xb0\x02\x54\x3b\x50\xac\x04\x29\xa8\xd5\x84\x1a\x94\x99\x02\xa6\xf2\x12\x73\x53\x41\xc2\x5c\xb5\x5c\x80\x00\x00\x00\xff\xff\xec\x80\xbb\x8c\xc3\x00\x00\x00") + +func _lgraphqlDeploytargetsAdddeploytargettoorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlDeploytargetsAdddeploytargettoorganizationGraphql, + "_lgraphql/deploytargets/addDeployTargetToOrganization.graphql", + ) +} + +func _lgraphqlDeploytargetsAdddeploytargettoorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlDeploytargetsAdddeploytargettoorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/deploytargets/addDeployTargetToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlDeploytargetsDeletedeploytargetGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\x4b\xcc\x4d\xb5\x52\x08\x2e\x29\xca\xcc\x4b\x57\xe4\xd2\x54\xa8\xe6\x52\x50\x48\x49\xcd\x49\x2d\x49\x75\x49\x2d\xc8\xc9\xaf\x0c\x49\x2c\x4a\x4f\x2d\xb1\x82\x8a\xf9\x17\xa4\xe6\x15\x67\x64\xa6\x95\x68\x64\xe6\x15\x94\x96\x58\x81\x95\x2b\x28\x40\x0c\x01\x9b\xc5\xa5\xa0\x50\xab\xc9\x55\xcb\x05\x08\x00\x00\xff\xff\x8e\x88\xf8\xcc\x66\x00\x00\x00") func _lgraphqlDeploytargetsDeletedeploytargetGraphqlBytes() ([]byte, error) { @@ -632,6 +656,26 @@ func _lgraphqlDeploytargetsListdeploytargetsGraphql() (*asset, error) { return a, nil } +var __lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x49\x49\x2d\xc8\xc9\xaf\x0c\x49\x2c\x4a\x4f\x2d\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x09\xe7\x17\xa5\x27\xe6\x65\x56\x81\x15\x42\x85\x35\xab\xb9\x14\x14\x8a\x52\x73\xf3\xcb\x52\x5d\x90\x34\xb9\x15\xe5\xe7\xfa\x23\xa9\xd6\xc8\xcc\x2b\x28\x2d\xb1\x52\x00\xa9\x56\x50\x40\x35\x1e\xc5\x36\x1d\xb0\x02\x54\x8b\x50\xec\x05\x29\xa8\xd5\x84\x1a\x94\x99\x02\xa6\xf2\x12\x73\x53\x41\xc2\x5c\xb5\x5c\x80\x00\x00\x00\xff\xff\x56\xb2\x5d\x48\xc8\x00\x00\x00") + +func _lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphql, + "_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql", + ) +} + +func _lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlDeploytargetsUpdatedeploytargetGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x91\x41\x6e\xea\x30\x10\x86\xf7\x73\x8a\x79\x12\x0b\x90\x38\x41\xb6\xaf\x8b\xd2\x05\xa0\xd2\x1e\xc0\xc5\x43\xb0\x9a\x78\x22\x67\x52\x09\x55\xdc\xbd\x0a\x24\xb1\x27\xce\x2a\xf1\xff\x8f\xa5\xf1\xf7\xd5\x9d\x18\x71\xec\x71\x0d\x88\x2b\x67\x0b\xdc\x79\xf9\xd7\xff\x7b\x53\x53\x81\x27\x09\xce\x97\xdb\x3e\x38\xb3\x6f\xb9\xa2\xcf\x50\xa9\x58\xf8\x9b\xbc\x4a\x02\x77\x42\xe1\x68\x44\x28\xe8\xa6\x6d\xaf\xaf\xdc\xca\x3c\x3b\x72\xd0\xd9\x57\xe7\x2a\xbb\xab\x4d\xa9\x37\xa8\xd9\x3b\xe1\xfe\xf8\x9f\xfd\xc5\x95\x05\xbe\x9d\x0e\xfb\x47\x75\x09\x8e\xbc\xad\x6e\xfb\x6c\xeb\x8a\x3b\x7b\x0c\xfc\xe3\x2c\x85\xbc\x79\xa7\xd2\xf1\xb4\xe4\x06\x7f\x01\x11\xb1\x6b\xac\x11\x7a\xa1\xa6\xe2\xdb\x87\x09\x25\x49\x31\x64\x87\x86\x7c\x7b\x75\x17\x59\x3b\xdf\x74\x52\x0c\x17\x10\x7b\x74\x2b\x67\x87\x53\x63\xe4\x7c\x8d\x25\xe2\x93\xe6\x03\xea\x76\x0a\x53\xa2\x09\xde\x38\x30\xb0\x7d\x32\x9e\xd2\x19\x5f\xcd\x3b\x5e\x9e\x60\x8f\xd8\x55\xf5\x64\x3e\xd2\x8f\x55\x8a\x3e\xf1\x10\x07\x72\x09\x99\x97\x38\xac\xb5\x28\x4b\x09\x06\xad\x48\x2b\x9b\x8d\x8d\xbe\x52\x7b\xc3\xc4\xfd\xf1\xbd\x6f\x12\x25\x10\xe1\x0f\xbf\xe7\x40\x46\x68\x2c\x52\xae\x91\x3f\x28\x7e\xa0\x90\xc1\xc2\xca\x90\xed\x07\xf9\xeb\x61\x8e\x17\x16\x64\xc2\x32\x62\x18\x9f\x77\x87\xbf\x00\x00\x00\xff\xff\x63\x54\xb3\x44\xb0\x03\x00\x00") func _lgraphqlDeploytargetsUpdatedeploytargetGraphqlBytes() ([]byte, error) { @@ -872,6 +916,26 @@ func _lgraphqlProjectsProjectsbyorganizationidGraphql() (*asset, error) { return a, nil } +var __lgraphqlProjectsRemoveprojectfromorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x28\xca\xcf\x4a\x4d\x2e\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x89\xe4\x17\xa5\x27\xe6\x65\x56\x81\xd5\x40\x85\x35\xab\xb9\x14\x14\x8a\x52\x73\xf3\xcb\x52\x03\x20\xea\xdd\x8a\xf2\x73\xfd\x91\x14\x6a\x64\xe6\x15\x94\x96\x58\x29\x80\x14\x2a\x28\xc0\x0d\x85\x19\xaf\x03\x16\x46\x35\x19\xc5\x22\x90\x82\x5a\x4d\xa8\xf6\xcc\x14\x30\x95\x97\x98\x9b\x0a\x12\xe6\xaa\xe5\x02\x04\x00\x00\xff\xff\x0f\x9a\x0e\x27\xb4\x00\x00\x00") + +func _lgraphqlProjectsRemoveprojectfromorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlProjectsRemoveprojectfromorganizationGraphql, + "_lgraphql/projects/removeProjectFromOrganization.graphql", + ) +} + +func _lgraphqlProjectsRemoveprojectfromorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlProjectsRemoveprojectfromorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/projects/removeProjectFromOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlProjectsRemoveprojectmetadatabykeyGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\x84\xf0\xb2\x53\x2b\xad\x14\x82\x4b\x8a\x32\xf3\xd2\x15\x35\xab\xc1\x62\x45\xa9\xb9\xf9\x65\xa9\x01\x45\xf9\x59\xa9\xc9\x25\xbe\xa9\x25\x89\x29\x89\x25\x89\x4e\x95\xde\xa9\x95\x10\x13\x40\x20\x33\xaf\xa0\xb4\xc4\xaa\x1a\xce\x07\x8b\xa5\x58\x81\x4c\x47\x11\x03\x1b\x0f\xb2\x04\x2e\x5a\x0b\x66\x69\x22\xb4\x22\xe9\xc8\x4b\xcc\x4d\x85\x73\x72\xa1\x36\x73\x41\x74\xd5\x02\x02\x00\x00\xff\xff\xfc\x0e\xa7\xd1\xc8\x00\x00\x00") func _lgraphqlProjectsRemoveprojectmetadatabykeyGraphqlBytes() ([]byte, error) { @@ -1332,6 +1396,26 @@ func _lgraphqlUsergroupsAddusertogroupGraphql() (*asset, error) { return a, nil } +var __lgraphqlUsergroupsAddusertoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x2d\x4e\x2d\xb2\x52\x08\x2d\x4e\x2d\xf2\xcc\x2b\x28\x2d\x51\xd4\x01\x09\xe6\x17\xa5\x27\xe6\x65\x56\x81\x95\x59\x29\x78\xe6\xc1\x84\xcb\xf3\x40\x8a\x9d\xf2\xf3\x73\x52\x13\xf3\x34\x15\xaa\xb9\x14\x14\x14\x14\x12\x53\x52\x40\xda\x43\xf2\xfd\x91\x74\x69\x64\x82\x4c\xb3\x82\x2a\x51\x50\x80\x58\x03\xb6\x0d\x2a\x82\x6a\x07\x8a\x95\x30\x15\x10\xeb\x20\xd6\x82\xc5\x6a\x35\xe1\x06\x66\xa6\x40\x19\x79\x89\xb9\xa9\x10\x49\x2e\x10\x06\x04\x00\x00\xff\xff\x31\x25\xe0\x75\xde\x00\x00\x00") + +func _lgraphqlUsergroupsAddusertoorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlUsergroupsAddusertoorganizationGraphql, + "_lgraphql/usergroups/addUserToOrganization.graphql", + ) +} + +func _lgraphqlUsergroupsAddusertoorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlUsergroupsAddusertoorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/usergroups/addUserToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlUsergroupsAllgroupmembersGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2a\x2c\x4d\x2d\xaa\x54\xa8\xe6\x52\x50\x50\x50\x48\xcc\xc9\x71\x2f\xca\x2f\x2d\xf0\x4d\xcd\x4d\x4a\x2d\x2a\xb6\x82\x0b\x14\x43\x15\x80\x40\x66\x0a\x9c\x99\x97\x98\x9b\x0a\xe7\xe4\x42\x34\x21\x14\x82\x40\x69\x71\x6a\x11\xaa\x08\x08\xa4\xe6\x26\x66\xe6\x60\x88\xa6\x67\x96\xe4\x24\x26\x79\xa6\xa0\x48\xd4\xa2\xf0\x8a\xf2\x73\x10\x16\x42\xa4\x6a\xb9\x6a\xb9\x00\x01\x00\x00\xff\xff\x02\xdf\xd4\xb3\xc4\x00\x00\x00") func _lgraphqlUsergroupsAllgroupmembersGraphqlBytes() ([]byte, error) { @@ -1744,10 +1828,12 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/deployments/getDeploymentsForEnvironment.graphql": _lgraphqlDeploymentsGetdeploymentsforenvironmentGraphql, "_lgraphql/deployments/updateDeployment.graphql": _lgraphqlDeploymentsUpdatedeploymentGraphql, "_lgraphql/deploytargets/addDeployTarget.graphql": _lgraphqlDeploytargetsAdddeploytargetGraphql, + "_lgraphql/deploytargets/addDeployTargetToOrganization.graphql": _lgraphqlDeploytargetsAdddeploytargettoorganizationGraphql, "_lgraphql/deploytargets/deleteDeployTarget.graphql": _lgraphqlDeploytargetsDeletedeploytargetGraphql, "_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql": _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql, "_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql": _lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql, "_lgraphql/deploytargets/listDeployTargets.graphql": _lgraphqlDeploytargetsListdeploytargetsGraphql, + "_lgraphql/deploytargets/removeDeployTargetFromOrganization.graphql": _lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphql, "_lgraphql/deploytargets/updateDeployTarget.graphql": _lgraphqlDeploytargetsUpdatedeploytargetGraphql, "_lgraphql/deploytargetconfigs/addDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsAdddeploytargetconfigGraphql, "_lgraphql/deploytargetconfigs/deleteDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsDeletedeploytargetconfigGraphql, @@ -1760,6 +1846,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/projects/projectByNameMetadata.graphql": _lgraphqlProjectsProjectbynamemetadataGraphql, "_lgraphql/projects/projectsByMetadata.graphql": _lgraphqlProjectsProjectsbymetadataGraphql, "_lgraphql/projects/projectsByOrganizationId.graphql": _lgraphqlProjectsProjectsbyorganizationidGraphql, + "_lgraphql/projects/removeProjectFromOrganization.graphql": _lgraphqlProjectsRemoveprojectfromorganizationGraphql, "_lgraphql/projects/removeProjectMetadataByKey.graphql": _lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, "_lgraphql/projects/updateProject.graphql": _lgraphqlProjectsUpdateprojectGraphql, "_lgraphql/projects/updateProjectMetadata.graphql": _lgraphqlProjectsUpdateprojectmetadataGraphql, @@ -1783,6 +1870,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/addSshKey.graphql": _lgraphqlUsergroupsAddsshkeyGraphql, "_lgraphql/usergroups/addUser.graphql": _lgraphqlUsergroupsAdduserGraphql, "_lgraphql/usergroups/addUserToGroup.graphql": _lgraphqlUsergroupsAddusertogroupGraphql, + "_lgraphql/usergroups/addUserToOrganization.graphql": _lgraphqlUsergroupsAddusertoorganizationGraphql, "_lgraphql/usergroups/allGroupMembers.graphql": _lgraphqlUsergroupsAllgroupmembersGraphql, "_lgraphql/usergroups/allUsers.graphql": _lgraphqlUsergroupsAllusersGraphql, "_lgraphql/usergroups/groupsByOrganizationId.graphql": _lgraphqlUsergroupsGroupsbyorganizationidGraphql, @@ -1868,12 +1956,14 @@ var _bintree = &bintree{nil, map[string]*bintree{ "updateDeployTargetConfig.graphql": &bintree{_lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql, map[string]*bintree{}}, }}, "deploytargets": &bintree{nil, map[string]*bintree{ - "addDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsAdddeploytargetGraphql, map[string]*bintree{}}, - "deleteDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsDeletedeploytargetGraphql, map[string]*bintree{}}, - "deployTargetsByOrganizationId.graphql": &bintree{_lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql, map[string]*bintree{}}, - "deployTargetsByOrganizationName.graphql": &bintree{_lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql, map[string]*bintree{}}, - "listDeployTargets.graphql": &bintree{_lgraphqlDeploytargetsListdeploytargetsGraphql, map[string]*bintree{}}, - "updateDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsUpdatedeploytargetGraphql, map[string]*bintree{}}, + "addDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsAdddeploytargetGraphql, map[string]*bintree{}}, + "addDeployTargetToOrganization.graphql": &bintree{_lgraphqlDeploytargetsAdddeploytargettoorganizationGraphql, map[string]*bintree{}}, + "deleteDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsDeletedeploytargetGraphql, map[string]*bintree{}}, + "deployTargetsByOrganizationId.graphql": &bintree{_lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql, map[string]*bintree{}}, + "deployTargetsByOrganizationName.graphql": &bintree{_lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql, map[string]*bintree{}}, + "listDeployTargets.graphql": &bintree{_lgraphqlDeploytargetsListdeploytargetsGraphql, map[string]*bintree{}}, + "removeDeployTargetFromOrganization.graphql": &bintree{_lgraphqlDeploytargetsRemovedeploytargetfromorganizationGraphql, map[string]*bintree{}}, + "updateDeployTarget.graphql": &bintree{_lgraphqlDeploytargetsUpdatedeploytargetGraphql, map[string]*bintree{}}, }}, "environments": &bintree{nil, map[string]*bintree{ "addOrUpdateEnvironment.graphql": &bintree{_lgraphqlEnvironmentsAddorupdateenvironmentGraphql, map[string]*bintree{}}, @@ -1905,6 +1995,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsProjectsbymetadataGraphql, map[string]*bintree{}}, "projectsByOrganizationId.graphql": &bintree{_lgraphqlProjectsProjectsbyorganizationidGraphql, map[string]*bintree{}}, + "removeProjectFromOrganization.graphql": &bintree{_lgraphqlProjectsRemoveprojectfromorganizationGraphql, map[string]*bintree{}}, "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, "updateProject.graphql": &bintree{_lgraphqlProjectsUpdateprojectGraphql, map[string]*bintree{}}, "updateProjectMetadata.graphql": &bintree{_lgraphqlProjectsUpdateprojectmetadataGraphql, map[string]*bintree{}}, @@ -1923,6 +2014,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "addSshKey.graphql": &bintree{_lgraphqlUsergroupsAddsshkeyGraphql, map[string]*bintree{}}, "addUser.graphql": &bintree{_lgraphqlUsergroupsAdduserGraphql, map[string]*bintree{}}, "addUserToGroup.graphql": &bintree{_lgraphqlUsergroupsAddusertogroupGraphql, map[string]*bintree{}}, + "addUserToOrganization.graphql": &bintree{_lgraphqlUsergroupsAddusertoorganizationGraphql, map[string]*bintree{}}, "allGroupMembers.graphql": &bintree{_lgraphqlUsergroupsAllgroupmembersGraphql, map[string]*bintree{}}, "allUsers.graphql": &bintree{_lgraphqlUsergroupsAllusersGraphql, map[string]*bintree{}}, "groupsByOrganizationId.graphql": &bintree{_lgraphqlUsergroupsGroupsbyorganizationidGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/projects.go b/api/lagoon/client/projects.go index cfe668f..eca867a 100644 --- a/api/lagoon/client/projects.go +++ b/api/lagoon/client/projects.go @@ -195,3 +195,16 @@ func (c *Client) ProjectsByOrganizationID(ctx context.Context, id uint, projects json.Unmarshal(data, projects) return nil } + +// RemoveProjectFromOrganization removes a project from an organization. +func (c *Client) RemoveProjectFromOrganization(ctx context.Context, in *schema.RemoveProjectFromOrganizationInput, out *schema.Project) error { + req, err := c.newRequest("_lgraphql/projects/removeProjectFromOrganization.graphql", in) + if err != nil { + return err + } + return c.client.Run(ctx, req, &struct { + Response *schema.Project `json:"removeProjectFromOrganization"` + }{ + Response: out, + }) +} diff --git a/api/lagoon/client/usergroups.go b/api/lagoon/client/usergroups.go index f7bd865..8bb67af 100644 --- a/api/lagoon/client/usergroups.go +++ b/api/lagoon/client/usergroups.go @@ -265,6 +265,19 @@ func (c *Client) AddGroupToOrganization(ctx context.Context, in *schema.AddGroup }) } +// AddUserToOrganization adds a User to an Organization. +func (c *Client) AddUserToOrganization(ctx context.Context, in *schema.AddUserToOrganizationInput, out *schema.Organization) error { + req, err := c.newRequest("_lgraphql/usergroups/addUserToOrganization.graphql", in) + if err != nil { + return err + } + return c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"addUserToOrganization"` + }{ + Response: out, + }) +} + // UsersByOrganization queries the Lagoon API for users by the given organization id func (c *Client) UsersByOrganization(ctx context.Context, id uint, users *[]schema.OrgUser) error { diff --git a/api/lagoon/deploytarget.go b/api/lagoon/deploytarget.go index 35a122e..761636b 100644 --- a/api/lagoon/deploytarget.go +++ b/api/lagoon/deploytarget.go @@ -13,6 +13,8 @@ type DeployTargets interface { ListDeployTargets(ctx context.Context, out *[]schema.DeployTarget) error DeployTargetsByOrganizationId(ctx context.Context, id uint, out *[]schema.DeployTarget) error DeployTargetsByOrganizationName(ctx context.Context, name string, out *[]schema.DeployTarget) error + AddDeployTargetToOrganization(ctx context.Context, in *schema.AddDeployTargetToOrganizationInput, out *schema.AddDeployTargetResponse) error + RemoveDeployTargetFromOrganization(ctx context.Context, in *schema.RemoveDeployTargetFromOrganizationInput, out *schema.DeleteDeployTargetResponse) error } func AddDeployTarget(ctx context.Context, in *schema.AddDeployTargetInput, out DeployTargets) (*schema.AddDeployTargetResponse, error) { @@ -47,3 +49,15 @@ func ListDeployTargetsByOrganizationName(ctx context.Context, name string, d Dep deploytargets := []schema.DeployTarget{} return &deploytargets, d.DeployTargetsByOrganizationName(ctx, name, &deploytargets) } + +// AddDeployTargetToOrganization adds a deploy target to an organization. +func AddDeployTargetToOrganization(ctx context.Context, in *schema.AddDeployTargetToOrganizationInput, out DeployTargets) (*schema.AddDeployTargetResponse, error) { + response := schema.AddDeployTargetResponse{} + return &response, out.AddDeployTargetToOrganization(ctx, in, &response) +} + +// RemoveDeployTargetFromOrganization removes a deploy target from an organization. +func RemoveDeployTargetFromOrganization(ctx context.Context, in *schema.RemoveDeployTargetFromOrganizationInput, out DeployTargets) (*schema.DeleteDeployTargetResponse, error) { + response := schema.DeleteDeployTargetResponse{} + return &response, out.RemoveDeployTargetFromOrganization(ctx, in, &response) +} diff --git a/api/lagoon/projects.go b/api/lagoon/projects.go index 48ff0de..3845e13 100644 --- a/api/lagoon/projects.go +++ b/api/lagoon/projects.go @@ -19,6 +19,7 @@ type Projects interface { UpdateProject(ctx context.Context, id int, patch schema.UpdateProjectPatchInput, project *schema.Project) error SSHEndpointsByProject(ctx context.Context, name string, project *schema.Project) error ProjectsByOrganizationID(ctx context.Context, name uint, project *[]schema.OrgProject) error + RemoveProjectFromOrganization(ctx context.Context, in *schema.RemoveProjectFromOrganizationInput, out *schema.Project) error } // GetMinimalProjectByName gets info of projects in lagoon that have matching metadata. @@ -74,3 +75,9 @@ func ListProjectsByOrganizationID(ctx context.Context, id uint, p Projects) (*[] project := []schema.OrgProject{} return &project, p.ProjectsByOrganizationID(ctx, id, &project) } + +// RemoveProjectFromOrganization removes a project from an organization. +func RemoveProjectFromOrganization(ctx context.Context, in *schema.RemoveProjectFromOrganizationInput, out Projects) (*schema.Project, error) { + response := schema.Project{} + return &response, out.RemoveProjectFromOrganization(ctx, in, &response) +} diff --git a/api/lagoon/usergroups.go b/api/lagoon/usergroups.go index acb4dde..d4e2784 100644 --- a/api/lagoon/usergroups.go +++ b/api/lagoon/usergroups.go @@ -109,16 +109,19 @@ func ListGroupsByOrganizationID(ctx context.Context, id uint, ug UserGroups) (*[ return &group, ug.GroupsByOrganizationID(ctx, id, &group) } +// AddGroupToOrganization adds a group to an organization. func AddGroupToOrganization(ctx context.Context, in *schema.AddGroupToOrganizationInput, ug UserGroups) (*schema.OrgGroup, error) { group := schema.OrgGroup{} return &group, ug.AddGroupToOrganization(ctx, in, &group) } +// UsersByOrganization lists users associated within an organization in lagoon via provided ID. func UsersByOrganization(ctx context.Context, id uint, ug UserGroups) (*[]schema.OrgUser, error) { user := []schema.OrgUser{} return &user, ug.UsersByOrganization(ctx, id, &user) } +// UsersByOrganizationName lists users associated within an organization in lagoon via provided Name. func UsersByOrganizationName(ctx context.Context, name string, ug UserGroups) (*[]schema.OrgUser, error) { user := []schema.OrgUser{} return &user, ug.UsersByOrganizationName(ctx, name, &user) diff --git a/api/schema/deploytarget.go b/api/schema/deploytarget.go index 077a02c..8ed873e 100644 --- a/api/schema/deploytarget.go +++ b/api/schema/deploytarget.go @@ -48,3 +48,13 @@ type DeleteDeployTargetInput struct { type DeleteDeployTargetResponse struct { DeleteDeployTarget string `json:"deleteDeployTarget,omitempty"` } + +type AddDeployTargetToOrganizationInput struct { + DeployTarget uint `json:"deployTarget"` + Organization uint `json:"organization"` +} + +type RemoveDeployTargetFromOrganizationInput struct { + DeployTarget uint `json:"deployTarget"` + Organization uint `json:"organization"` +} diff --git a/api/schema/project.go b/api/schema/project.go index 1414506..6105824 100644 --- a/api/schema/project.go +++ b/api/schema/project.go @@ -124,8 +124,8 @@ type UpdateProjectPatchInput struct { BuildImage *null.String `json:"buildImage,omitempty"` } -// AddProjectToOrganizationInput -type AddProjectToOrganizationInput struct { +// RemoveProjectFromOrganizationInput is based on the Lagoon API type. +type RemoveProjectFromOrganizationInput struct { Project uint `json:"project"` Organization uint `json:"organization"` } diff --git a/api/schema/user.go b/api/schema/user.go index 603be57..d6357d6 100644 --- a/api/schema/user.go +++ b/api/schema/user.go @@ -19,6 +19,11 @@ type User struct { GroupRoles []GroupRoles `json:"groupRoles,omitempy"` } +type UserInput struct { + ID string `json:"id,omitempty"` + Email string `json:"email,omitempty"` +} + type GroupRoles struct { Name string `json:"name,omitempty"` Role string `json:"role,omitempty"` @@ -29,3 +34,9 @@ type AllUsersFilter struct { GitlabID uint `json:"gitlabId,omitempty"` Email string `json:"email,omitempty"` } + +type AddUserToOrganizationInput struct { + User UserInput `json:"user"` + Organization uint `json:"organization"` + Owner bool `json:"owner,omitempty"` +} From 78ab64a18d9da6c782aacd64788e6c96645558d2 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 20 Oct 2023 15:46:20 +1100 Subject: [PATCH 12/22] Corresponding removeUser cmd --- .../removeUserFromOrganization.graphql | 13 ++++ api/lagoon/client/lgraphql/lgraphql.go | 61 +++++++++++++------ api/lagoon/client/usergroups.go | 13 ++++ 3 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 api/lagoon/client/_lgraphql/usergroups/removeUserFromOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/usergroups/removeUserFromOrganization.graphql b/api/lagoon/client/_lgraphql/usergroups/removeUserFromOrganization.graphql new file mode 100644 index 0000000..bec2b78 --- /dev/null +++ b/api/lagoon/client/_lgraphql/usergroups/removeUserFromOrganization.graphql @@ -0,0 +1,13 @@ +mutation ( + $user: UserInput!, + $organization: Int!, + $owner: Boolean) { + removeUserFromOrganization(input: { + user: $user + organization: $organization + owner: $owner + }) { + id + name + } +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index 9d03491..69b3a2b 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -69,6 +69,7 @@ // _lgraphql/usergroups/me.graphql // _lgraphql/usergroups/removeGroupsFromProject.graphql // _lgraphql/usergroups/removeUserFromGroup.graphql +// _lgraphql/usergroups/removeUserFromOrganization.graphql // _lgraphql/usergroups/userByEmail.graphql // _lgraphql/usergroups/userBySSHFingerprint.graphql // _lgraphql/usergroups/userBySSHKey.graphql @@ -1536,6 +1537,26 @@ func _lgraphqlUsergroupsRemoveuserfromgroupGraphql() (*asset, error) { return a, nil } +var __lgraphqlUsergroupsRemoveuserfromorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8d\x31\x0a\x02\x31\x10\x45\xfb\x9c\xe2\x0b\x16\xbb\xe0\x09\x52\x5a\x08\x5b\x59\x79\x80\x80\x83\x04\xcc\x8c\xcc\x26\x0a\xca\xde\x5d\x66\xa2\xb0\x5b\x85\xfc\x79\xff\xbf\xd2\x6a\xaa\x59\x18\x43\x00\xf6\x6d\x26\x8d\xb8\xcc\xa4\x13\x3f\x5a\xdd\x1d\x2c\x14\xbd\x25\xce\x6f\xc7\x22\x26\xfe\xc7\x2f\x36\xf8\x28\x72\xa7\xc4\x23\x3e\x01\x50\x2a\xf2\x24\xeb\x9f\x54\xca\x79\x55\x1c\xb2\x0d\x46\xa7\x80\xee\x71\x9d\xff\xb7\x8a\x8d\xb1\xdf\xbb\xab\x3b\x03\xb0\x8c\xbf\xa1\x7c\xf5\x87\x53\x21\x8b\xc3\x12\xbe\x01\x00\x00\xff\xff\x7e\xd2\x27\x2a\xd1\x00\x00\x00") + +func _lgraphqlUsergroupsRemoveuserfromorganizationGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlUsergroupsRemoveuserfromorganizationGraphql, + "_lgraphql/usergroups/removeUserFromOrganization.graphql", + ) +} + +func _lgraphqlUsergroupsRemoveuserfromorganizationGraphql() (*asset, error) { + bytes, err := _lgraphqlUsergroupsRemoveuserfromorganizationGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/usergroups/removeUserFromOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlUsergroupsUserbyemailGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x4e\xbd\xce\xc2\x30\x10\xdb\xfb\x14\xf7\x49\xdf\x50\x5e\x81\x11\x09\x16\x24\x06\x40\xec\x11\x98\x72\x22\x3f\xe5\x92\x0c\x11\xea\xbb\xa3\x14\x08\x55\xea\xe9\xce\xb6\x6c\x3f\x22\x24\x51\xfb\x0f\xa3\x58\x2f\xe9\x10\x84\x6d\xf7\xb7\xa0\x67\x43\x44\x14\x3d\x64\x95\xd6\x59\x6b\x3f\x8e\xb7\xf3\x6b\xc8\xe0\x4b\x39\x47\xad\x7c\x57\x16\x1f\x76\xca\xa0\x30\x5a\x55\xc4\xd9\x19\x03\x1b\xca\xef\xfd\x6d\x8b\xe4\x27\xe9\x55\x43\x86\x9d\x26\x64\xdc\x91\x8e\xa9\x9f\x71\x27\xa5\xe3\x8c\xdc\xb0\xed\x20\xbd\xf0\xa4\x75\x5c\x22\x50\x01\xbf\xa2\xa1\x5c\x9d\xb8\xd8\xef\x9d\x46\x3d\x6b\xb6\x43\x9c\x46\x15\x30\x34\xc3\x2b\x00\x00\xff\xff\xa1\x66\xca\x90\x63\x01\x00\x00") func _lgraphqlUsergroupsUserbyemailGraphqlBytes() ([]byte, error) { @@ -1877,6 +1898,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/me.graphql": _lgraphqlUsergroupsMeGraphql, "_lgraphql/usergroups/removeGroupsFromProject.graphql": _lgraphqlUsergroupsRemovegroupsfromprojectGraphql, "_lgraphql/usergroups/removeUserFromGroup.graphql": _lgraphqlUsergroupsRemoveuserfromgroupGraphql, + "_lgraphql/usergroups/removeUserFromOrganization.graphql": _lgraphqlUsergroupsRemoveuserfromorganizationGraphql, "_lgraphql/usergroups/userByEmail.graphql": _lgraphqlUsergroupsUserbyemailGraphql, "_lgraphql/usergroups/userBySSHFingerprint.graphql": _lgraphqlUsergroupsUserbysshfingerprintGraphql, "_lgraphql/usergroups/userBySSHKey.graphql": _lgraphqlUsergroupsUserbysshkeyGraphql, @@ -2008,25 +2030,26 @@ var _bintree = &bintree{nil, map[string]*bintree{ "uploadFilesForTask.graphql": &bintree{_lgraphqlTasksUploadfilesfortaskGraphql, map[string]*bintree{}}, }}, "usergroups": &bintree{nil, map[string]*bintree{ - "addGroup.graphql": &bintree{_lgraphqlUsergroupsAddgroupGraphql, map[string]*bintree{}}, - "addGroupToOrganization.graphql": &bintree{_lgraphqlUsergroupsAddgrouptoorganizationGraphql, map[string]*bintree{}}, - "addGroupsToProject.graphql": &bintree{_lgraphqlUsergroupsAddgroupstoprojectGraphql, map[string]*bintree{}}, - "addSshKey.graphql": &bintree{_lgraphqlUsergroupsAddsshkeyGraphql, map[string]*bintree{}}, - "addUser.graphql": &bintree{_lgraphqlUsergroupsAdduserGraphql, map[string]*bintree{}}, - "addUserToGroup.graphql": &bintree{_lgraphqlUsergroupsAddusertogroupGraphql, map[string]*bintree{}}, - "addUserToOrganization.graphql": &bintree{_lgraphqlUsergroupsAddusertoorganizationGraphql, map[string]*bintree{}}, - "allGroupMembers.graphql": &bintree{_lgraphqlUsergroupsAllgroupmembersGraphql, map[string]*bintree{}}, - "allUsers.graphql": &bintree{_lgraphqlUsergroupsAllusersGraphql, map[string]*bintree{}}, - "groupsByOrganizationId.graphql": &bintree{_lgraphqlUsergroupsGroupsbyorganizationidGraphql, map[string]*bintree{}}, - "me.graphql": &bintree{_lgraphqlUsergroupsMeGraphql, map[string]*bintree{}}, - "removeGroupsFromProject.graphql": &bintree{_lgraphqlUsergroupsRemovegroupsfromprojectGraphql, map[string]*bintree{}}, - "removeUserFromGroup.graphql": &bintree{_lgraphqlUsergroupsRemoveuserfromgroupGraphql, map[string]*bintree{}}, - "userByEmail.graphql": &bintree{_lgraphqlUsergroupsUserbyemailGraphql, map[string]*bintree{}}, - "userBySSHFingerprint.graphql": &bintree{_lgraphqlUsergroupsUserbysshfingerprintGraphql, map[string]*bintree{}}, - "userBySSHKey.graphql": &bintree{_lgraphqlUsergroupsUserbysshkeyGraphql, map[string]*bintree{}}, - "userCanSSHToEnvironment.graphql": &bintree{_lgraphqlUsergroupsUsercansshtoenvironmentGraphql, map[string]*bintree{}}, - "usersByOrganization.graphql": &bintree{_lgraphqlUsergroupsUsersbyorganizationGraphql, map[string]*bintree{}}, - "usersByOrganizationName.graphql": &bintree{_lgraphqlUsergroupsUsersbyorganizationnameGraphql, map[string]*bintree{}}, + "addGroup.graphql": &bintree{_lgraphqlUsergroupsAddgroupGraphql, map[string]*bintree{}}, + "addGroupToOrganization.graphql": &bintree{_lgraphqlUsergroupsAddgrouptoorganizationGraphql, map[string]*bintree{}}, + "addGroupsToProject.graphql": &bintree{_lgraphqlUsergroupsAddgroupstoprojectGraphql, map[string]*bintree{}}, + "addSshKey.graphql": &bintree{_lgraphqlUsergroupsAddsshkeyGraphql, map[string]*bintree{}}, + "addUser.graphql": &bintree{_lgraphqlUsergroupsAdduserGraphql, map[string]*bintree{}}, + "addUserToGroup.graphql": &bintree{_lgraphqlUsergroupsAddusertogroupGraphql, map[string]*bintree{}}, + "addUserToOrganization.graphql": &bintree{_lgraphqlUsergroupsAddusertoorganizationGraphql, map[string]*bintree{}}, + "allGroupMembers.graphql": &bintree{_lgraphqlUsergroupsAllgroupmembersGraphql, map[string]*bintree{}}, + "allUsers.graphql": &bintree{_lgraphqlUsergroupsAllusersGraphql, map[string]*bintree{}}, + "groupsByOrganizationId.graphql": &bintree{_lgraphqlUsergroupsGroupsbyorganizationidGraphql, map[string]*bintree{}}, + "me.graphql": &bintree{_lgraphqlUsergroupsMeGraphql, map[string]*bintree{}}, + "removeGroupsFromProject.graphql": &bintree{_lgraphqlUsergroupsRemovegroupsfromprojectGraphql, map[string]*bintree{}}, + "removeUserFromGroup.graphql": &bintree{_lgraphqlUsergroupsRemoveuserfromgroupGraphql, map[string]*bintree{}}, + "removeUserFromOrganization.graphql": &bintree{_lgraphqlUsergroupsRemoveuserfromorganizationGraphql, map[string]*bintree{}}, + "userByEmail.graphql": &bintree{_lgraphqlUsergroupsUserbyemailGraphql, map[string]*bintree{}}, + "userBySSHFingerprint.graphql": &bintree{_lgraphqlUsergroupsUserbysshfingerprintGraphql, map[string]*bintree{}}, + "userBySSHKey.graphql": &bintree{_lgraphqlUsergroupsUserbysshkeyGraphql, map[string]*bintree{}}, + "userCanSSHToEnvironment.graphql": &bintree{_lgraphqlUsergroupsUsercansshtoenvironmentGraphql, map[string]*bintree{}}, + "usersByOrganization.graphql": &bintree{_lgraphqlUsergroupsUsersbyorganizationGraphql, map[string]*bintree{}}, + "usersByOrganizationName.graphql": &bintree{_lgraphqlUsergroupsUsersbyorganizationnameGraphql, map[string]*bintree{}}, }}, }}, }} diff --git a/api/lagoon/client/usergroups.go b/api/lagoon/client/usergroups.go index 8bb67af..36e8270 100644 --- a/api/lagoon/client/usergroups.go +++ b/api/lagoon/client/usergroups.go @@ -278,6 +278,19 @@ func (c *Client) AddUserToOrganization(ctx context.Context, in *schema.AddUserTo }) } +// RemoveUserFromOrganization removes a User from an Organization. TODO - Create new input type for this +func (c *Client) RemoveUserFromOrganization(ctx context.Context, in *schema.AddUserToOrganizationInput, out *schema.Organization) error { + req, err := c.newRequest("_lgraphql/usergroups/removeUserFromOrganization.graphql", in) + if err != nil { + return err + } + return c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"removeUserFromOrganization"` + }{ + Response: out, + }) +} + // UsersByOrganization queries the Lagoon API for users by the given organization id func (c *Client) UsersByOrganization(ctx context.Context, id uint, users *[]schema.OrgUser) error { From 73831e83e104e32b8c8b3acf32be50a102ce1028 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Mon, 23 Oct 2023 14:45:03 +1100 Subject: [PATCH 13/22] Included missing fields addProjectInput --- api/schema/project.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/schema/project.go b/api/schema/project.go index 6105824..7c1800f 100644 --- a/api/schema/project.go +++ b/api/schema/project.go @@ -34,6 +34,12 @@ type AddProjectInput struct { BuildImage string `json:"buildImage,omitempty"` Organization uint `json:"organization,omitempty"` AddOrgOwner bool `json:"addOrgOwner,omitempty"` + RouterPattern string `json:"routerPattern,omitempty"` + ProblemsUI uint `json:"problemsUi,omitempty"` + FactsUI uint `json:"factsUi,omitempty"` + ProductionBuildPriority uint `json:"productionBuildPriority,omitempty"` + DevelopmentBuildPriority uint `json:"developmentBuildPriority,omitempty"` + DeploymentsDisabled uint `json:"deploymentsDisabled,omitempty"` } // Project is the Lagoon API Project object. From 037b2d611755060e9a38b5580260fd11031630f7 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Mon, 23 Oct 2023 16:19:46 +1100 Subject: [PATCH 14/22] Updated quota type to account for negatives --- api/schema/organization.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/api/schema/organization.go b/api/schema/organization.go index 39562e1..787475c 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -18,11 +18,11 @@ type AddOrganizationInput struct { Name string `json:"name"` FriendlyName string `json:"friendlyName"` Description string `json:"description,omitempty"` - QuotaProject uint `json:"quotaProject"` - QuotaGroup uint `json:"quotaGroup,omitempty"` - QuotaNotification uint `json:"quotaNotification,omitempty"` - QuotaEnvironment uint `json:"quotaEnvironment,omitempty"` - QuotaRoute uint `json:"quotaRoute"` + QuotaProject int `json:"quotaProject"` + QuotaGroup int `json:"quotaGroup,omitempty"` + QuotaNotification int `json:"quotaNotification,omitempty"` + QuotaEnvironment int `json:"quotaEnvironment,omitempty"` + QuotaRoute int `json:"quotaRoute"` } type OrgProject struct { @@ -103,11 +103,11 @@ type UpdateOrganizationPatchInput struct { Name *string `json:"name,omitempty"` FriendlyName *string `json:"friendlyName,omitempty"` Description *string `json:"description,omitempty"` - QuotaProject *uint `json:"quotaProject,omitempty"` - QuotaGroup *uint `json:"quotaGroup,omitempty"` - QuotaNotification *uint `json:"quotaNotification,omitempty"` - QuotaEnvironment *uint `json:"quotaEnvironment,omitempty"` - QuotaRoute *uint `json:"quotaRoute,omitempty"` + QuotaProject *int `json:"quotaProject,omitempty"` + QuotaGroup *int `json:"quotaGroup,omitempty"` + QuotaNotification *int `json:"quotaNotification,omitempty"` + QuotaEnvironment *int `json:"quotaEnvironment,omitempty"` + QuotaRoute *int `json:"quotaRoute,omitempty"` } type UpdateOrganizationInput struct { From d023d12a5ed30e92355adecfa01ae461793c3bfa Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 25 Oct 2023 11:55:20 +1100 Subject: [PATCH 15/22] Fixes up AddOrganizationInput schema --- api/schema/organization.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/schema/organization.go b/api/schema/organization.go index 787475c..f6e0667 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -18,11 +18,11 @@ type AddOrganizationInput struct { Name string `json:"name"` FriendlyName string `json:"friendlyName"` Description string `json:"description,omitempty"` - QuotaProject int `json:"quotaProject"` + QuotaProject int `json:"quotaProject,omitempty"` QuotaGroup int `json:"quotaGroup,omitempty"` QuotaNotification int `json:"quotaNotification,omitempty"` QuotaEnvironment int `json:"quotaEnvironment,omitempty"` - QuotaRoute int `json:"quotaRoute"` + QuotaRoute int `json:"quotaRoute,omitempty"` } type OrgProject struct { From bde140a3340b1ba2025411b0e207362dc33c85b5 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Wed, 25 Oct 2023 12:10:32 +1100 Subject: [PATCH 16/22] Fixing up schema --- api/schema/organization.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/schema/organization.go b/api/schema/organization.go index f6e0667..efed4a3 100644 --- a/api/schema/organization.go +++ b/api/schema/organization.go @@ -16,7 +16,7 @@ type Organization struct { type AddOrganizationInput struct { ID uint `json:"id,omitempty"` Name string `json:"name"` - FriendlyName string `json:"friendlyName"` + FriendlyName string `json:"friendlyName,omitempty"` Description string `json:"description,omitempty"` QuotaProject int `json:"quotaProject,omitempty"` QuotaGroup int `json:"quotaGroup,omitempty"` @@ -37,22 +37,22 @@ type OrgProject struct { type OrgEnvironment struct { ID uint `json:"id,omitempty"` Name string `json:"name,omitempty"` - ProjectID uint `json:"project,omitempty"` + Project OrgProject `json:"project,omitempty"` DeployType DeployType `json:"deployType,omitempty"` DeployHeadRef string `json:"deployHeadRef,omitempty"` DeployTitle string `json:"deployTitle,omitempty"` EnvironmentType EnvType `json:"environmentType,omitempty"` OpenshiftProjectName string `json:"openshiftProjectName,omitempty"` AutoIdle uint `json:"autoIdle,omitempty"` - KubernetesNamespacePattern *string `json:"kubernetesNamespacePattern,omitempty"` + KubernetesNamespacePattern string `json:"kubernetesNamespacePattern,omitempty"` Updated string `json:"updated,omitempty"` Created string `json:"created,omitempty"` Deleted string `json:"deleted,omitempty"` Route string `json:"route,omitempty"` Routes string `json:"routes,omitempty"` Services []EnvironmentService `json:"services,omitempty"` - DeployTarget DeployTarget `json:"openshift,omitempty"` - Kubernetes *uint `json:"kubernetes,omitempty"` + Openshift DeployTarget `json:"openshift,omitempty"` + Kubernetes DeployTarget `json:"kubernetes,omitempty"` } // AddGroupToOrganizationInput is based on the input to AddGroupToOrganization. From 415ed5612ff010f7c8be7c5b0eb0a62c94c6a07c Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Mon, 20 Nov 2023 12:05:01 +1100 Subject: [PATCH 17/22] Removed addExistingProjectToOrganization mutation --- .../addExistingProjectToOrganization.graphql | 11 ----- api/lagoon/client/lgraphql/lgraphql.go | 43 +++++-------------- 2 files changed, 10 insertions(+), 44 deletions(-) delete mode 100644 api/lagoon/client/_lgraphql/projects/addExistingProjectToOrganization.graphql diff --git a/api/lagoon/client/_lgraphql/projects/addExistingProjectToOrganization.graphql b/api/lagoon/client/_lgraphql/projects/addExistingProjectToOrganization.graphql deleted file mode 100644 index 4906d9a..0000000 --- a/api/lagoon/client/_lgraphql/projects/addExistingProjectToOrganization.graphql +++ /dev/null @@ -1,11 +0,0 @@ -mutation ( - $project: Int!, - $organization: Int!,){ - addProjectToOrganization(input: { - project: $project, - organization: $organization, - }) { - id - name - } -} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index 69b3a2b..14b0bb4 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -31,7 +31,6 @@ // _lgraphql/deploytargetconfigs/deleteDeployTargetConfig.graphql // _lgraphql/deploytargetconfigs/deployTargetConfigsByProjectId.graphql // _lgraphql/deploytargetconfigs/updateDeployTargetConfig.graphql -// _lgraphql/projects/addExistingProjectToOrganization.graphql // _lgraphql/projects/addProject.graphql // _lgraphql/projects/minimalProjectByName.graphql // _lgraphql/projects/projectByName.graphql @@ -777,26 +776,6 @@ func _lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql() (*asset, erro return a, nil } -var __lgraphqlProjectsAddexistingprojecttoorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\x29\x28\xca\xcf\x4a\x4d\x2e\xb1\x52\xf0\xcc\x2b\x51\xd4\x01\x89\xe4\x17\xa5\x27\xe6\x65\x56\x81\xd5\x40\x85\x35\xab\xb9\x14\x14\x12\x53\x52\x02\x20\x8a\x43\xf2\xfd\x91\xd4\x68\x64\xe6\x15\x94\x96\x58\x29\x80\xd4\x28\x28\xc0\xcd\x83\x99\xac\x03\x16\x46\x35\x14\xc5\x0e\x90\x82\x5a\x4d\xa8\xf6\xcc\x14\x30\x95\x97\x98\x9b\x0a\x12\xe6\xaa\xe5\x02\x04\x00\x00\xff\xff\x86\x33\xbc\xab\xaf\x00\x00\x00") - -func _lgraphqlProjectsAddexistingprojecttoorganizationGraphqlBytes() ([]byte, error) { - return bindataRead( - __lgraphqlProjectsAddexistingprojecttoorganizationGraphql, - "_lgraphql/projects/addExistingProjectToOrganization.graphql", - ) -} - -func _lgraphqlProjectsAddexistingprojecttoorganizationGraphql() (*asset, error) { - bytes, err := _lgraphqlProjectsAddexistingprojecttoorganizationGraphqlBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "_lgraphql/projects/addExistingProjectToOrganization.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - var __lgraphqlProjectsAddprojectGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x7c\x92\xcf\x4e\xc3\x30\x0c\xc6\xef\x7b\x8a\x4c\xe2\xb0\x49\x7b\x82\x1d\x41\x1c\x26\x90\x36\x09\xf1\x00\x5e\xe3\x75\x41\xa9\x53\x1c\x67\x08\x10\xef\x8e\xda\x35\xff\xc6\xd8\xa1\x97\xcf\xdf\xd7\xd8\xfe\xb9\x0b\x02\x62\x1c\xa9\xc5\x4c\xa9\x3b\x82\x0e\xd7\xea\x45\xd8\x50\x3b\x5f\x0d\x8a\xe3\x16\xc8\x7c\x8d\x9e\xb5\xda\x90\x8c\x6a\x6b\xe4\x95\x6d\xed\xf4\x61\x7f\x70\x56\x23\x47\xf9\x9c\xef\x91\xfc\xd1\x1c\x64\x0c\xcf\x6b\x6d\xc7\xee\x0d\x1b\xd9\x81\x08\x32\x55\xb9\x3d\x03\x35\x47\xf4\x95\xd8\x07\x6b\x19\xdf\x03\x7a\xb9\x28\xb0\xd3\xa1\x19\x7a\x7c\xa4\x93\x61\x47\x1d\x92\xd4\xed\x41\x10\xb7\xd1\x16\xf3\x10\x5e\x1c\x43\x8b\x0f\x60\x9b\x2c\x6a\x3c\xa1\x75\xfd\x90\x2f\x7e\xe5\x9f\x4d\x67\x24\xbb\x40\xeb\x2d\xb7\xdb\x0f\x1a\xa6\xbd\x77\xce\x22\xd0\xd4\x88\x39\x81\xe0\x13\x7e\xc6\xd7\x97\xea\x7b\xa6\x94\x52\xa0\xf5\x34\xee\xc2\x50\x1f\x64\x3d\xe9\x4a\x9d\x97\x3e\xee\x7e\x35\x49\xf5\xd6\x2b\x08\xd1\x12\x11\x4c\x2c\xa2\x5c\x50\xc8\x44\xd2\x6f\x33\x8c\x0c\xe1\x4f\xf1\x92\xca\x7f\xbc\x62\x30\xa3\x4a\xd4\x62\xa9\x06\x56\xf1\x4b\x96\xeb\xe8\xae\x23\x8d\xa1\x0c\x33\x71\x4d\x0b\x28\xa9\x96\x8c\xa3\xe1\x36\xe1\x9b\x07\x90\x9e\x2f\xf1\x97\xc7\x90\x87\xca\x67\x50\xdc\xc4\x58\xfd\x59\x26\xf2\x46\x17\x27\x70\x2e\xce\x86\xef\x37\x00\x00\xff\xff\xc5\xe9\x48\x5a\x95\x03\x00\x00") func _lgraphqlProjectsAddprojectGraphqlBytes() ([]byte, error) { @@ -1860,7 +1839,6 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/deploytargetconfigs/deleteDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsDeletedeploytargetconfigGraphql, "_lgraphql/deploytargetconfigs/deployTargetConfigsByProjectId.graphql": _lgraphqlDeploytargetconfigsDeploytargetconfigsbyprojectidGraphql, "_lgraphql/deploytargetconfigs/updateDeployTargetConfig.graphql": _lgraphqlDeploytargetconfigsUpdatedeploytargetconfigGraphql, - "_lgraphql/projects/addExistingProjectToOrganization.graphql": _lgraphqlProjectsAddexistingprojecttoorganizationGraphql, "_lgraphql/projects/addProject.graphql": _lgraphqlProjectsAddprojectGraphql, "_lgraphql/projects/minimalProjectByName.graphql": _lgraphqlProjectsMinimalprojectbynameGraphql, "_lgraphql/projects/projectByName.graphql": _lgraphqlProjectsProjectbynameGraphql, @@ -2010,17 +1988,16 @@ var _bintree = &bintree{nil, map[string]*bintree{ "updateOrganization.graphql": &bintree{_lgraphqlOrganizationsUpdateorganizationGraphql, map[string]*bintree{}}, }}, "projects": &bintree{nil, map[string]*bintree{ - "addExistingProjectToOrganization.graphql": &bintree{_lgraphqlProjectsAddexistingprojecttoorganizationGraphql, map[string]*bintree{}}, - "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, - "minimalProjectByName.graphql": &bintree{_lgraphqlProjectsMinimalprojectbynameGraphql, map[string]*bintree{}}, - "projectByName.graphql": &bintree{_lgraphqlProjectsProjectbynameGraphql, map[string]*bintree{}}, - "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, - "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsProjectsbymetadataGraphql, map[string]*bintree{}}, - "projectsByOrganizationId.graphql": &bintree{_lgraphqlProjectsProjectsbyorganizationidGraphql, map[string]*bintree{}}, - "removeProjectFromOrganization.graphql": &bintree{_lgraphqlProjectsRemoveprojectfromorganizationGraphql, map[string]*bintree{}}, - "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, - "updateProject.graphql": &bintree{_lgraphqlProjectsUpdateprojectGraphql, map[string]*bintree{}}, - "updateProjectMetadata.graphql": &bintree{_lgraphqlProjectsUpdateprojectmetadataGraphql, map[string]*bintree{}}, + "addProject.graphql": &bintree{_lgraphqlProjectsAddprojectGraphql, map[string]*bintree{}}, + "minimalProjectByName.graphql": &bintree{_lgraphqlProjectsMinimalprojectbynameGraphql, map[string]*bintree{}}, + "projectByName.graphql": &bintree{_lgraphqlProjectsProjectbynameGraphql, map[string]*bintree{}}, + "projectByNameMetadata.graphql": &bintree{_lgraphqlProjectsProjectbynamemetadataGraphql, map[string]*bintree{}}, + "projectsByMetadata.graphql": &bintree{_lgraphqlProjectsProjectsbymetadataGraphql, map[string]*bintree{}}, + "projectsByOrganizationId.graphql": &bintree{_lgraphqlProjectsProjectsbyorganizationidGraphql, map[string]*bintree{}}, + "removeProjectFromOrganization.graphql": &bintree{_lgraphqlProjectsRemoveprojectfromorganizationGraphql, map[string]*bintree{}}, + "removeProjectMetadataByKey.graphql": &bintree{_lgraphqlProjectsRemoveprojectmetadatabykeyGraphql, map[string]*bintree{}}, + "updateProject.graphql": &bintree{_lgraphqlProjectsUpdateprojectGraphql, map[string]*bintree{}}, + "updateProjectMetadata.graphql": &bintree{_lgraphqlProjectsUpdateprojectmetadataGraphql, map[string]*bintree{}}, }}, "sshEndpointsByProject.graphql": &bintree{_lgraphqlSshendpointsbyprojectGraphql, map[string]*bintree{}}, "taskByID.graphql": &bintree{_lgraphqlTaskbyidGraphql, map[string]*bintree{}}, From ddc2c02dc5438404424896d08851c5521862a829 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 24 Nov 2023 14:28:44 +1100 Subject: [PATCH 18/22] Updated queries --- .../deployTargetsByOrganizationId.graphql | 30 ++++++++----------- .../deployTargetsByOrganizationName.graphql | 6 +--- .../organizations/organizationById.graphql | 4 ++- .../organizations/organizationByName.graphql | 4 ++- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql index f7afc0a..b961793 100644 --- a/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql +++ b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql @@ -1,21 +1,17 @@ query ( $id: Int!) { - organizationById( - id: $id) { - deployTargets { - id - name - created - consoleUrl - cloudRegion - cloudProvider - friendlyName - token - sshHost - sshPort - routerPattern - buildImage - monitoringConfig + organizationById(id: $id) { + deployTargets { + id + name + created + cloudRegion + cloudProvider + friendlyName + sshHost + sshPort + routerPattern + buildImage + } } } - } diff --git a/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql index 1933cb0..ebbe02d 100644 --- a/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql +++ b/api/lagoon/client/_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql @@ -1,21 +1,17 @@ query ( $name: String!) { - organizationByName( - name: $name) { + organizationByName(name: $name) { deployTargets { id name created - consoleUrl cloudRegion cloudProvider friendlyName - token sshHost sshPort routerPattern buildImage - monitoringConfig } } } diff --git a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql index 7ec3472..fa17357 100644 --- a/api/lagoon/client/_lgraphql/organizations/organizationById.graphql +++ b/api/lagoon/client/_lgraphql/organizations/organizationById.graphql @@ -5,9 +5,11 @@ query ( id name description - quotaProject friendlyName + quotaProject quotaGroup quotaNotification + quotaEnvironment + quotaRoute } } diff --git a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql index 738e7b3..6da2633 100644 --- a/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql +++ b/api/lagoon/client/_lgraphql/organizations/organizationByName.graphql @@ -5,9 +5,11 @@ query ( id name description - quotaProject friendlyName + quotaProject quotaGroup quotaNotification + quotaEnvironment + quotaRoute } } From 800a70e84ea2460ccf0c29c81e7b5a4ae56ef133 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 24 Nov 2023 14:33:29 +1100 Subject: [PATCH 19/22] Included lgraphql --- api/lagoon/client/lgraphql/lgraphql.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index d80f8be..8e9ccf3 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -622,7 +622,7 @@ func _lgraphqlDeploytargetsDeletedeploytargetGraphql() (*asset, error) { return a, nil } -var __lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8c\x31\x4e\x04\x31\x0c\x45\xfb\x39\x85\x91\xb6\x58\xae\x40\x09\x0d\xd3\xa0\x11\x82\x03\x84\xb5\x37\x58\x64\x6c\x70\x1c\xa4\x80\xb8\x3b\xda\x51\xac\xd9\x22\xd2\xff\x2f\xcf\xff\xab\x91\x75\x38\x4e\x00\x07\xc6\x3b\x98\xc5\x6f\x6e\xe1\x77\x02\x00\x50\xcb\x49\xf8\x27\x39\xab\xdc\xf7\x19\x8f\x1b\xbd\x58\x07\xc6\x90\x90\x3e\x8b\xf6\x97\x64\x99\xbc\x0e\x76\x91\x46\x90\xb4\xd2\x88\x27\xa3\xe4\x14\x1f\x27\x95\xaa\x85\x5e\xad\x04\x28\xda\xf0\x99\x32\xab\x5c\x93\xc5\xf4\x9b\x91\x6c\xb0\xb3\x31\x09\x96\xfe\xb4\xef\xba\x7e\x50\x9c\xd4\xfa\xfe\xa8\xd5\xf7\xb6\xa8\x45\x33\x6d\x4e\xb6\x24\x77\xb2\xf0\xdf\x1a\x17\x9c\xd7\x94\x63\x6c\x55\x61\x57\x63\xc9\x0f\x2a\x67\xce\x1b\xfe\x9b\xe2\xfd\x07\x00\x00\xff\xff\x1c\x62\x15\x17\x2e\x01\x00\x00") +var __lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8d\x41\x8e\xc2\x30\x0c\x45\xf7\x39\x85\x47\xea\xa2\x73\x85\x59\xce\x6a\xba\x19\x55\x88\x0b\x84\xda\x04\x4b\x69\x0c\x8e\x83\x14\x50\xef\x8e\x58\x34\x2d\x1b\xcb\xef\x7d\xeb\xfb\x56\x48\x2b\xf4\x0e\xa0\x63\xfc\x81\x21\xd9\xd7\x37\x3c\x1d\x00\x80\x68\xf0\x89\x1f\xde\x58\xd2\x6f\x1d\xb0\x7f\x1f\x74\x8c\x6b\x0e\x80\x74\x8d\x52\x8f\x5e\x03\x59\x6e\x16\x80\xb1\xad\xc9\xcf\xd4\x60\x52\xf2\x46\x5b\x38\x45\x29\x78\xa0\xc0\x92\x3e\xdd\xa8\x72\x67\x24\x6d\xf6\xac\x4c\x09\x63\xfd\xdf\xd7\xe5\x7c\xf9\x93\x6c\x7b\x1e\x45\x37\x56\x29\x46\x3a\x7a\x33\xd2\xed\xc1\xa9\x70\xc4\x61\xf6\x61\x2d\x5a\xdc\x3a\x17\xf7\x0a\x00\x00\xff\xff\xe2\x3c\x45\xaa\x0f\x01\x00\x00") func _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphqlBytes() ([]byte, error) { return bindataRead( @@ -642,7 +642,7 @@ func _lgraphqlDeploytargetsDeploytargetsbyorganizationidGraphql() (*asset, error return a, nil } -var __lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x90\xcd\x4e\x05\x21\x0c\x85\xf7\x3c\x45\x4d\x5c\x5c\x5f\xc1\xa5\x6e\x74\x63\x26\xfe\x3c\x40\xbd\xf4\x62\x23\xb4\x5a\x8a\xc9\x68\xe6\xdd\xcd\xcc\x28\xe8\x86\x70\xbe\x9e\x8f\x90\xbe\x37\xb2\x19\x0e\x01\xe0\x5c\xb0\xd0\x25\x3c\xb8\xb1\xa4\xb3\x0b\xf8\x0a\x00\x00\x6a\x09\x85\x3f\xd1\x59\xe5\x6a\xbe\xc3\x42\x87\x8d\x03\xec\xf5\xcd\xfa\x2d\x03\x44\x7a\xcb\x3a\x3f\xa2\x25\xf2\xda\x29\x00\xc7\x7e\x5d\x85\x1e\x8e\x46\xe8\x34\x86\x47\x95\xaa\x99\x9e\x2c\x0f\x94\xb5\xc5\x7b\x4a\xac\xf2\x9f\x4d\xa6\x1f\x1c\xc9\x3a\x3d\x19\x93\xc4\xbc\xfd\xb2\x43\xd7\x57\x1a\x62\xad\x2f\x37\x5a\xfd\x6f\x9e\xd4\x46\x36\x6d\x4e\x36\xa1\x3b\xd9\xb0\x9e\x1b\xe7\x78\x5b\x30\x8d\x67\x8b\x0a\xbb\xae\xab\xba\x56\x39\x71\xfa\x19\x2c\x61\x3f\x97\xf0\x1d\x00\x00\xff\xff\x35\x68\x51\x4c\x59\x01\x00\x00") +var __lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x8e\x4d\x8e\xc2\x30\x0c\x46\xf7\x39\x85\x47\x9a\x45\xe7\x0a\xb3\x9c\xd5\xb0\x41\x15\x70\x01\xd3\x98\x60\x29\x8d\xc1\x71\x90\x0a\xea\xdd\x11\xad\x9a\xc2\x26\xca\xf7\xfc\xfc\x73\x2d\xa4\x03\x34\x0e\xe0\x3b\x61\x4f\xbf\xb0\x37\xe5\x14\xbe\x7e\xe0\xe1\x00\x00\x44\x03\x26\xbe\xa3\xb1\xa4\xbf\x61\x8b\x3d\x35\xb3\x37\xe9\x8b\x05\xe0\xe9\x12\x65\x38\xa0\x06\xb2\x5c\x29\x00\xfb\xfa\x7d\x35\xd4\xd0\x29\xa1\xd1\x5a\xec\xa2\x14\xbf\xa3\xc0\x92\x3e\x59\xab\x72\x63\x4f\x5a\xe9\x49\x99\x92\x8f\xd3\x2d\x15\xe6\x7c\xfe\x97\x6c\xef\xb9\x15\x5d\xb3\x4a\x31\xd2\x16\xcd\x48\xd7\x05\xc7\xc2\xd1\x6f\x7a\x0c\xcb\xa0\xd1\xcd\xef\xe8\x9e\x01\x00\x00\xff\xff\x51\x79\xa0\x01\x18\x01\x00\x00") func _lgraphqlDeploytargetsDeploytargetsbyorganizationnameGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1822,7 +1822,7 @@ func _lgraphqlOrganizationsDeleteorganizationGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\xcc\x41\x0a\xc2\x30\x10\x05\xd0\x7d\x4e\xf1\x85\x2e\xea\x15\x5c\xba\x91\x6e\x8a\x57\x08\x49\x2a\x23\x3a\xd3\x8e\x93\x45\x14\xef\x2e\x29\x51\xbb\x18\xf8\x3c\xfe\x9f\x25\x27\x2d\xe8\x1d\xd0\x51\x3c\x60\x60\xdb\xed\xf1\x72\x00\x20\x7a\xf1\x4c\x4f\x6f\x24\x7c\x2c\x43\xec\x57\x05\x6a\xaf\xa3\xf8\xad\x55\x68\x81\xfd\x3d\xb5\x18\xd3\x23\x28\xcd\x75\xdb\x64\xc9\x62\xfe\xac\x72\x4d\xc1\x1a\x4d\x4a\x89\xe3\xad\x8c\xff\xdd\xda\x3a\xa9\xe4\x79\x0b\xa3\x18\x4d\x14\xfc\xef\xdd\xdb\xd5\xfb\x04\x00\x00\xff\xff\xd8\x99\xb0\xf5\xbd\x00\x00\x00") +var __lgraphqlOrganizationsOrganizationbyidGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcd\x41\xca\xc2\x30\x10\x05\xe0\x7d\x4f\x31\x3f\x74\xd1\xff\x0a\x2e\x05\x91\x6e\x8a\x78\x83\x90\x4c\x65\xc4\xce\xb4\xe3\x44\x88\xe2\xdd\x25\x35\x62\x5c\x04\x1e\x1f\xef\x65\x96\x88\x9a\xa0\x6b\x00\x5a\x0a\x1b\xe8\xd9\xfe\xfe\xe1\xd1\x00\x00\x88\x9e\x1c\xd3\xdd\x19\x09\x6f\x53\x1f\xba\x55\x01\x72\xaf\xa5\xf0\xa9\x65\x28\x81\xdd\x84\x25\x06\xbc\x7a\xa5\x39\x6f\x8b\x8c\x4a\xc8\xe1\x92\x86\x6f\x69\x89\x62\xee\xa0\x72\x46\x6f\x35\xed\x55\xe2\x5c\xc3\x20\x46\x23\x79\x57\x7d\xb7\xfa\x8e\x6f\xa4\xc2\x13\xf2\xcf\xfe\x28\xd1\xde\x37\x9e\x4d\x7e\xaf\x00\x00\x00\xff\xff\x19\xdb\x0e\xd3\xe5\x00\x00\x00") func _lgraphqlOrganizationsOrganizationbyidGraphqlBytes() ([]byte, error) { return bindataRead( @@ -1842,7 +1842,7 @@ func _lgraphqlOrganizationsOrganizationbyidGraphql() (*asset, error) { return a, nil } -var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8d\x31\x0e\xc2\x30\x0c\x45\xf7\x9c\xe2\x23\x31\x94\x2b\x30\xb2\xb0\x55\x48\x9c\xc0\x4a\xdc\xca\x88\xc6\xad\x49\x86\x82\x7a\x77\x44\x08\x28\x9b\xf5\xfc\xfc\xbc\x64\xb6\x15\x9d\x03\xf6\x91\x26\x3e\xe2\x9a\x4c\xe2\xb8\x3b\xe0\xe5\x00\x40\x6d\xa4\x28\x4f\x4a\xa2\xf1\xb4\xf6\x34\x71\x57\x38\xf0\xd5\xcb\xd5\x4f\x06\x24\x34\xdb\x3a\x06\x7e\x78\x93\xf9\x53\xa8\x64\xc9\x9a\xe8\x62\x7a\x63\x9f\x2a\x1a\x4c\x38\x86\x7b\xf9\xd0\x5a\x67\xd3\x3c\xb7\xa0\xd7\x24\x83\x78\xfa\xe7\x36\xb7\xb9\x77\x00\x00\x00\xff\xff\xea\x81\xe5\x19\xc6\x00\x00\x00") +var __lgraphqlOrganizationsOrganizationbynameGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\xcd\x41\x0a\xc2\x30\x10\x05\xd0\x7d\x4e\xf1\x05\x17\xf5\x0a\x2e\x05\x71\x57\x44\x4f\x10\xda\x69\x19\xb1\x33\xed\x98\x08\x55\x7a\x77\x31\x8d\x10\x77\xe1\xe5\xff\x3f\x53\x24\x9b\x51\x39\x60\x2b\x7e\xa0\x3d\xae\xc1\x58\xfa\xcd\x0e\x6f\x07\x00\x6a\xbd\x17\x7e\xf9\xc0\x2a\x87\xb9\xf6\x03\x55\xc9\x81\x35\x9e\x5a\xbf\x30\xc0\x6d\xf1\x9b\x9f\x2d\x3d\x1a\xe3\xf1\xbb\x90\xa5\x33\x26\x69\xef\x69\x2e\xd3\x14\x35\xf8\xb3\xe9\x8d\x9a\x50\xd2\xc9\x34\x8e\x25\xd4\x1a\xb8\xe3\xc6\x17\x73\xc9\x8f\xf2\x64\x53\x19\x48\xfe\xfa\x17\x8d\x61\xbd\xb1\xb8\xc5\x7d\x02\x00\x00\xff\xff\xc3\xe8\x9e\x1a\xee\x00\x00\x00") func _lgraphqlOrganizationsOrganizationbynameGraphqlBytes() ([]byte, error) { return bindataRead( From 3585e6dbc3106857b58afcea3e0d0e25bd96a25a Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 24 Nov 2023 17:59:05 +1100 Subject: [PATCH 20/22] Combined deploytargetsbyid & byname --- api/lagoon/client/deploytargets.go | 81 ++++++++++++------------------ api/lagoon/deploytarget.go | 15 ++---- 2 files changed, 37 insertions(+), 59 deletions(-) diff --git a/api/lagoon/client/deploytargets.go b/api/lagoon/client/deploytargets.go index 5d1f1cc..e56db40 100644 --- a/api/lagoon/client/deploytargets.go +++ b/api/lagoon/client/deploytargets.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - + "github.com/machinebox/graphql" "github.com/uselagoon/machinery/api/schema" ) @@ -59,59 +59,44 @@ func (c *Client) DeleteDeployTarget(ctx context.Context, in *schema.DeleteDeploy return c.client.Run(ctx, req, &out) } -// DeployTargetsByOrganizationId queries the Lagoon API for deploy targets by the given organization id +// DeployTargetsByOrganizationNameOrID queries the Lagoon API for deploy targets by the given organization name // and unmarshals the response into organization. -func (c *Client) DeployTargetsByOrganizationId(ctx context.Context, id uint, out *[]schema.DeployTarget) error { - - req, err := c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql", - map[string]interface{}{ - "id": id, - }) - if err != nil { - return err - } - +// Need to rework the argument types here +func (c *Client) DeployTargetsByOrganizationNameOrID(ctx context.Context, name *string, id *uint, out *[]schema.DeployTarget) error { + var req *graphql.Request + var err error o := &schema.Organization{} - err = c.client.Run(ctx, req, &struct { - Response *schema.Organization `json:"organizationById"` - }{ - Response: o, - }) - if err != nil { - return err - } - if len(o.DeployTargets) == 0 { - return fmt.Errorf("no deploy targets found for organization %s", o.Name) - } - data, err := json.Marshal(o.DeployTargets) - if err != nil { - return err - } - json.Unmarshal(data, out) - return nil -} - -// DeployTargetsByOrganizationName queries the Lagoon API for deploy targets by the given organization name -// and unmarshals the response into organization. -func (c *Client) DeployTargetsByOrganizationName(ctx context.Context, name string, out *[]schema.DeployTarget) error { - req, err := c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql", - map[string]interface{}{ - "name": name, + if *name != "" { + req, err = c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql", + map[string]interface{}{ + "name": name, + }) + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationByName"` + }{ + Response: o, }) - if err != nil { - return err + if err != nil { + return err + } + } else { + if *id > 0 { + req, err = c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql", + map[string]interface{}{ + "id": id, + }) + err = c.client.Run(ctx, req, &struct { + Response *schema.Organization `json:"organizationByID"` + }{ + Response: o, + }) + if err != nil { + return err + } + } } - o := &schema.Organization{} - err = c.client.Run(ctx, req, &struct { - Response *schema.Organization `json:"organizationByName"` - }{ - Response: o, - }) - if err != nil { - return err - } if len(o.DeployTargets) == 0 { return fmt.Errorf("no deploy targets found for organization %s", o.Name) } diff --git a/api/lagoon/deploytarget.go b/api/lagoon/deploytarget.go index 761636b..d427cdc 100644 --- a/api/lagoon/deploytarget.go +++ b/api/lagoon/deploytarget.go @@ -11,8 +11,7 @@ type DeployTargets interface { UpdateDeployTarget(ctx context.Context, in *schema.UpdateDeployTargetInput, out *schema.UpdateDeployTargetResponse) error DeleteDeployTarget(ctx context.Context, in *schema.DeleteDeployTargetInput, out *schema.DeleteDeployTargetResponse) error ListDeployTargets(ctx context.Context, out *[]schema.DeployTarget) error - DeployTargetsByOrganizationId(ctx context.Context, id uint, out *[]schema.DeployTarget) error - DeployTargetsByOrganizationName(ctx context.Context, name string, out *[]schema.DeployTarget) error + DeployTargetsByOrganizationNameOrID(ctx context.Context, name *string, id *uint, out *[]schema.DeployTarget) error AddDeployTargetToOrganization(ctx context.Context, in *schema.AddDeployTargetToOrganizationInput, out *schema.AddDeployTargetResponse) error RemoveDeployTargetFromOrganization(ctx context.Context, in *schema.RemoveDeployTargetFromOrganizationInput, out *schema.DeleteDeployTargetResponse) error } @@ -38,16 +37,10 @@ func ListDeployTargets(ctx context.Context, out DeployTargets) (*[]schema.Deploy return &deploytargets, out.ListDeployTargets(ctx, &deploytargets) } -// ListDeployTargetsByOrganizationId gets deploy targets associated with an organization in lagoon via provided ID. -func ListDeployTargetsByOrganizationId(ctx context.Context, id uint, d DeployTargets) (*[]schema.DeployTarget, error) { +// ListDeployTargetsByOrganizationNameOrID gets deploy targets associated with an organization in lagoon via provided Name & ID. +func ListDeployTargetsByOrganizationNameOrID(ctx context.Context, name *string, id *uint, d DeployTargets) (*[]schema.DeployTarget, error) { deploytargets := []schema.DeployTarget{} - return &deploytargets, d.DeployTargetsByOrganizationId(ctx, id, &deploytargets) -} - -// ListDeployTargetsByOrganizationName gets deploy targets associated with an organization in lagoon via provided Name. -func ListDeployTargetsByOrganizationName(ctx context.Context, name string, d DeployTargets) (*[]schema.DeployTarget, error) { - deploytargets := []schema.DeployTarget{} - return &deploytargets, d.DeployTargetsByOrganizationName(ctx, name, &deploytargets) + return &deploytargets, d.DeployTargetsByOrganizationNameOrID(ctx, name, id, &deploytargets) } // AddDeployTargetToOrganization adds a deploy target to an organization. From c4ce6f8b3c7d60e149300bb1d050d7a57580805b Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Fri, 24 Nov 2023 18:08:14 +1100 Subject: [PATCH 21/22] Updated condition --- api/lagoon/client/deploytargets.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/lagoon/client/deploytargets.go b/api/lagoon/client/deploytargets.go index e56db40..fab5fb3 100644 --- a/api/lagoon/client/deploytargets.go +++ b/api/lagoon/client/deploytargets.go @@ -67,7 +67,7 @@ func (c *Client) DeployTargetsByOrganizationNameOrID(ctx context.Context, name * var err error o := &schema.Organization{} - if *name != "" { + if name != nil { req, err = c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationName.graphql", map[string]interface{}{ "name": name, @@ -81,7 +81,7 @@ func (c *Client) DeployTargetsByOrganizationNameOrID(ctx context.Context, name * return err } } else { - if *id > 0 { + if id != nil { req, err = c.newRequest("_lgraphql/deploytargets/deployTargetsByOrganizationId.graphql", map[string]interface{}{ "id": id, From 7f02449cf1e5356796e03eb5d74219efa429f656 Mon Sep 17 00:00:00 2001 From: cgoodwin90 Date: Mon, 27 Nov 2023 18:01:18 +1100 Subject: [PATCH 22/22] Included allOrganizations --- .../organizations/allOrganizations.graphql | 13 +++++++++++ api/lagoon/client/lgraphql/lgraphql.go | 23 +++++++++++++++++++ api/lagoon/client/organizations.go | 14 +++++++++++ api/lagoon/organizations.go | 7 ++++++ 4 files changed, 57 insertions(+) create mode 100644 api/lagoon/client/_lgraphql/organizations/allOrganizations.graphql diff --git a/api/lagoon/client/_lgraphql/organizations/allOrganizations.graphql b/api/lagoon/client/_lgraphql/organizations/allOrganizations.graphql new file mode 100644 index 0000000..deadf99 --- /dev/null +++ b/api/lagoon/client/_lgraphql/organizations/allOrganizations.graphql @@ -0,0 +1,13 @@ +query { + allOrganizations { + id + name + description + friendlyName + quotaProject + quotaGroup + quotaNotification + quotaEnvironment + quotaRoute + } +} diff --git a/api/lagoon/client/lgraphql/lgraphql.go b/api/lagoon/client/lgraphql/lgraphql.go index 8e9ccf3..541bd1f 100644 --- a/api/lagoon/client/lgraphql/lgraphql.go +++ b/api/lagoon/client/lgraphql/lgraphql.go @@ -82,6 +82,7 @@ // _lgraphql/usergroups/usersByOrganization.graphql // _lgraphql/usergroups/usersByOrganizationName.graphql // _lgraphql/organizations/addOrganization.graphql +// _lgraphql/organizations/allOrganizations.graphql // _lgraphql/organizations/deleteOrganization.graphql // _lgraphql/organizations/organizationById.graphql // _lgraphql/organizations/organizationByName.graphql @@ -1802,6 +1803,26 @@ func _lgraphqlOrganizationsAddorganizationGraphql() (*asset, error) { return a, nil } +var __lgraphqlOrganizationsAllorganizationsGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8c\x41\x0a\xc2\x40\x0c\x45\xf7\x73\x8a\x5c\x46\xdc\x55\xf1\x06\x61\x26\x95\xc8\x34\x69\xd3\x8c\x50\xa5\x77\x97\x06\x74\x5c\x25\xff\xf1\xff\x5b\x1a\xd9\x06\xef\x04\x80\xb5\x5e\xec\x8e\xc2\x2f\x74\x56\x59\x03\x02\x70\x89\x23\x38\x51\x3c\x85\xd6\x6c\x3c\x1f\x95\xc8\xa3\x31\x49\xa9\xdb\xf0\x2d\x2c\x4d\x1d\xaf\xa6\x0f\xca\xde\xc1\xd9\xb4\xcd\x3d\x0e\xea\x3c\x72\xc6\x9f\x26\xe8\x49\x9e\x6c\x2a\x13\xc9\xdf\xf2\xa6\xcd\x0f\xf3\x9e\xf6\xf4\x09\x00\x00\xff\xff\xf9\xa7\x53\xe6\xae\x00\x00\x00") + +func _lgraphqlOrganizationsAllorganizationsGraphqlBytes() ([]byte, error) { + return bindataRead( + __lgraphqlOrganizationsAllorganizationsGraphql, + "_lgraphql/organizations/allOrganizations.graphql", + ) +} + +func _lgraphqlOrganizationsAllorganizationsGraphql() (*asset, error) { + bytes, err := _lgraphqlOrganizationsAllorganizationsGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "_lgraphql/organizations/allOrganizations.graphql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var __lgraphqlOrganizationsDeleteorganizationGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xca\x2d\x2d\x49\x2c\xc9\xcc\xcf\x53\xd0\xe0\x52\x50\x50\xc9\x4c\xb1\x52\xf0\xcc\x2b\x51\xe4\xd2\xac\xe6\x52\x50\x48\x49\xcd\x49\x2d\x49\xf5\x2f\x4a\x4f\xcc\xcb\xac\x02\xab\x02\x29\x52\x50\xc8\xcc\x2b\x28\x2d\xb1\x52\xa8\x06\x73\x14\x14\x40\x9a\x54\x32\x53\xc0\xbc\x5a\x2e\x05\x05\x4d\xae\x5a\x2e\x40\x00\x00\x00\xff\xff\x54\xd8\xea\x66\x57\x00\x00\x00") func _lgraphqlOrganizationsDeleteorganizationGraphqlBytes() ([]byte, error) { @@ -2016,6 +2037,7 @@ var _bindata = map[string]func() (*asset, error){ "_lgraphql/usergroups/usersByOrganization.graphql": _lgraphqlUsergroupsUsersbyorganizationGraphql, "_lgraphql/usergroups/usersByOrganizationName.graphql": _lgraphqlUsergroupsUsersbyorganizationnameGraphql, "_lgraphql/organizations/addOrganization.graphql": _lgraphqlOrganizationsAddorganizationGraphql, + "_lgraphql/organizations/allOrganizations.graphql": _lgraphqlOrganizationsAllorganizationsGraphql, "_lgraphql/organizations/deleteOrganization.graphql": _lgraphqlOrganizationsDeleteorganizationGraphql, "_lgraphql/organizations/organizationById.graphql": _lgraphqlOrganizationsOrganizationbyidGraphql, "_lgraphql/organizations/organizationByName.graphql": _lgraphqlOrganizationsOrganizationbynameGraphql, @@ -2115,6 +2137,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "lagoonVersion.graphql": &bintree{_lgraphqlLagoonversionGraphql, map[string]*bintree{}}, "organizations": &bintree{nil, map[string]*bintree{ "addOrganization.graphql": &bintree{_lgraphqlOrganizationsAddorganizationGraphql, map[string]*bintree{}}, + "allOrganizations.graphql": &bintree{_lgraphqlOrganizationsAllorganizationsGraphql, map[string]*bintree{}}, "deleteOrganization.graphql": &bintree{_lgraphqlOrganizationsDeleteorganizationGraphql, map[string]*bintree{}}, "organizationById.graphql": &bintree{_lgraphqlOrganizationsOrganizationbyidGraphql, map[string]*bintree{}}, "organizationByName.graphql": &bintree{_lgraphqlOrganizationsOrganizationbynameGraphql, map[string]*bintree{}}, diff --git a/api/lagoon/client/organizations.go b/api/lagoon/client/organizations.go index 895086e..daded7d 100644 --- a/api/lagoon/client/organizations.go +++ b/api/lagoon/client/organizations.go @@ -88,3 +88,17 @@ func (c *Client) UpdateOrganization( Response: organization, }) } + +// AllOrganizations queries the Lagoon API for all organizations. +func (c *Client) AllOrganizations(ctx context.Context, organizations *[]schema.Organization) error { + req, err := c.newRequest("_lgraphql/organizations/allOrganizations.graphql", nil) + if err != nil { + return err + } + + return c.client.Run(ctx, req, &struct { + Response *[]schema.Organization `json:"allOrganizations"` + }{ + Response: organizations, + }) +} diff --git a/api/lagoon/organizations.go b/api/lagoon/organizations.go index 95bd89d..8593e6c 100644 --- a/api/lagoon/organizations.go +++ b/api/lagoon/organizations.go @@ -14,6 +14,7 @@ type Organizations interface { OrganizationByName(ctx context.Context, name string, organization *schema.Organization) error DeleteOrg(ctx context.Context, id uint, organization *schema.DeleteOrganizationInput) error UpdateOrganization(ctx context.Context, id uint, patch schema.UpdateOrganizationPatchInput, result *schema.Organization) error + AllOrganizations(ctx context.Context, organizations *[]schema.Organization) error } // GetOrganizationByID gets info of an organization in lagoon that matches the provided ID. @@ -39,3 +40,9 @@ func UpdateOrganization(ctx context.Context, id uint, patch schema.UpdateOrganiz result := schema.Organization{} return &result, o.UpdateOrganization(ctx, id, patch, &result) } + +// AllOrganizations lists all organizations. +func AllOrganizations(ctx context.Context, o Organizations) (*[]schema.Organization, error) { + organization := []schema.Organization{} + return &organization, o.AllOrganizations(ctx, &organization) +}