def managed(name, config, api_url=None, page_id=None, api_key=None, api_version=None):
 complete_diff = {}
 ret = _default_ret(name)
 for (endpoint_name, endpoint_expected_config) in six.iteritems(config):
  endpoint_existing_config_ret = __salt__['statuspage.retrieve'](endpoint=endpoint_name, api_url=api_url, page_id=page_id, api_key=api_key, api_version=api_version)
  if (not endpoint_existing_config_ret.get('result')):
   ret.update({'comment': endpoint_existing_config_ret.get('comment')})
   return ret
  endpoint_existing_config = endpoint_existing_config_ret.get('out')
  complete_diff[endpoint_name] = _compute_diff(endpoint_expected_config, endpoint_existing_config)
 ret.update({'changes': complete_diff})
 if __opts__.get('test'):
  ret.update({'comment': 'Testing mode. Would apply the following changes:', 'result': None})
  return ret
 for (endpoint_name, endpoint_diff) in six.iteritems(complete_diff):
  endpoint_sg = endpoint_name[:(-1)]
  for new_endpoint in endpoint_diff.get('add'):
   log.debug('Defining new {endpoint}: {props}'.format(endpoint=endpoint_sg, props=new_endpoint))
   __salt__['statuspage.create'](endpoint=endpoint_name, api_url=api_url, page_id=page_id, api_key=api_key, api_version=api_version, **new_endpoint)
  for update_endpoint in endpoint_diff.get('update'):
   endpoint_id = update_endpoint.pop('id')
   log.debug('Updating {endpoint} #{id}: {props}'.format(endpoint=endpoint_sg, id=endpoint_id, props=update_endpoint))
   __salt__['statuspage.update'](endpoint=endpoint_name, id=endpoint_id, api_url=api_url, page_id=page_id, api_key=api_key, api_version=api_version, **update_endpoint)
  for remove_endpoint in endpoint_diff.get('remove'):
   endpoint_id = remove_endpoint.pop('id')
   log.debug('Removing {endpoint} #{id}'.format(endpoint=endpoint_sg, id=endpoint_id))
   __salt__['statuspage.update'](endpoint=endpoint_name, id=endpoint_id, api_url=api_url, page_id=page_id, api_key=api_key, api_version=api_version)

def managed ( name , config , api_url = None , page_id = None , api_key = None , api_version = None ) : complete_diff = { } ret = _default_ret ( name ) for ( endpoint_name , endpoint_expected_config ) in six . iteritems ( config ) : endpoint_existing_config_ret = __salt__ [ 'statuspage.retrieve' ] ( endpoint = endpoint_name , api_url = api_url , page_id = page_id , api_key = api_key , api_version = api_version ) if ( not endpoint_existing_config_ret . get ( 'result' ) ) : ret . update ( { 'comment' : endpoint_existing_config_ret . get ( 'comment' ) } ) return ret endpoint_existing_config = endpoint_existing_config_ret . get ( 'out' ) complete_diff [ endpoint_name ] = _compute_diff ( endpoint_expected_config , endpoint_existing_config ) ret . update ( { 'changes' : complete_diff } ) if __opts__ . get ( 'test' ) : ret . update ( { 'comment' : 'Testing mode. Would apply the following changes:' , 'result' : None } ) return ret for ( endpoint_name , endpoint_diff ) in six . iteritems ( complete_diff ) : endpoint_sg = endpoint_name [ : ( - 1 ) ] for new_endpoint in endpoint_diff . get ( 'add' ) : log . debug ( 'Defining new {endpoint}: {props}' . format ( endpoint = endpoint_sg , props = new_endpoint ) ) __salt__ [ 'statuspage.create' ] ( endpoint = endpoint_name , api_url = api_url , page_id = page_id , api_key = api_key , api_version = api_version , ** new_endpoint ) for update_endpoint in endpoint_diff . get ( 'update' ) : endpoint_id = update_endpoint . pop ( 'id' ) log . debug ( 'Updating {endpoint} #{id}: {props}' . format ( endpoint = endpoint_sg , id = endpoint_id , props = update_endpoint ) ) __salt__ [ 'statuspage.update' ] ( endpoint = endpoint_name , id = endpoint_id , api_url = api_url , page_id = page_id , api_key = api_key , api_version = api_version , ** update_endpoint ) for remove_endpoint in endpoint_diff . get ( 'remove' ) : endpoint_id = remove_endpoint . pop ( 'id' ) log . debug ( 'Removing {endpoint} #{id}' . format ( endpoint = endpoint_sg , id = endpoint_id ) ) __salt__ [ 'statuspage.update' ] ( endpoint = endpoint_name , id = endpoint_id , api_url = api_url , page_id = page_id , api_key = api_key , api_version = api_version )
puts the transaction manager into a manual state: managed transactions have to be committed explicitly by the user .