Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jdk:
services:
- docker
before_install:
- docker pull apiman/on-wildfly10:1.2.4.Final
- docker pull apiman/on-wildfly10:1.2.8.Final
script:
- docker run -d -p 8080:8080 apiman/on-wildfly10:1.2.4.Final
- ./gradlew test -PintegrationTest --info
- docker run -d -p 8080:8080 apiman/on-wildfly10:1.2.8.Final
- ./gradlew test -PintegrationTest --info --stacktrace
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Adds the ability to wait for the server to start before attempting to run commands.
- Improvements to internal code structure.

## [0.2.3] - 2016-09-22
### Added
- Adds support for multiple versions of an API in the same declaration file.
Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Here's how it works:

Here's a simple YAML file (you can use JSON if you want):

# simple.yml
# simpleApi.yml
---
org:
name: "test"
Expand All @@ -73,17 +73,34 @@ Here's a simple YAML file (you can use JSON if you want):
config:
endpoint: "http://example.com"
endpointType: "rest"
public: true
public: false
gateway: "TheGateway"
plans:
- planId: "planExample"
version: "1.0"
policies:
- name: "CachingPolicy"
config:
ttl: 60

# simplePlan.yml
---
org:
name: "test"
description: "Test organisation"
plans:
- name: "planExample"
description: "This is a plan"
version: "1.0"
policies:
- name: "CachingPolicy"
config:
ttl: 120

### Step 2: Apply the environment declaration

$ ./apiman apply -f simple.yml
INFO Loaded declaration: examples/declarative/simple.yml
$ ./apiman apply -f simpleApi.yml
INFO Loaded declaration: examples/declarative/simpleApi.yml
INFO Adding org: test
INFO Adding API: example
INFO Configuring API: example
Expand Down
3 changes: 2 additions & 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.3'
version '0.2.4-SNAPSHOT'

