• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RestApi类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.apigateway.model.RestApi的典型用法代码示例。如果您正苦于以下问题:Java RestApi类的具体用法?Java RestApi怎么用?Java RestApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RestApi类属于com.amazonaws.services.apigateway.model包,在下文中一共展示了RestApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deploy

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
public void deploy(AwsKeyPair keyPair, String region, final String restApiName, final String stage, Proxy proxy) {
    final AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(keyPair.key, keyPair.secret));

    ClientConfiguration cc = Util.createConfiguration(proxy);

    AmazonApiGateway ag = AmazonApiGatewayClientBuilder.standard().withCredentials(credentials) //
            .withClientConfiguration(cc) //
            .withRegion(region) //
            .build();
    GetRestApisResult apis = ag.getRestApis(new GetRestApisRequest().withLimit(10000));
    Optional<RestApi> api = apis.getItems().stream().filter(item -> item.getName().equals(restApiName)).findFirst();
    RestApi a = api.orElseThrow(() -> new RuntimeException("no rest api found with name='" + restApiName + "'"));
    String restApiId = a.getId();
    log.info("creating deployment of " + restApiId + " to stage " + stage);
    CreateDeploymentResult r = ag
            .createDeployment(new CreateDeploymentRequest().withRestApiId(restApiId).withStageName(stage));
    Map<String, Map<String, MethodSnapshot>> summary = r.getApiSummary();
    log.info("created deployment");
    log.info("summary=" + summary);
}
 
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:22,代码来源:ApiGatewayDeployer.java


