Get an integration for a given method in a given API

    CLI Example:

    .. code-block:: bash

        salt myminion boto_apigateway.describe_api_integration restApiId resourcePath httpMethod
172020
def describe_api_integration(restApiId, resourcePath, httpMethod, region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    try:
        resource = describe_api_resource(restApiId, resourcePath, region=region,
                                         key=key, keyid=keyid, profile=profile).get('resource')
        if resource:
            conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
            integration = conn.get_integration(restApiId=restApiId, resourceId=resource['id'], httpMethod=httpMethod)
            return {'integration': _convert_datetime_str(integration)}
        return {'error': 'no such resource'}
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
24775
def definition
      {
        method_logical_id => {
          type: "AWS::ApiGateway::Method",
          properties: {
            resource_id: "!Ref #{resource_id}",
            rest_api_id: "!Ref #{RestApi.logical_id}",
            http_method: @route.method,
            request_parameters: {},
            authorization_type: authorization_type,
            integration: {
              integration_http_method: "POST",
              type: "AWS_PROXY",
              uri: "!Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${{namespace}LambdaFunction.Arn}/invocations"
            },
            method_responses: []
          }
        }
      }
    end
992084
def get_http_method(self, method):
        """"""
        return self.http_methods[method](self.url, **self.http_method_args)
574451
def get_rest_api():
    
    assert _has_local_install

    url=[]
    ok = _run_st(['geturl', '--api'], lines=url)
    if not ok:
        raise ChildProcessError('streamtool geturl')
    return url[0]
216658
def method_missing(method_id, *args)
      if [:get, :post, :put, :delete].include?(method_id)
        path, options = *args
        options ||= {}
        options[:query] = (default_params.merge(options[:query] || {}))
        options[:headers] = (self.class.default_options[:headers].merge(options[:headers] || {}))

        CrowdFlower.request_hook.call(method_id, path, options) do
          self.class.send(method_id, url(path), options)
        end
      else
        super
      end
    end
810675
def generate_snake_method_body(api, options, &def_block)
      if def_block
        if options[:fails]
          ->(*args, &block){ (res = def_block.(api, *args, &block)) == options[:fails] ? nil: res }
        elsif options[:boolean]
          ->(*args, &block){ def_block.(api, *args, &block) != 0 }
        else
          ->(*args, &block){ def_block.(api, *args, &block) }
        end
      else
        if options[:fails]
          ->(*args, &block){ (res = block ? block[api.call(*args)] : api.call(*args)) == options[:fails] ? nil : res }
        elsif options[:boolean]
          ->(*args, &block){ block ? block[api.call(*args)] : api.call(*args) != 0 }
        else
          ->(*args, &block){ block ? block[api.call(*args)] : api.call(*args) }
        end
      end
    end
664974
function getHandler (method, trans, version) {
  return function (req, res, next) {
    res.setHeader('Allow', Object.values(allowedMethods).join(','));

    let service = req.params.__service;
    let id = req.params.__id;
    let action = req.params.__action;
    let path = '/' + service +
      (id? '/' + id : '') +
      (action? '/' + action : '');
    
    // guess whether id is an action?
    if (id && !action) {
      if (!(validator.isNumeric(id) || validator.isMongoId(id))) {
        action = id;
      }
    }
    service += (action? '.' + action : '');
    
    debug(`REST handler calling service \'${service}\'`);
    debug(` => cmd  \'${method}\'`);
    debug(` => path \'${path}\'`);
    debug(` => version \'${version}\'`);

    // The service success callback which sets res.data or calls next() with the error
    const callback = function (err, data) {
      debug(' => service response:', err, data);
      if (err) return next(err.cause || err);

      res.data = data;

      if (!data) {
        debug(`No content returned for '${req.url}'`);
        res.status(statusCodes.noContent);
      } else if (method === 'post') {
        res.status(statusCodes.created);
      }

      return next();
    };

    trans.act({
      topic: `poplar.${service}`,
      cmd: method,
      path: path,
      version: version,
      headers: req.headers || {},
      query: req.query || {},
      body: req.body || {}
    }, callback);
  };
}
142268
def salt_api():
    '''
    
    '''
    import salt.utils.process
    salt.utils.process.notify_systemd()

    import salt.cli.api
    sapi = salt.cli.api.SaltAPI()  # pylint: disable=E1120
    sapi.start()
385058
def method_id(self, api_info):
    """"""
    # This is done here for now because at __init__ time, the method is known
    # but not the api, and thus not the api name.  Later, in
    # ApiConfigGenerator.__method_descriptor, the api name is known.
    if api_info.resource_name:
      resource_part = '.%s' % self.__safe_name(api_info.resource_name)
    else:
      resource_part = ''
    return '%s%s.%s' % (self.__safe_name(api_info.name), resource_part,
                        self.__safe_name(self.name))
862941
def get_api_connector(cls):
        
        if cls._api is None:  # pragma: no cover
            cls.load_config()
            cls.debug('initialize connection to remote server')
            apihost = cls.get('api.host')
            if not apihost:
                raise MissingConfiguration()

            apienv = cls.get('api.env')
            if apienv and apienv in cls.apienvs:
                apihost = cls.apienvs[apienv]

            cls._api = XMLRPCClient(host=apihost, debug=cls.verbose)

        return cls._api
519500
def delete_api_method(restApiId, resourcePath, httpMethod, region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    try:
        resource = describe_api_resource(restApiId, resourcePath, region=region,
                                         key=key, keyid=keyid, profile=profile).get('resource')
        if resource:
            conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
            conn.delete_method(restApiId=restApiId, resourceId=resource['id'], httpMethod=httpMethod)
            return {'deleted': True}
        return {'deleted': False, 'error': 'get API method failed: no such resource'}
    except ClientError as e:
        return {'deleted': False, 'error': __utils__['boto3.get_error'](e)}
1323461
def create_and_setup_methods(
                                    self,
                                    restapi,
                                    resource,
                                    api_key_required,
                                    uri,
                                    authorization_type,
                                    authorizer_resource,
                                    depth
                                ):
        
        for method_name in self.http_methods:
            method = troposphere.apigateway.Method(method_name + str(depth))
            method.RestApiId = troposphere.Ref(restapi)
            if type(resource) is troposphere.apigateway.Resource:
                method.ResourceId = troposphere.Ref(resource)
            else:
                method.ResourceId = resource
            method.HttpMethod = method_name.upper()
            method.AuthorizationType = authorization_type
            if authorizer_resource:
                method.AuthorizerId = troposphere.Ref(authorizer_resource)
            method.ApiKeyRequired = api_key_required
            method.MethodResponses = []
            self.cf_template.add_resource(method)
            self.cf_api_resources.append(method.title)

            if not self.credentials_arn:
                self.get_credentials_arn()
            credentials = self.credentials_arn  # This must be a Role ARN

            integration = troposphere.apigateway.Integration()
            integration.CacheKeyParameters = []
            integration.CacheNamespace = 'none'
            integration.Credentials = credentials
            integration.IntegrationHttpMethod = 'POST'
            integration.IntegrationResponses = []
            integration.PassthroughBehavior = 'NEVER'
            integration.Type = 'AWS_PROXY'
            integration.Uri = uri
            method.Integration = integration
1183272
def describe_api_resource(restApiId, path,
                          region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    r = describe_api_resources(restApiId, region=region, key=key, keyid=keyid, profile=profile)
    resources = r.get('resources')
    if resources is None:
        return r
    for resource in resources:
        if resource['path'] == path:
            return {'resource': resource}
    return {'resource': None}
134187
def get_api_gateway_resource(name):
    """"""
    client = boto3.client('apigateway', region_name=PRIMARY_REGION)
    matches = [x for x in client.get_rest_apis().get('items', list())
               if x['name'] == API_GATEWAY]
    match = matches.pop()
    resources = client.get_resources(restApiId=match.get('id'))
    resource_id = None
    for item in resources.get('items', list()):
        if item.get('pathPart', '/') != name:
            continue
        resource_id = item['id']
    return resource_id
1281621
protected Api getApi(String orgId, String apiId, String version) throws IOException {
        String apiIdx = getApiIdx(orgId, apiId, version);
        Api api;
        synchronized (mutex) {
            api = apiCache.get(apiIdx);
        }

        if (api == null) {
            api = super.getApi(getApiId(orgId, apiId, version));
            synchronized (mutex) {
                if (api != null) {
                    apiCache.put(apiIdx, api);
                }
            }
        }

        return api;
    }
77262
def api(func=None, timeout=API_TIMEOUT):  # incoming
    
    if func is None:
        return partial(api, timeout=timeout)
    else:
        wrapper = _get_api_decorator(func=func, timeout=timeout)
        return wrapper
1044269
def call(cls, method, *args, **kwargs):
        
        api = None
        empty_key = kwargs.pop('empty_key', False)
        try:
            api = cls.get_api_connector()
            apikey = cls.get('api.key')
            if not apikey and not empty_key:
                cls.echo("No apikey found, please use 'gandi setup' "
                         "command")
                sys.exit(1)
        except MissingConfiguration:
            if api and empty_key:
                apikey = ''
            elif not kwargs.get('safe'):
                cls.echo("No configuration found, please use 'gandi setup' "
                         "command")
                sys.exit(1)
            else:
                return []

        # make the call
        cls.debug('calling method: %s' % method)
        for arg in args:
            cls.debug('with params: %r' % arg)
        try:
            resp = api.request(method, apikey, *args,
                               **{'dry_run': kwargs.get('dry_run', False),
                                  'return_dry_run':
                                  kwargs.get('return_dry_run', False)})
            cls.dump('responded: %r' % resp)
            return resp
        except APICallFailed as err:
            if kwargs.get('safe'):
                return []
            if err.code == 530040:
                cls.echo("Error: It appears you haven't purchased any credits "
                         "yet.\n"
                         "Please visit https://www.gandi.net/credit/buy to "
                         "learn more and buy credits.")
                sys.exit(1)
            if err.code == 510150:
                cls.echo("Invalid API key, please use 'gandi setup' command.")
                sys.exit(1)
            if isinstance(err, DryRunException):
                if kwargs.get('return_dry_run', False):
                    return err.dry_run
                else:
                    for msg in err.dry_run:
                        # TODO use trads with %s
                        cls.echo(msg['reason'])
                        cls.echo('\t' + ' '.join(msg['attr']))
                    sys.exit(1)
            error = UsageError(err.errors)
            setattr(error, 'code', err.code)
            raise error