Skip to content

Commit

Permalink
Merge pull request #1 from apigee/export
Browse files Browse the repository at this point in the history
Export features
  • Loading branch information
ssvaidyanathan authored Oct 14, 2024
2 parents 44ec935 + effe68f commit e1d6d4e
Show file tree
Hide file tree
Showing 25 changed files with 940 additions and 399 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ replay_pid*
.classpath
.project
bin/
export/
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The [samples folder](./samples) provides a README with Getting Started steps and

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

Expand All @@ -38,19 +39,34 @@ mvn install -P<profile> -Dapigee.apihub.config.dir=$path -Dapigee.apihub.config.
#### 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
mvn install -P{profile} -DprojectId=${project} -Dfile={path}
# Options
-P<profile>
Pick a profile in the pom.xml.
Apigee API Hub location, config directory, option are picked 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
export - export all entities to a file
sync - Delete and recreate.
-Dapigee.apihub.config.dir
path to the directory containing the configuration
-Dapigee.apihub.config.dir
path to the directory containing the configuration
-Dapigee.apihub.config.exportDir
path to the directory where the entities will be exported to
-Dapigee.apihub.force.delete
set this flag to true to forcefully delete all dependent entities (applicable for apis and apiversions)
-Dbearer
access token. Service Account file takes precedence
```

#### Individual goals
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<groupId>com.apigee.apihub.config</groupId>
<artifactId>apigee-apihub-maven-plugin</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>apigee-apihub-maven-plugin</name>
<description>Plugin to manage operations in the Apigee API Hub</description>
Expand Down Expand Up @@ -65,12 +65,12 @@
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>1.21.0</version>
<version>1.28.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-apihub</artifactId>
<version>0.1.0</version>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
Expand Down
22 changes: 19 additions & 3 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ mvn install -P{profile} -DprojectId=${project} -Dfile={path}
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
export - export all entities to a file
sync - Delete and recreate.
-Dapigee.apihub.config.dir
path to the directory containing the configuration
-Dapigee.apihub.config.exportDir
path to the directory where the entities will be exported to
-Dapigee.apihub.force.delete
set this flag to true to forcefully delete all dependent entities (applicable for apis and apiversions)
-Dbearer
access token. Service Account file takes precedence
Expand All @@ -28,8 +35,8 @@ mvn install -P{profile} -DprojectId=${project} -Dfile={path}

# Samples

## Prerequisites (Apigee Hub setup)
- Follow the [steps](https://cloud.google.com/apigee/docs/api-hub/get-started-api-hub) to provision Apigee Hub
## Prerequisites (Apigee API hub setup)
- Follow the [steps](https://cloud.google.com/apigee/docs/api-hub/get-started-api-hub) to provision Apigee API hub
- Create a Service Account with the Apigee API hub permissions, download the service account key file

## API Configuration
Expand All @@ -56,17 +63,26 @@ To use, edit samples/pom.xml and update values as specified.
<apigee.apihub.config.options>${options}</apigee.apihub.config.options> <!-- Options like none, create, update, delete, sync. Default is none-->
<apigee.apihub.serviceaccount.file>${file}</apigee.apihub.serviceaccount.file> <!-- Service Account File. Use this or "apigee.apihub.bearer". Service Account takes precedence -->
<apigee.apihub.bearer>${bearer}</apigee.apihub.bearer> <!-- Bearer Token. Use this or "apigee.apihub.serviceaccount.file" -->
<apigee.apihub.force.delete>false</apigee.apihub.force.delete> <!-- Force delete entities. Default is false -->
<apigee.apihub.config.exportDir>./export</apigee.apihub.config.exportDir> <!-- Export Directory -->
```

To run, jump to the sample project `cd /samples` and run

```bash
mvn install -P{profile} -DprojectId={projectId} -Doptions={option} -Dfile={path}
mvn install -P{profile} -DprojectId={projectId} -Dlocation={location} -Dapigee.apihub.config.options={option} -Dfile={path}
```
where
- `profile` is the Maven profile in the pom.xml
- `projectId` is the GCP Project ID where Apigee Hub is provisioned
- `location` is the GCP Region where Apigee Hub is provisioned
- `options` to either "create", "update", "delete" or "sync" the API into the API Hub
- `path` is the path to your Service Account Key file

or to run it directly using your access token, run

```bash
mvn install -P{profile} -DprojectId={projectId} -Dlocation={location} -Dapigee.apihub.config.options={option} -Dbearer=$(gcloud auth print-access-token)
```