示例2: buildResourceList

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected List<Resource> buildResourceList(RestApi api) {
    List<Resource> resourceList = new ArrayList<>();

    Resources resources = api.getResources();
    resourceList.addAll(resources.getItem());

    LOG.debug("Building list of resources. Stack trace: ", new Throwable());

    final RateLimiter rl = RateLimiter.create(2);
    while (resources._isLinkAvailable("next")) {
        rl.acquire();
        resources = resources.getNext();
        resourceList.addAll(resources.getItem());
    }

    return resourceList;
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:18,代码来源:ApiGatewaySdkApiImporter.java


示例3: createResource

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected Resource createResource(RestApi api, String parentResourceId, String part, List<Resource> resources) {
    final Optional<Resource> existingResource = getResource(parentResourceId, part, resources);

    // create resource if doesn't exist
    if (!existingResource.isPresent()) {

        LOG.info("Creating resource '" + part + "' on " + parentResourceId);

        CreateResourceInput input = new CreateResourceInput();
        input.setPathPart(part);
        Resource resource = api.getResourceById(parentResourceId);

        Resource created = resource.createResource(input);

        resources.add(created);

        return created;
    } else {
        return existingResource.get();
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:22,代码来源:ApiGatewaySdkApiImporter.java


示例4: createApi

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
@Override
public String createApi(Raml raml, String name, JSONObject config) {
    this.config = config;

    // TODO: What to use as description?
    final RestApi api = createApi(getApiName(raml, name), null);

    LOG.info("Created API "+api.getId());
    
    try {
        final Resource rootResource = getRootResource(api).get();
        deleteDefaultModels(api);
        createModels(api, raml.getSchemas(), false);
        createResources(api, createResourcePath(api, rootResource, raml.getBasePath()),
                         new HashMap<String, UriParameter>(), raml.getResources(), false);
    } catch (Throwable t) {
        LOG.error("Error creating API, rolling back", t);
        rollback(api);
        throw t;
    }
    return api.getId();
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:23,代码来源:ApiGatewaySdkRamlApiImporter.java


示例5: createModels

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
private void createModels(RestApi api, List<Map<String, String>> schemas, boolean update) {
    for (Map<String, String> entries : schemas) {
        for (Map.Entry<String, String> entry : entries.entrySet()) {
            final String schemaName = entry.getKey();
            final String schemaValue = entry.getValue();

            models.add(schemaName);

            if (update && getModel(api, schemaName).isPresent()) {
                updateModel(api, schemaName, schemaValue);
            } else {
                createModel(api, schemaName, schemaValue);
            }
        }
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:17,代码来源:ApiGatewaySdkRamlApiImporter.java


示例6: createModel

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
@Nullable
private String createModel(RestApi api, String mime, MimeType mimeType) {
    final String schema = mimeType.getSchema();

    if (schema != null) {
        if (schema.matches("\\w+")) {
            return schema;
        }

        final String modelName = generateModelName();

        models.add(modelName);
        createModel(api, modelName, null, schema, mime);

        return modelName;
    }

    return null;
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:20,代码来源:ApiGatewaySdkRamlApiImporter.java


示例7: createApi

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
@Override
public String createApi(Raml raml, String name, JSONObject config) {
    this.config = config;

    // TODO: What to use as description?
    final RestApi api = createApi(getApiName(raml, name), null);

    LOG.info("Created API "+api.getId());
    
    try {
        final Resource rootResource = getRootResource(api).get();
        deleteDefaultModels(api);
        createModels(api, raml.getSchemas(), false);
        createResources(api, createResourcePath(api, rootResource, raml.getBasePath()), raml.getResources(), false);
    } catch (Throwable t) {
        LOG.error("Error creating API, rolling back", t);
        rollback(api);
        throw t;
    }
    return api.getId();
}
 
开发者ID:Stockflare,项目名称:aws-api-gateway,代码行数:22,代码来源:ApiGatewaySdkRamlApiImporter.java


示例8: getDefinitions

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
private static Map<String, io.swagger.models.Model> getDefinitions(RestApi restApi)
		throws IOException, JsonParseException, JsonMappingException {
	Map<String, io.swagger.models.Model> result = new HashMap<String, io.swagger.models.Model>();
	for (Models models = restApi.getModels(); models != null; models = safeGetNext(models)) {
		for (Model modelItem : models.getItem()) {
			String content = modelItem.getSchema(); 
			io.swagger.models.Model model = 
					Json.mapper().readValue(content, io.swagger.models.Model.class);
			if (model instanceof ModelImpl) {
				((ModelImpl) model).setName(modelItem.getName());
			}
			model.setDescription(modelItem.getDescription());
			result.put(modelItem.getName(), model);
		}
	}
	return result;
}
 
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:18,代码来源:APIGExporter.java


示例9: run

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
public void run()
{
	String AWSAccessKey="AKIAJM7YMMLXKUH5EWRQ";
	String AWSSecretKey="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";
	
       BasicAWSCredentials awsCredentials = new BasicAWSCredentials(AWSAccessKey, AWSSecretKey);

       AmazonApiGatewayClient apiClient = new AmazonApiGatewayClient(awsCredentials);
       apiClient.setRegion(Region.getRegion(Regions.US_WEST_2));
       
       GetRestApisRequest graReq = new GetRestApisRequest();
	GetRestApisResult graRes = apiClient.getRestApis(graReq);
	RestApi theApi = null;
	for ( RestApi api : graRes.getItems() )
	{
		System.out.println("Found existing REST API: " + api.getName());
		if ( "TestAPI".equals(api.getName()))
		{
			theApi = api;
			
			
			
			GetExportRequest geReq = new GetExportRequest()
					.withRestApiId(api.getId())
					.withExportType("swagger")
					.withStageName("TEST");
			GetExportResult geRes = apiClient.getExport(geReq);
			String f = new String(geRes.getBody().array());
			int x = 1;
			String from = "";
			PatchOperation po = new PatchOperation()
					.withFrom(from)
					.withOp(Op.Replace)
					.withPath("");
		}
	}

}
 
开发者ID:ServerlessJavaMaven,项目名称:ServerlessJavaMaven,代码行数:39,代码来源:Tester.java


示例10: deleteApi

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
private void deleteApi() {
    final GetRestApisRequest graprq = new GetRestApisRequest();

    final GetRestApisResult graprs = this.awsApiClient.getRestApis(graprq);

    graprs.getItems()
            .stream()
            .filter(ra -> ra.getName().equals(ApiName))
            .map(RestApi::getId)
            .map(id -> new DeleteRestApiRequest().withRestApiId(id))
            .forEach(this.awsApiClient::deleteRestApi);

}
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:14,代码来源:OauthHandlerDeployer.java


示例11: createApi

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected RestApi createApi(String name, String description) {
    LOG.info("Creating API with name " + name);

    CreateRestApiInput input = new CreateRestApiInput();
    input.setName(name);
    input.setDescription(description);

    return apiGateway.createRestApi(input);
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewaySdkApiImporter.java


示例12: getRootResource

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected Optional<Resource> getRootResource(RestApi api) {
    for (Resource r : buildResourceList(api)) {
        if ("/".equals(r.getPath())) {
            return Optional.of(r);
        }
    }
    return Optional.empty();
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:9,代码来源:ApiGatewaySdkApiImporter.java


示例13: deleteDefaultModels

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected void deleteDefaultModels(RestApi api) {
    buildModelList(api).stream().forEach(model -> {
        LOG.info("Removing default model " + model.getName());
        try {
            model.deleteModel();
        } catch (Throwable ignored) {
        } // todo: temporary catch until API fix
    });
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewaySdkApiImporter.java


示例14: buildModelList

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected List<Model> buildModelList(RestApi api) {
    List<Model> modelList = new ArrayList<>();

    Models models = api.getModels();
    modelList.addAll(models.getItem());

    while (models._isLinkAvailable("next")) {
        models = models.getNext();
        modelList.addAll(models.getItem());
    }

    return modelList;
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:14,代码来源:ApiGatewaySdkApiImporter.java


示例15: createModel

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected void createModel(RestApi api, String modelName, String description, String schema, String modelContentType) {
    this.processedModels.add(modelName);

    CreateModelInput input = new CreateModelInput();

    input.setName(modelName);
    input.setDescription(description);
    input.setContentType(modelContentType);
    input.setSchema(schema);

    api.createModel(input);
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:13,代码来源:ApiGatewaySdkApiImporter.java


示例16: cleanupModels

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected void cleanupModels(RestApi api, Set<String> models) {
    List<Model> existingModels = buildModelList(api);
    Stream<Model> modelsToDelete = existingModels.stream().filter(model -> !models.contains(model.getName()));

    modelsToDelete.forEach(model -> {
        LOG.info("Removing deleted model " + model.getName());
        model.deleteModel();
    });
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewaySdkApiImporter.java


示例17: getResource

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected Optional<Resource> getResource(RestApi api, String fullPath) {
    for (Resource r : buildResourceList(api)) {
        if (r.getPath().equals(fullPath)) {
            return Optional.of(r);
        }
    }

    return Optional.empty();
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:10,代码来源:ApiGatewaySdkApiImporter.java


示例18: getModel

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
protected Optional<Model> getModel(RestApi api, String modelName) {
    try {
        return Optional.of(api.getModelByName(modelName));
    } catch (Exception ignored) {
        return Optional.empty();
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:8,代码来源:ApiGatewaySdkApiImporter.java


示例19: updateApi

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
@Override
public void updateApi(String apiId, Raml raml, JSONObject config) {
    this.config = config;

    RestApi api = getApi(apiId);
    Optional<Resource> rootResource = getRootResource(api);

    createModels(api, raml.getSchemas(), true);
    createResources(api, createResourcePath(api, rootResource.get(), raml.getBasePath()),
                     new HashMap<String, UriParameter>(), raml.getResources(), true);

    cleanupResources(api, this.paths);
    cleanupModels(api, this.models);
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:15,代码来源:ApiGatewaySdkRamlApiImporter.java


示例20: createResources

import com.amazonaws.services.apigateway.model.RestApi; //导入依赖的package包/类
private void createResources(RestApi api, Resource rootResource, Map<String, UriParameter> ancestorRequestParameters,
                            Map<String, org.raml.model.Resource> resources, boolean update) {
    for (Map.Entry<String, org.raml.model.Resource> entry : resources.entrySet()) {
        final org.raml.model.Resource resource = entry.getValue();
        final Resource parentResource = createResourcePath(api, rootResource, entry.getKey());

        Map<String, UriParameter> requestParameters = new HashMap<String, UriParameter>(resource.getUriParameters());
        requestParameters.putAll(ancestorRequestParameters);

        createMethods(api, parentResource, requestParameters, resource.getActions(), update);
        createResources(api, parentResource, requestParameters, resource.getResources(), update);
    }
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:14,代码来源:ApiGatewaySdkRamlApiImporter.java



注:本文中的com.amazonaws.services.apigateway.model.RestApi类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExhibitorEnsembleProvider类代码示例发布时间:2022-05-23
下一篇:
Java Pixel类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap