Get metadata from the API

@param string $apiModule Module
@param string $apiAction Action
@param array $apiParameters Parameters
@param array $optional
@return bool|object
@throws InvalidRequestException
437789
public function getMetadata($apiModule, $apiAction, $apiParameters = [], array $optional = [])
    {
        return $this->_request('API.getMetadata', [
            'apiModule' => $apiModule,
            'apiAction' => $apiAction,
            'apiParameters' => $apiParameters,
        ], $optional);
    }
215683
public function getEMailParam($name, $default = null, $optional = false)
    {
        $value = $this->getParam($name, $default, $optional);
        if ($value !== null) {
            if (!preg_match('/^.+@.+\...+$/', $value)) {
                throw new InvalidParameterException("Parameter '{$name}' is invalid");
            }
        }
        return $value;
    }
353240
protected function generateMethod($apiName, $operation = [], $api = [])
    {

        $filterParams = compact('apiName', 'operation', 'api');
        $method = [' * @method', 'array'];

        $data = "";
        $request = $api['request'];
        $description = $this->sanitizeDescription($request['description'], ['noMarkdown' => true, 'shorten' => true]);
        $description = $this->applyFilter('DocMethodDescription', $description, $filterParams);
        $params = $this->applyFilter('DocMethodParams', $operation['parameters'], $filterParams);
        $filterParams['params'] = $params;
        if (!empty($params)) {
            $data = $this->applyFilter('DocMethodData', 'array $parameters', $filterParams);
        }

        $method[] = $this->applyFilter('DocMethodSignature', "$apiName($data)", $filterParams);
        $method[] = $description;

        return implode("\t", $method);

    }
1207309
private function getApiDoc(bool $collection, string $resourceClass, ResourceMetadata $resourceMetadata, string $operationName, array $resourceHydraDoc, array $entrypointHydraDoc = []): ApiDoc
    {
        if ($collection) {
            $method = $this->operationMethodResolver->getCollectionOperationMethod($resourceClass, $operationName);
            $route = $this->operationMethodResolver->getCollectionOperationRoute($resourceClass, $operationName);
            $operationHydraDoc = $this->getCollectionOperationHydraDoc($resourceMetadata->getShortName(), $method, $entrypointHydraDoc);
        } else {
            $method = $this->operationMethodResolver->getItemOperationMethod($resourceClass, $operationName);
            $route = $this->operationMethodResolver->getItemOperationRoute($resourceClass, $operationName);
            $operationHydraDoc = $this->getOperationHydraDoc($method, $resourceHydraDoc);
        }

        $data = [
            'resource' => $route->getPath(),
            'description' => $operationHydraDoc['hydra:title'] ?? '',
            'resourceDescription' => $resourceHydraDoc['hydra:title'] ?? '',
            'section' => $resourceHydraDoc['hydra:title'] ?? '',
        ];

        if (isset($operationHydraDoc['expects']) && 'owl:Nothing' !== $operationHydraDoc['expects']) {
            $data['input'] = sprintf('%s:%s:%s', ApiPlatformParser::IN_PREFIX, $resourceClass, $operationName);
        }

        if (isset($operationHydraDoc['returns']) && 'owl:Nothing' !== $operationHydraDoc['returns']) {
            $data['output'] = sprintf('%s:%s:%s', ApiPlatformParser::OUT_PREFIX, $resourceClass, $operationName);
        }

        if ($collection && 'GET' === $method) {
            $resourceFilters = $resourceMetadata->getCollectionOperationAttribute($operationName, 'filters', [], true);

            $data['filters'] = [];
            foreach ($resourceFilters as $filterId) {
                if ($filter = $this->getFilter($filterId)) {
                    foreach ($filter->getDescription($resourceClass) as $name => $definition) {
                        $data['filters'][] = ['name' => $name] + $definition;
                    }
                }
            }
        }

        $apiDoc = new ApiDoc($data);
        $apiDoc->setRoute($route);

        return $apiDoc;
    }
