Organizations -> orgs consistency (#189)

* Organizations -> orgs consistency

* Fix up some tests and some mistaken substitutions
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-07-11 12:00:49 -04:00
1 parent e1afed75ff
commit acce195dcb
89 files changed
+1778 -1770

No files matched your search

+2 -2
View File
@@ -99,7 +99,7 @@ type Config struct {
// SRVLookup enables the client to lookup the host through DNS SRV lookup
SRVLookup bool
// Org is the organization to use if not overridden per-call
// Org is the org to use if not overridden per-call
Org string
// Project is the project to use if not overridden per-call
@@ -449,7 +449,7 @@ func (c *Client) SetAddr(addr string) error {
return c.config.setAddr(addr)
}
// SetOrg sets the organization the client will use by default
// SetOrg sets the org the client will use by default
func (c *Client) SetOrg(org string) {
c.modifyLock.Lock()
defer c.modifyLock.Unlock()
+3 -3
View File
@@ -29,7 +29,7 @@ func TestGroup_List(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
proj, apiErr, err := org.CreateProject(context.Background(), &scopes.Project{})
@@ -105,7 +105,7 @@ func TestGroup_Crud(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
@@ -179,7 +179,7 @@ func TestGroup_Errors(t *testing.T) {
ctx := tc.Context()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
+2 -2
View File
@@ -18,7 +18,7 @@ func TestCatalogs_Crud(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
p, apiErr, err := org.CreateProject(tc.Context(), &scopes.Project{})
@@ -73,7 +73,7 @@ func TestCatalogs_Errors(t *testing.T) {
ctx := tc.Context()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
p, apiErr, err := org.CreateProject(ctx, &scopes.Project{})
+8 -8
View File
@@ -30,22 +30,22 @@ var createFuncs = map[string][]*createInfo{
},
"scopes": {
{
baseType: "Organization",
baseType: "Org",
targetType: "Project",
path: `"projects"`,
},
{
baseType: "Organization",
baseType: "Org",
targetType: "groups.Group",
path: `"groups"`,
},
{
baseType: "Organization",
baseType: "Org",
targetType: "roles.Role",
path: `"roles"`,
},
{
baseType: "Organization",
baseType: "Org",
targetType: "users.User",
path: `"users"`,
},
@@ -101,8 +101,8 @@ func (s {{ .BaseType }}) Create{{ .TargetName }}(ctx context.Context, r *{{ .Tar
return nil, nil, fmt.Errorf("nil client in Create{{ .TargetType }} request")
}
if s.Id == "" {
{{ if (eq .BaseType "Organization") }}
// Assume the client has been configured with organization already and
{{ if (eq .BaseType "Org") }}
// Assume the client has been configured with org already and
// move on
{{ else if (eq .BaseType "Project") }}
// Assume the client has been configured with project already and move
@@ -113,7 +113,7 @@ func (s {{ .BaseType }}) Create{{ .TargetName }}(ctx context.Context, r *{{ .Tar
} else {
// If it's explicitly set here, override anything that might be in the
// client
{{ if (eq .BaseType "Organization") }}
{{ if (eq .BaseType "Org") }}
ctx = context.WithValue(ctx, "org", s.Id)
{{ else if (eq .BaseType "Project") }}
ctx = context.WithValue(ctx, "project", s.Id)
@@ -136,7 +136,7 @@ func (s {{ .BaseType }}) Create{{ .TargetName }}(ctx context.Context, r *{{ .Tar
return nil, nil, fmt.Errorf("error decoding Create{{ .TargetType }} repsonse: %w", err)
}
{{ if (eq .TargetType "Organization") }}
{{ if (eq .TargetType "Org") }}
target.Client = s.Client.Clone()
target.Client.SetOrgnization(target.Id)
{{ else if (eq .TargetType "Project") }}
+7 -7
View File
@@ -18,22 +18,22 @@ type deleteInfo struct {
var deleteFuncs = map[string][]*deleteInfo{
"scopes": {
{
"Organization",
"Org",
"Project",
"projects",
},
{
"Organization",
"Org",
"groups.Group",
"groups",
},
{
"Organization",
"Org",
"roles.Role",
"roles",
},
{
"Organization",
"Org",
"users.User",
"users",
},
@@ -90,8 +90,8 @@ func (s {{ .BaseType }}) Delete{{ .TargetName }}(ctx context.Context, r *{{ .Tar
return false, nil, fmt.Errorf("nil client in Delete{{ .TargetName }} request")
}
if s.Id == "" {
{{ if (eq .BaseType "Organization") }}
// Assume the client has been configured with organization already and
{{ if (eq .BaseType "Org") }}
// Assume the client has been configured with org already and
// move on
{{ else if (eq .BaseType "Project") }}
// Assume the client has been configured with project already and move
@@ -102,7 +102,7 @@ func (s {{ .BaseType }}) Delete{{ .TargetName }}(ctx context.Context, r *{{ .Tar
} else {
// If it's explicitly set here, override anything that might be in the
// client
{{ if (eq .BaseType "Organization") }}
{{ if (eq .BaseType "Org") }}
ctx = context.WithValue(ctx, "org", s.Id)
{{ else if (eq .BaseType "Project") }}
ctx = context.WithValue(ctx, "project", s.Id)
+4 -4
View File
@@ -82,10 +82,10 @@ var inputStructs = []*structInfo{
templateTypeResource,
},
{
os.Getenv("GEN_BASEPATH") + "/internal/gen/controller/api/resources/scopes/organization.pb.go",
"Organization",
os.Getenv("GEN_BASEPATH") + "/api/scopes/organization.gen.go",
"Organization",
os.Getenv("GEN_BASEPATH") + "/internal/gen/controller/api/resources/scopes/org.pb.go",
"Org",
os.Getenv("GEN_BASEPATH") + "/api/scopes/org.gen.go",
"Org",
"scopes",
"",
"",
+8 -8
View File
@@ -18,22 +18,22 @@ type listInfo struct {
var listFuncs = map[string][]*listInfo{
"scopes": {
{
baseType: "Organization",
baseType: "Org",
targetType: "Project",
path: "projects",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "groups.Group",
path: "groups",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "roles.Role",
path: "roles",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "users.User",
path: "users",
},
@@ -84,8 +84,8 @@ func (s {{ .BaseType }}) List{{ .TargetName }}s(ctx context.Context) ([]*{{ .Tar
return nil, nil, fmt.Errorf("nil client in List{{ .TargetName }} request")
}
if s.Id == "" {
{{ if (eq .BaseType "Organization") }}
// Assume the client has been configured with organization already and
{{ if (eq .BaseType "Org") }}
// Assume the client has been configured with org already and
// move on
{{ else if (eq .BaseType "Project") }}
// Assume the client has been configured with project already and move
@@ -96,7 +96,7 @@ func (s {{ .BaseType }}) List{{ .TargetName }}s(ctx context.Context) ([]*{{ .Tar
} else {
// If it's explicitly set here, override anything that might be in the
// client
{{ if (eq .BaseType "Organization") }}
{{ if (eq .BaseType "Org") }}
ctx = context.WithValue(ctx, "org", s.Id)
{{ else if (eq .BaseType "Project") }}
ctx = context.WithValue(ctx, "project", s.Id)
@@ -124,7 +124,7 @@ func (s {{ .BaseType }}) List{{ .TargetName }}s(ctx context.Context) ([]*{{ .Tar
}
for _, t := range target.Items {
{{ if (eq .TargetType "Organization") }}
{{ if (eq .TargetType "Org") }}
t.Client = s.Client.Clone()
t.Client.SetOrgnization(t.Id)
{{ else if (eq .TargetType "Project") }}
+8 -8
View File
@@ -18,22 +18,22 @@ type readInfo struct {
var readFuncs = map[string][]*readInfo{
"scopes": {
{
baseType: "Organization",
baseType: "Org",
targetType: "Project",
path: "projects",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "groups.Group",
path: "groups",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "roles.Role",
path: "roles",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "users.User",
path: "users",
},
@@ -89,8 +89,8 @@ func (s {{ .BaseType }}) Read{{ .TargetName }}(ctx context.Context, r *{{ .Targe
return nil, nil, fmt.Errorf("nil client in Read{{ .TargetName }} request")
}
if s.Id == "" {
{{ if (eq .BaseType "Organization") }}
// Assume the client has been configured with organization already and
{{ if (eq .BaseType "Org") }}
// Assume the client has been configured with org already and
// move on
{{ else if (eq .BaseType "Project") }}
// Assume the client has been configured with project already and move
@@ -101,7 +101,7 @@ func (s {{ .BaseType }}) Read{{ .TargetName }}(ctx context.Context, r *{{ .Targe
} else {
// If it's explicitly set here, override anything that might be in the
// client
{{ if (eq .BaseType "Organization") }}
{{ if (eq .BaseType "Org") }}
ctx = context.WithValue(ctx, "org", s.Id)
{{ else if (eq .BaseType "Project") }}
ctx = context.WithValue(ctx, "project", s.Id)
@@ -127,7 +127,7 @@ func (s {{ .BaseType }}) Read{{ .TargetName }}(ctx context.Context, r *{{ .Targe
return nil, nil, fmt.Errorf("error decoding Read{{ .TargetName }} repsonse: %w", err)
}
{{ if (eq .TargetType "Organization") }}
{{ if (eq .TargetType "Org") }}
target.Client = s.Client.Clone()
target.Client.SetOrgnization(target.Id)
{{ else if (eq .TargetType "Project") }}
+8 -8
View File
@@ -18,22 +18,22 @@ type updateInfo struct {
var updateFuncs = map[string][]*updateInfo{
"scopes": {
{
baseType: "Organization",
baseType: "Org",
targetType: "Project",
path: "projects",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "groups.Group",
path: "groups",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "roles.Role",
path: "roles",
},
{
baseType: "Organization",
baseType: "Org",
targetType: "users.User",
path: "users",
},
@@ -89,8 +89,8 @@ func (s {{ .BaseType }}) Update{{ .TargetName }}(ctx context.Context, r *{{ .Tar
return nil, nil, fmt.Errorf("nil client in Create{{ .TargetName }} request")
}
if s.Id == "" {
{{ if (eq .BaseType "Organization") }}
// Assume the client has been configured with organization already and
{{ if (eq .BaseType "Org") }}
// Assume the client has been configured with org already and
// move on
{{ else if (eq .BaseType "Project") }}
// Assume the client has been configured with project already and move
@@ -101,7 +101,7 @@ func (s {{ .BaseType }}) Update{{ .TargetName }}(ctx context.Context, r *{{ .Tar
} else {
// If it's explicitly set here, override anything that might be in the
// client
{{ if (eq .BaseType "Organization") }}
{{ if (eq .BaseType "Org") }}
ctx = context.WithValue(ctx, "org", s.Id)
{{ else if (eq .BaseType "Project") }}
ctx = context.WithValue(ctx, "project", s.Id)
@@ -127,7 +127,7 @@ func (s {{ .BaseType }}) Update{{ .TargetName }}(ctx context.Context, r *{{ .Tar
return nil, nil, fmt.Errorf("error decoding Update{{ .TargetName }} repsonse: %w", err)
}
{{ if (eq .TargetType "Organization") }}
{{ if (eq .TargetType "Org") }}
target.Client = s.Client.Clone()
target.Client.SetOrgnization(target.Id)
{{ else if (eq .TargetType "Project") }}
+2 -2
View File
@@ -32,8 +32,8 @@ type Role struct {
// Whether the resource is disabled
Disabled *bool `json:"disabled,omitempty"`
// The scope the grants will apply to. If the role is at the global scope,
// this can be an organization or project. If the role is at an organization
// scope, this can be a project within the organization. It is invalid for
// this can be an org or project. If the role is at an org
// scope, this can be a project within the org. It is invalid for
// this to be anything other than the role's scope when the role's scope is
// a project.
GrantScopeId *string `json:"grant_scope_id,omitempty"`
+4 -4
View File
@@ -31,7 +31,7 @@ func TestCustom(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
proj, apiErr, err := org.CreateProject(context.Background(), &scopes.Project{})
@@ -130,7 +130,7 @@ func TestRole_List(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
proj, apiErr, err := org.CreateProject(context.Background(), &scopes.Project{})
@@ -206,7 +206,7 @@ func TestRole_Crud(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
@@ -278,7 +278,7 @@ func TestRole_Errors(t *testing.T) {
ctx := tc.Context()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
+8 -8
View File
@@ -12,13 +12,13 @@ import (
"github.com/hashicorp/watchtower/api/users"
)
func (s Organization) CreateProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
func (s Org) CreateProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in CreateProject request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -51,13 +51,13 @@ func (s Organization) CreateProject(ctx context.Context, r *Project) (*Project,
return target, apiErr, nil
}
func (s Organization) CreateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
func (s Org) CreateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in Creategroups.Group request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -89,13 +89,13 @@ func (s Organization) CreateGroup(ctx context.Context, r *groups.Group) (*groups
return target, apiErr, nil
}
func (s Organization) CreateRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
func (s Org) CreateRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in Createroles.Role request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -127,13 +127,13 @@ func (s Organization) CreateRole(ctx context.Context, r *roles.Role) (*roles.Rol
return target, apiErr, nil
}
func (s Organization) CreateUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
func (s Org) CreateUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in Createusers.User request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
+8 -8
View File
@@ -13,13 +13,13 @@ import (
)
// DeleteProject returns true iff the Project existed when the delete attempt was made.
func (s Organization) DeleteProject(ctx context.Context, r *Project) (bool, *api.Error, error) {
func (s Org) DeleteProject(ctx context.Context, r *Project) (bool, *api.Error, error) {
if s.Client == nil {
return false, nil, fmt.Errorf("nil client in DeleteProject request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -57,13 +57,13 @@ func (s Organization) DeleteProject(ctx context.Context, r *Project) (bool, *api
}
// DeleteGroup returns true iff the groups.Group existed when the delete attempt was made.
func (s Organization) DeleteGroup(ctx context.Context, r *groups.Group) (bool, *api.Error, error) {
func (s Org) DeleteGroup(ctx context.Context, r *groups.Group) (bool, *api.Error, error) {
if s.Client == nil {
return false, nil, fmt.Errorf("nil client in DeleteGroup request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -101,13 +101,13 @@ func (s Organization) DeleteGroup(ctx context.Context, r *groups.Group) (bool, *
}
// DeleteRole returns true iff the roles.Role existed when the delete attempt was made.
func (s Organization) DeleteRole(ctx context.Context, r *roles.Role) (bool, *api.Error, error) {
func (s Org) DeleteRole(ctx context.Context, r *roles.Role) (bool, *api.Error, error) {
if s.Client == nil {
return false, nil, fmt.Errorf("nil client in DeleteRole request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -145,13 +145,13 @@ func (s Organization) DeleteRole(ctx context.Context, r *roles.Role) (bool, *api
}
// DeleteUser returns true iff the users.User existed when the delete attempt was made.
func (s Organization) DeleteUser(ctx context.Context, r *users.User) (bool, *api.Error, error) {
func (s Org) DeleteUser(ctx context.Context, r *users.User) (bool, *api.Error, error) {
if s.Client == nil {
return false, nil, fmt.Errorf("nil client in DeleteUser request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
+8 -8
View File
@@ -11,13 +11,13 @@ import (
"github.com/hashicorp/watchtower/api/users"
)
func (s Organization) ListProjects(ctx context.Context) ([]*Project, *api.Error, error) {
func (s Org) ListProjects(ctx context.Context) ([]*Project, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ListProject request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -58,13 +58,13 @@ func (s Organization) ListProjects(ctx context.Context) ([]*Project, *api.Error,
return target.Items, apiErr, nil
}
func (s Organization) ListGroups(ctx context.Context) ([]*groups.Group, *api.Error, error) {
func (s Org) ListGroups(ctx context.Context) ([]*groups.Group, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ListGroup request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -104,13 +104,13 @@ func (s Organization) ListGroups(ctx context.Context) ([]*groups.Group, *api.Err
return target.Items, apiErr, nil
}
func (s Organization) ListRoles(ctx context.Context) ([]*roles.Role, *api.Error, error) {
func (s Org) ListRoles(ctx context.Context) ([]*roles.Role, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ListRole request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -150,13 +150,13 @@ func (s Organization) ListRoles(ctx context.Context) ([]*roles.Role, *api.Error,
return target.Items, apiErr, nil
}
func (s Organization) ListUsers(ctx context.Context) ([]*users.User, *api.Error, error) {
func (s Org) ListUsers(ctx context.Context) ([]*users.User, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ListUser request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -11,12 +11,12 @@ import (
"github.com/hashicorp/watchtower/api/internal/strutil"
)
type Organization struct {
type Org struct {
Client *api.Client `json:"-"`
defaultFields []string
// The ID of the Organization
// The ID of the Org
// Output only.
Id string `json:"id,omitempty"`
// Optional name for identification purposes
@@ -31,15 +31,15 @@ type Organization struct {
UpdatedTime time.Time `json:"updated_time,omitempty"`
}
func (s *Organization) SetDefault(key string) {
func (s *Org) SetDefault(key string) {
s.defaultFields = strutil.AppendIfMissing(s.defaultFields, key)
}
func (s *Organization) UnsetDefault(key string) {
func (s *Org) UnsetDefault(key string) {
s.defaultFields = strutil.StrListDelete(s.defaultFields, key)
}
func (s Organization) MarshalJSON() ([]byte, error) {
func (s Org) MarshalJSON() ([]byte, error) {
m := structs.Map(s)
if m == nil {
m = make(map[string]interface{})
+3 -3
View File
@@ -18,7 +18,7 @@ func TestProjects_List(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
ctx := context.Background()
@@ -72,7 +72,7 @@ func TestProjects_Crud(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
@@ -121,7 +121,7 @@ func TestProject_Errors(t *testing.T) {
ctx := tc.Context()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
createdProj, apiErr, err := org.CreateProject(ctx, &scopes.Project{})
+8 -8
View File
@@ -12,13 +12,13 @@ import (
"github.com/hashicorp/watchtower/api/users"
)
func (s Organization) ReadProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
func (s Org) ReadProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ReadProject request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -54,13 +54,13 @@ func (s Organization) ReadProject(ctx context.Context, r *Project) (*Project, *a
return target, apiErr, nil
}
func (s Organization) ReadGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
func (s Org) ReadGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ReadGroup request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -95,13 +95,13 @@ func (s Organization) ReadGroup(ctx context.Context, r *groups.Group) (*groups.G
return target, apiErr, nil
}
func (s Organization) ReadRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
func (s Org) ReadRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ReadRole request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -136,13 +136,13 @@ func (s Organization) ReadRole(ctx context.Context, r *roles.Role) (*roles.Role,
return target, apiErr, nil
}
func (s Organization) ReadUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
func (s Org) ReadUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in ReadUser request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
+8 -8
View File
@@ -12,13 +12,13 @@ import (
"github.com/hashicorp/watchtower/api/users"
)
func (s Organization) UpdateProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
func (s Org) UpdateProject(ctx context.Context, r *Project) (*Project, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in CreateProject request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -54,13 +54,13 @@ func (s Organization) UpdateProject(ctx context.Context, r *Project) (*Project,
return target, apiErr, nil
}
func (s Organization) UpdateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
func (s Org) UpdateGroup(ctx context.Context, r *groups.Group) (*groups.Group, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in CreateGroup request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -95,13 +95,13 @@ func (s Organization) UpdateGroup(ctx context.Context, r *groups.Group) (*groups
return target, apiErr, nil
}
func (s Organization) UpdateRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
func (s Org) UpdateRole(ctx context.Context, r *roles.Role) (*roles.Role, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in CreateRole request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
@@ -136,13 +136,13 @@ func (s Organization) UpdateRole(ctx context.Context, r *roles.Role) (*roles.Rol
return target, apiErr, nil
}
func (s Organization) UpdateUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
func (s Org) UpdateUser(ctx context.Context, r *users.User) (*users.User, *api.Error, error) {
if s.Client == nil {
return nil, nil, fmt.Errorf("nil client in CreateUser request")
}
if s.Id == "" {
// Assume the client has been configured with organization already and
// Assume the client has been configured with org already and
// move on
} else {
+3 -3
View File
@@ -20,7 +20,7 @@ func TestUsers_List(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
ctx := context.Background()
@@ -74,7 +74,7 @@ func TestUser_Crud(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
@@ -124,7 +124,7 @@ func TestUser_Errors(t *testing.T) {
ctx := tc.Context()
client := tc.Client()
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
+20
View File
@@ -247,6 +247,17 @@ func TestRepository_LookupAuthToken(t *testing.T) {
return
}
require.NotNil(tt.want, "got %v, wanted nil", got)
// TODO: This test fails by a very small amount -- 500 nanos ish in
// my experience -- if they are required to be equal. I think this
// is because the resolution of the timestamp in the db does not
// match the resolution in Go code. But might be worth checking
// into.
wantGoTimeExpr, err := ptypes.Timestamp(tt.want.AuthToken.GetExpirationTime().Timestamp)
require.NoError(err)
gotGoTimeExpr, err := ptypes.Timestamp(got.AuthToken.GetExpirationTime().Timestamp)
require.NoError(err)
assert.WithinDuration(wantGoTimeExpr, gotGoTimeExpr, time.Millisecond)
tt.want.AuthToken.ExpirationTime = got.AuthToken.ExpirationTime
assert.Empty(cmp.Diff(tt.want.AuthToken, got.AuthToken, protocmp.Transform()))
})
}
@@ -328,7 +339,16 @@ func TestRepository_ValidateToken(t *testing.T) {
return
}
require.NotNil(tt.want, "Got %v but wanted nil", got)
// NOTE: See comment in LookupAuthToken about this logic
wantGoTimeExpr, err := ptypes.Timestamp(tt.want.AuthToken.GetExpirationTime().Timestamp)
require.NoError(err)
gotGoTimeExpr, err := ptypes.Timestamp(got.AuthToken.GetExpirationTime().Timestamp)
require.NoError(err)
assert.WithinDuration(wantGoTimeExpr, gotGoTimeExpr, time.Millisecond)
tt.want.AuthToken.ExpirationTime = got.AuthToken.ExpirationTime
assert.Empty(cmp.Diff(tt.want.AuthToken, got.AuthToken, protocmp.Transform()))
// preTime1 should be the value prior to the ValidateToken was called so it should equal creation time
preTime1, err := ptypes.Timestamp(got.GetApproximateLastAccessTime().GetTimestamp())
require.NoError(err)
+1 -1
View File
@@ -202,7 +202,7 @@ func (c *Command) FlagSet(bit FlagSetBit) *FlagSets {
Default: NotSetValue,
EnvVar: api.EnvWatchtowerOrg,
Completion: complete.PredictAnything,
Usage: "Organization in which to make the request; overrides any set in the address.",
Usage: "Org in which to make the request; overrides any set in the address.",
})
f.StringVar(&StringVar{
+1 -1
View File
@@ -667,7 +667,7 @@ func (s *stringMapValue) Hidden() bool { return s.hidden }
func mapToKV(m map[string]string) string {
list := make([]string, 0, len(m))
for k, _ := range m {
for k := range m {
list = append(list, k)
}
sort.Strings(list)
+1 -1
View File
@@ -430,7 +430,7 @@ func (b *Server) CreateDevDatabase(dialect string) error {
}
}
scope, err = iam.NewOrganization()
scope, err = iam.NewOrg()
if err != nil {
c()
return fmt.Errorf("error creating new org scope: %w", err)
@@ -115,7 +115,7 @@ func (c *Command) Flags() *base.FlagSets {
Name: "dev-org-id",
Target: &c.flagDevOrgId,
EnvVar: "WATCHTWER_DEV_ORG_ID",
Usage: "Auto-created organization ID. This only applies when running in \"dev\" " +
Usage: "Auto-created org ID. This only applies when running in \"dev\" " +
"mode.",
})
+1 -1
View File
@@ -88,7 +88,7 @@ func (c *Command) Flags() *base.FlagSets {
Name: "dev-org-id",
Target: &c.flagDevOrgId,
EnvVar: "WATCHTWER_DEV_ORG_ID",
Usage: "Auto-created organization ID. This only applies when running in \"dev\" " +
Usage: "Auto-created org ID. This only applies when running in \"dev\" " +
"mode.",
})
@@ -23,14 +23,14 @@ type CreateProjectCommand struct {
}
func (c *CreateProjectCommand) Synopsis() string {
return "Creates a project within an organization"
return "Creates a project within an org"
}
func (c *CreateProjectCommand) Help() string {
helpText := `
Usage: watchtower projects create
Creates a project within the organization specified by the ID from the
Creates a project within the org specified by the ID from the
"org-id" parameter or the associated environment variable.
Example:
@@ -86,7 +86,7 @@ func (c *CreateProjectCommand) Run(args []string) int {
return 2
}
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
+2 -2
View File
@@ -30,7 +30,7 @@ func (c *ReadProjectCommand) Help() string {
Usage: watchtower projects read
Returns information about a project specified by the ID. It is an error if
the project is not within the organization specified via the "org-id"
the project is not within the org specified via the "org-id"
parameter or the associated environment variable.
Example:
@@ -79,7 +79,7 @@ func (c *ReadProjectCommand) Run(args []string) int {
return 2
}
org := &scopes.Organization{
org := &scopes.Org{
Client: client,
}
+14 -14
View File
@@ -438,7 +438,7 @@ BEGIN;
drop table iam_group cascade;
drop table iam_user cascade;
drop table iam_scope_project cascade;
drop table iam_scope_organization cascade;
drop table iam_scope_org cascade;
drop table iam_scope_global cascade;
drop table iam_scope cascade;
drop table iam_scope_type_enm cascade;
@@ -476,14 +476,14 @@ COMMIT;
begin;
create table iam_scope_type_enm (
string text not null primary key check(string in ('unknown', 'global', 'organization', 'project'))
string text not null primary key check(string in ('unknown', 'global', 'org', 'project'))
);
insert into iam_scope_type_enm (string)
values
('unknown'),
('global'),
('organization'),
('org'),
('project');
@@ -515,7 +515,7 @@ create table iam_scope (
and parent_id is null
)
or (
type = 'organization'
type = 'org'
and parent_id = 'global'
)
or (
@@ -539,7 +539,7 @@ create table iam_scope_global (
name text unique
);
create table iam_scope_organization (
create table iam_scope_org (
scope_id wt_scope_id primary key
references iam_scope(public_id)
on delete cascade
@@ -554,7 +554,7 @@ create table iam_scope_organization (
create table iam_scope_project (
scope_id wt_scope_id not null references iam_scope(public_id) on delete cascade on update cascade,
parent_id wt_public_id not null references iam_scope_organization(scope_id) on delete cascade on update cascade,
parent_id wt_public_id not null references iam_scope_org(scope_id) on delete cascade on update cascade,
name text,
unique(parent_id, name),
primary key(scope_id, parent_id)
@@ -572,8 +572,8 @@ begin
(new.public_id, new.name);
return new;
end if;
if new.type = 'organization' then
insert into iam_scope_organization (scope_id, parent_id, name)
if new.type = 'org' then
insert into iam_scope_org (scope_id, parent_id, name)
values
(new.public_id, new.parent_id, new.name);
return new;
@@ -650,7 +650,7 @@ insert on iam_scope
-- iam_sub_names will allow us to enforce the different name constraints for
-- organizations and projects via a before update trigger on the iam_scope
-- orgs and projects via a before update trigger on the iam_scope
-- table.
create or replace function
iam_sub_names()
@@ -662,8 +662,8 @@ begin
update iam_scope_global set name = new.name where scope_id = old.public_id;
return new;
end if;
if new.type = 'organization' then
update iam_scope_organization set name = new.name where scope_id = old.public_id;
if new.type = 'org' then
update iam_scope_org set name = new.name where scope_id = old.public_id;
return new;
end if;
if new.type = 'project' then
@@ -707,7 +707,7 @@ create or replace function
returns trigger
as $$
begin
perform from iam_scope where public_id = new.scope_id and type in ('global', 'organization');
perform from iam_scope where public_id = new.scope_id and type in ('global', 'org');
if not found then
raise exception 'invalid scope type for user creation';
end if;
@@ -742,12 +742,12 @@ begin
if role_scope_type = 'project' then
raise exception 'invalid to set grant_scope_id to non-same scope_id when role scope type is project';
end if;
if role_scope_type = 'organization' then
if role_scope_type = 'org' then
-- Look up the parent scope ID for the scope ID given
select isc.parent_id from iam_scope isc where isc.public_id = new.grant_scope_id into parent_scope_id;
-- Allow iff the grant scope ID's parent matches the role's scope ID; that
-- is, match if the role belongs to a direct child scope of this
-- organization
-- org
if parent_scope_id = new.scope_id then
return new;
end if;
@@ -3,7 +3,7 @@ BEGIN;
drop table iam_group cascade;
drop table iam_user cascade;
drop table iam_scope_project cascade;
drop table iam_scope_organization cascade;
drop table iam_scope_org cascade;
drop table iam_scope_global cascade;
drop table iam_scope cascade;
drop table iam_scope_type_enm cascade;
+13 -13
View File
@@ -1,14 +1,14 @@
begin;
create table iam_scope_type_enm (
string text not null primary key check(string in ('unknown', 'global', 'organization', 'project'))
string text not null primary key check(string in ('unknown', 'global', 'org', 'project'))
);
insert into iam_scope_type_enm (string)
values
('unknown'),
('global'),
('organization'),
('org'),
('project');
@@ -40,7 +40,7 @@ create table iam_scope (
and parent_id is null
)
or (
type = 'organization'
type = 'org'
and parent_id = 'global'
)
or (
@@ -64,7 +64,7 @@ create table iam_scope_global (
name text unique
);
create table iam_scope_organization (
create table iam_scope_org (
scope_id wt_scope_id primary key
references iam_scope(public_id)
on delete cascade
@@ -79,7 +79,7 @@ create table iam_scope_organization (
create table iam_scope_project (
scope_id wt_scope_id not null references iam_scope(public_id) on delete cascade on update cascade,
parent_id wt_public_id not null references iam_scope_organization(scope_id) on delete cascade on update cascade,
parent_id wt_public_id not null references iam_scope_org(scope_id) on delete cascade on update cascade,
name text,
unique(parent_id, name),
primary key(scope_id, parent_id)
@@ -97,8 +97,8 @@ begin
(new.public_id, new.name);
return new;
end if;
if new.type = 'organization' then
insert into iam_scope_organization (scope_id, parent_id, name)
if new.type = 'org' then
insert into iam_scope_org (scope_id, parent_id, name)
values
(new.public_id, new.parent_id, new.name);
return new;
@@ -175,7 +175,7 @@ insert on iam_scope
-- iam_sub_names will allow us to enforce the different name constraints for
-- organizations and projects via a before update trigger on the iam_scope
-- orgs and projects via a before update trigger on the iam_scope
-- table.
create or replace function
iam_sub_names()
@@ -187,8 +187,8 @@ begin
update iam_scope_global set name = new.name where scope_id = old.public_id;
return new;
end if;
if new.type = 'organization' then
update iam_scope_organization set name = new.name where scope_id = old.public_id;
if new.type = 'org' then
update iam_scope_org set name = new.name where scope_id = old.public_id;
return new;
end if;
if new.type = 'project' then
@@ -232,7 +232,7 @@ create or replace function
returns trigger
as $$
begin
perform from iam_scope where public_id = new.scope_id and type in ('global', 'organization');
perform from iam_scope where public_id = new.scope_id and type in ('global', 'org');
if not found then
raise exception 'invalid scope type for user creation';
end if;
@@ -267,12 +267,12 @@ begin
if role_scope_type = 'project' then
raise exception 'invalid to set grant_scope_id to non-same scope_id when role scope type is project';
end if;
if role_scope_type = 'organization' then
if role_scope_type = 'org' then
-- Look up the parent scope ID for the scope ID given
select isc.parent_id from iam_scope isc where isc.public_id = new.grant_scope_id into parent_scope_id;
-- Allow iff the grant scope ID's parent matches the role's scope ID; that
-- is, match if the role belongs to a direct child scope of this
-- organization
-- org
if parent_scope_id = new.scope_id then
return new;
end if;
+22 -22
View File
@@ -18,13 +18,13 @@
"paths": {
"/v1/orgs": {
"get": {
"summary": "Lists all Organizations",
"operationId": "OrganizationService_ListOrganizations",
"summary": "Lists all Orgs",
"operationId": "OrgService_ListOrgs",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/controller.api.services.v1.ListOrganizationsResponse"
"$ref": "#/definitions/controller.api.services.v1.ListOrgsResponse"
}
}
},
@@ -37,19 +37,19 @@
}
],
"tags": [
"controller.api.services.v1.OrganizationService"
"controller.api.services.v1.OrgService"
]
}
},
"/v1/orgs/{id}": {
"get": {
"summary": "Gets a single Organization",
"operationId": "OrganizationService_GetOrganization",
"summary": "Gets a single Org",
"operationId": "OrgService_GetOrg",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.scopes.v1.Organization"
"$ref": "#/definitions/controller.api.resources.scopes.v1.Org"
}
}
},
@@ -68,7 +68,7 @@
}
],
"tags": [
"controller.api.services.v1.OrganizationService"
"controller.api.services.v1.OrgService"
]
}
},
@@ -3053,8 +3053,8 @@
},
"/v1/orgs/{org_id}:authenticate": {
"post": {
"summary": "Authenticate a user to an Organization and retrieve an authentication token.",
"operationId": "OrganizationService_Authenticate",
"summary": "Authenticate a user to an Org and retrieve an authentication token.",
"operationId": "OrgService_Authenticate",
"responses": {
"200": {
"description": "",
@@ -3080,14 +3080,14 @@
}
],
"tags": [
"controller.api.services.v1.OrganizationService"
"controller.api.services.v1.OrgService"
]
}
},
"/v1/orgs/{org_id}:deauthenticate": {
"post": {
"summary": "Deauthenticate an authentication token from an Organization.",
"operationId": "OrganizationService_Deauthenticate",
"summary": "Deauthenticate an authentication token from an Org.",
"operationId": "OrgService_Deauthenticate",
"responses": {
"200": {
"description": "A successful response.",
@@ -3105,7 +3105,7 @@
}
],
"tags": [
"controller.api.services.v1.OrganizationService"
"controller.api.services.v1.OrgService"
]
}
}
@@ -3374,7 +3374,7 @@
},
"grant_scope_id": {
"type": "string",
"description": "The scope the grants will apply to. If the role is at the global scope,\nthis can be an organization or project. If the role is at an organization\nscope, this can be a project within the organization. It is invalid for\nthis to be anything other than the role's scope when the role's scope is\na project."
"description": "The scope the grants will apply to. If the role is at the global scope,\nthis can be an org or project. If the role is at an org\nscope, this can be a project within the org. It is invalid for\nthis to be anything other than the role's scope when the role's scope is\na project."
},
"version": {
"type": "integer",
@@ -3425,12 +3425,12 @@
},
"title": "Role contains all fields related to a Role resource"
},
"controller.api.resources.scopes.v1.Organization": {
"controller.api.resources.scopes.v1.Org": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The ID of the Organization\nOutput only.",
"description": "The ID of the Org\nOutput only.",
"readOnly": true
},
"name": {
@@ -3454,7 +3454,7 @@
"readOnly": true
}
},
"title": "Organization contains all fields related to an Organization resource"
"title": "Org contains all fields related to an Org resource"
},
"controller.api.resources.scopes.v1.Project": {
"type": "object",
@@ -3805,11 +3805,11 @@
}
}
},
"controller.api.services.v1.GetOrganizationResponse": {
"controller.api.services.v1.GetOrgResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/controller.api.resources.scopes.v1.Organization"
"$ref": "#/definitions/controller.api.resources.scopes.v1.Org"
}
}
},
@@ -3881,13 +3881,13 @@
}
}
},
"controller.api.services.v1.ListOrganizationsResponse": {
"controller.api.services.v1.ListOrgsResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/controller.api.resources.scopes.v1.Organization"
"$ref": "#/definitions/controller.api.resources.scopes.v1.Org"
}
}
}
@@ -49,8 +49,8 @@ type Role struct {
// Whether the resource is disabled
Disabled *wrappers.BoolValue `protobuf:"bytes,6,opt,name=disabled,proto3" json:"disabled,omitempty"`
// The scope the grants will apply to. If the role is at the global scope,
// this can be an organization or project. If the role is at an organization
// scope, this can be a project within the organization. It is invalid for
// this can be an org or project. If the role is at an org
// scope, this can be a project within the org. It is invalid for
// this to be anything other than the role's scope when the role's scope is
// a project.
GrantScopeId *wrappers.StringValue `protobuf:"bytes,7,opt,name=grant_scope_id,proto3" json:"grant_scope_id,omitempty"`
@@ -0,0 +1,222 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0
// protoc v3.12.3
// source: controller/api/resources/scopes/v1/org.proto
package scopes
import (
proto "github.com/golang/protobuf/proto"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// Org contains all fields related to an Org resource
type Org struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The ID of the Org
// Output only.
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// Optional name for identification purposes
Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
// Optional user-set descripton for identification purposes
Description *wrappers.StringValue `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
// The time this resource was created
// Output only.
CreatedTime *timestamp.Timestamp `protobuf:"bytes,4,opt,name=created_time,proto3" json:"created_time,omitempty"`
// The time this resource was last updated.
// Output only.
UpdatedTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=updated_time,proto3" json:"updated_time,omitempty"`
}
func (x *Org) Reset() {
*x = Org{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_resources_scopes_v1_org_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Org) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Org) ProtoMessage() {}
func (x *Org) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_resources_scopes_v1_org_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Org.ProtoReflect.Descriptor instead.
func (*Org) Descriptor() ([]byte, []int) {
return file_controller_api_resources_scopes_v1_org_proto_rawDescGZIP(), []int{0}
}
func (x *Org) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Org) GetName() *wrappers.StringValue {
if x != nil {
return x.Name
}
return nil
}
func (x *Org) GetDescription() *wrappers.StringValue {
if x != nil {
return x.Description
}
return nil
}
func (x *Org) GetCreatedTime() *timestamp.Timestamp {
if x != nil {
return x.CreatedTime
}
return nil
}
func (x *Org) GetUpdatedTime() *timestamp.Timestamp {
if x != nil {
return x.UpdatedTime
}
return nil
}
var File_controller_api_resources_scopes_v1_org_proto protoreflect.FileDescriptor
var file_controller_api_resources_scopes_v1_org_proto_rawDesc = []byte{
0x0a, 0x2c, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65,
0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72,
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e,
0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x87, 0x02, 0x0a, 0x03, 0x4f, 0x72, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x0a,
0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65,
0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a,
0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,
0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3e, 0x0a,
0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,
0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x55, 0x5a,
0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68,
0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77, 0x65, 0x72,
0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f,
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73,
0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x3b, 0x73, 0x63,
0x6f, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_controller_api_resources_scopes_v1_org_proto_rawDescOnce sync.Once
file_controller_api_resources_scopes_v1_org_proto_rawDescData = file_controller_api_resources_scopes_v1_org_proto_rawDesc
)
func file_controller_api_resources_scopes_v1_org_proto_rawDescGZIP() []byte {
file_controller_api_resources_scopes_v1_org_proto_rawDescOnce.Do(func() {
file_controller_api_resources_scopes_v1_org_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_api_resources_scopes_v1_org_proto_rawDescData)
})
return file_controller_api_resources_scopes_v1_org_proto_rawDescData
}
var file_controller_api_resources_scopes_v1_org_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_controller_api_resources_scopes_v1_org_proto_goTypes = []interface{}{
(*Org)(nil), // 0: controller.api.resources.scopes.v1.Org
(*wrappers.StringValue)(nil), // 1: google.protobuf.StringValue
(*timestamp.Timestamp)(nil), // 2: google.protobuf.Timestamp
}
var file_controller_api_resources_scopes_v1_org_proto_depIdxs = []int32{
1, // 0: controller.api.resources.scopes.v1.Org.name:type_name -> google.protobuf.StringValue
1, // 1: controller.api.resources.scopes.v1.Org.description:type_name -> google.protobuf.StringValue
2, // 2: controller.api.resources.scopes.v1.Org.created_time:type_name -> google.protobuf.Timestamp
2, // 3: controller.api.resources.scopes.v1.Org.updated_time:type_name -> google.protobuf.Timestamp
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_controller_api_resources_scopes_v1_org_proto_init() }
func file_controller_api_resources_scopes_v1_org_proto_init() {
if File_controller_api_resources_scopes_v1_org_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_api_resources_scopes_v1_org_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Org); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_controller_api_resources_scopes_v1_org_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_controller_api_resources_scopes_v1_org_proto_goTypes,
DependencyIndexes: file_controller_api_resources_scopes_v1_org_proto_depIdxs,
MessageInfos: file_controller_api_resources_scopes_v1_org_proto_msgTypes,
}.Build()
File_controller_api_resources_scopes_v1_org_proto = out.File
file_controller_api_resources_scopes_v1_org_proto_rawDesc = nil
file_controller_api_resources_scopes_v1_org_proto_goTypes = nil
file_controller_api_resources_scopes_v1_org_proto_depIdxs = nil
}
@@ -1,223 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0
// protoc v3.12.3
// source: controller/api/resources/scopes/v1/organization.proto
package scopes
import (
proto "github.com/golang/protobuf/proto"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// Organization contains all fields related to an Organization resource
type Organization struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The ID of the Organization
// Output only.
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// Optional name for identification purposes
Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
// Optional user-set descripton for identification purposes
Description *wrappers.StringValue `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
// The time this resource was created
// Output only.
CreatedTime *timestamp.Timestamp `protobuf:"bytes,4,opt,name=created_time,proto3" json:"created_time,omitempty"`
// The time this resource was last updated.
// Output only.
UpdatedTime *timestamp.Timestamp `protobuf:"bytes,5,opt,name=updated_time,proto3" json:"updated_time,omitempty"`
}
func (x *Organization) Reset() {
*x = Organization{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_resources_scopes_v1_organization_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Organization) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Organization) ProtoMessage() {}
func (x *Organization) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_resources_scopes_v1_organization_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Organization.ProtoReflect.Descriptor instead.
func (*Organization) Descriptor() ([]byte, []int) {
return file_controller_api_resources_scopes_v1_organization_proto_rawDescGZIP(), []int{0}
}
func (x *Organization) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Organization) GetName() *wrappers.StringValue {
if x != nil {
return x.Name
}
return nil
}
func (x *Organization) GetDescription() *wrappers.StringValue {
if x != nil {
return x.Description
}
return nil
}
func (x *Organization) GetCreatedTime() *timestamp.Timestamp {
if x != nil {
return x.CreatedTime
}
return nil
}
func (x *Organization) GetUpdatedTime() *timestamp.Timestamp {
if x != nil {
return x.UpdatedTime
}
return nil
}
var File_controller_api_resources_scopes_v1_organization_proto protoreflect.FileDescriptor
var file_controller_api_resources_scopes_v1_organization_proto_rawDesc = []byte{
0x0a, 0x35, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65,
0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x73, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72,
0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x90, 0x02, 0x0a,
0x0c, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x3e, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c,
0x75, 0x65, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12,
0x3e, 0x0a, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18,
0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
0x70, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12,
0x3e, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18,
0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
0x70, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x42,
0x55, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61,
0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x74, 0x6f, 0x77,
0x65, 0x72, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72,
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x3b,
0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_controller_api_resources_scopes_v1_organization_proto_rawDescOnce sync.Once
file_controller_api_resources_scopes_v1_organization_proto_rawDescData = file_controller_api_resources_scopes_v1_organization_proto_rawDesc
)
func file_controller_api_resources_scopes_v1_organization_proto_rawDescGZIP() []byte {
file_controller_api_resources_scopes_v1_organization_proto_rawDescOnce.Do(func() {
file_controller_api_resources_scopes_v1_organization_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_api_resources_scopes_v1_organization_proto_rawDescData)
})
return file_controller_api_resources_scopes_v1_organization_proto_rawDescData
}
var file_controller_api_resources_scopes_v1_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_controller_api_resources_scopes_v1_organization_proto_goTypes = []interface{}{
(*Organization)(nil), // 0: controller.api.resources.scopes.v1.Organization
(*wrappers.StringValue)(nil), // 1: google.protobuf.StringValue
(*timestamp.Timestamp)(nil), // 2: google.protobuf.Timestamp
}
var file_controller_api_resources_scopes_v1_organization_proto_depIdxs = []int32{
1, // 0: controller.api.resources.scopes.v1.Organization.name:type_name -> google.protobuf.StringValue
1, // 1: controller.api.resources.scopes.v1.Organization.description:type_name -> google.protobuf.StringValue
2, // 2: controller.api.resources.scopes.v1.Organization.created_time:type_name -> google.protobuf.Timestamp
2, // 3: controller.api.resources.scopes.v1.Organization.updated_time:type_name -> google.protobuf.Timestamp
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_controller_api_resources_scopes_v1_organization_proto_init() }
func file_controller_api_resources_scopes_v1_organization_proto_init() {
if File_controller_api_resources_scopes_v1_organization_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_api_resources_scopes_v1_organization_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Organization); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_controller_api_resources_scopes_v1_organization_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_controller_api_resources_scopes_v1_organization_proto_goTypes,
DependencyIndexes: file_controller_api_resources_scopes_v1_organization_proto_depIdxs,
MessageInfos: file_controller_api_resources_scopes_v1_organization_proto_msgTypes,
}.Build()
File_controller_api_resources_scopes_v1_organization_proto = out.File
file_controller_api_resources_scopes_v1_organization_proto_rawDesc = nil
file_controller_api_resources_scopes_v1_organization_proto_goTypes = nil
file_controller_api_resources_scopes_v1_organization_proto_depIdxs = nil
}
@@ -1001,22 +1001,22 @@ type GroupServiceClient interface {
// ListGroups returns a list of stored groups which exist inside the org
// referenced inside the request. The request must include the org id for
// the groups being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListGroups(ctx context.Context, in *ListGroupsRequest, opts ...grpc.CallOption) (*ListGroupsResponse, error)
// CreateGroup creates and stores a group in watchtower. The provided
// request must include the org id in which the group will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another group in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another group in the same org, an error is returned.
CreateGroup(ctx context.Context, in *CreateGroupRequest, opts ...grpc.CallOption) (*CreateGroupResponse, error)
// UpdateGroup updates an existing group in watchtower. The provided
// group must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided group. An error is returned if either the organization
// in the provided group. An error is returned if either the org
// or group ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateGroup(ctx context.Context, in *UpdateGroupRequest, opts ...grpc.CallOption) (*UpdateGroupResponse, error)
// DeleteGroup removes a group from Watchtower. If the provided org or group ids
// are malformed or not provided an error is returned. No error is returned
@@ -1089,22 +1089,22 @@ type GroupServiceServer interface {
// ListGroups returns a list of stored groups which exist inside the org
// referenced inside the request. The request must include the org id for
// the groups being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListGroups(context.Context, *ListGroupsRequest) (*ListGroupsResponse, error)
// CreateGroup creates and stores a group in watchtower. The provided
// request must include the org id in which the group will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another group in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another group in the same org, an error is returned.
CreateGroup(context.Context, *CreateGroupRequest) (*CreateGroupResponse, error)
// UpdateGroup updates an existing group in watchtower. The provided
// group must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided group. An error is returned if either the organization
// in the provided group. An error is returned if either the org
// or group ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateGroup(context.Context, *UpdateGroupRequest) (*UpdateGroupResponse, error)
// DeleteGroup removes a group from Watchtower. If the provided org or group ids
// are malformed or not provided an error is returned. No error is returned
@@ -0,0 +1,991 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0
// protoc v3.12.3
// source: controller/api/services/v1/org_service.proto
package services
import (
context "context"
proto "github.com/golang/protobuf/proto"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
authtokens "github.com/hashicorp/watchtower/internal/gen/controller/api/resources/authtokens"
scopes "github.com/hashicorp/watchtower/internal/gen/controller/api/resources/scopes"
_ "google.golang.org/genproto/googleapis/api/annotations"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type GetOrgRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
View string `protobuf:"bytes,2,opt,name=view,proto3" json:"view,omitempty"`
}
func (x *GetOrgRequest) Reset() {
*x = GetOrgRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetOrgRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetOrgRequest) ProtoMessage() {}
func (x *GetOrgRequest) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetOrgRequest.ProtoReflect.Descriptor instead.
func (*GetOrgRequest) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{0}
}
func (x *GetOrgRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *GetOrgRequest) GetView() string {
if x != nil {
return x.View
}
return ""
}
type GetOrgResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Item *scopes.Org `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
}
func (x *GetOrgResponse) Reset() {
*x = GetOrgResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetOrgResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetOrgResponse) ProtoMessage() {}
func (x *GetOrgResponse) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetOrgResponse.ProtoReflect.Descriptor instead.
func (*GetOrgResponse) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{1}
}
func (x *GetOrgResponse) GetItem() *scopes.Org {
if x != nil {
return x.Item
}
return nil
}
type ListOrgsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
View string `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"`
}
func (x *ListOrgsRequest) Reset() {
*x = ListOrgsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListOrgsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListOrgsRequest) ProtoMessage() {}
func (x *ListOrgsRequest) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListOrgsRequest.ProtoReflect.Descriptor instead.
func (*ListOrgsRequest) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{2}
}
func (x *ListOrgsRequest) GetView() string {
if x != nil {
return x.View
}
return ""
}
type ListOrgsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Items []*scopes.Org `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
}
func (x *ListOrgsResponse) Reset() {
*x = ListOrgsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListOrgsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListOrgsResponse) ProtoMessage() {}
func (x *ListOrgsResponse) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListOrgsResponse.ProtoReflect.Descriptor instead.
func (*ListOrgsResponse) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{3}
}
func (x *ListOrgsResponse) GetItems() []*scopes.Org {
if x != nil {
return x.Items
}
return nil
}
type PasswordCredential struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
LoginName string `protobuf:"bytes,1,opt,name=login_name,json=loginName,proto3" json:"login_name,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
}
func (x *PasswordCredential) Reset() {
*x = PasswordCredential{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PasswordCredential) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PasswordCredential) ProtoMessage() {}
func (x *PasswordCredential) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PasswordCredential.ProtoReflect.Descriptor instead.
func (*PasswordCredential) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{4}
}
func (x *PasswordCredential) GetLoginName() string {
if x != nil {
return x.LoginName
}
return ""
}
func (x *PasswordCredential) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
type AuthenticateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
// The id to the authmethod in the system being used for authentication. The auth method must be in the org
// being logged in to.
AuthMethodId string `protobuf:"bytes,2,opt,name=auth_method_id,json=authMethodId,proto3" json:"auth_method_id,omitempty"`
// This can be "cookie" or "token". If not provided, "token" will be used. For now only type "token" is returned.
TokenType string `protobuf:"bytes,3,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"`
PasswordCredential *PasswordCredential `protobuf:"bytes,4,opt,name=password_credential,json=passwordCredential,proto3" json:"password_credential,omitempty"`
}
func (x *AuthenticateRequest) Reset() {
*x = AuthenticateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AuthenticateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AuthenticateRequest) ProtoMessage() {}
func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead.
func (*AuthenticateRequest) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{5}
}
func (x *AuthenticateRequest) GetOrgId() string {
if x != nil {
return x.OrgId
}
return ""
}
func (x *AuthenticateRequest) GetAuthMethodId() string {
if x != nil {
return x.AuthMethodId
}
return ""
}
func (x *AuthenticateRequest) GetTokenType() string {
if x != nil {
return x.TokenType
}
return ""
}
func (x *AuthenticateRequest) GetPasswordCredential() *PasswordCredential {
if x != nil {
return x.PasswordCredential
}
return nil
}
type AuthenticateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Item *authtokens.AuthToken `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
}
func (x *AuthenticateResponse) Reset() {
*x = AuthenticateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *AuthenticateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AuthenticateResponse) ProtoMessage() {}
func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead.
func (*AuthenticateResponse) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{6}
}
func (x *AuthenticateResponse) GetItem() *authtokens.AuthToken {
if x != nil {
return x.Item
}
return nil
}
type DeauthenticateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
}
func (x *DeauthenticateRequest) Reset() {
*x = DeauthenticateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeauthenticateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeauthenticateRequest) ProtoMessage() {}
func (x *DeauthenticateRequest) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeauthenticateRequest.ProtoReflect.Descriptor instead.
func (*DeauthenticateRequest) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{7}
}
func (x *DeauthenticateRequest) GetOrgId() string {
if x != nil {
return x.OrgId
}
return ""
}
type DeauthenticateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *DeauthenticateResponse) Reset() {
*x = DeauthenticateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeauthenticateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeauthenticateResponse) ProtoMessage() {}
func (x *DeauthenticateResponse) ProtoReflect() protoreflect.Message {
mi := &file_controller_api_services_v1_org_service_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeauthenticateResponse.ProtoReflect.Descriptor instead.
func (*DeauthenticateResponse) Descriptor() ([]byte, []int) {
return file_controller_api_services_v1_org_service_proto_rawDescGZIP(), []int{8}
}
var File_controller_api_services_v1_org_service_proto protoreflect.FileDescriptor
var file_controller_api_services_v1_org_service_proto_rawDesc = []byte{
0x0a, 0x2c, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69,
0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67,
0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1a,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x2c, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x6f,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2c, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c,
0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73,
0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x61,
0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74,
0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x33, 0x0a, 0x0d,
0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x76, 0x69, 0x65,
0x77, 0x22, 0x4d, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x63, 0x6f,
0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x72, 0x67, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d,
0x22, 0x25, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x76, 0x69, 0x65, 0x77, 0x22, 0x51, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4f,
0x72, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x05, 0x69,
0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e,
0x4f, 0x72, 0x67, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x4f, 0x0a, 0x12, 0x50, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c,
0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12,
0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0xd2, 0x01, 0x0a, 0x13,
0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6f, 0x72, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x72, 0x67, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x61, 0x75,
0x74, 0x68, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0c, 0x61, 0x75, 0x74, 0x68, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x49, 0x64,
0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12,
0x5f, 0x0a, 0x13, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x63, 0x72, 0x65, 0x64,
0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x63,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f,
0x72, 0x64, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x12, 0x70, 0x61,
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c,
0x22, 0x5d, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x2e,
0x41, 0x75, 0x74, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22,
0x2e, 0x0a, 0x15, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6f, 0x72, 0x67, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x72, 0x67, 0x49, 0x64, 0x22,
0x18, 0x0a, 0x16, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xf7, 0x05, 0x0a, 0x0a, 0x4f, 0x72,
0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x92, 0x01, 0x0a, 0x06, 0x47, 0x65, 0x74,
0x4f, 0x72, 0x67, 0x12, 0x29, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31,
0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a,
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4f,
0x72, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, 0xe4, 0x93,
0x02, 0x15, 0x12, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x73, 0x2f, 0x7b, 0x69, 0x64,
0x7d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x13, 0x12, 0x11, 0x47, 0x65, 0x74, 0x73,
0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x4f, 0x72, 0x67, 0x12, 0x8a, 0x01,
0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x73, 0x12, 0x2b, 0x2e, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f,
0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x73, 0x92, 0x41, 0x10, 0x12, 0x0e, 0x4c, 0x69, 0x73, 0x74,
0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x4f, 0x72, 0x67, 0x73, 0x12, 0xea, 0x01, 0x0a, 0x0c, 0x41,
0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2f, 0x2e, 0x63, 0x6f,
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74,
0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e,
0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x77,
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x73,
0x2f, 0x7b, 0x6f, 0x72, 0x67, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e,
0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92,
0x41, 0x45, 0x12, 0x43, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65,
0x20, 0x61, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x6e, 0x20, 0x4f, 0x72,
0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x61,
0x6e, 0x20, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x12, 0xd9, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x61, 0x75,
0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x31, 0x2e, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e,
0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x61, 0x75, 0x74,
0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x60, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x22, 0x20, 0x2f, 0x76, 0x31, 0x2f, 0x6f,
0x72, 0x67, 0x73, 0x2f, 0x7b, 0x6f, 0x72, 0x67, 0x5f, 0x69, 0x64, 0x7d, 0x3a, 0x64, 0x65, 0x61,
0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x92, 0x41, 0x35, 0x12, 0x33,
0x44, 0x65, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x61,
0x6e, 0x20, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x20, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x61, 0x6e, 0x20, 0x4f,
0x72, 0x67, 0x2e, 0x42, 0x4f, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x77, 0x61, 0x74, 0x63,
0x68, 0x74, 0x6f, 0x77, 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f,
0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_controller_api_services_v1_org_service_proto_rawDescOnce sync.Once
file_controller_api_services_v1_org_service_proto_rawDescData = file_controller_api_services_v1_org_service_proto_rawDesc
)
func file_controller_api_services_v1_org_service_proto_rawDescGZIP() []byte {
file_controller_api_services_v1_org_service_proto_rawDescOnce.Do(func() {
file_controller_api_services_v1_org_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_api_services_v1_org_service_proto_rawDescData)
})
return file_controller_api_services_v1_org_service_proto_rawDescData
}
var file_controller_api_services_v1_org_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_controller_api_services_v1_org_service_proto_goTypes = []interface{}{
(*GetOrgRequest)(nil), // 0: controller.api.services.v1.GetOrgRequest
(*GetOrgResponse)(nil), // 1: controller.api.services.v1.GetOrgResponse
(*ListOrgsRequest)(nil), // 2: controller.api.services.v1.ListOrgsRequest
(*ListOrgsResponse)(nil), // 3: controller.api.services.v1.ListOrgsResponse
(*PasswordCredential)(nil), // 4: controller.api.services.v1.PasswordCredential
(*AuthenticateRequest)(nil), // 5: controller.api.services.v1.AuthenticateRequest
(*AuthenticateResponse)(nil), // 6: controller.api.services.v1.AuthenticateResponse
(*DeauthenticateRequest)(nil), // 7: controller.api.services.v1.DeauthenticateRequest
(*DeauthenticateResponse)(nil), // 8: controller.api.services.v1.DeauthenticateResponse
(*scopes.Org)(nil), // 9: controller.api.resources.scopes.v1.Org
(*authtokens.AuthToken)(nil), // 10: controller.api.resources.authtokens.v1.AuthToken
}
var file_controller_api_services_v1_org_service_proto_depIdxs = []int32{
9, // 0: controller.api.services.v1.GetOrgResponse.item:type_name -> controller.api.resources.scopes.v1.Org
9, // 1: controller.api.services.v1.ListOrgsResponse.items:type_name -> controller.api.resources.scopes.v1.Org
4, // 2: controller.api.services.v1.AuthenticateRequest.password_credential:type_name -> controller.api.services.v1.PasswordCredential
10, // 3: controller.api.services.v1.AuthenticateResponse.item:type_name -> controller.api.resources.authtokens.v1.AuthToken
0, // 4: controller.api.services.v1.OrgService.GetOrg:input_type -> controller.api.services.v1.GetOrgRequest
2, // 5: controller.api.services.v1.OrgService.ListOrgs:input_type -> controller.api.services.v1.ListOrgsRequest
5, // 6: controller.api.services.v1.OrgService.Authenticate:input_type -> controller.api.services.v1.AuthenticateRequest
7, // 7: controller.api.services.v1.OrgService.Deauthenticate:input_type -> controller.api.services.v1.DeauthenticateRequest
1, // 8: controller.api.services.v1.OrgService.GetOrg:output_type -> controller.api.services.v1.GetOrgResponse
3, // 9: controller.api.services.v1.OrgService.ListOrgs:output_type -> controller.api.services.v1.ListOrgsResponse
6, // 10: controller.api.services.v1.OrgService.Authenticate:output_type -> controller.api.services.v1.AuthenticateResponse
8, // 11: controller.api.services.v1.OrgService.Deauthenticate:output_type -> controller.api.services.v1.DeauthenticateResponse
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_controller_api_services_v1_org_service_proto_init() }
func file_controller_api_services_v1_org_service_proto_init() {
if File_controller_api_services_v1_org_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_api_services_v1_org_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetOrgRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetOrgResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListOrgsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListOrgsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PasswordCredential); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AuthenticateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*AuthenticateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeauthenticateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_api_services_v1_org_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeauthenticateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_controller_api_services_v1_org_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_controller_api_services_v1_org_service_proto_goTypes,
DependencyIndexes: file_controller_api_services_v1_org_service_proto_depIdxs,
MessageInfos: file_controller_api_services_v1_org_service_proto_msgTypes,
}.Build()
File_controller_api_services_v1_org_service_proto = out.File
file_controller_api_services_v1_org_service_proto_rawDesc = nil
file_controller_api_services_v1_org_service_proto_goTypes = nil
file_controller_api_services_v1_org_service_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// OrgServiceClient is the client API for OrgService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type OrgServiceClient interface {
// GetOrg returns a stored Org if present. The provided request
// must include the org id for the org being retrieved. If
// that id is missing, malformed or reference a non existing resource an error is returned.
GetOrg(ctx context.Context, in *GetOrgRequest, opts ...grpc.CallOption) (*GetOrgResponse, error)
// ListOrgs returns a list of stored orgs which exist in watchtower.
ListOrgs(ctx context.Context, in *ListOrgsRequest, opts ...grpc.CallOption) (*ListOrgsResponse, error)
// Authenticate validates credentials provided and returns an auth token.
Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error)
// Logout terminates a user's current session.
Deauthenticate(ctx context.Context, in *DeauthenticateRequest, opts ...grpc.CallOption) (*DeauthenticateResponse, error)
}
type orgServiceClient struct {
cc grpc.ClientConnInterface
}
func NewOrgServiceClient(cc grpc.ClientConnInterface) OrgServiceClient {
return &orgServiceClient{cc}
}
func (c *orgServiceClient) GetOrg(ctx context.Context, in *GetOrgRequest, opts ...grpc.CallOption) (*GetOrgResponse, error) {
out := new(GetOrgResponse)
err := c.cc.Invoke(ctx, "/controller.api.services.v1.OrgService/GetOrg", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orgServiceClient) ListOrgs(ctx context.Context, in *ListOrgsRequest, opts ...grpc.CallOption) (*ListOrgsResponse, error) {
out := new(ListOrgsResponse)
err := c.cc.Invoke(ctx, "/controller.api.services.v1.OrgService/ListOrgs", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orgServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) {
out := new(AuthenticateResponse)
err := c.cc.Invoke(ctx, "/controller.api.services.v1.OrgService/Authenticate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orgServiceClient) Deauthenticate(ctx context.Context, in *DeauthenticateRequest, opts ...grpc.CallOption) (*DeauthenticateResponse, error) {
out := new(DeauthenticateResponse)
err := c.cc.Invoke(ctx, "/controller.api.services.v1.OrgService/Deauthenticate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// OrgServiceServer is the server API for OrgService service.
type OrgServiceServer interface {
// GetOrg returns a stored Org if present. The provided request
// must include the org id for the org being retrieved. If
// that id is missing, malformed or reference a non existing resource an error is returned.
GetOrg(context.Context, *GetOrgRequest) (*GetOrgResponse, error)
// ListOrgs returns a list of stored orgs which exist in watchtower.
ListOrgs(context.Context, *ListOrgsRequest) (*ListOrgsResponse, error)
// Authenticate validates credentials provided and returns an auth token.
Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error)
// Logout terminates a user's current session.
Deauthenticate(context.Context, *DeauthenticateRequest) (*DeauthenticateResponse, error)
}
// UnimplementedOrgServiceServer can be embedded to have forward compatible implementations.
type UnimplementedOrgServiceServer struct {
}
func (*UnimplementedOrgServiceServer) GetOrg(context.Context, *GetOrgRequest) (*GetOrgResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetOrg not implemented")
}
func (*UnimplementedOrgServiceServer) ListOrgs(context.Context, *ListOrgsRequest) (*ListOrgsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListOrgs not implemented")
}
func (*UnimplementedOrgServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented")
}
func (*UnimplementedOrgServiceServer) Deauthenticate(context.Context, *DeauthenticateRequest) (*DeauthenticateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Deauthenticate not implemented")
}
func RegisterOrgServiceServer(s *grpc.Server, srv OrgServiceServer) {
s.RegisterService(&_OrgService_serviceDesc, srv)
}
func _OrgService_GetOrg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetOrgRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrgServiceServer).GetOrg(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/controller.api.services.v1.OrgService/GetOrg",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrgServiceServer).GetOrg(ctx, req.(*GetOrgRequest))
}
return interceptor(ctx, in, info, handler)
}
func _OrgService_ListOrgs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListOrgsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrgServiceServer).ListOrgs(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/controller.api.services.v1.OrgService/ListOrgs",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrgServiceServer).ListOrgs(ctx, req.(*ListOrgsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _OrgService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AuthenticateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrgServiceServer).Authenticate(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/controller.api.services.v1.OrgService/Authenticate",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrgServiceServer).Authenticate(ctx, req.(*AuthenticateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _OrgService_Deauthenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeauthenticateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrgServiceServer).Deauthenticate(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/controller.api.services.v1.OrgService/Deauthenticate",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrgServiceServer).Deauthenticate(ctx, req.(*DeauthenticateRequest))
}
return interceptor(ctx, in, info, handler)
}
var _OrgService_serviceDesc = grpc.ServiceDesc{
ServiceName: "controller.api.services.v1.OrgService",
HandlerType: (*OrgServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetOrg",
Handler: _OrgService_GetOrg_Handler,
},
{
MethodName: "ListOrgs",
Handler: _OrgService_ListOrgs_Handler,
},
{
MethodName: "Authenticate",
Handler: _OrgService_Authenticate_Handler,
},
{
MethodName: "Deauthenticate",
Handler: _OrgService_Deauthenticate_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "controller/api/services/v1/org_service.proto",
}
@@ -1,5 +1,5 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: controller/api/services/v1/organization_service.proto
// source: controller/api/services/v1/org_service.proto
/*
Package services is a reverse proxy.
@@ -32,11 +32,11 @@ var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var (
filter_OrganizationService_GetOrganization_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
filter_OrgService_GetOrg_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_OrganizationService_GetOrganization_0(ctx context.Context, marshaler runtime.Marshaler, client OrganizationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetOrganizationRequest
func request_OrgService_GetOrg_0(ctx context.Context, marshaler runtime.Marshaler, client OrgServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetOrgRequest
var metadata runtime.ServerMetadata
var (
@@ -60,17 +60,17 @@ func request_OrganizationService_GetOrganization_0(ctx context.Context, marshale
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrganizationService_GetOrganization_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrgService_GetOrg_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetOrganization(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.GetOrg(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_OrganizationService_GetOrganization_0(ctx context.Context, marshaler runtime.Marshaler, server OrganizationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetOrganizationRequest
func local_request_OrgService_GetOrg_0(ctx context.Context, marshaler runtime.Marshaler, server OrgServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetOrgRequest
var metadata runtime.ServerMetadata
var (
@@ -94,52 +94,52 @@ func local_request_OrganizationService_GetOrganization_0(ctx context.Context, ma
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrganizationService_GetOrganization_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrgService_GetOrg_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetOrganization(ctx, &protoReq)
msg, err := server.GetOrg(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_OrganizationService_ListOrganizations_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
filter_OrgService_ListOrgs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_OrganizationService_ListOrganizations_0(ctx context.Context, marshaler runtime.Marshaler, client OrganizationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListOrganizationsRequest
func request_OrgService_ListOrgs_0(ctx context.Context, marshaler runtime.Marshaler, client OrgServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListOrgsRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrganizationService_ListOrganizations_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrgService_ListOrgs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ListOrganizations(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.ListOrgs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_OrganizationService_ListOrganizations_0(ctx context.Context, marshaler runtime.Marshaler, server OrganizationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListOrganizationsRequest
func local_request_OrgService_ListOrgs_0(ctx context.Context, marshaler runtime.Marshaler, server OrgServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListOrgsRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrganizationService_ListOrganizations_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrgService_ListOrgs_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ListOrganizations(ctx, &protoReq)
msg, err := server.ListOrgs(ctx, &protoReq)
return msg, metadata, err
}
func request_OrganizationService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client OrganizationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func request_OrgService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client OrgServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AuthenticateRequest
var metadata runtime.ServerMetadata
@@ -174,7 +174,7 @@ func request_OrganizationService_Authenticate_0(ctx context.Context, marshaler r
}
func local_request_OrganizationService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server OrganizationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func local_request_OrgService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server OrgServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AuthenticateRequest
var metadata runtime.ServerMetadata
@@ -209,7 +209,7 @@ func local_request_OrganizationService_Authenticate_0(ctx context.Context, marsh
}
func request_OrganizationService_Deauthenticate_0(ctx context.Context, marshaler runtime.Marshaler, client OrganizationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func request_OrgService_Deauthenticate_0(ctx context.Context, marshaler runtime.Marshaler, client OrgServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DeauthenticateRequest
var metadata runtime.ServerMetadata
@@ -236,7 +236,7 @@ func request_OrganizationService_Deauthenticate_0(ctx context.Context, marshaler
}
func local_request_OrganizationService_Deauthenticate_0(ctx context.Context, marshaler runtime.Marshaler, server OrganizationServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func local_request_OrgService_Deauthenticate_0(ctx context.Context, marshaler runtime.Marshaler, server OrgServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DeauthenticateRequest
var metadata runtime.ServerMetadata
@@ -263,12 +263,12 @@ func local_request_OrganizationService_Deauthenticate_0(ctx context.Context, mar
}
// RegisterOrganizationServiceHandlerServer registers the http handlers for service OrganizationService to "mux".
// UnaryRPC :call OrganizationServiceServer directly.
// RegisterOrgServiceHandlerServer registers the http handlers for service OrgService to "mux".
// UnaryRPC :call OrgServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterOrganizationServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server OrganizationServiceServer) error {
func RegisterOrgServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server OrgServiceServer) error {
mux.Handle("GET", pattern_OrganizationService_GetOrganization_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_OrgService_GetOrg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -277,18 +277,18 @@ func RegisterOrganizationServiceHandlerServer(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_OrganizationService_GetOrganization_0(rctx, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_OrgService_GetOrg_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_GetOrganization_0(ctx, mux, outboundMarshaler, w, req, response_OrganizationService_GetOrganization_0{resp}, mux.GetForwardResponseOptions()...)
forward_OrgService_GetOrg_0(ctx, mux, outboundMarshaler, w, req, response_OrgService_GetOrg_0{resp}, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_OrganizationService_ListOrganizations_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_OrgService_ListOrgs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -297,18 +297,18 @@ func RegisterOrganizationServiceHandlerServer(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_OrganizationService_ListOrganizations_0(rctx, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_OrgService_ListOrgs_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_ListOrganizations_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_OrgService_ListOrgs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_OrganizationService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_OrgService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -317,18 +317,18 @@ func RegisterOrganizationServiceHandlerServer(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_OrganizationService_Authenticate_0(rctx, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_OrgService_Authenticate_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_OrganizationService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...)
forward_OrgService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_OrgService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_OrganizationService_Deauthenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_OrgService_Deauthenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -337,23 +337,23 @@ func RegisterOrganizationServiceHandlerServer(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_OrganizationService_Deauthenticate_0(rctx, inboundMarshaler, server, req, pathParams)
resp, md, err := local_request_OrgService_Deauthenticate_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_Deauthenticate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_OrgService_Deauthenticate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterOrganizationServiceHandlerFromEndpoint is same as RegisterOrganizationServiceHandler but
// RegisterOrgServiceHandlerFromEndpoint is same as RegisterOrgServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterOrganizationServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
func RegisterOrgServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
@@ -373,23 +373,23 @@ func RegisterOrganizationServiceHandlerFromEndpoint(ctx context.Context, mux *ru
}()
}()
return RegisterOrganizationServiceHandler(ctx, mux, conn)
return RegisterOrgServiceHandler(ctx, mux, conn)
}
// RegisterOrganizationServiceHandler registers the http handlers for service OrganizationService to "mux".
// RegisterOrgServiceHandler registers the http handlers for service OrgService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterOrganizationServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterOrganizationServiceHandlerClient(ctx, mux, NewOrganizationServiceClient(conn))
func RegisterOrgServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterOrgServiceHandlerClient(ctx, mux, NewOrgServiceClient(conn))
}
// RegisterOrganizationServiceHandlerClient registers the http handlers for service OrganizationService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "OrganizationServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "OrganizationServiceClient"
// RegisterOrgServiceHandlerClient registers the http handlers for service OrgService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "OrgServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "OrgServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "OrganizationServiceClient" to call the correct interceptors.
func RegisterOrganizationServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client OrganizationServiceClient) error {
// "OrgServiceClient" to call the correct interceptors.
func RegisterOrgServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client OrgServiceClient) error {
mux.Handle("GET", pattern_OrganizationService_GetOrganization_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_OrgService_GetOrg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -398,18 +398,18 @@ func RegisterOrganizationServiceHandlerClient(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_OrganizationService_GetOrganization_0(rctx, inboundMarshaler, client, req, pathParams)
resp, md, err := request_OrgService_GetOrg_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_GetOrganization_0(ctx, mux, outboundMarshaler, w, req, response_OrganizationService_GetOrganization_0{resp}, mux.GetForwardResponseOptions()...)
forward_OrgService_GetOrg_0(ctx, mux, outboundMarshaler, w, req, response_OrgService_GetOrg_0{resp}, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_OrganizationService_ListOrganizations_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("GET", pattern_OrgService_ListOrgs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -418,18 +418,18 @@ func RegisterOrganizationServiceHandlerClient(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_OrganizationService_ListOrganizations_0(rctx, inboundMarshaler, client, req, pathParams)
resp, md, err := request_OrgService_ListOrgs_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_ListOrganizations_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_OrgService_ListOrgs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_OrganizationService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_OrgService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -438,18 +438,18 @@ func RegisterOrganizationServiceHandlerClient(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_OrganizationService_Authenticate_0(rctx, inboundMarshaler, client, req, pathParams)
resp, md, err := request_OrgService_Authenticate_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_OrganizationService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...)
forward_OrgService_Authenticate_0(ctx, mux, outboundMarshaler, w, req, response_OrgService_Authenticate_0{resp}, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_OrganizationService_Deauthenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle("POST", pattern_OrgService_Deauthenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -458,54 +458,54 @@ func RegisterOrganizationServiceHandlerClient(ctx context.Context, mux *runtime.
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_OrganizationService_Deauthenticate_0(rctx, inboundMarshaler, client, req, pathParams)
resp, md, err := request_OrgService_Deauthenticate_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_OrganizationService_Deauthenticate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_OrgService_Deauthenticate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
type response_OrganizationService_GetOrganization_0 struct {
type response_OrgService_GetOrg_0 struct {
proto.Message
}
func (m response_OrganizationService_GetOrganization_0) XXX_ResponseBody() interface{} {
response := m.Message.(*GetOrganizationResponse)
func (m response_OrgService_GetOrg_0) XXX_ResponseBody() interface{} {
response := m.Message.(*GetOrgResponse)
return response.Item
}
type response_OrganizationService_Authenticate_0 struct {
type response_OrgService_Authenticate_0 struct {
proto.Message
}
func (m response_OrganizationService_Authenticate_0) XXX_ResponseBody() interface{} {
func (m response_OrgService_Authenticate_0) XXX_ResponseBody() interface{} {
response := m.Message.(*AuthenticateResponse)
return response.Item
}
var (
pattern_OrganizationService_GetOrganization_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "orgs", "id"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_OrgService_GetOrg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "orgs", "id"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_OrganizationService_ListOrganizations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "orgs"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_OrgService_ListOrgs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "orgs"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_OrganizationService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "orgs", "org_id"}, "authenticate", runtime.AssumeColonVerbOpt(true)))
pattern_OrgService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "orgs", "org_id"}, "authenticate", runtime.AssumeColonVerbOpt(true)))
pattern_OrganizationService_Deauthenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "orgs", "org_id"}, "deauthenticate", runtime.AssumeColonVerbOpt(true)))
pattern_OrgService_Deauthenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "orgs", "org_id"}, "deauthenticate", runtime.AssumeColonVerbOpt(true)))
)
var (
forward_OrganizationService_GetOrganization_0 = runtime.ForwardResponseMessage
forward_OrgService_GetOrg_0 = runtime.ForwardResponseMessage
forward_OrganizationService_ListOrganizations_0 = runtime.ForwardResponseMessage
forward_OrgService_ListOrgs_0 = runtime.ForwardResponseMessage
forward_OrganizationService_Authenticate_0 = runtime.ForwardResponseMessage
forward_OrgService_Authenticate_0 = runtime.ForwardResponseMessage
forward_OrganizationService_Deauthenticate_0 = runtime.ForwardResponseMessage
forward_OrgService_Deauthenticate_0 = runtime.ForwardResponseMessage
)
File diff suppressed because it is too large. Load diff
@@ -938,22 +938,22 @@ type ProjectServiceClient interface {
// ListProjects returns a list of stored projects which exist inside the org
// referenced inside the request. The request must include the org id for
// the projects being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListProjects(ctx context.Context, in *ListProjectsRequest, opts ...grpc.CallOption) (*ListProjectsResponse, error)
// CreateProject creates and stores a project in watchtower. The provided
// request must include the org id in which the project will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another project in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another project in the same org, an error is returned.
CreateProject(ctx context.Context, in *CreateProjectRequest, opts ...grpc.CallOption) (*CreateProjectResponse, error)
// UpdateProject updates an existing project in watchtower. The provided
// project must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided project. An error is returned if either the organization
// in the provided project. An error is returned if either the org
// or project ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateProject(ctx context.Context, in *UpdateProjectRequest, opts ...grpc.CallOption) (*UpdateProjectResponse, error)
// DeleteProject remotes a project and all child resources from Watchtower.
// If the provided org or project ids are malformed or not provided an error
@@ -1026,22 +1026,22 @@ type ProjectServiceServer interface {
// ListProjects returns a list of stored projects which exist inside the org
// referenced inside the request. The request must include the org id for
// the projects being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListProjects(context.Context, *ListProjectsRequest) (*ListProjectsResponse, error)
// CreateProject creates and stores a project in watchtower. The provided
// request must include the org id in which the project will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another project in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another project in the same org, an error is returned.
CreateProject(context.Context, *CreateProjectRequest) (*CreateProjectResponse, error)
// UpdateProject updates an existing project in watchtower. The provided
// project must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided project. An error is returned if either the organization
// in the provided project. An error is returned if either the org
// or project ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateProject(context.Context, *UpdateProjectRequest) (*UpdateProjectResponse, error)
// DeleteProject remotes a project and all child resources from Watchtower.
// If the provided org or project ids are malformed or not provided an error
@@ -2210,22 +2210,22 @@ type RoleServiceClient interface {
// ListRoles returns a list of stored roles which exist inside the org
// referenced inside the request. The request must include the org id for
// the roles being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error)
// CreateRole creates and stores a role in watchtower. The provided
// request must include the org id in which the role will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another role in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another role in the same org, an error is returned.
CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*CreateRoleResponse, error)
// UpdateRole updates an existing role in watchtower. The provided
// role must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided role. An error is returned if either the organization
// in the provided role. An error is returned if either the org
// or role ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*UpdateRoleResponse, error)
// DeleteRole removes a role from Watchtower. If the provided org or role ids
// are malformed or not provided an error is returned. No error is returned
@@ -2235,36 +2235,36 @@ type RoleServiceClient interface {
DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*DeleteRoleResponse, error)
// AddRolePrincipals adds users and/or groups to a role. The provided request must include
// the org id and the role id which the users and/or groups will be added to. If the
// org id is missing, malformed or references a non existing organization,
// org id is missing, malformed or references a non existing org,
// an error is returned.
AddRolePrincipals(ctx context.Context, in *AddRolePrincipalsRequest, opts ...grpc.CallOption) (*AddRolePrincipalsResponse, error)
// SetRolePrincipals sets the role's users and/or groups. Any existing principals on
// the role are deleted if they are not included in this request. The provided
// request must include the org id and the role id which the users and/or groups
// will be set to. If the org id is missing, malformed or references a non
// existing organization, an error is returned.
// existing org, an error is returned.
SetRolePrincipals(ctx context.Context, in *SetRolePrincipalsRequest, opts ...grpc.CallOption) (*SetRolePrincipalsResponse, error)
// RemoveRolePrincipals removes the users and/or groups from the specified role.
// The provided request must include the org id and the role id which the users
// and/or groups will be removed from. If the org id is missing, malformed or references a non
// existing organization, an error is returned. It is not an error to have duplicate
// existing org, an error is returned. It is not an error to have duplicate
// user/group ids.
RemoveRolePrincipals(ctx context.Context, in *RemoveRolePrincipalsRequest, opts ...grpc.CallOption) (*RemoveRolePrincipalsResponse, error)
// AddRoleGrants adds grants to a role. The provided request must include
// the org id and the role id which the grants will be added to. If the
// org id is missing, malformed or references a non existing organization,
// org id is missing, malformed or references a non existing org,
// an error is returned. It is not an error to have duplicate grants.
AddRoleGrants(ctx context.Context, in *AddRoleGrantsRequest, opts ...grpc.CallOption) (*AddRoleGrantsResponse, error)
// SetRoleGrants sets the role's grants. Any existing grants on the role are
// deleted if they are not included in this request. The provided request must
// include the org id and the role id which the grants will be set to. If the
// org id is missing, malformed or references a non existing organization, an
// org id is missing, malformed or references a non existing org, an
// error is returned. It is not an error to have duplicate grants.
SetRoleGrants(ctx context.Context, in *SetRoleGrantsRequest, opts ...grpc.CallOption) (*SetRoleGrantsResponse, error)
// RemoveRoleGrants removes the users and/or groups from the specified role.
// The provided request must include the org id and the role id which the users
// and/or groups will be removed from. If the org id is missing, malformed or references a non
// existing organization, an error is returned. It is not an error to have duplicate
// existing org, an error is returned. It is not an error to have duplicate
// user/group ids.
RemoveRoleGrants(ctx context.Context, in *RemoveRoleGrantsRequest, opts ...grpc.CallOption) (*RemoveRoleGrantsResponse, error)
}
@@ -2386,22 +2386,22 @@ type RoleServiceServer interface {
// ListRoles returns a list of stored roles which exist inside the org
// referenced inside the request. The request must include the org id for
// the roles being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error)
// CreateRole creates and stores a role in watchtower. The provided
// request must include the org id in which the role will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another role in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another role in the same org, an error is returned.
CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error)
// UpdateRole updates an existing role in watchtower. The provided
// role must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided role. An error is returned if either the organization
// in the provided role. An error is returned if either the org
// or role ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error)
// DeleteRole removes a role from Watchtower. If the provided org or role ids
// are malformed or not provided an error is returned. No error is returned
@@ -2411,36 +2411,36 @@ type RoleServiceServer interface {
DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error)
// AddRolePrincipals adds users and/or groups to a role. The provided request must include
// the org id and the role id which the users and/or groups will be added to. If the
// org id is missing, malformed or references a non existing organization,
// org id is missing, malformed or references a non existing org,
// an error is returned.
AddRolePrincipals(context.Context, *AddRolePrincipalsRequest) (*AddRolePrincipalsResponse, error)
// SetRolePrincipals sets the role's users and/or groups. Any existing principals on
// the role are deleted if they are not included in this request. The provided
// request must include the org id and the role id which the users and/or groups
// will be set to. If the org id is missing, malformed or references a non
// existing organization, an error is returned.
// existing org, an error is returned.
SetRolePrincipals(context.Context, *SetRolePrincipalsRequest) (*SetRolePrincipalsResponse, error)
// RemoveRolePrincipals removes the users and/or groups from the specified role.
// The provided request must include the org id and the role id which the users
// and/or groups will be removed from. If the org id is missing, malformed or references a non
// existing organization, an error is returned. It is not an error to have duplicate
// existing org, an error is returned. It is not an error to have duplicate
// user/group ids.
RemoveRolePrincipals(context.Context, *RemoveRolePrincipalsRequest) (*RemoveRolePrincipalsResponse, error)
// AddRoleGrants adds grants to a role. The provided request must include
// the org id and the role id which the grants will be added to. If the
// org id is missing, malformed or references a non existing organization,
// org id is missing, malformed or references a non existing org,
// an error is returned. It is not an error to have duplicate grants.
AddRoleGrants(context.Context, *AddRoleGrantsRequest) (*AddRoleGrantsResponse, error)
// SetRoleGrants sets the role's grants. Any existing grants on the role are
// deleted if they are not included in this request. The provided request must
// include the org id and the role id which the grants will be set to. If the
// org id is missing, malformed or references a non existing organization, an
// org id is missing, malformed or references a non existing org, an
// error is returned. It is not an error to have duplicate grants.
SetRoleGrants(context.Context, *SetRoleGrantsRequest) (*SetRoleGrantsResponse, error)
// RemoveRoleGrants removes the users and/or groups from the specified role.
// The provided request must include the org id and the role id which the users
// and/or groups will be removed from. If the org id is missing, malformed or references a non
// existing organization, an error is returned. It is not an error to have duplicate
// existing org, an error is returned. It is not an error to have duplicate
// user/group ids.
RemoveRoleGrants(context.Context, *RemoveRoleGrantsRequest) (*RemoveRoleGrantsResponse, error)
}
@@ -929,22 +929,22 @@ type UserServiceClient interface {
// ListUsers returns a list of stored users which exist inside the org
// referenced inside the request. The request must include the org id for
// the users being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error)
// CreateUser creates and stores a user in watchtower. The provided
// request must include the org id in which the user will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another user in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another user in the same org, an error is returned.
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error)
// UpdateUser updates an existing user in watchtower. The provided
// user must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided user. An error is returned if either the organization
// in the provided user. An error is returned if either the org
// or user ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error)
// DeleteUser removes a user from Watchtower. If the provided org or user ids
// are malformed or not provided an error is returned. No error is returned
@@ -1017,22 +1017,22 @@ type UserServiceServer interface {
// ListUsers returns a list of stored users which exist inside the org
// referenced inside the request. The request must include the org id for
// the users being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error)
// CreateUser creates and stores a user in watchtower. The provided
// request must include the org id in which the user will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another user in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another user in the same org, an error is returned.
CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
// UpdateUser updates an existing user in watchtower. The provided
// user must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided user. An error is returned if either the organization
// in the provided user. An error is returned if either the org
// or user ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error)
// DeleteUser removes a user from Watchtower. If the provided org or user ids
// are malformed or not provided an error is returned. No error is returned
+1 -1
View File
@@ -48,7 +48,7 @@ func (a *AuthAccount) VetForWrite(ctx context.Context, r db.Reader, opType db.Op
}
func (a *AuthAccount) validScopeTypes() []scope.Type {
return []scope.Type{scope.Organization}
return []scope.Type{scope.Org}
}
// GetScope returns the scope for the auth account.
+1 -1
View File
@@ -1,3 +1,3 @@
// iam package is for identity access management of watchtower. It includes typical
// iam resources like Organizations, Projects, Users, Groups, etc.
// iam resources like Orgs, Projects, Users, Groups, etc.
package iam
+3 -3
View File
@@ -12,7 +12,7 @@ import (
"google.golang.org/protobuf/proto"
)
// Group is made up of principals which are scoped to an organization.
// Group is made up of principals which are scoped to an org.
type Group struct {
*store.Group
tableName string `gorm:"-"`
@@ -23,7 +23,7 @@ var _ Resource = (*Group)(nil)
var _ Clonable = (*Group)(nil)
var _ db.VetForWriter = (*Group)(nil)
// NewGroup creates a new in memory group with a scope (project/organization)
// NewGroup creates a new in memory group with a scope (project/org)
// and allowed options include: withDescripion, WithName.
func NewGroup(scopeId string, opt ...Option) (*Group, error) {
if scopeId == "" {
@@ -67,7 +67,7 @@ func (g *Group) VetForWrite(ctx context.Context, r db.Reader, opType db.OpType,
}
func (u *Group) validScopeTypes() []scope.Type {
return []scope.Type{scope.Organization, scope.Project}
return []scope.Type{scope.Org, scope.Project}
}
// GetScope returns the scope for the Group.
+2 -2
View File
@@ -29,9 +29,9 @@ func Test_PublicIds(t *testing.T) {
assert.True(t, strings.HasPrefix(id, GroupPrefix+"_"))
})
t.Run("scopes", func(t *testing.T) {
id, err := newScopeId(scope.Organization)
id, err := newScopeId(scope.Org)
require.NoError(t, err)
assert.True(t, strings.HasPrefix(id, scope.Organization.Prefix()))
assert.True(t, strings.HasPrefix(id, scope.Org.Prefix()))
id, err = newScopeId(scope.Project)
require.NoError(t, err)
+1 -1
View File
@@ -18,7 +18,7 @@ func Test_GetOpts(t *testing.T) {
})
t.Run("withScope", func(t *testing.T) {
assert := assert.New(t)
s, err := NewOrganization()
s, err := NewOrg()
assert.NoError(err)
assert.NotNil(s.Scope)
+1 -1
View File
@@ -193,7 +193,7 @@ func (r *Repository) stdMetadata(ctx context.Context, resource Resource) (oplog.
}
}
switch newScope.Type {
case scope.Organization.String():
case scope.Org.String():
return oplog.Metadata{
"resource-public-id": []string{resource.GetPublicId()},
"scope-id": []string{newScope.PublicId},
+1 -1
View File
@@ -78,7 +78,7 @@ func (r *Repository) UpdateGroup(ctx context.Context, group *Group, fieldMaskPat
resource, rowsUpdated, err := r.update(ctx, g, dbMask, nullFields)
if err != nil {
if db.IsUniqueError(err) {
return nil, db.NoRowsAffected, fmt.Errorf("update group: group %s already exists in organization %s: %w", group.Name, group.ScopeId, db.ErrNotUnique)
return nil, db.NoRowsAffected, fmt.Errorf("update group: group %s already exists in org %s: %w", group.Name, group.ScopeId, db.ErrNotUnique)
}
return nil, db.NoRowsAffected, fmt.Errorf("update group: %w for %s", err, group.PublicId)
}
+1 -1
View File
@@ -377,7 +377,7 @@ func TestRepository_UpdateGroup(t *testing.T) {
newScopeId: org.PublicId,
wantErr: true,
wantDup: true,
wantErrMsg: " already exists in organization " + org.PublicId,
wantErrMsg: " already exists in org " + org.PublicId,
wantIsError: db.ErrNotUnique,
},
{
+1 -1
View File
@@ -80,7 +80,7 @@ func (r *Repository) UpdateRole(ctx context.Context, role *Role, fieldMaskPaths
resource, rowsUpdated, err := r.update(ctx, c, dbMask, nullFields)
if err != nil {
if db.IsUniqueError(err) {
return nil, db.NoRowsAffected, fmt.Errorf("update role: role %s already exists in organization %s: %w", role.Name, role.ScopeId, db.ErrNotUnique)
return nil, db.NoRowsAffected, fmt.Errorf("update role: role %s already exists in org %s: %w", role.Name, role.ScopeId, db.ErrNotUnique)
}
return nil, db.NoRowsAffected, fmt.Errorf("update role: %w for %s", err, c.PublicId)
}
+1 -1
View File
@@ -374,7 +374,7 @@ func TestRepository_UpdateRole(t *testing.T) {
newScopeId: org.PublicId,
wantErr: true,
wantDup: true,
wantErrMsg: " already exists in organization " + org.PublicId,
wantErrMsg: " already exists in org " + org.PublicId,
wantIsError: db.ErrNotUnique,
},
}
+11 -11
View File
@@ -131,25 +131,25 @@ func (r *Repository) DeleteScope(ctx context.Context, withPublicId string, opt .
return rowsDeleted, nil
}
// ListProjects in an organization and supports the WithLimit option.
func (r *Repository) ListProjects(ctx context.Context, withOrganizationId string, opt ...Option) ([]*Scope, error) {
if withOrganizationId == "" {
return nil, fmt.Errorf("list projects: missing organization id %w", db.ErrInvalidParameter)
// ListProjects in an org and supports the WithLimit option.
func (r *Repository) ListProjects(ctx context.Context, withOrgId string, opt ...Option) ([]*Scope, error) {
if withOrgId == "" {
return nil, fmt.Errorf("list projects: missing org id %w", db.ErrInvalidParameter)
}
var projects []*Scope
err := r.list(ctx, &projects, "parent_id = ? and type = ?", []interface{}{withOrganizationId, scope.Project.String()}, opt...)
err := r.list(ctx, &projects, "parent_id = ? and type = ?", []interface{}{withOrgId, scope.Project.String()}, opt...)
if err != nil {
return nil, fmt.Errorf("list projects: %w", err)
}
return projects, nil
}
// ListOrganizations and supports the WithLimit option.
func (r *Repository) ListOrganizations(ctx context.Context, opt ...Option) ([]*Scope, error) {
var organizations []*Scope
err := r.list(ctx, &organizations, "parent_id = ? and type = ?", []interface{}{"global", scope.Organization.String()}, opt...)
// ListOrgs and supports the WithLimit option.
func (r *Repository) ListOrgs(ctx context.Context, opt ...Option) ([]*Scope, error) {
var orgs []*Scope
err := r.list(ctx, &orgs, "parent_id = ? and type = ?", []interface{}{"global", scope.Org.String()}, opt...)
if err != nil {
return nil, fmt.Errorf("list organizations: %w", err)
return nil, fmt.Errorf("list orgs: %w", err)
}
return organizations, nil
return orgs, nil
}
+18 -18
View File
@@ -28,7 +28,7 @@ func Test_Repository_Scope_Create(t *testing.T) {
require.NoError(err)
id := testId(t)
s, err := NewOrganization(WithName(id))
s, err := NewOrg(WithName(id))
require.NoError(err)
s, err = repo.CreateScope(context.Background(), s)
require.NoError(err)
@@ -49,9 +49,9 @@ func Test_Repository_Scope_Create(t *testing.T) {
wrapper := db.TestWrapper(t)
repo, err := NewRepository(rw, rw, wrapper)
require.NoError(err)
publicId, err := newScopeId(scope.Organization)
publicId, err := newScopeId(scope.Org)
require.NoError(err)
s, err := NewOrganization()
s, err := NewOrg()
require.NoError(err)
s, err = repo.CreateScope(context.Background(), s, WithPublicId(publicId))
require.NoError(err)
@@ -72,7 +72,7 @@ func Test_Repository_Scope_Create(t *testing.T) {
require.NoError(err)
id := testId(t)
s, err := NewOrganization(WithName(id))
s, err := NewOrg(WithName(id))
require.NoError(err)
s, err = repo.CreateScope(context.Background(), s)
require.NoError(err)
@@ -80,7 +80,7 @@ func Test_Repository_Scope_Create(t *testing.T) {
assert.NotEmpty(s.GetPublicId())
assert.Equal(s.GetName(), id)
s2, err := NewOrganization(WithName(id))
s2, err := NewOrg(WithName(id))
require.NoError(err)
s2, err = repo.CreateScope(context.Background(), s2)
require.Error(err)
@@ -94,7 +94,7 @@ func Test_Repository_Scope_Create(t *testing.T) {
require.NoError(err)
id := testId(t)
s, err := NewOrganization(WithName(id))
s, err := NewOrg(WithName(id))
require.NoError(err)
s, err = repo.CreateScope(context.Background(), s)
require.NoError(err)
@@ -473,8 +473,8 @@ func Test_Repository_ListProjects(t *testing.T) {
org := testOrg(t, conn, "", "")
type args struct {
withOrganizationId string
opt []Option
withOrgId string
opt []Option
}
tests := []struct {
name string
@@ -487,8 +487,8 @@ func Test_Repository_ListProjects(t *testing.T) {
name: "no-limit",
createCnt: repo.defaultLimit + 1,
args: args{
withOrganizationId: org.PublicId,
opt: []Option{WithLimit(-1)},
withOrgId: org.PublicId,
opt: []Option{WithLimit(-1)},
},
wantCnt: repo.defaultLimit + 1,
wantErr: false,
@@ -497,7 +497,7 @@ func Test_Repository_ListProjects(t *testing.T) {
name: "default-limit",
createCnt: repo.defaultLimit + 1,
args: args{
withOrganizationId: org.PublicId,
withOrgId: org.PublicId,
},
wantCnt: repo.defaultLimit,
wantErr: false,
@@ -506,8 +506,8 @@ func Test_Repository_ListProjects(t *testing.T) {
name: "custom-limit",
createCnt: repo.defaultLimit + 1,
args: args{
withOrganizationId: org.PublicId,
opt: []Option{WithLimit(3)},
withOrgId: org.PublicId,
opt: []Option{WithLimit(3)},
},
wantCnt: 3,
wantErr: false,
@@ -516,7 +516,7 @@ func Test_Repository_ListProjects(t *testing.T) {
name: "bad-org",
createCnt: 1,
args: args{
withOrganizationId: "bad-id",
withOrgId: "bad-id",
},
wantCnt: 0,
wantErr: false,
@@ -531,7 +531,7 @@ func Test_Repository_ListProjects(t *testing.T) {
testProjects = append(testProjects, testProject(t, conn, org.PublicId))
}
assert.Equal(tt.createCnt, len(testProjects))
got, err := repo.ListProjects(context.Background(), tt.args.withOrganizationId, tt.args.opt...)
got, err := repo.ListProjects(context.Background(), tt.args.withOrgId, tt.args.opt...)
if tt.wantErr {
require.Error(err)
return
@@ -542,7 +542,7 @@ func Test_Repository_ListProjects(t *testing.T) {
}
}
func Test_Repository_ListOrganizations(t *testing.T) {
func Test_Repository_ListOrgs(t *testing.T) {
t.Parallel()
conn, _ := db.TestSetup(t, "postgres")
const testLimit = 10
@@ -589,13 +589,13 @@ func Test_Repository_ListOrganizations(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
require.NoError(conn.Where("type = 'organization'").Delete(allocScope()).Error)
require.NoError(conn.Where("type = 'org'").Delete(allocScope()).Error)
testOrgs := []*Scope{}
for i := 0; i < tt.createCnt; i++ {
testOrgs = append(testOrgs, testOrg(t, conn, "", ""))
}
assert.Equal(tt.createCnt, len(testOrgs))
got, err := repo.ListOrganizations(context.Background(), tt.args.opt...)
got, err := repo.ListOrgs(context.Background(), tt.args.opt...)
if tt.wantErr {
require.Error(err)
return
+2 -2
View File
@@ -110,9 +110,9 @@ func Test_Repository_create(t *testing.T) {
require.NoError(err)
id := testId(t)
s, err := NewOrganization(WithName("fname-" + id))
s, err := NewOrg(WithName("fname-" + id))
assert.NoError(err)
s.PublicId, err = newScopeId(scope.Organization)
s.PublicId, err = newScopeId(scope.Org)
require.NoError(err)
retScope, err := repo.create(context.Background(), s)
require.NoError(err)
+8 -8
View File
@@ -28,7 +28,7 @@ func (r *Repository) CreateUser(ctx context.Context, user *User, opt ...Option)
resource, err := r.create(ctx, u.(*User))
if err != nil {
if db.IsUniqueError(err) {
return nil, fmt.Errorf("create user: user %s already exists in organization %s", user.Name, user.ScopeId)
return nil, fmt.Errorf("create user: user %s already exists in org %s", user.Name, user.ScopeId)
}
return nil, fmt.Errorf("create user: %w for %s", err, u.(*User).PublicId)
}
@@ -71,7 +71,7 @@ func (r *Repository) UpdateUser(ctx context.Context, user *User, fieldMaskPaths
resource, rowsUpdated, err := r.update(ctx, u.(*User), dbMask, nullFields, opt...)
if err != nil {
if db.IsUniqueError(err) {
return nil, db.NoRowsAffected, fmt.Errorf("update user: user %s already exists in organization %s", user.Name, user.ScopeId)
return nil, db.NoRowsAffected, fmt.Errorf("update user: user %s already exists in org %s", user.Name, user.ScopeId)
}
return nil, db.NoRowsAffected, fmt.Errorf("update user: %w for %s", err, user.PublicId)
}
@@ -110,13 +110,13 @@ func (r *Repository) DeleteUser(ctx context.Context, withPublicId string, opt ..
return rowsDeleted, nil
}
// ListUsers in an organization and supports the WithLimit option.
func (r *Repository) ListUsers(ctx context.Context, withOrganizationId string, opt ...Option) ([]*User, error) {
if withOrganizationId == "" {
return nil, fmt.Errorf("list users: missing organization id %w", db.ErrInvalidParameter)
// ListUsers in an org and supports the WithLimit option.
func (r *Repository) ListUsers(ctx context.Context, withOrgId string, opt ...Option) ([]*User, error) {
if withOrgId == "" {
return nil, fmt.Errorf("list users: missing org id %w", db.ErrInvalidParameter)
}
var users []*User
err := r.list(ctx, &users, "scope_id = ?", []interface{}{withOrganizationId}, opt...)
err := r.list(ctx, &users, "scope_id = ?", []interface{}{withOrgId}, opt...)
if err != nil {
return nil, fmt.Errorf("list users: %w", err)
}
@@ -155,7 +155,7 @@ func (r *Repository) LookupUserWithLogin(ctx context.Context, withAuthAccountId
metadata := oplog.Metadata{
"resource-public-id": []string{withAuthAccountId},
"scope-id": []string{acct.ScopeId},
"scope-type": []string{scope.Organization.String()},
"scope-type": []string{scope.Org.String()},
"resource-type": []string{"auth-account"},
}
+11 -11
View File
@@ -71,7 +71,7 @@ func TestRepository_CreateUser(t *testing.T) {
},
wantDup: true,
wantErr: true,
wantErrMsg: "create user: user %s already exists in organization %s",
wantErrMsg: "create user: user %s already exists in org %s",
},
}
for _, tt := range tests {
@@ -279,7 +279,7 @@ func TestRepository_UpdateUser(t *testing.T) {
},
wantErr: true,
wantDup: true,
wantErrMsg: `update user: user %s already exists in organization %s`,
wantErrMsg: `update user: user %s already exists in org %s`,
},
{
name: "modified-scope",
@@ -461,8 +461,8 @@ func TestRepository_ListUsers(t *testing.T) {
org, _ := TestScopes(t, conn)
type args struct {
withOrganizationId string
opt []Option
withOrgId string
opt []Option
}
tests := []struct {
name string
@@ -475,8 +475,8 @@ func TestRepository_ListUsers(t *testing.T) {
name: "no-limit",
createCnt: repo.defaultLimit + 1,
args: args{
withOrganizationId: org.PublicId,
opt: []Option{WithLimit(-1)},
withOrgId: org.PublicId,
opt: []Option{WithLimit(-1)},
},
wantCnt: repo.defaultLimit + 1,
wantErr: false,
@@ -485,7 +485,7 @@ func TestRepository_ListUsers(t *testing.T) {
name: "default-limit",
createCnt: repo.defaultLimit + 1,
args: args{
withOrganizationId: org.PublicId,
withOrgId: org.PublicId,
},
wantCnt: repo.defaultLimit,
wantErr: false,
@@ -494,8 +494,8 @@ func TestRepository_ListUsers(t *testing.T) {
name: "custom-limit",
createCnt: repo.defaultLimit + 1,
args: args{
withOrganizationId: org.PublicId,
opt: []Option{WithLimit(3)},
withOrgId: org.PublicId,
opt: []Option{WithLimit(3)},
},
wantCnt: 3,
wantErr: false,
@@ -504,7 +504,7 @@ func TestRepository_ListUsers(t *testing.T) {
name: "bad-org",
createCnt: 1,
args: args{
withOrganizationId: "bad-id",
withOrgId: "bad-id",
},
wantCnt: 0,
wantErr: false,
@@ -519,7 +519,7 @@ func TestRepository_ListUsers(t *testing.T) {
testUsers = append(testUsers, TestUser(t, conn, org.PublicId))
}
assert.Equal(tt.createCnt, len(testUsers))
got, err := repo.ListUsers(context.Background(), tt.args.withOrganizationId, tt.args.opt...)
got, err := repo.ListUsers(context.Background(), tt.args.withOrgId, tt.args.opt...)
if tt.wantErr {
require.Error(err)
return
+2 -2
View File
@@ -24,7 +24,7 @@ var _ Resource = (*Role)(nil)
var _ Clonable = (*Role)(nil)
var _ db.VetForWriter = (*Role)(nil)
// NewRole creates a new in memory role with a scope (project/organization)
// NewRole creates a new in memory role with a scope (project/org)
// allowed options include: withDescripion, WithName, withGrantScopeId.
func NewRole(scopeId string, opt ...Option) (*Role, error) {
if scopeId == "" {
@@ -68,7 +68,7 @@ func (role *Role) VetForWrite(ctx context.Context, r db.Reader, opType db.OpType
}
func (u *Role) validScopeTypes() []scope.Type {
return []scope.Type{scope.Organization, scope.Project}
return []scope.Type{scope.Org, scope.Project}
}
// Getscope returns the scope for the Role.
+15 -15
View File
@@ -14,7 +14,7 @@ import (
)
// Scope is used to create a hierarchy of "containers" that encompass the scope of
// an IAM resource. Scopes are Global, Organizations and Projects.
// an IAM resource. Scopes are Global, Orgs and Projects.
type Scope struct {
*store.Scope
@@ -28,16 +28,16 @@ var _ Resource = (*Scope)(nil)
var _ db.VetForWriter = (*Scope)(nil)
var _ Clonable = (*Scope)(nil)
func NewOrganization(opt ...Option) (*Scope, error) {
func NewOrg(opt ...Option) (*Scope, error) {
global := allocScope()
global.PublicId = "global"
opt = append(opt, withScope(&global))
return newScope(scope.Organization, opt...)
return newScope(scope.Org, opt...)
}
func NewProject(organizationPublicId string, opt ...Option) (*Scope, error) {
func NewProject(orgPublicId string, opt ...Option) (*Scope, error) {
org := allocScope()
org.PublicId = organizationPublicId
org.PublicId = orgPublicId
opt = append(opt, withScope(&org))
p, err := newScope(scope.Project, opt...)
if err != nil {
@@ -119,23 +119,23 @@ func (s *Scope) VetForWrite(ctx context.Context, r db.Reader, opType db.OpType,
return errors.New("global scope cannot be created")
case s.ParentId == "":
switch s.Type {
case scope.Organization.String():
return errors.New("organization must have global parent")
case scope.Org.String():
return errors.New("org must have global parent")
case scope.Project.String():
return errors.New("project has no organization")
return errors.New("project has no org")
}
case s.Type == scope.Organization.String():
case s.Type == scope.Org.String():
if s.ParentId != "global" {
return errors.New(`organization's parent must be "global"`)
return errors.New(`org's parent must be "global"`)
}
case s.Type == scope.Project.String():
parentScope := allocScope()
parentScope.PublicId = s.ParentId
if err := r.LookupByPublicId(ctx, &parentScope, opt...); err != nil {
return fmt.Errorf("unable to verify project's organization scope: %w", err)
return fmt.Errorf("unable to verify project's org scope: %w", err)
}
if parentScope.Type != scope.Organization.String() {
return errors.New("project parent scope is not an organization")
if parentScope.Type != scope.Org.String() {
return errors.New("project parent scope is not an org")
}
}
}
@@ -147,8 +147,8 @@ func (s *Scope) ResourceType() resource.Type {
switch s.Type {
case scope.Global.String():
return resource.Global
case scope.Organization.String():
return resource.Organization
case scope.Org.String():
return resource.Org
case scope.Project.String():
return resource.Project
default:
+11 -11
View File
@@ -21,10 +21,10 @@ func TestScope_New(t *testing.T) {
t.Run("valid-org-with-project", func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
w := db.New(conn)
s, err := NewOrganization()
s, err := NewOrg()
require.NoError(err)
require.NotNil(s.Scope)
s.PublicId, err = newScopeId(scope.Organization)
s.PublicId, err = newScopeId(scope.Org)
require.NoError(err)
err = w.Create(context.Background(), s)
require.NoError(err)
@@ -58,10 +58,10 @@ func TestScope_Create(t *testing.T) {
t.Run("valid", func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
w := db.New(conn)
s, err := NewOrganization()
s, err := NewOrg()
require.NoError(err)
require.NotNil(s.Scope)
s.PublicId, err = newScopeId(scope.Organization)
s.PublicId, err = newScopeId(scope.Org)
require.NoError(err)
err = w.Create(context.Background(), s)
require.NoError(err)
@@ -70,10 +70,10 @@ func TestScope_Create(t *testing.T) {
t.Run("valid-with-parent", func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
w := db.New(conn)
s, err := NewOrganization()
s, err := NewOrg()
require.NoError(err)
require.NotNil(s.Scope)
s.PublicId, err = newScopeId(scope.Organization)
s.PublicId, err = newScopeId(scope.Org)
require.NoError(err)
err = w.Create(context.Background(), s)
require.NoError(err)
@@ -85,7 +85,7 @@ func TestScope_Create(t *testing.T) {
require.NotNil(project.Scope)
assert.Equal(project.Scope.ParentId, s.PublicId)
assert.Equal(project.GetDescription(), id)
project.PublicId, err = newScopeId(scope.Organization)
project.PublicId, err = newScopeId(scope.Org)
require.NoError(err)
err = w.Create(context.Background(), project)
@@ -165,9 +165,9 @@ func TestScope_Actions(t *testing.T) {
}
func TestScope_ResourceType(t *testing.T) {
o, err := NewOrganization()
o, err := NewOrg()
require.NoError(t, err)
assert.Equal(t, o.ResourceType(), resource.Organization)
assert.Equal(t, o.ResourceType(), resource.Org)
assert.Equal(t, o.GetParentId(), resource.Global.String())
}
@@ -202,7 +202,7 @@ func TestScope_GlobalErrors(t *testing.T) {
require.Error(t, err)
// Should fail as there's no scope
_, err = newScope(scope.Organization)
_, err = newScope(scope.Org)
require.Error(t, err)
assert.True(t, strings.Contains(err.Error(), "missing its parent"))
})
@@ -218,7 +218,7 @@ func TestScope_GlobalErrors(t *testing.T) {
t.Run("check org parent at vet time", func(t *testing.T) {
// Org must have global parent
s := allocScope()
s.Type = scope.Organization.String()
s.Type = scope.Org.String()
s.PublicId = "o_1234"
s.ParentId = "global"
err := s.VetForWrite(context.Background(), nil, db.CreateOp)
+3 -3
View File
@@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
)
// TestScopes creates an organization and project suitable for testing.
// TestScopes creates an org and project suitable for testing.
func TestScopes(t *testing.T, conn *gorm.DB) (org *Scope, prj *Scope) {
t.Helper()
require := require.New(t)
@@ -22,7 +22,7 @@ func TestScopes(t *testing.T, conn *gorm.DB) (org *Scope, prj *Scope) {
repo, err := NewRepository(rw, rw, wrapper)
require.NoError(err)
org, err = NewOrganization()
org, err = NewOrg()
require.NoError(err)
org, err = repo.CreateScope(context.Background(), org)
require.NoError(err)
@@ -47,7 +47,7 @@ func testOrg(t *testing.T, conn *gorm.DB, name, description string) (org *Scope)
repo, err := NewRepository(rw, rw, wrapper)
require.NoError(err)
o, err := NewOrganization(WithDescription(description), WithName(name))
o, err := NewOrg(WithDescription(description), WithName(name))
require.NoError(err)
o, err = repo.CreateScope(context.Background(), o)
require.NoError(err)
+2 -2
View File
@@ -12,7 +12,7 @@ import (
"google.golang.org/protobuf/proto"
)
// User defines watchtower users which are scoped to an Organization
// User defines watchtower users which are scoped to an Org
type User struct {
*store.User
tableName string `gorm:"-"`
@@ -68,7 +68,7 @@ func (u *User) VetForWrite(ctx context.Context, r db.Reader, opType db.OpType, o
}
func (u *User) validScopeTypes() []scope.Type {
return []scope.Type{scope.Organization}
return []scope.Type{scope.Org}
}
// GetScope returns the scope for the User
+6 -6
View File
@@ -20,8 +20,8 @@ func TestNewUser(t *testing.T) {
id := testId(t)
type args struct {
organizationPublicId string
opt []Option
orgPublicId string
opt []Option
}
tests := []struct {
name string
@@ -34,8 +34,8 @@ func TestNewUser(t *testing.T) {
{
name: "valid",
args: args{
organizationPublicId: org.PublicId,
opt: []Option{WithName(id), WithDescription(id)},
orgPublicId: org.PublicId,
opt: []Option{WithName(id), WithDescription(id)},
},
wantErr: false,
wantName: id,
@@ -44,7 +44,7 @@ func TestNewUser(t *testing.T) {
{
name: "valid-with-no-name",
args: args{
organizationPublicId: org.PublicId,
orgPublicId: org.PublicId,
},
wantErr: false,
},
@@ -60,7 +60,7 @@ func TestNewUser(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
got, err := NewUser(tt.args.organizationPublicId, tt.args.opt...)
got, err := NewUser(tt.args.orgPublicId, tt.args.opt...)
if tt.wantErr {
require.Error(err)
assert.Equal(tt.wantErrMsg, err.Error())
+2 -2
View File
@@ -214,8 +214,8 @@ func Parse(scopeId, userId, grantString string) (Grant, error) {
switch {
case scopeId == "global":
grant.scope.Type = scope.Global
case strings.HasPrefix(scopeId, scope.Organization.Prefix()):
grant.scope.Type = scope.Organization
case strings.HasPrefix(scopeId, scope.Org.Prefix()):
grant.scope.Type = scope.Org
case strings.HasPrefix(scopeId, scope.Project.Prefix()):
grant.scope.Type = scope.Project
default:
+5 -5
View File
@@ -147,7 +147,7 @@ func Test_MarshallingAndCloning(t *testing.T) {
name: "empty",
input: Grant{
scope: Scope{
Type: scope.Organization,
Type: scope.Org,
},
},
jsonOutput: `{}`,
@@ -364,7 +364,7 @@ func Test_Parse(t *testing.T) {
expected: Grant{
scope: Scope{
Id: "o_scope",
Type: scope.Organization,
Type: scope.Org,
},
id: "foobar",
typ: resource.HostCatalog,
@@ -380,7 +380,7 @@ func Test_Parse(t *testing.T) {
expected: Grant{
scope: Scope{
Id: "o_scope",
Type: scope.Organization,
Type: scope.Org,
},
id: "foobar",
typ: resource.HostCatalog,
@@ -414,7 +414,7 @@ func Test_Parse(t *testing.T) {
expected: Grant{
scope: Scope{
Id: "o_1234",
Type: scope.Organization,
Type: scope.Org,
},
id: "foobar",
typ: resource.HostCatalog,
@@ -454,7 +454,7 @@ func Test_Parse(t *testing.T) {
expected: Grant{
scope: Scope{
Id: "o_scope",
Type: scope.Organization,
Type: scope.Org,
},
id: "u_abcd1234",
actions: map[action.Type]bool{
@@ -31,8 +31,8 @@ message Role {
google.protobuf.BoolValue disabled = 6;
// The scope the grants will apply to. If the role is at the global scope,
// this can be an organization or project. If the role is at an organization
// scope, this can be a project within the organization. It is invalid for
// this can be an org or project. If the role is at an org
// scope, this can be a project within the org. It is invalid for
// this to be anything other than the role's scope when the role's scope is
// a project.
google.protobuf.StringValue grant_scope_id = 7 [json_name="grant_scope_id"];
@@ -7,9 +7,9 @@ option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
// Organization contains all fields related to an Organization resource
message Organization {
// The ID of the Organization
// Org contains all fields related to an Org resource
message Org {
// The ID of the Org
// Output only.
string id = 1;
@@ -32,7 +32,7 @@ service GroupService {
// ListGroups returns a list of stored groups which exist inside the org
// referenced inside the request. The request must include the org id for
// the groups being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
rpc ListGroups(ListGroupsRequest) returns (ListGroupsResponse) {
option (google.api.http) = {
get: "/v1/orgs/{org_id}/groups"
@@ -48,8 +48,8 @@ service GroupService {
// CreateGroup creates and stores a group in watchtower. The provided
// request must include the org id in which the group will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another group in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another group in the same org, an error is returned.
rpc CreateGroup(CreateGroupRequest) returns (CreateGroupResponse) {
option (google.api.http) = {
post: "/v1/orgs/{org_id}/groups"
@@ -70,10 +70,10 @@ service GroupService {
// group must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided group. An error is returned if either the organization
// in the provided group. An error is returned if either the org
// or group ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
rpc UpdateGroup(UpdateGroupRequest) returns (UpdateGroupResponse) {
option (google.api.http) = {
patch: "/v1/orgs/{org_id}/groups/{id}"
@@ -6,31 +6,31 @@ option go_package = "github.com/hashicorp/watchtower/internal/gen/controller/api
import "protoc-gen-swagger/options/annotations.proto";
import "google/api/annotations.proto";
import "controller/api/resources/scopes/v1/organization.proto";
import "controller/api/resources/scopes/v1/org.proto";
import "controller/api/resources/authtokens/v1/authtoken.proto";
service OrganizationService {
service OrgService {
// GetOrganization returns a stored Organization if present. The provided request
// must include the org id for the organization being retrieved. If
// GetOrg returns a stored Org if present. The provided request
// must include the org id for the org being retrieved. If
// that id is missing, malformed or reference a non existing resource an error is returned.
rpc GetOrganization(GetOrganizationRequest) returns (GetOrganizationResponse) {
rpc GetOrg(GetOrgRequest) returns (GetOrgResponse) {
option (google.api.http) = {
get: "/v1/orgs/{id}"
response_body: "item"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary: "Gets a single Organization"
summary: "Gets a single Org"
};
}
// ListOrganizations returns a list of stored organizations which exist in watchtower.
rpc ListOrganizations(ListOrganizationsRequest) returns (ListOrganizationsResponse) {
// ListOrgs returns a list of stored orgs which exist in watchtower.
rpc ListOrgs(ListOrgsRequest) returns (ListOrgsResponse) {
option (google.api.http) = {
get: "/v1/orgs"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary: "Lists all Organizations"
summary: "Lists all Orgs"
};
}
@@ -42,7 +42,7 @@ service OrganizationService {
response_body: "item"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary: "Authenticate a user to an Organization and retrieve an authentication token."
summary: "Authenticate a user to an Org and retrieve an authentication token."
};
}
@@ -52,26 +52,26 @@ service OrganizationService {
post: "/v1/orgs/{org_id}:deauthenticate"
};
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary: "Deauthenticate an authentication token from an Organization."
summary: "Deauthenticate an authentication token from an Org."
};
}
}
message GetOrganizationRequest {
message GetOrgRequest {
string id = 1;
string view = 2;
}
message GetOrganizationResponse {
resources.scopes.v1.Organization item = 1;
message GetOrgResponse {
resources.scopes.v1.Org item = 1;
}
message ListOrganizationsRequest {
message ListOrgsRequest {
string view = 1;
}
message ListOrganizationsResponse {
repeated resources.scopes.v1.Organization items = 1;
message ListOrgsResponse {
repeated resources.scopes.v1.Org items = 1;
}
message PasswordCredential {
@@ -28,7 +28,7 @@ service ProjectService {
// ListProjects returns a list of stored projects which exist inside the org
// referenced inside the request. The request must include the org id for
// the projects being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) {
option (google.api.http) = {
get: "/v1/orgs/{org_id}/projects"
@@ -41,8 +41,8 @@ service ProjectService {
// CreateProject creates and stores a project in watchtower. The provided
// request must include the org id in which the project will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another project in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another project in the same org, an error is returned.
rpc CreateProject(CreateProjectRequest) returns (CreateProjectResponse) {
option (google.api.http) = {
post: "/v1/orgs/{org_id}/projects"
@@ -58,10 +58,10 @@ service ProjectService {
// project must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided project. An error is returned if either the organization
// in the provided project. An error is returned if either the org
// or project ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
rpc UpdateProject(UpdateProjectRequest) returns (UpdateProjectResponse) {
option (google.api.http) = {
patch: "/v1/orgs/{org_id}/projects/{id}"
@@ -33,7 +33,7 @@ service RoleService {
// ListRoles returns a list of stored roles which exist inside the org
// referenced inside the request. The request must include the org id for
// the roles being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
rpc ListRoles(ListRolesRequest) returns (ListRolesResponse) {
option (google.api.http) = {
get: "/v1/orgs/{org_id}/roles"
@@ -49,8 +49,8 @@ service RoleService {
// CreateRole creates and stores a role in watchtower. The provided
// request must include the org id in which the role will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another role in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another role in the same org, an error is returned.
rpc CreateRole(CreateRoleRequest) returns (CreateRoleResponse) {
option (google.api.http) = {
post: "/v1/orgs/{org_id}/roles"
@@ -71,10 +71,10 @@ service RoleService {
// role must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided role. An error is returned if either the organization
// in the provided role. An error is returned if either the org
// or role ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
rpc UpdateRole(UpdateRoleRequest) returns (UpdateRoleResponse) {
option (google.api.http) = {
patch: "/v1/orgs/{org_id}/roles/{id}"
@@ -110,7 +110,7 @@ service RoleService {
// AddRolePrincipals adds users and/or groups to a role. The provided request must include
// the org id and the role id which the users and/or groups will be added to. If the
// org id is missing, malformed or references a non existing organization,
// org id is missing, malformed or references a non existing org,
// an error is returned.
rpc AddRolePrincipals(AddRolePrincipalsRequest) returns (AddRolePrincipalsResponse) {
option (google.api.http) = {
@@ -132,7 +132,7 @@ service RoleService {
// the role are deleted if they are not included in this request. The provided
// request must include the org id and the role id which the users and/or groups
// will be set to. If the org id is missing, malformed or references a non
// existing organization, an error is returned.
// existing org, an error is returned.
rpc SetRolePrincipals(SetRolePrincipalsRequest) returns (SetRolePrincipalsResponse) {
option (google.api.http) = {
post: "/v1/orgs/{org_id}/roles/{role_id}:set-principals"
@@ -152,7 +152,7 @@ service RoleService {
// RemoveRolePrincipals removes the users and/or groups from the specified role.
// The provided request must include the org id and the role id which the users
// and/or groups will be removed from. If the org id is missing, malformed or references a non
// existing organization, an error is returned. It is not an error to have duplicate
// existing org, an error is returned. It is not an error to have duplicate
// user/group ids.
rpc RemoveRolePrincipals(RemoveRolePrincipalsRequest) returns (RemoveRolePrincipalsResponse) {
option (google.api.http) = {
@@ -172,7 +172,7 @@ service RoleService {
// AddRoleGrants adds grants to a role. The provided request must include
// the org id and the role id which the grants will be added to. If the
// org id is missing, malformed or references a non existing organization,
// org id is missing, malformed or references a non existing org,
// an error is returned. It is not an error to have duplicate grants.
rpc AddRoleGrants(AddRoleGrantsRequest) returns (AddRoleGrantsResponse) {
option (google.api.http) = {
@@ -193,7 +193,7 @@ service RoleService {
// SetRoleGrants sets the role's grants. Any existing grants on the role are
// deleted if they are not included in this request. The provided request must
// include the org id and the role id which the grants will be set to. If the
// org id is missing, malformed or references a non existing organization, an
// org id is missing, malformed or references a non existing org, an
// error is returned. It is not an error to have duplicate grants.
rpc SetRoleGrants(SetRoleGrantsRequest) returns (SetRoleGrantsResponse) {
option (google.api.http) = {
@@ -214,7 +214,7 @@ service RoleService {
// RemoveRoleGrants removes the users and/or groups from the specified role.
// The provided request must include the org id and the role id which the users
// and/or groups will be removed from. If the org id is missing, malformed or references a non
// existing organization, an error is returned. It is not an error to have duplicate
// existing org, an error is returned. It is not an error to have duplicate
// user/group ids.
rpc RemoveRoleGrants(RemoveRoleGrantsRequest) returns (RemoveRoleGrantsResponse) {
option (google.api.http) = {
@@ -28,7 +28,7 @@ service UserService {
// ListUsers returns a list of stored users which exist inside the org
// referenced inside the request. The request must include the org id for
// the users being retrieved. If the org id is missing, malformed, or
// reference a non existing organization, an error is returned.
// reference a non existing org, an error is returned.
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {
option (google.api.http) = {
get: "/v1/orgs/{org_id}/users"
@@ -41,8 +41,8 @@ service UserService {
// CreateUser creates and stores a user in watchtower. The provided
// request must include the org id in which the user will be created.
// If the org id is missing, malformed or references a non existing
// organization, an error is returned. If a name is provided that is in
// use in another user in the same organization, an error is returned.
// org, an error is returned. If a name is provided that is in
// use in another user in the same org, an error is returned.
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) {
option (google.api.http) = {
post: "/v1/orgs/{org_id}/users"
@@ -58,10 +58,10 @@ service UserService {
// user must not have any read only fields set. The update mask must be
// included in the request and contain at least 1 mutable field. To unset
// a field's value, include the field in the update mask and don't set it
// in the provided user. An error is returned if either the organization
// in the provided user. An error is returned if either the org
// or user ids are missing or reference a non existing resource. An error
// is also returned if the request attempts to update the name to one that is
// already in use in this organization.
// already in use in this org.
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) {
option (google.api.http) = {
patch: "/v1/orgs/{org_id}/users/{id}"
+5 -5
View File
@@ -20,7 +20,7 @@ import (
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/host_catalogs"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/host_sets"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/hosts"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/organizations"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/orgs"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/projects"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/roles"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/users"
@@ -69,12 +69,12 @@ func handleGrpcGateway(c *Controller) (http.Handler, error) {
if err := services.RegisterHostServiceHandlerServer(ctx, mux, &hosts.Service{}); err != nil {
return nil, fmt.Errorf("failed to register host service handler: %w", err)
}
os, err := organizations.NewService(c.IamRepoFn)
os, err := orgs.NewService(c.IamRepoFn)
if err != nil {
return nil, fmt.Errorf("failed to create organization handler service: %w", err)
return nil, fmt.Errorf("failed to create org handler service: %w", err)
}
if err := services.RegisterOrganizationServiceHandlerServer(ctx, mux, os); err != nil {
return nil, fmt.Errorf("failed to register organization service handler: %w", err)
if err := services.RegisterOrgServiceHandlerServer(ctx, mux, os); err != nil {
return nil, fmt.Errorf("failed to register org service handler: %w", err)
}
ps, err := projects.NewService(c.IamRepoFn)
if err != nil {
@@ -79,7 +79,7 @@ const (
// if !authorizer.isAuthorized(amd.UserId, "ReadResource", req.GetId()) { return nil, UnauthorizedError }
// ...
//
// A new token will be created by the Authenticate method on an Organization. The token value will be returned
// A new token will be created by the Authenticate method on an Org. The token value will be returned
// through json and not be intercepted by these tools.
// TODO: Intercept the outgoing Authenticate/Deauthenticate response and manipulate
// the response if the token type was cookie.
@@ -18,13 +18,13 @@ import (
"github.com/stretchr/testify/require"
)
// Any generated service would do, but using organization since the path is the shortest for testing.
// Any generated service would do, but using orgs since the path is the shortest for testing.
type fakeHandler struct {
pbs.UnimplementedOrganizationServiceServer
pbs.UnimplementedOrgServiceServer
validateFn func(context.Context)
}
func (s *fakeHandler) GetOrganization(ctx context.Context, _ *pbs.GetOrganizationRequest) (*pbs.GetOrganizationResponse, error) {
func (s *fakeHandler) GetOrg(ctx context.Context, _ *pbs.GetOrgRequest) (*pbs.GetOrgResponse, error) {
s.validateFn(ctx)
return nil, errors.New("Doesn't matter this is just for testing input.")
}
@@ -177,7 +177,7 @@ func TestAuthTokenAuthenticator(t *testing.T) {
assert.Equal(t, tc.wantAuthTokMd, tMD)
}}
mux := runtime.NewServeMux(runtime.WithMetadata(TokenAuthenticator(hclog.L(), repoFn)))
require.NoError(t, services.RegisterOrganizationServiceHandlerServer(context.Background(), mux, hook))
require.NoError(t, services.RegisterOrgServiceHandlerServer(context.Background(), mux, hook))
req := httptest.NewRequest("GET", "http://127.0.0.1/v1/orgs/1", nil)
for k, v := range tc.headers {
@@ -364,9 +364,9 @@ type ancestorProvider interface {
// validateAncestors verifies that the ancestors of this call are properly set and provided.
func validateAncestors(r ancestorProvider) map[string]string {
if r.GetOrgId() == "" {
return map[string]string{orgIdFieldName: "Missing organization id."}
return map[string]string{orgIdFieldName: "Missing org id."}
}
if !validId(r.GetOrgId(), scope.Organization.Prefix()+"_") {
if !validId(r.GetOrgId(), scope.Org.Prefix()+"_") {
return map[string]string{orgIdFieldName: "Improperly formatted identifier."}
}
if r.GetProjectId() != "" && !validId(r.GetProjectId(), scope.Project.Prefix()+"_") {
@@ -181,14 +181,14 @@ func TestList(t *testing.T) {
},
{
name: "Invalid Org Id",
req: &pbs.ListGroupsRequest{OrgId: scope.Organization.Prefix() + "_this is invalid"},
req: &pbs.ListGroupsRequest{OrgId: scope.Org.Prefix() + "_this is invalid"},
res: nil,
errCode: codes.InvalidArgument,
},
// TODO: When an org doesn't exist, we should return a 404 instead of an empty list.
{
name: "Unfound Org",
req: &pbs.ListGroupsRequest{OrgId: scope.Organization.Prefix() + "_DoesntExis"},
req: &pbs.ListGroupsRequest{OrgId: scope.Org.Prefix() + "_DoesntExis"},
res: &pbs.ListGroupsResponse{},
errCode: codes.OK,
},
@@ -399,7 +399,7 @@ func validateAncestors(r ancestorProvider) map[string]string {
return badFields
}
if !validId(r.GetOrgId(), scope.Organization.Prefix()+"_") {
if !validId(r.GetOrgId(), scope.Org.Prefix()+"_") {
badFields[orgIdFieldName] = "The field is incorrectly formatted."
}
if !validId(r.GetProjectId(), scope.Project.Prefix()+"_") {
@@ -1,4 +1,4 @@
package organizations
package orgs
import (
"context"
@@ -23,12 +23,12 @@ var (
reInvalidID = regexp.MustCompile("[^A-Za-z0-9]")
)
// Service handles request as described by the pbs.OrganizationServiceServer interface.
// Service handles request as described by the pbs.OrgServiceServer interface.
type Service struct {
repo common.IamRepoFactory
}
// NewService returns an organization service which handles organization related requests to watchtower.
// NewService returns an org service which handles org related requests to watchtower.
func NewService(repo common.IamRepoFactory) (Service, error) {
if repo == nil {
return Service{}, fmt.Errorf("nil iam repository provided")
@@ -36,21 +36,21 @@ func NewService(repo common.IamRepoFactory) (Service, error) {
return Service{repo: repo}, nil
}
var _ pbs.OrganizationServiceServer = Service{}
var _ pbs.OrgServiceServer = Service{}
// ListOrganizations is not yet implemented but will implement the interface pbs.OrganizationServiceServer.
func (s Service) ListOrganizations(ctx context.Context, req *pbs.ListOrganizationsRequest) (*pbs.ListOrganizationsResponse, error) {
// ListOrgs is not yet implemented but will implement the interface pbs.OrgServiceServer.
func (s Service) ListOrgs(ctx context.Context, req *pbs.ListOrgsRequest) (*pbs.ListOrgsResponse, error) {
auth := handlers.ToTokenMetadata(ctx)
_ = auth
ol, err := s.listFromRepo(ctx)
if err != nil {
return nil, err
}
return &pbs.ListOrganizationsResponse{Items: ol}, nil
return &pbs.ListOrgsResponse{Items: ol}, nil
}
// GetOrganizations implements the interface pbs.OrganizationServiceServer.
func (s Service) GetOrganization(ctx context.Context, req *pbs.GetOrganizationRequest) (*pbs.GetOrganizationResponse, error) {
// GetOrgs implements the interface pbs.OrgServiceServer.
func (s Service) GetOrg(ctx context.Context, req *pbs.GetOrgRequest) (*pbs.GetOrgResponse, error) {
auth := handlers.ToTokenMetadata(ctx)
_ = auth
if err := validateGetRequest(req); err != nil {
@@ -60,20 +60,20 @@ func (s Service) GetOrganization(ctx context.Context, req *pbs.GetOrganizationRe
if err != nil {
return nil, err
}
return &pbs.GetOrganizationResponse{Item: o}, nil
return &pbs.GetOrgResponse{Item: o}, nil
}
// Authenticate implements the interface pbs.OrganizationServiceServer.
// Authenticate implements the interface pbs.OrgServiceServer.
func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest) (*pbs.AuthenticateResponse, error) {
return nil, status.Error(codes.Unimplemented, "Requested method is unimplemented for Organization.")
return nil, status.Error(codes.Unimplemented, "Requested method is unimplemented for Orgs.")
}
// Deauthenticate implements the interface pbs.OrganizationServiceServer.
// Deauthenticate implements the interface pbs.OrgServiceServer.
func (s Service) Deauthenticate(ctx context.Context, req *pbs.DeauthenticateRequest) (*pbs.DeauthenticateResponse, error) {
return nil, status.Error(codes.Unimplemented, "Requested method is unimplemented for Organization.")
return nil, status.Error(codes.Unimplemented, "Requested method is unimplemented for Orgs.")
}
func (s Service) getFromRepo(ctx context.Context, id string) (*pb.Organization, error) {
func (s Service) getFromRepo(ctx context.Context, id string) (*pb.Org, error) {
repo, err := s.repo()
if err != nil {
return nil, err
@@ -83,29 +83,29 @@ func (s Service) getFromRepo(ctx context.Context, id string) (*pb.Organization,
return nil, err
}
if p == nil {
return nil, handlers.NotFoundErrorf("Organization %q doesn't exist.", id)
return nil, handlers.NotFoundErrorf("Org %q doesn't exist.", id)
}
return toProto(p), nil
}
func (s Service) listFromRepo(ctx context.Context) ([]*pb.Organization, error) {
func (s Service) listFromRepo(ctx context.Context) ([]*pb.Org, error) {
repo, err := s.repo()
if err != nil {
return nil, err
}
ol, err := repo.ListOrganizations(ctx)
ol, err := repo.ListOrgs(ctx)
if err != nil {
return nil, err
}
var outOl []*pb.Organization
var outOl []*pb.Org
for _, o := range ol {
outOl = append(outOl, toProto(o))
}
return outOl, nil
}
func toProto(in *iam.Scope) *pb.Organization {
out := pb.Organization{
func toProto(in *iam.Scope) *pb.Org {
out := pb.Org{
Id: in.GetPublicId(),
CreatedTime: in.GetCreateTime().GetTimestamp(),
UpdatedTime: in.GetUpdateTime().GetTimestamp(),
@@ -124,10 +124,10 @@ func toProto(in *iam.Scope) *pb.Organization {
// * The path passed in is correctly formatted
// * All required parameters are set
// * There are no conflicting parameters provided
func validateGetRequest(req *pbs.GetOrganizationRequest) error {
func validateGetRequest(req *pbs.GetOrgRequest) error {
badFields := make(map[string]string)
if !validId(req.GetId(), scope.Organization.Prefix()+"_") {
badFields["id"] = "Invalid formatted organization id."
if !validId(req.GetId(), scope.Org.Prefix()+"_") {
badFields["id"] = "Invalid formatted org id."
}
if len(badFields) > 0 {
return handlers.InvalidArgumentErrorf("Improperly formatted identifier.", badFields)
@@ -1,4 +1,4 @@
package organizations_test
package orgs_test
import (
"context"
@@ -9,7 +9,7 @@ import (
pb "github.com/hashicorp/watchtower/internal/gen/controller/api/resources/scopes"
pbs "github.com/hashicorp/watchtower/internal/gen/controller/api/services"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/organizations"
"github.com/hashicorp/watchtower/internal/servers/controller/handlers/orgs"
"github.com/hashicorp/watchtower/internal/types/scope"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/require"
)
func createDefaultOrganizationAndRepo(t *testing.T) (*iam.Scope, func() (*iam.Repository, error)) {
func createDefaultOrgAndRepo(t *testing.T) (*iam.Scope, func() (*iam.Repository, error)) {
t.Helper()
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
@@ -43,12 +43,12 @@ func createDefaultOrganizationAndRepo(t *testing.T) (*iam.Scope, func() (*iam.Re
func TestGet(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
org, repo := createDefaultOrganizationAndRepo(t)
toMerge := &pbs.GetOrganizationRequest{
org, repo := createDefaultOrgAndRepo(t)
toMerge := &pbs.GetOrgRequest{
Id: org.GetPublicId(),
}
pOrganization := &pb.Organization{
pOrg := &pb.Org{
Id: org.GetPublicId(),
Name: &wrapperspb.StringValue{Value: org.GetName()},
Description: &wrapperspb.StringValue{Value: org.GetDescription()},
@@ -58,46 +58,46 @@ func TestGet(t *testing.T) {
cases := []struct {
name string
req *pbs.GetOrganizationRequest
res *pbs.GetOrganizationResponse
req *pbs.GetOrgRequest
res *pbs.GetOrgResponse
errCode codes.Code
}{
{
name: "Get an Existing organization",
req: &pbs.GetOrganizationRequest{Id: org.GetPublicId()},
res: &pbs.GetOrganizationResponse{Item: pOrganization},
name: "Get an Existing org",
req: &pbs.GetOrgRequest{Id: org.GetPublicId()},
res: &pbs.GetOrgResponse{Item: pOrg},
errCode: codes.OK,
},
{
name: "Get a non existing organization",
req: &pbs.GetOrganizationRequest{Id: scope.Organization.Prefix() + "_DoesntExis"},
name: "Get a non existing org",
req: &pbs.GetOrgRequest{Id: scope.Org.Prefix() + "_DoesntExis"},
res: nil,
errCode: codes.NotFound,
},
{
name: "Wrong id prefix",
req: &pbs.GetOrganizationRequest{Id: "j_1234567890"},
req: &pbs.GetOrgRequest{Id: "j_1234567890"},
res: nil,
errCode: codes.InvalidArgument,
},
{
name: "space in id",
req: &pbs.GetOrganizationRequest{Id: scope.Organization.Prefix() + "_1 23456789"},
req: &pbs.GetOrgRequest{Id: scope.Org.Prefix() + "_1 23456789"},
res: nil,
errCode: codes.InvalidArgument,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
req := proto.Clone(toMerge).(*pbs.GetOrganizationRequest)
req := proto.Clone(toMerge).(*pbs.GetOrgRequest)
proto.Merge(req, tc.req)
s, err := organizations.NewService(repo)
s, err := orgs.NewService(repo)
require.NoError(err, "Couldn't create new project service.")
got, gErr := s.GetOrganization(context.Background(), req)
assert.Equal(tc.errCode, status.Code(gErr), "GetOrganization(%+v) got error %v, wanted %v", req, gErr, tc.errCode)
assert.True(proto.Equal(got, tc.res), "GetOrganization(%q) got response %q, wanted %q", req, got, tc.res)
got, gErr := s.GetOrg(context.Background(), req)
assert.Equal(tc.errCode, status.Code(gErr), "GetOrg(%+v) got error %v, wanted %v", req, gErr, tc.errCode)
assert.True(proto.Equal(got, tc.res), "GetOrg(%q) got response %q, wanted %q", req, got, tc.res)
})
}
}
@@ -111,19 +111,19 @@ func TestList(t *testing.T) {
return iam.NewRepository(rw, rw, wrap)
}
s, err := organizations.NewService(repoFn)
s, err := orgs.NewService(repoFn)
require.NoError(err)
ctx := context.Background()
resp, err := s.ListOrganizations(ctx, &pbs.ListOrganizationsRequest{})
resp, err := s.ListOrgs(ctx, &pbs.ListOrgsRequest{})
assert.NoError(err)
assert.Equal(&pbs.ListOrganizationsResponse{}, resp)
assert.Equal(&pbs.ListOrgsResponse{}, resp)
var orgs []*pb.Organization
var orgs []*pb.Org
for i := 0; i < 10; i++ {
o, _ := iam.TestScopes(t, conn)
orgs = append(orgs, &pb.Organization{Id: o.PublicId, CreatedTime: o.GetCreateTime().GetTimestamp(), UpdatedTime: o.GetUpdateTime().GetTimestamp()})
orgs = append(orgs, &pb.Org{Id: o.PublicId, CreatedTime: o.GetCreateTime().GetTimestamp(), UpdatedTime: o.GetUpdateTime().GetTimestamp()})
}
resp, err = s.ListOrganizations(ctx, &pbs.ListOrganizationsRequest{})
resp, err = s.ListOrgs(ctx, &pbs.ListOrgsRequest{})
assert.NoError(err)
assert.Empty(cmp.Diff(resp, &pbs.ListOrganizationsResponse{Items: orgs}, protocmp.Transform(), protocmp.SortRepeatedFields(&pbs.ListOrganizationsResponse{}, "items")))
assert.Empty(cmp.Diff(resp, &pbs.ListOrgsResponse{Items: orgs}, protocmp.Transform(), protocmp.SortRepeatedFields(&pbs.ListOrgsResponse{}, "items")))
}
@@ -352,9 +352,9 @@ type ancestorProvider interface {
// validateAncestors verifies that the ancestors of this call are properly set and provided.
func validateAncestors(r ancestorProvider) map[string]string {
if r.GetOrgId() == "" {
return map[string]string{orgIdFieldName: "Missing organization id."}
return map[string]string{orgIdFieldName: "Missing org id."}
}
if !validId(r.GetOrgId(), scope.Organization.Prefix()+"_") {
if !validId(r.GetOrgId(), scope.Org.Prefix()+"_") {
return map[string]string{orgIdFieldName: "Improperly formatted identifier."}
}
return map[string]string{}
@@ -157,14 +157,14 @@ func TestList(t *testing.T) {
},
{
name: "Invalid Org Id",
req: &pbs.ListProjectsRequest{OrgId: scope.Organization.Prefix() + "_this is invalid"},
req: &pbs.ListProjectsRequest{OrgId: scope.Org.Prefix() + "_this is invalid"},
res: nil,
errCode: codes.InvalidArgument,
},
// TODO: When an org doesn't exist, we should return a 404 instead of an empty list.
{
name: "Unfound Org",
req: &pbs.ListProjectsRequest{OrgId: scope.Organization.Prefix() + "_DoesntExis"},
req: &pbs.ListProjectsRequest{OrgId: scope.Org.Prefix() + "_DoesntExis"},
res: &pbs.ListProjectsResponse{},
errCode: codes.OK,
},
@@ -717,9 +717,9 @@ type ancestorProvider interface {
// validateAncestors verifies that the ancestors of this call are properly set and provided.
func validateAncestors(r ancestorProvider) map[string]string {
if r.GetOrgId() == "" {
return map[string]string{orgIdFieldName: "Missing organization id."}
return map[string]string{orgIdFieldName: "Missing org id."}
}
if !validId(r.GetOrgId(), scope.Organization.Prefix()+"_") {
if !validId(r.GetOrgId(), scope.Org.Prefix()+"_") {
return map[string]string{orgIdFieldName: "Improperly formatted identifier."}
}
if r.GetProjectId() != "" && !validId(r.GetProjectId(), scope.Project.Prefix()+"_") {
@@ -188,14 +188,14 @@ func TestList(t *testing.T) {
},
{
name: "Invalid Org Id",
req: &pbs.ListRolesRequest{OrgId: scope.Organization.Prefix() + "_this is invalid"},
req: &pbs.ListRolesRequest{OrgId: scope.Org.Prefix() + "_this is invalid"},
res: nil,
errCode: codes.InvalidArgument,
},
// TODO: When an org doesn't exist, we should return a 404 instead of an empty list.
{
name: "Unfound Org",
req: &pbs.ListRolesRequest{OrgId: scope.Organization.Prefix() + "_DoesntExis"},
req: &pbs.ListRolesRequest{OrgId: scope.Org.Prefix() + "_DoesntExis"},
res: &pbs.ListRolesResponse{},
errCode: codes.OK,
},
@@ -354,9 +354,9 @@ type ancestorProvider interface {
// validateAncestors verifies that the ancestors of this call are properly set and provided.
func validateAncestors(r ancestorProvider) map[string]string {
if r.GetOrgId() == "" {
return map[string]string{orgIdFieldName: "Missing organization id."}
return map[string]string{orgIdFieldName: "Missing org id."}
}
if !validId(r.GetOrgId(), scope.Organization.Prefix()+"_") {
if !validId(r.GetOrgId(), scope.Org.Prefix()+"_") {
return map[string]string{orgIdFieldName: "Improperly formatted identifier."}
}
return map[string]string{}
@@ -154,7 +154,7 @@ func TestList(t *testing.T) {
// TODO: When an org doesn't exist, we should return a 404 instead of an empty list.
{
name: "Unfound Org",
req: &pbs.ListUsersRequest{OrgId: scope.Organization.Prefix() + "_DoesntExis"},
req: &pbs.ListUsersRequest{OrgId: scope.Org.Prefix() + "_DoesntExis"},
res: &pbs.ListUsersResponse{},
errCode: codes.OK,
},
+4 -4
View File
@@ -9,7 +9,7 @@ const (
User Type = 2
StaticGroup Type = 3
Role Type = 4
Organization Type = 5
Org Type = 5
StaticGroupMember Type = 6
StaticGroupUserMember Type = 7
AssignedRole Type = 8
@@ -33,7 +33,7 @@ func (r Type) String() string {
"user",
"static-group",
"role",
"organization",
"org",
"static-group-member",
"static-group-user-member",
"assigned-role",
@@ -61,8 +61,8 @@ func StringToResourceType(s string) Type {
return StaticGroup
case Role.String():
return Role
case Organization.String():
return Organization
case Org.String():
return Org
case StaticGroupMember.String():
return StaticGroupMember
case StaticGroupUserMember.String():
+2 -2
View File
@@ -33,8 +33,8 @@ func Test_Resource(t *testing.T) {
want: Role,
},
{
typeString: "organization",
want: Organization,
typeString: "org",
want: Org,
},
{
typeString: "static-group-member",
+7 -7
View File
@@ -4,17 +4,17 @@ package scope
type Type uint32
const (
Unknown Type = 0
Global Type = 1
Organization Type = 2
Project Type = 3
Unknown Type = 0
Global Type = 1
Org Type = 2
Project Type = 3
)
func (s Type) String() string {
return [...]string{
"unknown",
"global",
"organization",
"org",
"project",
}[s]
}
@@ -32,8 +32,8 @@ func StringToScopeType(s string) Type {
switch s {
case Global.String():
return Global
case Organization.String():
return Organization
case Org.String():
return Org
case Project.String():
return Project
default:
+3 -3
View File
@@ -21,8 +21,8 @@ func Test_StringToScopeType(t *testing.T) {
},
{
name: "org",
s: "organization",
want: Organization,
s: "org",
want: Org,
wantPrefix: "o",
},
{
@@ -33,7 +33,7 @@ func Test_StringToScopeType(t *testing.T) {
},
{
name: "unknown",
s: "org",
s: "blahblah",
want: Unknown,
wantPrefix: "unknown",
},