Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Sep 22, 2016
2 parents e80196e + 7ad65eb commit 120ffa9
Show file tree
Hide file tree
Showing 25 changed files with 203 additions and 56 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.3] - 2016-09-22
### Added
- Adds support for multiple versions of an API in the same declaration file.
### Changed
- Use of 'initialVersion' in declaration files is deprecated and will be removed in future - use 'version' instead.

## [0.2.2] - 2016-09-20
### Added
- Adds support for XML format Java properties files.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Here's a simple YAML file (you can use JSON if you want):
apis:
- name: "example"
description: "Example API"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "http://example.com"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

group 'io.apiman.cli'
version '0.2.2'
version '0.2.3'

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative/backend-requires-http-auth.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"name": "example",
"description": "Example API",
"initialVersion": "1.0",
"version": "1.0",
"published": true,
"config": {
"endpoint": "http://example.com",
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative/backend-requires-http-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
apis:
- name: "example"
description: "Example API"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "http://example.com"
Expand Down
4 changes: 2 additions & 2 deletions examples/declarative/shared-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{
"name": "example1",
"description": "Example API 1",
"initialVersion": "1.0",
"version": "1.0",
"published": true,
"config": {
"endpoint": "http://example.com",
Expand All @@ -53,7 +53,7 @@
{
"name": "example2",
"description": "Example API 2",
"initialVersion": "1.0",
"version": "1.0",
"published": true,
"config": {
"endpoint": "http://example.com",
Expand Down
4 changes: 2 additions & 2 deletions examples/declarative/shared-policies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
apis:
- name: "example1"
description: "Example API 1"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "http://example.com"
Expand All @@ -36,7 +36,7 @@
- "sharedPolicy"
- name: "example2"
description: "Example API 2"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "http://example.com"
Expand Down
4 changes: 2 additions & 2 deletions examples/declarative/shared-properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
apis:
- name: "example1"
description: "Example API 1"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "${commonApiEndpoint}"
Expand All @@ -27,7 +27,7 @@
gateway: "test-gw"
- name: "example2"
description: "Example API 2"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "${commonApiEndpoint}"
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative/simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"name": "example",
"description": "Example API",
"initialVersion": "1.0",
"version": "1.0",
"published": true,
"config": {
"endpoint": "http://example.com",
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
apis:
- name: "example"
description: "Example API"
initialVersion: "1.0"
version: "1.0"
published: true
config:
endpoint: "http://example.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.core.api.model.ApiPolicy;
import io.apiman.cli.core.api.model.ApiVersion;
import io.apiman.cli.core.api.model.ServiceConfig;
import retrofit.client.Response;
import retrofit.http.*;
Expand All @@ -33,11 +34,17 @@ public interface Version11xServerApi {
@POST("/organizations/{orgName}/services")
Response create(@Path("orgName") String orgName, @Body Api api);

@POST("/organizations/{orgName}/services/{serviceName}/versions")
Response createVersion(@Path("orgName") String orgName, @Path("serviceName") String serviceName, @Body ApiVersion apiVersion);

@GET("/organizations/{orgName}/services")
List<Api> list(@Path("orgName") String orgName);

@GET("/organizations/{orgName}/services/{serviceName}")
Api fetch(@Path("orgName") String orgName, @Path("serviceName") String serviceName);

@GET("/organizations/{orgName}/services/{serviceName}/versions/{version}")
Api fetch(@Path("orgName") String orgName, @Path("serviceName") String serviceName, @Path("version") String version);
Api fetchVersion(@Path("orgName") String orgName, @Path("serviceName") String serviceName, @Path("version") String version);

@PUT("/organizations/{orgName}/services/{serviceName}/versions/{version}")
Response configure(@Path("orgName") String orgName, @Path("serviceName") String serviceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.core.api.model.ApiConfig;
import io.apiman.cli.core.api.model.ApiPolicy;
import io.apiman.cli.core.api.model.ApiVersion;
import retrofit.client.Response;
import retrofit.http.*;

Expand All @@ -33,11 +34,17 @@ public interface Version12xServerApi {
@POST("/organizations/{orgName}/apis")
Response create(@Path("orgName") String orgName, @Body Api api);

@POST("/organizations/{orgName}/apis/{apiName}/versions")
Response createVersion(@Path("orgName") String orgName, @Path("apiName") String apiName, @Body ApiVersion apiVersion);

@GET("/organizations/{orgName}/apis")
List<Api> list(@Path("orgName") String orgName);

@GET("/organizations/{orgName}/apis/{apiName}")
Api fetch(@Path("orgName") String orgName, @Path("apiName") String apiName);

@GET("/organizations/{orgName}/apis/{apiName}/versions/{version}")
Api fetch(@Path("orgName") String orgName, @Path("apiName") String apiName, @Path("version") String version);
Api fetchVersion(@Path("orgName") String orgName, @Path("apiName") String apiName, @Path("version") String version);

@PUT("/organizations/{orgName}/apis/{apiName}/versions/{version}")
Response configure(@Path("orgName") String orgName, @Path("apiName") String apiName,
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/io/apiman/cli/core/api/VersionAgnosticApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.core.api.model.ApiConfig;
import io.apiman.cli.core.api.model.ApiPolicy;
import io.apiman.cli.core.api.model.ApiVersion;
import retrofit.client.Response;

import java.util.List;
Expand All @@ -29,9 +30,13 @@
public interface VersionAgnosticApi {
Response create(String orgName, Api api);

Response createVersion(String orgName, String apiName, ApiVersion apiVersion);

List<Api> list(String orgName);

Api fetch(String orgName, String apiName, String version);
Api fetch(String orgName, String apiName);

Api fetchVersion(String orgName, String apiName, String version);

Response configure(String orgName, String apiName,
String version, ApiConfig config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

import io.apiman.cli.core.api.Version11xServerApi;
import io.apiman.cli.core.api.VersionAgnosticApi;
import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.core.api.model.ApiConfig;
import io.apiman.cli.core.api.model.ApiPolicy;
import io.apiman.cli.core.api.model.ServiceConfig;
import io.apiman.cli.core.api.model.*;
import io.apiman.cli.management.factory.AbstractManagementApiFactory;
import io.apiman.cli.management.factory.ManagementApiFactory;
import retrofit.client.Response;
Expand All @@ -46,14 +43,24 @@ public Response create(String orgName, Api api) {
return delegate.create(orgName, api);
}

@Override
public Response createVersion(String orgName, String apiName, ApiVersion apiVersion) {
return delegate.createVersion(orgName, apiName, apiVersion);
}

@Override
public List<Api> list(String orgName) {
return delegate.list(orgName);
}

@Override
public Api fetch(String orgName, String apiName, String version) {
return delegate.fetch(orgName, apiName, version);
public Api fetch(String orgName, String apiName) {
return delegate.fetch(orgName, apiName);
}

@Override
public Api fetchVersion(String orgName, String apiName, String version) {
return delegate.fetchVersion(orgName, apiName, version);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.core.api.model.ApiConfig;
import io.apiman.cli.core.api.model.ApiPolicy;
import io.apiman.cli.core.api.model.ApiVersion;
import io.apiman.cli.management.factory.AbstractManagementApiFactory;
import io.apiman.cli.management.factory.ManagementApiFactory;
import retrofit.client.Response;
Expand All @@ -43,14 +44,24 @@ public Response create(String orgName, Api api) {
return delegate.create(orgName, api);
}

@Override
public Response createVersion(String orgName, String apiName, ApiVersion apiVersion) {
return delegate.createVersion(orgName, apiName, apiVersion);
}

@Override
public List<Api> list(String orgName) {
return delegate.list(orgName);
}

@Override
public Api fetch(String orgName, String apiName, String version) {
return delegate.fetch(orgName, apiName, version);
public Api fetch(String orgName, String apiName) {
return delegate.fetch(orgName, apiName);
}

@Override
public Api fetchVersion(String orgName, String apiName, String version) {
return delegate.fetchVersion(orgName, apiName, version);
}

@Override
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/io/apiman/cli/core/api/model/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public class Api {
@JsonProperty
private String organizationName;

/**
* Note: use {@link #version} instead for declarative API configuration.
*/
@JsonProperty
private String initialVersion;

Expand All @@ -59,10 +62,22 @@ public String getName() {
return name;
}

public void setInitialVersion(String initialVersion) {
this.initialVersion = initialVersion;
}

public String getInitialVersion() {
return initialVersion;
}

public void setVersion(String version) {
this.version = version;
}

public String getVersion() {
return version;
}

public String getStatus() {
return status;
}
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/io/apiman/cli/core/api/model/ApiVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.apiman.cli.core.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Models an API version.
*
* @author Pete Cornish {@literal <[email protected]>}
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ApiVersion {
@JsonProperty
private String version;

/**
* Never clone a previous version when creating a new version.
*/
@JsonProperty
final private boolean clone = false;

public ApiVersion(String version) {
this.version = version;
}
}
Loading

0 comments on commit 120ffa9

Please sign in to comment.