14 changes: 7 additions & 7 deletions samples/apiVersions.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
{
"name":"api1/versions/version-1",
"name":"projects/PROJECT_ID/locations/LOCATION/apis/api1/versions/version-1",
"displayName":"version-1",
"description":"version-1",
"documentation":{
"externalUri":"https://api-docs.example.com"
},
"deployments":[
"deployment1"
"projects/PROJECT_ID/locations/LOCATION/deployments/deployment1"
],
"lifecycle":{
"attribute":"system-lifecycle",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-lifecycle",
"enumValues":{
"values":[
{
Expand All @@ -20,7 +20,7 @@
}
},
"attributes":{
"sample-attribute1":{
"projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute1":{
"enumValues":{
"values":[
{
Expand All @@ -30,17 +30,17 @@
}
}
},
"selectedDeployment":"deployment1"
"selectedDeployment":"projects/PROJECT_ID/locations/LOCATION/deployments/deployment1"
},
{
"name":"api1/versions/version-2",
"name":"projects/PROJECT_ID/locations/LOCATION/apis/api1/versions/version-2",
"displayName":"version-2",
"description":"version-2",
"documentation":{
"externalUri":"https://api-docs.example.com"
},
"lifecycle":{
"attribute":"system-lifecycle",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-lifecycle",
"enumValues":{
"values":[
{
Expand Down
16 changes: 8 additions & 8 deletions samples/apis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name":"api1",
"name":"projects/PROJECT_ID/locations/LOCATION/apis/api1",
"displayName":"API 1",
"description":"API 1",
"documentation":{
Expand All @@ -11,7 +11,7 @@
"email":"[email protected]"
},
"targetUser":{
"attribute":"system-target-user",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-target-user",
"enumValues":{
"values":[
{
Expand All @@ -21,7 +21,7 @@
}
},
"team":{
"attribute":"system-team",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-team",
"enumValues":{
"values":[
{
Expand All @@ -31,7 +31,7 @@
}
},
"businessUnit":{
"attribute":"system-business-unit",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-business-unit",
"enumValues":{
"values":[
{
Expand All @@ -41,7 +41,7 @@
}
},
"maturityLevel":{
"attribute":"system-maturity-level",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-maturity-level",
"enumValues":{
"values":[
{
Expand All @@ -51,7 +51,7 @@
}
},
"apiStyle":{
"attribute":"system-api-style",
"attribute":"projects/PROJECT_ID/locations/LOCATION/attributes/system-api-style",
"enumValues":{
"values":[
{
Expand All @@ -61,10 +61,10 @@
}
},
"attributes":{
"sample-attribute10":{
"projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute10":{
"stringValues":{
"values":[
"Test"
"Test123"
]
}
}
Expand Down
24 changes: 12 additions & 12 deletions samples/attributes.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "sample-attribute1",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute1",
"displayName": "sample-attribute1",
"description": "Sample Attribute 1",
"scope": "VERSION",
Expand All @@ -17,82 +17,82 @@
"description": "https://google.com"
}
],
"cardinality": 1,
"cardinality": 1
},
{
"name": "sample-attribute2",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute2",
"displayName": "sample-attribute2",
"description": "Sample Attribute 2",
"scope": "SPEC",
"dataType": "JSON",
"cardinality": 1
},
{
"name": "sample-attribute3",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute3",
"displayName": "sample-attribute3",
"description": "Sample Attribute 3",
"scope": "DEPLOYMENT",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute4",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute4",
"displayName": "sample-attribute4",
"description": "Sample Attribute 4",
"scope": "DEPLOYMENT",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute5",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute5",
"displayName": "sample-attribute5",
"description": "Sample Attribute 5",
"scope": "DEPENDENCY",
"dataType": "JSON",
"cardinality": 1
},
{
"name": "sample-attribute6",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute6",
"displayName": "sample-attribute6",
"description": "Sample Attribute 6",
"scope": "EXTERNAL_API",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute7",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute7",
"displayName": "sample-attribute7",
"description": "Sample Attribute 7",
"scope": "EXTERNAL_API",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute8",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute8",
"displayName": "sample-attribute8",
"description": "Sample Attribute 8",
"scope": "DEPENDENCY",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute9",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute9",
"displayName": "sample-attribute9",
"description": "Sample Attribute 9",
"scope": "DEPENDENCY",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute10",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute10",
"displayName": "sample-attribute10",
"description": "Sample Attribute 10",
"scope": "API",
"dataType": "STRING",
"cardinality": 1
},
{
"name": "sample-attribute11",
"name": "projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute11",
"displayName": "sample-attribute11",
"description": "Sample Attribute 11",
"scope": "EXTERNAL_API",
Expand Down
10 changes: 5 additions & 5 deletions samples/dependencies.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[
{
"name":"dependency1",
"name":"projects/PROJECT_ID/locations/LOCATION/dependencies/dependency1",
"description": "Dependency 1",
"consumer":{
"externalApiResourceName":"externalApis/externalApi1"
"externalApiResourceName":"projects/PROJECT_ID/locations/LOCATION/externalApis/externalApi1"
},
"supplier":{
"externalApiResourceName":"externalApis/externalApi2"
"externalApiResourceName":"projects/PROJECT_ID/locations/LOCATION/externalApis/externalApi2"
},
"attributes":{
"sample-attribute8":{
"projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute8":{
"stringValues":{
"values":[
"dependency1"
]
}
},
"sample-attribute9":{
"projects/PROJECT_ID/locations/LOCATION/attributes/sample-attribute9":{
"stringValues":{
"values":[
"dependency2"
Expand Down
Loading

0 comments on commit e1d6d4e

Please sign in to comment.