Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
25c76025
Commit
25c76025
authored
Apr 25, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Domains: Add/Remove Admins - DLs: Add/Remove Owners
parent
8a64acef
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
445 additions
and
74 deletions
+445
-74
README.md
README.md
+19
-0
TODOS.md
TODOS.md
+5
-5
zimbra-admin-api.js
lib/zimbra-admin-api.js
+267
-37
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
package.json
package.json
+1
-1
index.js
src/index.js
+21
-22
dictionary.js
src/utils/dictionary.js
+27
-0
distribution_list.js
src/zimbra/distribution_list.js
+18
-0
domain.js
src/zimbra/domain.js
+12
-1
zimbra.js
src/zimbra/zimbra.js
+6
-7
test.js
test/js/spec/test.js
+68
-0
No files found.
README.md
View file @
25c76025
...
...
@@ -351,6 +351,15 @@ domain.countAccounts(callback);
If the
`Domain`
is empty, no 'Accounts', the result will be a
`{}`
.
### Add / Remove Admin
```
javascript
domain
.
addAdmin
(
'new_member@example.com'
,
callback
);
// {} if Success
domain
.
removeAdmin
(
'new_member@example.com'
,
callback
);
// {} if Success
```
### Domain Admins
Return an Array of the Domain Admins
`Accounts`
.
...
...
@@ -387,6 +396,16 @@ dl.removeMembers(['1@example.com', '2@example.com'], callback);
// Return Error if any of the emails isn't a member
```
### Add / Remove Owner
```
javascript
dl
.
addOwner
(
'new_member@example.com'
,
callback
);
// {} if Success
dl
.
removeOwner
(
'new_member@example.com'
,
callback
);
// {} if Success
```
### Get Owners
Owners are the Zimbra emails addresses that are allowed to send emails to the
`DL`
.
If a
`DL`
has at least one
`Owener`
is a
**Private DL**
.
...
...
TODOS.md
View file @
25c76025
...
...
@@ -11,15 +11,15 @@
## DistributionList
*
[
]
Listas privadas
*
[
]
Toda su gestion
*
[
X
]
Listas privadas
*
[
X
]
Toda su gestion
## Domains
*
[
]
Add y remove Admins
*
[
X
]
Add y remove Admins
*
[
]
Devolver Tipo de renovación
*
[
]
Devolver Empresa (esto entiendo necesitamos otro API)
*
[
X
]
Devolver Tipo de renovación
*
[
X
]
Devolver Empresa (esto entiendo necesitamos otro API)
*
[
X
]
Devolver casillas segun el tipo de plan, cantidad asignadas y cantidad utilizadas para un dominio
*
[
X
]
Limite de casillas
*
[
X
]
Devolver Fecha de la proxima renovación
...
...
lib/zimbra-admin-api.js
View file @
25c76025
This diff is collapsed.
Click to expand it.
lib/zimbra-admin-api.js.map
View file @
25c76025
This diff is collapsed.
Click to expand it.
package.json
View file @
25c76025
{
"name"
:
"zimbra-admin-api-js"
,
"version"
:
"0.0.1
4
"
,
"version"
:
"0.0.1
5
"
,
"private"
:
true
,
"main"
:
"lib/zimbra-admin-api.js"
,
"dependencies"
:
{
...
...
src/index.js
View file @
25c76025
...
...
@@ -262,23 +262,15 @@ export default class ZimbraAdminApi {
// }
grantRight
(
target_data
,
grantee_data
,
right_name
,
callback
)
{
const
request_data
=
{
};
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
'GrantRight'
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
response_name
=
`
${
request_data
.
request_name
}
Response`
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseEmptyResponse
;
if
(
target_data
)
request_data
.
params
.
params
.
target
=
{
'type'
:
target_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
};
if
(
grantee_data
)
request_data
.
params
.
params
.
grantee
=
{
'type'
:
grantee_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
grantee_data
.
identifier
),
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
request_data
.
params
.
params
.
right
=
{
'_content'
:
right_name
};
this
.
performRequest
(
request_data
);
}
...
...
@@ -399,6 +391,7 @@ export default class ZimbraAdminApi {
// }
getGrants
(
target_data
,
grantee_data
,
callback
)
{
const
request_data
=
{
};
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
const
resource
=
'Grant'
;
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
`Get
${
resource
}
s`
;
...
...
@@ -407,17 +400,8 @@ export default class ZimbraAdminApi {
request_data
.
callback
=
callback
;
request_data
.
resource
=
resource
;
request_data
.
parse_response
=
this
.
parseAllResponse
;
if
(
target_data
)
request_data
.
params
.
params
.
target
=
{
'type'
:
target_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
};
if
(
grantee_data
)
request_data
.
params
.
params
.
grantee
=
{
'type'
:
grantee_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
grantee_data
.
identifier
),
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
this
.
performRequest
(
request_data
);
}
...
...
@@ -507,6 +491,21 @@ export default class ZimbraAdminApi {
this
.
performRequest
(
request_data
);
}
revokeRight
(
target_data
,
grantee_data
,
right_name
,
callback
)
{
const
request_data
=
{
};
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
'RevokeRight'
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
response_name
=
`
${
request_data
.
request_name
}
Response`
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseEmptyResponse
;
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
request_data
.
params
.
params
.
right
=
{
'_content'
:
right_name
};
this
.
performRequest
(
request_data
);
}
// Search the Directory
// search_object = {
// query: An LDAP query or null for everything,
...
...
src/utils/dictionary.js
View file @
25c76025
...
...
@@ -37,6 +37,33 @@ export default class Dictionary {
return
result
;
}
buildTargetGrantee
(
target_data
,
grantee_data
)
{
let
target
=
null
,
grantee
=
null
;
if
(
target_data
)
target
=
{
'type'
:
target_data
.
type
,
'by'
:
this
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
}
if
(
grantee_data
)
grantee
=
{
'type'
:
grantee_data
.
type
,
'by'
:
this
.
byIdOrName
(
grantee_data
.
identifier
),
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
return
([
target
,
grantee
]);
}
buildGranteeData
(
grantee_id
,
type
)
{
return
{
'type'
:
type
,
'by'
:
this
.
byIdOrName
(
grantee_id
),
'all'
:
1
,
'_content'
:
grantee_id
,
'identifier'
:
grantee_id
};
}
classFactory
(
resource
,
object
,
client
)
{
const
class_name
=
this
.
resourceToClass
(
resource
.
toLowerCase
());
return
new
class_name
(
object
,
client
);
...
...
src/zimbra/distribution_list.js
View file @
25c76025
...
...
@@ -7,6 +7,7 @@ export default class DistributionList extends Zimbra {
constructor
(
dl_obj
,
zimbra_api_client
)
{
super
(
dl_obj
,
zimbra_api_client
);
this
.
members
=
this
.
parseMembers
(
dl_obj
);
this
.
ownerRights
=
'sendToDistList'
;
}
// Add members to DL
...
...
@@ -14,6 +15,14 @@ export default class DistributionList extends Zimbra {
this
.
api
.
addDistributionListMember
(
this
.
id
,
members
,
callback
);
}
addOwner
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
grantRight
(
grantee_data
,
this
.
ownerRights
,
callback
);
}
// return the ID of the owner
getOwners
(
callback
)
{
if
(
this
.
owners
)
return
callback
(
null
,
this
.
owners
);
...
...
@@ -53,4 +62,13 @@ export default class DistributionList extends Zimbra {
this
.
api
.
removeDistributionListMember
(
this
.
id
,
members
,
callback
);
}
removeOwner
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
revokeRight
(
grantee_data
,
this
.
ownerRights
,
callback
);
}
}
src/zimbra/domain.js
View file @
25c76025
...
...
@@ -10,7 +10,10 @@ export default class Domain extends Zimbra {
}
addAdmin
(
account_id
,
callback
)
{
const
grantee_data
=
this
.
buildGranteeData
(
account_id
,
'Account'
);
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
grantRight
(
grantee_data
,
this
.
domainAdminRights
,
callback
);
}
...
...
@@ -80,4 +83,12 @@ export default class Domain extends Zimbra {
return
results
;
}
removeAdmin
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
revokeRight
(
grantee_data
,
this
.
domainAdminRights
,
callback
);
}
}
src/zimbra/zimbra.js
View file @
25c76025
...
...
@@ -28,13 +28,8 @@ export default class Zimbra {
return
{
type
:
type
,
identifier
:
this
.
id
};
}
buildGranteeData
(
object_id
,
type
)
{
return
{
'type'
:
type
,
'by'
:
this
.
api
.
dictionary
.
byIdOrName
(
object_id
),
'all'
:
1
,
'_content'
:
object_id
};
buildGranteeData
(
grantee_id
,
type
)
{
return
this
.
api
.
dictionary
.
buildGranteeData
(
grantee_id
,
type
);
}
parseACL
(
acls
)
{
...
...
@@ -62,4 +57,8 @@ export default class Zimbra {
this
.
api
.
grantRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
);
}
revokeRight
(
grantee_data
,
right_name
,
callback
){
this
.
api
.
revokeRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
);
}
}
test/js/spec/test.js
View file @
25c76025
...
...
@@ -456,7 +456,41 @@
});
});
it
(
'addAdmin should add Admin'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
domain_admin
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'.dev'
;
api
.
createDomain
(
resource_name
,
{},
function
(
err
,
data
){
if
(
err
)
console
.
error
(
err
);
let
domain
=
data
;
domain
.
addAdmin
(
domain_admin
,
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
err
).
to
.
be
.
null
;
domain
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
[
0
].
grantee
.
name
).
to
.
be
.
equal
(
domain_admin
);
done
();
});
});
});
});
it
(
'removeAdmin should remove the Admin'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
domain_admin
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'.dev'
;
api
.
createDomain
(
resource_name
,
{},
function
(
err
,
domain
){
domain
.
addAdmin
(
domain_admin
,
function
(
e
,
d
){
domain
.
removeAdmin
(
domain_admin
,
function
(
e
,
d
){
domain
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
.
length
).
to
.
be
.
equal
(
0
);
done
();
});
});
});
});
});
});
...
...
@@ -554,6 +588,40 @@
});
});
it
(
'addOwner should add Owner'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
owner_email
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'@customer.dev'
;
api
.
createDistributionList
(
resource_name
,
{},
function
(
err
,
dl
){
dl
.
addOwner
(
owner_email
,
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
err
).
to
.
be
.
null
;
dl
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
[
0
].
grantee
.
name
).
to
.
be
.
equal
(
owner_email
);
done
();
});
});
});
});
it
(
'removeOwner should remove the Owner'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
owner_email
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'@customer.dev'
;
api
.
createDistributionList
(
resource_name
,
{},
function
(
err
,
dl
){
dl
.
addOwner
(
owner_email
,
function
(
e
,
d
){
dl
.
removeOwner
(
owner_email
,
function
(
e
,
d
){
dl
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
.
length
).
to
.
be
.
equal
(
0
);
done
();
});
});
});
});
});
});
describe
(
'Grants tests'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment