Skip to content

Commit 5b1fa4a

Browse files
authored
Merge pull request #33 from bitmovin/feature/organizations
Feature/organizations
2 parents e2b7b34 + 990942c commit 5b1fa4a

File tree

7 files changed

+271
-1
lines changed

7 files changed

+271
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import urljoin from 'url-join';
2+
import http from '../../http';
3+
import permissions from './permissions';
4+
import tenants from './tenants';
5+
6+
export const groups = (configuration, organizationId, http) => {
7+
const { get, post, delete_ } = http;
8+
const groupsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'organizations', organizationId, 'groups');
9+
10+
let fn = (groupId) => {
11+
return {
12+
details: () => {
13+
let url = urljoin(groupsBaseUrl, groupId);
14+
return get(configuration, url);
15+
},
16+
delete: () => {
17+
let url = urljoin(groupsBaseUrl, groupId);
18+
return delete_(configuration, url);
19+
},
20+
permissions: permissions(configuration, organizationId, groupId),
21+
tenants: tenants(configuration, organizationId, groupId)
22+
};
23+
};
24+
25+
fn.add = (group) => {
26+
const url = urljoin(groupsBaseUrl);
27+
return post(configuration, url, group);
28+
};
29+
30+
fn.list = () => {
31+
const url = urljoin(groupsBaseUrl);
32+
return get(configuration, url);
33+
};
34+
35+
return fn;
36+
};
37+
38+
export default (configuration, organizationId) => { return groups(configuration, organizationId, http); };

bitmovin/account/organizations/organizations.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import urljoin from 'url-join';
22
import http from '../../http';
3+
import groups from './groups';
34

