This repository has been archived by the owner on Apr 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
tenant.go
94 lines (75 loc) · 3.36 KB
/
tenant.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package stormpath
//Tenant
//
//When you sign up for Stormpath, a private data space is created for you. This space is represented as a Tenant resource in the Stormpath REST API. Your Tenant resource can be thought of as your global starting point. You can access everything in your space by accessing your Tenant resource first and then interacting with its other linked resources (Applications, Directories, etc).
type Tenant struct {
customDataAwareResource
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
Accounts *Accounts `json:"accounts,omitempty"`
Applications *Applications `json:"applications,omitempty"`
Directories *Directories `json:"directories,omitempty"`
Groups *Groups `json:"groups,omitempty"`
Organizations *Organizations `json:"organizations,omitempty"`
}
//CurrentTenant retrieves the Tenant associated with the current API key.
func CurrentTenant() (*Tenant, error) {
tenant := &Tenant{}
err := client.get(buildRelativeURL("tenants", "current"), tenant)
return tenant, err
}
//GetApplications retrieves the collection of all the applications associated with the Tenant.
//
//The collection can be filtered and/or paginated by passing the desire ApplicationCriteria value.
func (tenant *Tenant) GetApplications(criteria ApplicationCriteria) (*Applications, error) {
apps := &Applications{}
err := client.get(buildAbsoluteURL(tenant.Applications.Href, criteria.toQueryString()), apps)
if err != nil {
return nil, err
}
return apps, nil
}
//GetAccounts retrieves the collection of all the accounts associated with the Tenant.
//
//The collection can be filtered and/or paginated by passing the desire AccountCriteria value.
func (tenant *Tenant) GetAccounts(criteria AccountCriteria) (*Accounts, error) {
accounts := &Accounts{}
err := client.get(buildAbsoluteURL(tenant.Accounts.Href, criteria.toQueryString()), accounts)
if err != nil {
return nil, err
}
return accounts, nil
}
//GetGroups retrieves the collection of all the groups associated with the Tenant.
//
//The collection can be filtered and/or paginated by passing the desire GroupCriteria value.
func (tenant *Tenant) GetGroups(criteria GroupCriteria) (*Groups, error) {
groups := &Groups{}
err := client.get(buildAbsoluteURL(tenant.Groups.Href, criteria.toQueryString()), groups)
if err != nil {
return nil, err
}
return groups, nil
}
//GetDirectories retrieves the collection of all the directories associated with the Tenant.
//
//The collection can be filtered and/or paginated by passing the desire DirectoryCriteria value
func (tenant *Tenant) GetDirectories(criteria DirectoryCriteria) (*Directories, error) {
directories := &Directories{}
err := client.get(buildAbsoluteURL(tenant.Directories.Href, criteria.toQueryString()), directories)
if err != nil {
return nil, err
}
return directories, nil
}
//GetOrganizations retrieves the collection of all the organizations associated with the Tenant.
//
//The collection can be filtered and/or paginated by passing the desire OrganizationCriteria value
func (tenant *Tenant) GetOrganizations(criteria OrganizationCriteria) (*Organizations, error) {
organizations := &Organizations{}
err := client.get(buildAbsoluteURL(tenant.Organizations.Href, criteria.toQueryString()), organizations)
if err != nil {
return nil, err
}
return organizations, nil
}