210761
private static function getSelfUrlParams($requestParams, $paramsNew, $opts)
    {
        $params = $requestParams;
        $paramsQuery = Str::parse($_SERVER['QUERY_STRING']);    // params from QUERY_STRING
        // compare $_GET with QUERY_STRING & REQUEST_URI to see what's been added/removed/changed
        //  if a param has changed between QUERY_STRING & $_GET, it will be added as a default
        //  if in QUERY_STRING, but not in REQUEST_URI, it will NOT be added as a default
        $cor = array_diff_assoc($paramsQuery, $_GET);   // Changed Or Removed params
        $coa = array_diff_assoc($_GET, $paramsQuery);   // Changed Or Added params
        foreach ($cor as $k => $v) {
            if (!isset($coa[$k])) {
                unset($params[$k]); // it's a remove
            } elseif (isset($coa[$k]) && $coa[$k] != $v) {
                continue;   // $_GET[param] has changed in code
            } elseif (!isset($requestParams[$k])) {
                // $k is in QUERY_STRING, but not REQUEST_URI (mod_rewrite created)
                unset($coa[$k]);
            }
        }
        foreach ($coa as $k => $v) {
            $params[$k] = $v;       // it's a change or add
        }
        if (!empty($opts['getLock'])) {
            foreach ($opts['getLock'] as $k) {
                if (isset($params[$k])) {
                    $params[$k] = isset($requestParams[$k])
                        ? $requestParams[$k]    // use REQUEST_URI val
                        : null;                         // not in REQUEST_URI
                }
            }
        }
        if (!$opts['keepParams']) {
            // keep default params only if in getProp
            foreach ($params as $k => $v) {
                if (!in_array($k, $opts['getProp'])) {
                    unset($params[$k]);
                }
            }
        }
        foreach ($paramsNew as $k => $v) {
            $params[$k] = $v;
        }
        return $params;
    }
680422
public function getApiRequest($apiUrl, $deferred)
    {
        return new Request([
            'url' => $apiUrl,
            'resolveCallback' =>
                function (Response $response) use ($deferred) {
                    $data = (string) $response->getBody();
                    $headers = $response->getHeaders();
                    $code = $response->getStatusCode();
                    $shortUrl = $this->handleResponse($data, $headers, $code);
                    if ($shortUrl === false) {
                        $deferred->reject();
                    } else {
                        $deferred->resolve($shortUrl);
                    }
                },
            'rejectCallback' => [$deferred, 'reject']
        ]);
    }
161374
public function toSymfonyResponse(ApiResponse $apiResponse, Request $request)
    {
        $format = $request->getRequestFormat($this->defaultResponseFormat);
        $serialized = $this->serializer->serialize($apiResponse->getData(), $format);
        $response = new Response($serialized, $apiResponse->getStatusCode(), $apiResponse->getHeaders());

        $response->headers->set('Content-Type', $request->getMimeType($format));

        return $response;
    }
720754
protected static function _staticRequest($method, $url, $params, $options)
    {
        $opts = \Stripe\Util\RequestOptions::parse($options);
        $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
        $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
        list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
        $opts->discardNonPersistentHeaders();
        return [$response, $opts];
    }
553978
public static function getUserClient($organization = null, $apiKey = null, $options = [])
    {
        $baseUrl = BaseClient::DEFAULT_API_BASE_URL;

        //bc compability, when first param was $options
        if (\is_array($organization)) {
            $options = $organization;
            $organization = null;
            $apiKey = null;
        }
        if (isset($options[self::API_BASE_URL])) {
            $baseUrl = $options[self::API_BASE_URL];
        }

        $client = self::getGuzzleClient($baseUrl, $options);

        return new UserClient($client, $organization, $apiKey);
    }