45
export const organizations = (configuration, http) => {
56
const { get, post, delete_ } = http;
@@ -14,7 +15,8 @@ export const organizations = (configuration, http) => {
1415
delete: () => {
1516
let url = urljoin(organizationsBaseUrl, organizationId);
1617
return delete_(configuration, url);
17-
}
18+
},
19+
groups: groups(configuration, organizationId)
1820
};
1921
};
2022

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import urljoin from 'url-join';
2+
import http from '../../http';
3+
4+
export const permissions = (configuration, organizationId, groupId, http) => {
5+
const { get, post, delete_ } = http;
6+
const permissionsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'organizations', organizationId, 'groups', groupId, 'permissions');
7+
8+
let fn = (groupId) => {
9+
return {
10+
details: () => {
11+
let url = urljoin(permissionsBaseUrl, groupId);
12+
return get(configuration, url);
13+
},
14+
delete: () => {
15+
let url = urljoin(permissionsBaseUrl, groupId);
16+
return delete_(configuration, url);
17+
}
18+
};
19+
};
20+
21+
fn.add = (permission) => {
22+
const url = urljoin(permissionsBaseUrl);
23+
return post(configuration, url, permission);
24+
};
25+
26+
fn.list = () => {
27+
const url = urljoin(permissionsBaseUrl);
28+
return get(configuration, url);
29+
};
30+
31+
return fn;
32+
};
33+
34+
export default (configuration, organizationId, groupId) => { return permissions(configuration, organizationId, groupId, http); };
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import urljoin from 'url-join';
2+
import http from '../../http';
3+
4+
export const tenants = (configuration, organizationId, groupId, http) => {
5+
const { get, post, delete_ } = http;
6+
const tenantsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'organizations', organizationId, 'groups', groupId, 'tenants');
7+
8+
let fn = (tenantId) => {
9+
return {
10+
details: () => {
11+
let url = urljoin(tenantsBaseUrl, tenantId);
12+
return get(configuration, url);
13+
},
14+
delete: () => {
15+
let url = urljoin(tenantsBaseUrl, tenantId);
16+
return delete_(configuration, url);
17+
}
18+
};
19+
};
20+
21+
fn.add = (tenant) => {
22+
const url = urljoin(tenantsBaseUrl);
23+
return post(configuration, url, tenant);
24+
};
25+
26+
fn.list = () => {
27+
const url = urljoin(tenantsBaseUrl);
28+
return get(configuration, url);
29+
};
30+
31+
return fn;
32+
};
33+
34+
export default (configuration, organizationId, groupId) => { return tenants(configuration, organizationId, groupId, http); };
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import urljoin from 'url-join';
2+
import { groups } from '../../../bitmovin/account/organizations/groups';
3+
4+
import {
5+
mockGet,
6+
mockPost,
7+
mockDelete,
8+
mockHttp,
9+
assertItReturnsUnderlyingPromise,
10+
assertItCallsCorrectUrl,
11+
testSetup,
12+
} from '../../assertions';
13+
14+
import {getConfiguration} from '../../utils';
15+
16+
let testConfiguration = getConfiguration();
17+
18+
describe('account', () => {
19+
beforeEach(testSetup);
20+
describe('organizations', () => {
21+
describe('groups', () => {
22+
const testOrgId = '123';
23+
const client = groups(testConfiguration, testOrgId, mockHttp);
24+
25+
describe('list', () => {
26+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups'), client.list);
27+
assertItReturnsUnderlyingPromise(mockGet, client.list);
28+
});
29+
30+
describe('add', () => {
31+
assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups'), client.add);
32+
assertItReturnsUnderlyingPromise(mockPost, client.add);
33+
});
34+
35+
describe('group', () => {
36+
const testGroupId = '123';
37+
38+
describe('details', () => {
39+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId), client(testGroupId).details);
40+
assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details);
41+
});
42+
describe('delete', () => {
43+
assertItCallsCorrectUrl('DELETE', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId), client(testGroupId).delete);
44+
assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete);
45+
});
46+
});
47+
});
48+
});
49+
});
50+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import urljoin from 'url-join';
2+
import { permissions } from '../../../bitmovin/account/organizations/permissions';
3+
4+
import {
5+
mockGet,
6+
mockPost,
7+
mockDelete,
8+
mockHttp,
9+
assertItReturnsUnderlyingPromise,
10+
assertItCallsCorrectUrl,
11+
testSetup,
12+
} from '../../assertions';
13+
14+
import {getConfiguration} from '../../utils';
15+
16+
let testConfiguration = getConfiguration();
17+
18+
describe('account', () => {
19+
beforeEach(testSetup);
20+
describe('organizations', () => {
21+
describe('groups', () => {
22+
describe('permissions', () => {
23+
const testOrgId = '123';
24+
const testGroupId = '123';
25+
26+
const client = permissions(testConfiguration, testOrgId, testGroupId, mockHttp);
27+
28+
describe('list', () => {
29+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions'), client.list);
30+
assertItReturnsUnderlyingPromise(mockGet, client.list);
31+
});
32+
33+
describe('add', () => {
34+
assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions'), client.add);
35+
assertItReturnsUnderlyingPromise(mockPost, client.add);
36+
});
37+
38+
describe('permission', () => {
39+
const testPermissionId = '123';
40+
41+
describe('details', () => {
42+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions', testPermissionId),
43+
client(testGroupId).details);
44+
assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details);
45+
});
46+
describe('delete', () => {
47+
assertItCallsCorrectUrl('DELETE', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions', testPermissionId),
48+
client(testGroupId).delete);
49+
assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete);
50+
});
51+
});
52+
});
53+
});
54+
});
55+
});
56+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import urljoin from 'url-join';
2+
import { tenants } from '../../../bitmovin/account/organizations/tenants';
3+
4+
import {
5+
mockGet,
6+
mockPost,
7+
mockDelete,
8+
mockHttp,
9+
assertItReturnsUnderlyingPromise,
10+
assertItCallsCorrectUrl,
11+
testSetup,
12+
} from '../../assertions';
13+
14+
import {getConfiguration} from '../../utils';
15+
16+
let testConfiguration = getConfiguration();
17+
18+
describe('account', () => {
19+
beforeEach(testSetup);
20+
describe('organizations', () => {
21+
describe('groups', () => {
22+
describe('tenants', () => {
23+
const testOrgId = '123';
24+
const testGroupId = '123';
25+
26+
const client = tenants(testConfiguration, testOrgId, testGroupId, mockHttp);
27+
28+
describe('list', () => {
29+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants'), client.list);
30+
assertItReturnsUnderlyingPromise(mockGet, client.list);
31+
});
32+
33+
describe('add', () => {
34+
assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants'), client.add);
35+
assertItReturnsUnderlyingPromise(mockPost, client.add);
36+
});
37+
38+
describe('tenant', () => {
39+
const testTenantId = '123';
40+
41+
describe('details', () => {
42+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants', testTenantId),
43+
client(testGroupId).details);
44+
assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details);
45+
});
46+
describe('delete', () => {
47+
assertItCallsCorrectUrl('DELETE', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants', testTenantId),
48+
client(testGroupId).delete);
49+
assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete);
50+
});
51+
});
52+
});
53+
});
54+
});
55+
});
56+

0 commit comments

Comments
 (0)