You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+25-21Lines changed: 25 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,24 +15,28 @@
15
15
16
16
## <aname="who"></a>Audience
17
17
18
-
You are an Apigee Edge API proxy developer, or you would like to learn about developing APIs that run on Apigee Edge. At a minimum, we assume you're familiar with Apigee Edge and how to create simple API proxies. To learn more, we recommend this [getting-started tutorial](https://docs.apigee.com/api-platform/get-started/get-started).
18
+
You are an Apigee Edge API proxy developer, or you would like to learn about
19
+
developing APIs that run on Apigee Edge. At a minimum, we assume you're familiar
20
+
with Apigee Edge and how to create simple API proxies. To learn more, we
> These samples were built to work with Apigee EDGE. The current version of
21
25
> Apigee is known as Apigee X. Most of these samples will work with Apigee X,
22
26
> but the deployment scripts will not, and the instructions for administrative
23
-
> actions (eg, sign up for an account at apigee.com) will not work either. In
27
+
> actions (eg, sign up for an account at apigee.com) will not work either. In
24
28
> those cases, you will need to substitute the appropriate actions relating to
25
29
> Apigee X!
26
30
27
31
> Bear with us, please!
28
32
29
33
## <aname="intro"></a>Intro
30
34
31
-
This repository contains a collection of sample API proxies that you can deploy and run on [Apigee Edge](https://apigee.com/api-management/#/products).
35
+
This repository contains a collection of sample API proxies that you can deploy and run on [Apigee Edge](https://apigee.com/api-management/#/products).
32
36
33
37

34
38
35
-
The samples provide a jump-start for developers who wish to design and create Apigee Edge API proxies. Each proxy sample includes a `deploy.sh` and `invoke.sh` script. These scripts let you easily deploy and run the proxies.
39
+
The samples provide a jump-start for developers who wish to design and create Apigee Edge API proxies. Each proxy sample includes a `deploy.sh` and `invoke.sh` script. These scripts let you easily deploy and run the proxies.
36
40
37
41
In addition, you'll find:
38
42
@@ -51,14 +55,14 @@ In addition, you'll find:
51
55
52
56
## <aname="using"></a>Using the sample proxies
53
57
54
-
Most developers begin by identifying an interesting sample based on a specific use case or need. You'll find the samples in the `./api-platform-samples/sample-proxies` folder. The Apigee doc site also has a handy [samples overview page](https://docs.apigee.com/api-platform/samples/samples-reference).
58
+
Most developers begin by identifying an interesting sample based on a specific use case or need. You'll find the samples in the `./api-platform-samples/sample-proxies` folder. The Apigee doc site also has a handy [samples overview page](https://docs.apigee.com/api-platform/samples/samples-reference).
55
59
56
60
57
-
For example, if you're interested in doing XML to JSON transformations, check out `api-platform-samples/sample-proxies/xmltojson`.
61
+
For example, if you're interested in doing XML to JSON transformations, check out `api-platform-samples/sample-proxies/xmltojson`.
58
62
59
63
## <aname="initial"></a>Setting up
60
64
61
-
Set up your deployment environment.
65
+
Set up your deployment environment.
62
66
63
67
1. Open the file `./api-platform-samples/setup/setenv.sh` in a text editor.|
64
68
@@ -79,17 +83,17 @@ We make it easy:
79
83
80
84
1. Be sure you've updated `./api-platform-samples/setup/setenv.sh` as explained previously.
81
85
82
-
2. cd to one of the sample proxy folders in `./api-platform-samples/sample-proxies`.
86
+
2. cd to one of the sample proxy folders in `./api-platform-samples/sample-proxies`.
83
87
84
88
3. Be sure you can execute the `deploy.sh` script. For example:
85
89
86
90
`chmod 744 deploy.sh`
87
91
88
-
4. Execute the deploy script.
92
+
4. Execute the deploy script.
89
93
90
94
`./deploy.sh`
91
95
92
-
**Note:** If you already have the proxy deployed, the script will undeploy it first, then redeploy a new revision.
96
+
**Note:** If you already have the proxy deployed, the script will undeploy it first, then redeploy a new revision.
93
97
94
98
Output like this means a successful deployment:
95
99
@@ -109,28 +113,28 @@ We make this easy too! Each sample API proxy directory contains a script, `invok
109
113
110
114
1. Be sure you've updated `./api-platform-samples/setup/setenv.sh` as explained previously.
111
115
112
-
2. cd to one of the sample proxy folders in `./api-platform-samples/sample-proxies`.
116
+
2. cd to one of the sample proxy folders in `./api-platform-samples/sample-proxies`.
113
117
114
118
3. Be sure you can execute the `invoke.sh` script. For example:
115
119
116
120
`chmod 744 invoke.sh`
117
121
118
122
4. Open the `invoke.sh` file and take a look at the code. Basically, the invoke scripts make `curl` requests to Apigee Edge. In some cases, `invoke.sh` performs other setup tasks, such as creating products, developer apps, and other entities on Edge.
119
123
120
-
**Tip:** Always open `invoke.sh` and look through it before executing it -- this will give you valuable insight into how the API proxy is called and any setup steps that are performed.
124
+
**Tip:** Always open `invoke.sh` and look through it before executing it -- this will give you valuable insight into how the API proxy is called and any setup steps that are performed.
121
125
122
-
4. Execute the `invoke.sh` script.
126
+
4. Execute the `invoke.sh` script.
123
127
124
128
`./invoke.sh`
125
129
126
130
127
131
## <a name="modifying"></a>Modifying a sample proxy
128
132
129
-
Feel free to modify and build upon the sample proxies. You can make changes in the Edge management UI or by editing the proxy XML files locally and redeploying. Whichever approach is comfortable for you.
133
+
Feel free to modify and build upon the sample proxies. You can make changes in the Edge management UI or by editing the proxy XML files locally and redeploying. Whichever approach is comfortable for you.
130
134
131
-
>Tip: If you use Sublime for local development, check out the [Sweetlime](https://github.com/apigee/Sweetlime) project on GitHub. Sweetlime is a Sublime plugin for developing API proxies for Apigee Edge.
135
+
>Tip: If you use Sublime for local development, check out the [Sweetlime](https://github.com/apigee/Sweetlime) project on GitHub. Sweetlime is a Sublime plugin for developing API proxies for Apigee Edge.
132
136
133
-
Simply redeploy the proxies for changes to take effect.
137
+
Simply redeploy the proxies for changes to take effect.
134
138
135
139
## <a name="bulk"></a>Bulk deployment
136
140
@@ -164,7 +168,7 @@ API products, apps, and developers.
164
168
165
169
### `/setup`
166
170
167
-
Simple scripts to help you deploy the sample API proxies and profiles that they
171
+
Simple scripts to help you deploy the sample API proxies and profiles that they
168
172
rely on, including API products, developers, and apps.
169
173
170
174
Set you Apigee API Platform account settings in `setenv.sh` ([Register for a free Apigee account](https://docs.apigee.com/api-platform/get-started/creating-apigee-edge-account))
@@ -187,14 +191,14 @@ To deploy all samples and API products, run `deploy_all.sh`
187
191
188
192
## <a name="docs"></a>Apigee Edge documentation
189
193
190
-
The Apigee Edge docs are [here](https://docs.apigee.com).
194
+
The Apigee Edge docs are [here](https://docs.apigee.com).
Optionally, you can deploy each of the sub-modules independently by running the same command within the specific directory.
48
+
Optionally, you can deploy each of the sub-modules independently by running the same command within the specific directory.
49
49
50
50
e.g.
51
51
@@ -76,7 +76,7 @@ The sample Apigee proxy is designed to be simple, yet concise, in order to conve
76
76
2.**A KVM policy** to retrieve a scopes map
77
77
3.**A JavaScript policy** to convert scopes to GraphQL entitlements
78
78
4.**A JavaScript Callout** to validate and authorize the GraphQL query.
79
-
79
+
80
80
The JavaScript Callout (in step 4), uses the [graphql-js](https://github.com/graphql/graphql-js) library to parse and syntactically validate the incoming GraphQL query. Upon validation, it proceeds to list the paths that are being accessed within the GraphQL query.
81
81
82
82
For example, this query:
@@ -98,7 +98,7 @@ query.resorts.name
98
98
```
99
99
100
100
In order to authorize the query, the JavaScript callout then compares the paths that are being accessed against the paths that the client is entitled to access. For a client request to be successfully authorized, the client entitlements must contain the paths being accessed in the query.
101
-
101
+
102
102
This is what the configuration looks like for the JavaScript callout (in step 4)
103
103
104
104
```
@@ -155,15 +155,15 @@ For this sample Apigee proxy, we are building the client entitlements list by us
155
155
}
156
156
```
157
157
158
-
Given the above map, if the arriving request has `reader` scope, it means that the client is entitled to execute introspection queries as well as read resorts related data.
158
+
Given the above map, if the arriving request has `reader` scope, it means that the client is entitled to execute introspection queries as well as read resorts related data.
159
159
160
160
While it's not necessary to have a scopes-to-entitlements map, it's a practical abstraction that allows you to logically group a set of entitlements and segment access to your GraphQL schema.
161
161
162
162
Scopes are filtered at the Apigee API Product level. As an example, you could have a set Apigee API Products designed like this:
163
163
164
164

165
165
166
-
This approach plays specially well with Apigee's consumption model with OAuth, Apps, and API Products. You could enforce that subscriptions to the `GraphQL Platinum` product require approval, where as the `GraphQL Bronze` product is open to all.
166
+
This approach plays specially well with Apigee's consumption model with OAuth, Apps, and API Products. You could enforce that subscriptions to the `GraphQL Platinum` product require approval, where as the `GraphQL Bronze` product is open to all.
167
167
168
168
### Using GraphQL Playground to test the API Proxy
169
169
@@ -177,13 +177,13 @@ To test the sample proxy, you can use the [GraphQL playground](https://legacy.gr
177
177
178
178
As soon as the GraphQL playground opens up, it sends a couple of introspection queries to the Apigee proxy.
179
179
You can open the [Apigee Trace Tool](https://docs.apigee.com/api-platform/debug/using-trace-tool-0) and refresh the playground to see the introspection query arriving.
Note that this proxy configured such that all requests are implicitly granted the entitlements needed to introspect the schema. That's why this first request goes through successfully.
184
184
185
-
However, if you try to send additional queries, you will see that Apigee blocks them.
186
-
185
+
However, if you try to send additional queries, you will see that Apigee blocks them.
186
+
187
187

188
188
189
189
You have to open the **Headers** tab in the playground, and add a **scope** header.
0 commit comments