Search in sources :

Example 1 with ApiBean

use of io.apiman.manager.api.beans.apis.ApiBean in project apiman by apiman.

the class RestHelper method hideSensitiveDataFromApiVersionBean.

/**
 * This method will hide sensitive data, such as created by, from the result
 *
 * @param apiVersionBean the apiVersionBean
 * @return the apiVersionBean without sensitive data
 */
public static ApiVersionBean hideSensitiveDataFromApiVersionBean(ApiVersionBean apiVersionBean) {
    ApiBean api = new ApiBean();
    api.setId(apiVersionBean.getApi().getId());
    api.setName(apiVersionBean.getApi().getName());
    api.setDescription(apiVersionBean.getApi().getDescription());
    OrganizationBean org = new OrganizationBean();
    org.setId(apiVersionBean.getApi().getOrganization().getId());
    org.setName(apiVersionBean.getApi().getOrganization().getName());
    org.setDescription(apiVersionBean.getApi().getOrganization().getDescription());
    api.setOrganization(org);
    ApiVersionBean apiVersion = new ApiVersionBean();
    apiVersion.setApi(api);
    apiVersion.setStatus(apiVersionBean.getStatus());
    apiVersion.setEndpointType(apiVersionBean.getEndpointType());
    apiVersion.setEndpointContentType(apiVersionBean.getEndpointContentType());
    apiVersion.setGateways(apiVersionBean.getGateways());
    apiVersion.setPublicAPI(apiVersionBean.isPublicAPI());
    apiVersion.setPlans(apiVersionBean.getPlans());
    apiVersion.setVersion(apiVersionBean.getVersion());
    apiVersion.setDefinitionType(apiVersionBean.getDefinitionType());
    return apiVersion;
}
Also used : ApiBean(io.apiman.manager.api.beans.apis.ApiBean) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) ApiVersionBean(io.apiman.manager.api.beans.apis.ApiVersionBean)

Example 2 with ApiBean

use of io.apiman.manager.api.beans.apis.ApiBean in project apiman by apiman.

the class EsStorage method createApiVersion.

/**
 * @see io.apiman.manager.api.core.IStorage#createApiVersion(io.apiman.manager.api.beans.apis.ApiVersionBean)
 */
@Override
public void createApiVersion(ApiVersionBean version) throws StorageException {
    ApiBean api = version.getApi();
    String id = id(api.getOrganization().getId(), api.getId(), version.getVersion());
    indexEntity(INDEX_MANAGER_POSTFIX_API_VERSION, id, EsMarshalling.marshall(version));
    PoliciesBean policies = PoliciesBean.from(PolicyType.Api, api.getOrganization().getId(), api.getId(), version.getVersion());
    indexEntity(INDEX_MANAGER_POSTFIX_API_POLICIES, id, EsMarshalling.marshall(policies));
}
Also used : ApiBean(io.apiman.manager.api.beans.apis.ApiBean) PoliciesBean(io.apiman.manager.api.es.beans.PoliciesBean)

Example 3 with ApiBean

use of io.apiman.manager.api.beans.apis.ApiBean in project apiman by apiman.

the class EsStorage method getApi.

/**
 * @see io.apiman.manager.api.core.IStorage#getApi(java.lang.String, java.lang.String)
 */
@Override
public ApiBean getApi(String organizationId, String id) throws StorageException {
    Map<String, Object> source = getEntity(INDEX_MANAGER_POSTFIX_API, id(organizationId, id));
    if (source == null) {
        return null;
    }
    ApiBean bean = EsMarshalling.unmarshallApi(source);
    bean.setOrganization(getOrganization(organizationId));
    return bean;
}
Also used : ApiBean(io.apiman.manager.api.beans.apis.ApiBean)

Example 4 with ApiBean

use of io.apiman.manager.api.beans.apis.ApiBean in project apiman by apiman.

the class EsStorage method deleteApiVersion.

/**
 * @see io.apiman.manager.api.core.IStorage#deleteApiVersion(io.apiman.manager.api.beans.apis.ApiVersionBean)
 */
@Override
public void deleteApiVersion(ApiVersionBean version) throws StorageException {
    deleteApiDefinition(version);
    ApiBean api = version.getApi();
    String id = id(api.getOrganization().getId(), api.getId(), version.getVersion());
    deleteEntity(INDEX_MANAGER_POSTFIX_API_VERSION, id);
    deleteEntity(INDEX_MANAGER_POSTFIX_API_POLICIES, id);
}
Also used : ApiBean(io.apiman.manager.api.beans.apis.ApiBean)

Example 5 with ApiBean

use of io.apiman.manager.api.beans.apis.ApiBean in project apiman by apiman.

the class EsMarshallingTest method testMarshallApiBean.

/**
 * Test method for {@link io.apiman.manager.api.es.EsMarshalling#marshall(io.apiman.manager.api.beans.apis.ApiBean)}.
 */
@Test
public void testMarshallApiBean() throws Exception {
    ApiBean bean = createBean(ApiBean.class);
    XContentBuilder builder = EsMarshalling.marshall(bean);
    Assert.assertEquals("{\"organizationId\":\"ID\",\"organizationName\":\"NAME\",\"id\":\"ID\",\"name\":\"NAME\",\"description\":\"DESCRIPTION\",\"createdBy\":\"CREATEDBY\",\"createdOn\":1,\"numPublished\":11}", Strings.toString(builder));
}
Also used : ApiBean(io.apiman.manager.api.beans.apis.ApiBean) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.Test)

Aggregations

ApiBean (io.apiman.manager.api.beans.apis.ApiBean)36 ApiVersionBean (io.apiman.manager.api.beans.apis.ApiVersionBean)14 StorageException (io.apiman.manager.api.core.exceptions.StorageException)14 NewApiBean (io.apiman.manager.api.beans.apis.NewApiBean)12 UpdateApiBean (io.apiman.manager.api.beans.apis.UpdateApiBean)12 ApiVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException)10 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)10 NotAuthorizedException (io.apiman.manager.api.rest.exceptions.NotAuthorizedException)10 OrganizationBean (io.apiman.manager.api.beans.orgs.OrganizationBean)9 ClientVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException)9 PlanVersionNotFoundException (io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException)9 ApiGatewayBean (io.apiman.manager.api.beans.apis.ApiGatewayBean)6 NewApiVersionBean (io.apiman.manager.api.beans.apis.NewApiVersionBean)6 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)6 ApiAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ApiAlreadyExistsException)6 ApiDefinitionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiDefinitionNotFoundException)6 ApiNotFoundException (io.apiman.manager.api.rest.exceptions.ApiNotFoundException)6 ApiVersionAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ApiVersionAlreadyExistsException)6 EntityStillActiveException (io.apiman.manager.api.rest.exceptions.EntityStillActiveException)6 InvalidApiStatusException (io.apiman.manager.api.rest.exceptions.InvalidApiStatusException)6