Java 类com.amazonaws.services.apigateway.model.IntegrationType 实例源码

项目:java-translatebot    文件:EventHandlerDeployer.java   
private void integratePostMethod(final CreateRestApiResult createApiResult, final CreateResourceResult crrs,
        final String iarn) {
    final PutIntegrationRequest pirq = new PutIntegrationRequest().withType(IntegrationType.AWS)
            .withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod("POST")
            .withIntegrationHttpMethod("POST")
            .withUri(iarn)
            .withPassthroughBehavior("WHEN_NO_TEMPLATES")
            .withRequestTemplates(Collections.emptyMap());
    this.awsApiClient.putIntegration(pirq);

    final PutIntegrationResponseRequest pirsrq = new PutIntegrationResponseRequest()
            .withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod("POST")
            .withStatusCode("200")
            .withResponseTemplates(Collections.singletonMap("application/json", ""));
    this.awsApiClient.putIntegrationResponse(pirsrq);

    final PutMethodResponseRequest pmrsrq = new PutMethodResponseRequest().withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod("POST")
            .withStatusCode("200")
            .withResponseModels(Collections.singletonMap("application/json", "Empty"));
    this.awsApiClient.putMethodResponse(pmrsrq);
}
项目:java-translatebot    文件:CommandHandlerDeployer.java   
private void integratePostMethod(final CreateRestApiResult createApiResult, final CreateResourceResult crrs,
        final String iarn) {
    final String template = loadTemplate();
    final PutIntegrationRequest pirq = new PutIntegrationRequest().withType(IntegrationType.AWS)
            .withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod("POST")
            .withIntegrationHttpMethod("POST")
            .withUri(iarn)
            .withPassthroughBehavior("WHEN_NO_TEMPLATES")
            .withRequestTemplates(Collections.singletonMap("application/x-www-form-urlencoded", template));
    this.awsApiClient.putIntegration(pirq);

    final PutIntegrationResponseRequest pirsrq = new PutIntegrationResponseRequest()
            .withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod("POST")
            .withStatusCode("200")
            .withResponseTemplates(Collections.singletonMap("application/json", ""));
    this.awsApiClient.putIntegrationResponse(pirsrq);

    final PutMethodResponseRequest pmrsrq = new PutMethodResponseRequest().withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod("POST")
            .withStatusCode("200")
            .withResponseModels(Collections.singletonMap("application/json", "Empty"));
    this.awsApiClient.putMethodResponse(pmrsrq);
}
项目:aws-apigateway-importer    文件:ApiGatewaySdkRamlApiImporter.java   
private void createIntegration(Resource resource, Method method, JSONObject config) {
    if (config == null) {
        return;
    }

    try {
        final JSONObject integ = config.getJSONObject(resource.getPath())
                .getJSONObject(method.getHttpMethod().toLowerCase())
                .getJSONObject("integration");

        IntegrationType type = IntegrationType.valueOf(integ.getString("type").toUpperCase());

        LOG.info("Creating integration with type " + type);

        PutIntegrationInput input = new PutIntegrationInput()
                .withType(type)
                .withUri(integ.getString("uri"))
                .withCredentials(integ.optString("credentials"))
                .withHttpMethod(integ.optString("httpMethod"))
                .withRequestParameters(jsonObjectToHashMapString(integ.optJSONObject("requestParameters")))
                .withRequestTemplates(jsonObjectToHashMapString(integ.optJSONObject("requestTemplates")))
                .withCacheNamespace(integ.optString("cacheNamespace"))
                .withCacheKeyParameters(jsonObjectToListString(integ.optJSONArray("cacheKeyParameters")));

        Integration integration = method.putIntegration(input);

        createIntegrationResponses(integration, integ.optJSONObject("responses"));
    } catch (JSONException e) {
        LOG.info(format("Skipping integration for method %s of %s: %s", method.getHttpMethod(), resource.getPath(), e));
    }
}
项目:aws-api-gateway    文件:ApiGatewaySdkRamlApiImporter.java   
private void createIntegration(Resource resource, Method method, JSONObject config) {
    if (config == null) {
        return;
    }

    try {
        final JSONObject integ = config.getJSONObject(resource.getPath())
                .getJSONObject(method.getHttpMethod().toLowerCase())
                .getJSONObject("integration");

        IntegrationType type = IntegrationType.valueOf(integ.getString("type").toUpperCase());

        LOG.info("Creating integration with type " + type);

        PutIntegrationInput input = new PutIntegrationInput()
                .withType(type)
                .withUri(integ.getString("uri"))
                .withCredentials(integ.optString("credentials"))
                .withHttpMethod(integ.optString("httpMethod"))
                .withRequestParameters(jsonObjectToHashMapString(integ.optJSONObject("requestParameters")))
                .withRequestTemplates(jsonObjectToHashMapString(integ.optJSONObject("requestTemplates")))
                .withCacheNamespace(integ.optString("cacheNamespace"))
                .withCacheKeyParameters(jsonObjectToListString(integ.optJSONArray("cacheKeyParameters")));

        Integration integration = method.putIntegration(input);

        createIntegrationResponses(integration, integ.optJSONObject("responses"));
    } catch (JSONException e) {
        LOG.info(format("Skipping integration for method %s of %s: %s", method.getHttpMethod(), resource.getPath(), e));
    }
}
项目:java-translatebot    文件:OauthHandlerDeployer.java   
private void createMethod(final CreateRestApiResult createApiResult, final CreateResourceResult crrs,
        final String iarn) {
    final HashMap<String, Boolean> params = new HashMap<>();
    params.put("method.request.querystring.code", true);
    params.put("method.request.querystring.state", false);
    final PutMethodRequest pmrq = new PutMethodRequest().withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod(HttpMethod)
            .withRequestParameters(params)
            .withAuthorizationType("NONE");
    this.awsApiClient.putMethod(pmrq);
    final String tplt = "{\"code\":\"$input.params('code')\",\"state\":\"$input.params('state')\"}";
    final PutIntegrationRequest pirq = new PutIntegrationRequest().withType(IntegrationType.AWS)
            .withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod(HttpMethod)
            .withIntegrationHttpMethod("POST")
            .withPassthroughBehavior("NEVER")
            .withRequestTemplates(Collections.singletonMap("application/json", tplt))
            .withUri(iarn);

    this.awsApiClient.putIntegration(pirq);

    final PutMethodResponseRequest pmrsrq = new PutMethodResponseRequest().withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod(HttpMethod)
            .withStatusCode("302")
            .withResponseParameters(Collections.singletonMap("method.response.header.Location", true))
            .withResponseModels(Collections.emptyMap());
    this.awsApiClient.putMethodResponse(pmrsrq);

    final PutIntegrationResponseRequest pirsrq = new PutIntegrationResponseRequest()
            .withRestApiId(createApiResult.getId())
            .withResourceId(crrs.getId())
            .withHttpMethod(HttpMethod)
            .withStatusCode("302")
            .withResponseParameters(Collections.singletonMap("method.response.header.Location",
                    "'http://translate.banjocreek.io/thankyou.html'"))
            .withResponseTemplates(Collections.emptyMap());
    this.awsApiClient.putIntegrationResponse(pirsrq);

}