Api

Version

mediamosa-30

Class

mediamosa_rest_call_acl_group_get_hostnames

Code

File: /sites/all/modules/mediamosa/modules/acl/mediamosa_acl.rest.class.inc
<?php

/**
 *  URI: /autorisation_group/$groupname/hostname
 *  Method: GET
 */
class mediamosa_rest_call_acl_group_get_hostnames extends mediamosa_rest_call {

  
// ------------------------------------------------------------------- Consts.
  // Rest vars;
  
const GROUPNAME 'groupname';
  const 
LIMIT 'limit';
  const 
OFFSET 'offset';

  
// ------------------------------------------------------- Functions (public).
  
public function get_var_setup() {
    
// Enrich with limit and offset vars.
    
$var_setup $this->get_var_setup_range();

    
$var_setup[mediamosa_rest_call::VARS][self::GROUPNAME] = array(
      
mediamosa_rest_call::VAR_TYPE => mediamosa_sdk::TYPE_STRING,
      
mediamosa_rest_call::VAR_IS_REQUIRED => mediamosa_rest_call::VAR_IS_REQUIRED_YES,
      
mediamosa_rest_call::VAR_DESCRIPTION => 'The name of the group.',
    );

    
// Enrich with required REST vars.
    
return self::get_var_setup_default($var_setup);
  }

  public function 
do_call() {
    
$mediamosa mediamosa::get();

    
// Get the app id(s).
    
$app_ids $this->get_param_value_app();
    
$group_name $this->get_param_value(self::GROUPNAME);

    
$offset $this->get_param_value_offset();
    
$limit $this->get_param_value_limit();

    
// Get the group.
    
$row mediamosa_acl_group::get_by_group_name($app_ids$group_name);
    if (!
$row) {
      throw new 
mediamosa_exception_error(mediamosa_error::ERRORCODE_ACL_GROUP_NOT_FOUND, array('@group' => $group_name));
    }

    
// Get the group.
    
$result mediamosa_acl_group::get_hostnames_by_group_name($app_ids$group_name$offset$limit);

    
// Add to result.
    
foreach ($result as $row) {
      
$row['hostname'] = $row['acl_name'];
      unset(
$row['acl_name']);
      
$mediamosa->add_item(fix_vars_acl_2_aut($row));
    }

    
$mediamosa->item_count_total $result->found_rows;

  }
}