buildscript {
repositories {
Expand All @@ -38,6 +38,7 @@ repositories {

compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

ext {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
28 changes: 18 additions & 10 deletions src/main/java/io/apiman/cli/Cli.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -17,14 +17,17 @@
package io.apiman.cli;

import com.google.common.collect.Lists;
import io.apiman.cli.command.AbstractCommand;
import io.apiman.cli.command.Command;
import io.apiman.cli.core.api.command.ApiCommand;
import io.apiman.cli.core.declarative.command.ApplyCommand;
import io.apiman.cli.core.gateway.command.GatewayCommand;
import io.apiman.cli.core.org.command.OrgCommand;
import io.apiman.cli.core.plugin.command.PluginCommand;
import io.apiman.cli.command.api.command.ApiCommand;
import io.apiman.cli.command.core.AbstractCommand;
import io.apiman.cli.command.core.Command;
import io.apiman.cli.command.declarative.command.ApplyCommand;
import io.apiman.cli.command.gateway.command.GatewayCommand;
import io.apiman.cli.command.org.command.OrgCommand;
import io.apiman.cli.command.plugin.command.PluginCommand;
import io.apiman.cli.service.ManagementApiService;
import io.apiman.cli.util.InjectionUtil;

import javax.inject.Inject;
import java.util.Map;

/**
Expand All @@ -33,8 +36,13 @@
* @author Pete Cornish {@literal <outofcoffee@gmail.com>}
*/
public class Cli extends AbstractCommand {
@Inject
public Cli(ManagementApiService managementApiService) {
super(managementApiService);
}

public static void main(String... args) {
new Cli().run(Lists.newArrayList(args));
InjectionUtil.getInjector().getInstance(Cli.class).run(Lists.newArrayList(args));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,10 +14,10 @@
* limitations under the License.
*/

package io.apiman.cli.core.api;
package io.apiman.cli.command.api;

import io.apiman.cli.core.common.command.ModelAction;
import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.command.api.model.Api;
import io.apiman.cli.command.common.command.ModelAction;

/**
* @author Pete Cornish {@literal <outofcoffee@gmail.com>}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,12 +14,12 @@
* limitations under the License.
*/

package io.apiman.cli.core.api;
package io.apiman.cli.command.api;

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 io.apiman.cli.command.api.model.Api;
import io.apiman.cli.command.api.model.ApiPolicy;
import io.apiman.cli.command.api.model.ApiVersion;
import io.apiman.cli.command.api.model.ServiceConfig;
import retrofit.client.Response;
import retrofit.http.*;

Expand All @@ -46,6 +46,9 @@ public interface Version11xServerApi {
@GET("/organizations/{orgName}/services/{serviceName}/versions/{version}")
Api fetchVersion(@Path("orgName") String orgName, @Path("serviceName") String serviceName, @Path("version") String version);

@GET("/organizations/{orgName}/services/{serviceName}/versions")
List<Api> fetchVersions(@Path("orgName") String orgName, @Path("serviceName") String serviceName);

@PUT("/organizations/{orgName}/services/{serviceName}/versions/{version}")
Response configure(@Path("orgName") String orgName, @Path("serviceName") String serviceName,
@Path("version") String version, @Body ServiceConfig config);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,12 +14,12 @@
* limitations under the License.
*/

package io.apiman.cli.core.api;
package io.apiman.cli.command.api;

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.command.api.model.Api;
import io.apiman.cli.command.api.model.ApiConfig;
import io.apiman.cli.command.api.model.ApiPolicy;
import io.apiman.cli.command.api.model.ApiVersion;
import retrofit.client.Response;
import retrofit.http.*;

Expand All @@ -46,6 +46,9 @@ public interface Version12xServerApi {
@GET("/organizations/{orgName}/apis/{apiName}/versions/{version}")
Api fetchVersion(@Path("orgName") String orgName, @Path("apiName") String apiName, @Path("version") String version);

@GET("/organizations/{orgName}/apis/{apiName}/versions")
List<Api> fetchVersions(@Path("orgName") String orgName, @Path("apiName") String apiName);

@PUT("/organizations/{orgName}/apis/{apiName}/versions/{version}")
Response configure(@Path("orgName") String orgName, @Path("apiName") String apiName,
@Path("version") String version, @Body ApiConfig config);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,12 +14,12 @@
* limitations under the License.
*/

package io.apiman.cli.core.api;
package io.apiman.cli.command.api;

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.command.api.model.ApiPolicy;
import io.apiman.cli.command.api.model.Api;
import io.apiman.cli.command.api.model.ApiConfig;
import io.apiman.cli.command.api.model.ApiVersion;
import retrofit.client.Response;

import java.util.List;
Expand All @@ -38,6 +38,8 @@ public interface VersionAgnosticApi {

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

List<Api> fetchVersions(String orgName, String apiName);

Response configure(String orgName, String apiName,
String version, ApiConfig config);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,13 +14,14 @@
* limitations under the License.
*/

package io.apiman.cli.core.api.command;
package io.apiman.cli.command.api.command;

import io.apiman.cli.core.common.command.AbstractModelCommand;
import io.apiman.cli.core.api.Version12xServerApi;
import io.apiman.cli.core.api.ApiMixin;
import io.apiman.cli.core.api.model.Api;
import io.apiman.cli.core.common.model.ManagementApiVersion;
import io.apiman.cli.command.common.command.AbstractModelCommand;
import io.apiman.cli.command.api.Version12xServerApi;
import io.apiman.cli.command.api.ApiMixin;
import io.apiman.cli.command.api.model.Api;
import io.apiman.cli.command.common.model.ManagementApiVersion;
import io.apiman.cli.service.ManagementApiService;
import org.kohsuke.args4j.Option;

/**
Expand All @@ -34,4 +35,8 @@ public abstract class AbstractApiCommand extends AbstractModelCommand<Api, Versi

@Option(name = "--serverVersion", aliases = {"-sv"}, usage = "Management API server version")
protected ManagementApiVersion serverVersion = ManagementApiVersion.DEFAULT_VERSION;

AbstractApiCommand(ManagementApiService managementApiService) {
super(managementApiService);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2016 Pete Cornish
* Copyright 2017 Pete Cornish
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -14,11 +14,13 @@
* limitations under the License.
*/

package io.apiman.cli.core.api.command;
package io.apiman.cli.command.api.command;

import io.apiman.cli.command.AbstractCommand;
import io.apiman.cli.command.Command;
import io.apiman.cli.command.core.AbstractCommand;
import io.apiman.cli.command.core.Command;
import io.apiman.cli.service.ManagementApiService;

import javax.inject.Inject;
import java.util.Map;

/**
Expand All @@ -27,6 +29,11 @@
* @author Pete Cornish {@literal <outofcoffee@gmail.com>}
*/
public class ApiCommand extends AbstractCommand {
@Inject
public ApiCommand(ManagementApiService managementApiService) {
super(managementApiService);
}

@Override
protected void populateCommands(Map<String, Class<? extends Command>> commandMap) {
commandMap.put("create", ApiCreateCommand.class);
Expand Down
Loading