1290352
private function call($module, $params = array()) {
    // set api data
    $params['api_key'] = $this->api_key;
    $params['format']  = $this->resp_type;

    // build URL
    $url = $this->endpoint . $module . '?' . http_build_query($params);

    // Set URL 
    curl_setopt($this->ch, CURLOPT_URL, $url);

    // Send the request & save response to $resp
    $resp['data'] = curl_exec($this->ch);
    if (curl_errno($this->ch)) {
      throw new GiantBombException('API call failed: ' . curl_error($this->ch));
    }

    // save http response code
    $resp['httpCode'] = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);

    if (!$resp || !$resp['data']) {
      throw new GiantBombException("Couldn't get information from API");
    }

    return $resp;
  }
47639
public function execute_action($api, $module, $function, $username, $params = array())
    {
        $action = 'cpanel';
        $params = array_merge($params, [
            'cpanel_jsonapi_apiversion' => $api,
            'cpanel_jsonapi_module' => $module,
            'cpanel_jsonapi_func' => $function,
            'cpanel_jsonapi_user' => $username,
        ]);
        $response = $this->runQuery($action, $params);

        return $response;
    }
1108179
final public function url($module, $controller = null, $action = null, array $params = array(), $hash = null) {
        $module = ucfirst(Util::hyphenToCamel($module));
        $moduleOptions = engineGet('config', 'modules', $module, false);
        $module = (isset($moduleOptions['alias'])) ? $moduleOptions['alias'] : $module;

        $return = Util::camelToHyphen($module);
        if ($controller)
            $return .= '/' . Util::camelToHyphen($controller);
        if ($action)
            $return .= '/' . Util::camelToHyphen($action);
        if (!empty($params))
            $return .= str_replace('//', '/' . urlencode(' ') . '/', '/' . join('/', $this->encodeParams($params)));
        if ($hash)
            $return .= '#' . $hash;

        return engineGet('serverPath') . $return;
    }
219142
public function getRequestStack($optional = false)
    {
        if ($this instanceof ContainerAwareInterface) {
            return $this->get('request_stack');
        }

        if (false === $optional && null === $this->requestStack) {
            throw new \RuntimeException('RequestStack not found. Setter not called?');
        }

        return $this->requestStack;
    }
438030
def _get_api_params(api_url=None,
                    page_id=None,
                    api_key=None,
                    api_version=None):
    '''
    
    '''
    statuspage_cfg = __salt__['config.get']('statuspage')
    if not statuspage_cfg:
        statuspage_cfg = {}
    return {
        'api_url': api_url or statuspage_cfg.get('api_url') or BASE_URL,  # optional
        'api_page_id': page_id or statuspage_cfg.get('page_id'),  # mandatory
        'api_key': api_key or statuspage_cfg.get('api_key'),  # mandatory
        'api_version': api_version or statuspage_cfg.get('api_version') or DEFAULT_VERSION
    }
510186
@Override
	public Result<Void> getAPIExample(AuthzTrans trans, HttpServletResponse resp, String nameOrContentType, boolean optional) {
		TimeTaken tt = trans.start(API_EXAMPLE, Env.SUB);
		try {
			String content =Examples.print(apiDF.getEnv(), nameOrContentType, optional); 
			resp.getOutputStream().print(content);
			setContentType(resp,content.contains("<?xml")?TYPE.XML:TYPE.JSON);
			return Result.ok();
		} catch (Exception e) {
			trans.error().log(e,IN,API_EXAMPLE);
			return Result.err(Result.ERR_NotImplemented,e.getMessage());
		} finally {
			tt.done();
		}
	}
59671
private Api getApiInternal(String apiOrgId, String apiId, String apiVersion) {
        String key = getApiIndex(apiOrgId, apiId, apiVersion);
        Api api;
        synchronized (mutex) {
            api = (Api) getMap().get(key);
        }
        return api;
    }
1120136
public function get($method, array $params, array $options = array())
    {
        $this->parseOptions($options);

        $params = array_merge($params, $this->apiKeys);

        $response = $this->httpAdapter->getContent(
            sprintf(self::API_ENDPOINT, $this->scheme, $this->outputFormat, $method .'?'. http_build_query($params)),
            $this->headers
        );

        return $this->responseHandler($response);
    }