Skip to content

Commit

Permalink
feat: API, Spec, Version, Attributes, Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ssvaidyanathan committed Sep 16, 2024
1 parent 240ac4d commit 048c853
Show file tree
Hide file tree
Showing 20 changed files with 2,580 additions and 66 deletions.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,84 @@ The code is distributed under the Apache License 2.0.

The [samples folder](./samples) provides a README with Getting Started steps and commands to hit the ground quickly.

## Prerequisites
You will need the following to run the samples:
- Apigee Edge developer account (in an Apigee hybrid org)
- [Java SDK >= 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
- [Maven 3.x](https://maven.apache.org/)

## Plugin Usage

To use the plugin, add the following dependency to your pom

```xml
<dependency>
<groupId>com.apigee.apihub.config</groupId>
<artifactId>apigee-apihub-maven-plugin</artifactId>
<version>1.x.x</version>
</dependency>
```

### Command

```
mvn install -P<profile> -Dapigee.apihub.config.dir=$path -Dapigee.apihub.config.options=$option
```

#### Options

```
-P<profile>
Pick a profile in the parent pom.xml (shared-pom.xml in the example).
Apigee org and env information comes from the profile.
-Dapigee.apihub.config.options
none - No action (default)
create - Create when not found. Pre-existing config is NOT updated even if it is different.
update - Update when found; create when not found
delete - Delete when found
sync - Delete and recreate.
-Dapigee.apihub.config.dir
path to the directory containing the configuration
```

#### Individual goals

To execute individual goals, you can use the prefix `apigee-apihub:<goal>`, for example `apigee-apihub:attributes`

The list of goals available are:
- apis
- apiversions
- specs
- attributes
- dependencies
- externalapis
- deployments

An example to just configure attributes will look like

```
mvn apigee-apihub:attributes -Pdev -Dapigee.apihub.config.options=create -Dapigee.apihub.config.dir=./config
```

**NOTE:** The config files must be in a single directory and should match the below naming conventions:

| Goal | File name |
| -------- | ------- |
| apis | apis.json |
| apiversions | apiVersions.json |
| specs | specs.json |
| attributes | attributes.json |
| externalapis | externalApis.json |
| dependencies | dependencies.json |
| deployments | deployments.json |


## Support
* Please send feature requests using [issues](https://github.com/apigee/apigee-apihub-maven-plugin/issues)
* Post a question in [Apigee community](https://community.apigee.com/index.html)
* Create an [issue](https://github.com/apigee/apigee-apihub-maven-plugin/issues/new)

## Disclaimer
This is not an officially supported Google product.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
Expand Down
16 changes: 8 additions & 8 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ mvn install -P{profile} -DprojectId=${project} -Dfile={path}
-P<profile>
Pick a profile in the pom.xml.
Apigee APi Hub location, config file, option are picked from the profile.
Apigee API Hub location, config directory, option are picked from the profile.
-Dapigee.apihub.config.options
none - No action (default)
create - Creates the API in the Apigee API Hub
update - Updates the API in the Apigee API Hub
delete - Deletes the API in the Apigee API Hub
sync - executes delete and update options mentioned above
create - Create when not found. Pre-existing config is NOT updated even if it is different.
update - Update when found; create when not found
delete - Delete when found
sync - Delete and recreate.
-Dfile
path to the service account key file that has the appropriate Apigee API Hub permissions
-Dapigee.apihub.config.dir
path to the directory containing the configuration
-Dbearer
access token. Service Account file takes precedence
Expand All @@ -34,7 +34,7 @@ mvn install -P{profile} -DprojectId=${project} -Dfile={path}

## API Configuration

- Check out the samples that includes the structure of the API, specs, deployment and artifact objects needed to push an API to the API Hub
- Check out the samples that includes the structure of the API, specs, deployment and other config objects needed to push an API to the API Hub


### Basic Implementation
Expand Down
53 changes: 53 additions & 0 deletions samples/apiVersions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"name":"api1/versions/version-1",
"displayName":"version-1",
"description":"version-1",
"documentation":{
"externalUri":"https://api-docs.example.com"
},
"deployments":[
"deployment1"
],
"lifecycle":{
"attribute":"system-lifecycle",
"enumValues":{
"values":[
{
"id":"concept"
}
]
}
},
"attributes":{
"sample-attribute1":{
"enumValues":{
"values":[
{
"id":"foo0"
}
]
}
}
},
"selectedDeployment":"deployment1"
},
{
"name":"api1/versions/version-2",
"displayName":"version-2",
"description":"version-2",
"documentation":{
"externalUri":"https://api-docs.example.com"
},
"lifecycle":{
"attribute":"system-lifecycle",
"enumValues":{
"values":[
{
"id":"design"
}
]
}
}
}
]
73 changes: 73 additions & 0 deletions samples/apis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[
{
"name":"api1",
"displayName":"API 1",
"description":"API 1",
"documentation":{
"externalUri":"https://api-docs.example.com"
},
"owner":{
"displayName":"API Owner",
"email":"[email protected]"
},
"targetUser":{
"attribute":"system-target-user",
"enumValues":{
"values":[
{
"id":"team"
}
]
}
},
"team":{
"attribute":"system-team",
"enumValues":{
"values":[
{
"id":"example-team"
}
]
}
},
"businessUnit":{
"attribute":"system-business-unit",
"enumValues":{
"values":[
{
"id":"example-business-unit"
}
]
}
},
"maturityLevel":{
"attribute":"system-maturity-level",
"enumValues":{
"values":[
{
"id":"level-1"
}
]
}
},
"apiStyle":{
"attribute":"system-api-style",
"enumValues":{
"values":[
{
"id":"rest"
}
]
}
},
"attributes":{
"sample-attribute10":{
"stringValues":{
"values":[
"Test"
]
}
}
}
}
]
52 changes: 52 additions & 0 deletions samples/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,57 @@
"scope": "EXTERNAL_API",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute7",
"displayName": "sample-attribute7",
"description": "Sample Attribute 7",
"scope": "EXTERNAL_API",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute8",
"displayName": "sample-attribute8",
"description": "Sample Attribute 8",
"scope": "DEPENDENCY",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute9",
"displayName": "sample-attribute9",
"description": "Sample Attribute 9",
"scope": "DEPENDENCY",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute10",
"displayName": "sample-attribute10",
"description": "Sample Attribute 10",
"scope": "API",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute11",
"displayName": "sample-attribute11",
"description": "Sample Attribute 11",
"scope": "EXTERNAL_API",
"dataType": "ENUM",
"allowedValues": [
{
"id": "foo0",
"displayName": "foo",
"description": "bar"
},
{
"id": "url0",
"displayName": "url",
"description": "https://google.com"
}
],
"cardinality": 1
}
]
28 changes: 28 additions & 0 deletions samples/dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"name":"dependency1",
"description": "Dependency 1",
"consumer":{
"externalApiResourceName":"externalApis/externalApi1"
},
"supplier":{
"externalApiResourceName":"externalApis/externalApi2"
},
"attributes":{
"sample-attribute8":{
"stringValues":{
"values":[
"dependency1"
]
}
},
"sample-attribute9":{
"stringValues":{
"values":[
"dependency2"
]
}
}
}
}
]
Loading

0 comments on commit 048c853

Please sign in to comment.