Functions
- sort_parent
-
Sort according to parent attribute.
- sort_parents
-
Sort arrayref of
names
with data fromitems
using parentattr
. - rest
-
Convenience wrapper for direct REST calls for
method
,operation
and optionsropts
. - get_id
-
Return the ID of an
operation
. If the name is an ID, return the ID without a lookup. If the operation is 'region', return the name.Options
-
Function to initialise tagstore or return cached version based on tagstore project name.
-
Function to postprocess sync operations when a tagstore is used.
Methods
- sync
-
For an
operation
(likeuser
,group
,service
, ...), given an hashref ofitems
(key is the name), compare it with all existing items:- Non-existing ones are added/created
- Existing ones are possibly updated
- Existing ones that are not requested are disbaled
Returns a hasref with responses for the created items. The keys are
create
,update
anddelete
and the values an arrayref of responses.For
endpoint
operations, as they have no name, use the<<interface
_<url>>> as the name for theitems
hashref.Following options are supported:
- filter: a function to filter the existing items. Return a true value to keep the existing item (false will ignore it). By default, all existing items are considered.
- delete: when the delete option is true, existing items that are not in the
items
hashref, will be deleted (instead of disabled). - keep: when the keep option is true, existing items that are not in the
items
hashref are ignored. This precedes any value ofdelete
option.
- get_item
-
Retrieve and augment an item with
name
from hashrefitems
.Modification to the data
- _process_response
-
Helper function for all 3 sync phases
res
is updated in place.Returns 1 on success, undef otherwise (and reports an error).
- create
-
Create
operation
items in arrayreftocreate
from configureditems
(using name attriutenameattr
), with result hashrefres
.res
is updated in place.postprocess
is a anonymous function called after a succesful REST call, and is passed following arguments: - update
-
Update
operation
items in arrayrefcheckupdate
fromfound
items with configureditems
, with result hashrefres
.res
is updated in place. - delete
-
Delete (or disable)
operation
items in arrayreftoremove
fromfound
existing items, with optionsopts
(fordelete
andignore
) and result hashrefres
.res
is updated in place.When
ignore
option is true, nothing will happen. Whendelete
is true, items will be delete; when items will be disabled. - sync_rolemap
-
Add missing roles for project/domain and group/user, and delete any when tagstore is used.
The roles are defined with a nested hashref, like the url is structured (with an arrayref of roles as value). E.g. $roles = { domain => { dom1 => { user => { user1 => [role1 role2], ... }, group => { ... }, }, ... project => { ... }, }
Options