Created
October 4, 2022 11:13
-
-
Save rickymoorhouse/95ca5237bf93f31c2d1629b94662882d to your computer and use it in GitHub Desktop.
Invoke IBM Cloud functions from API Connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| swagger: '2.0' | |
| info: | |
| version: 1.0.0 | |
| title: IBM Cloud Functions | |
| x-ibm-name: ibm-cloud-functions | |
| basePath: /ibm-cloud-functions | |
| x-ibm-configuration: | |
| properties: | |
| function-url: | |
| value: YOUR-FUNCTION-URL | |
| description: URL of the IBM Cloud function endpoint | |
| iam-apikey: | |
| value: YOUR-API-KEY | |
| description: IBM Cloud IAM API KEY | |
| cors: | |
| enabled: true | |
| gateway: datapower-api-gateway | |
| type: rest | |
| phase: realized | |
| enforced: true | |
| testable: true | |
| assembly: | |
| execute: | |
| - set-variable: | |
| version: 2.0.0 | |
| title: setup iam request | |
| actions: | |
| - set: message.headers.content-type | |
| value: application/x-www-form-urlencoded | |
| type: string | |
| - set: message.headers.accept | |
| value: application/json | |
| type: string | |
| - set: message.body | |
| type: string | |
| value: >- | |
| grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$(iam-apikey) | |
| - invoke: | |
| version: 2.2.0 | |
| title: 'invoke: iam' | |
| backend-type: json | |
| header-control: | |
| type: blocklist | |
| values: [] | |
| parameter-control: | |
| type: allowlist | |
| values: [] | |
| http-version: HTTP/1.1 | |
| timeout: 60 | |
| verb: POST | |
| chunked-uploads: false | |
| persistent-connection: false | |
| cache-response: time-to-live | |
| cache-ttl: 900 | |
| stop-on-error: [] | |
| websocket-upgrade: false | |
| target-url: https://iam.cloud.ibm.com/identity/token | |
| output: iam | |
| cache-key: iam-api-key | |
| - parse: | |
| version: 2.1.0 | |
| title: parse response | |
| parse-settings-reference: | |
| default: apic-default-parsesettings | |
| use-content-type: true | |
| input: iam | |
| output: iam | |
| - set-variable: | |
| version: 2.0.0 | |
| title: setup function call | |
| actions: | |
| - set: message.headers.authorization | |
| value: Bearer $(iam.body.access_token) | |
| type: string | |
| - set: message.body | |
| value: $(request.body) | |
| type: any | |
| - set: message.headers.accept | |
| value: application/json | |
| type: string | |
| - invoke: | |
| version: 2.2.0 | |
| title: invoke functions | |
| backend-type: detect | |
| header-control: | |
| type: allowlist | |
| values: | |
| - Accept | |
| - Authorization | |
| parameter-control: | |
| type: allowlist | |
| values: [] | |
| http-version: HTTP/1.1 | |
| timeout: 60 | |
| verb: POST | |
| chunked-uploads: true | |
| persistent-connection: true | |
| cache-response: protocol | |
| cache-ttl: 900 | |
| stop-on-error: [] | |
| graphql-send-type: detect | |
| websocket-upgrade: false | |
| target-url: $(function-url) | |
| - map: | |
| version: 2.0.0 | |
| title: map | |
| inputs: | |
| input: | |
| schema: | |
| description: '' | |
| type: object | |
| properties: | |
| activationId: | |
| type: string | |
| name: activationId | |
| annotations: | |
| type: array | |
| items: | |
| properties: | |
| key: | |
| type: string | |
| name: key | |
| value: | |
| type: string | |
| name: value | |
| type: object | |
| name: annotations | |
| duration: | |
| type: number | |
| name: duration | |
| end: | |
| type: number | |
| name: end | |
| logs: | |
| type: array | |
| items: | |
| required: [] | |
| properties: {} | |
| type: object | |
| name: logs | |
| name: | |
| type: string | |
| name: name | |
| namespace: | |
| type: string | |
| name: namespace | |
| publish: | |
| type: boolean | |
| name: publish | |
| response: | |
| type: object | |
| properties: | |
| result: | |
| type: object | |
| properties: | |
| message: | |
| type: string | |
| name: message | |
| name: result | |
| size: | |
| type: number | |
| name: size | |
| status: | |
| type: string | |
| name: status | |
| success: | |
| type: boolean | |
| name: success | |
| name: response | |
| start: | |
| type: number | |
| name: start | |
| subject: | |
| type: string | |
| name: subject | |
| version: | |
| type: string | |
| name: version | |
| example: >- | |
| {"activationId":"ff02e385f2e44a2782e385f2e4fa2733","annotations":[{"key":"path","value":"dc6f8fa6-3ff5-4db6-8fb3-a6fc538c672b/example-function"},{"key":"waitTime","value":170},{"key":"transId","value":"a52036cf250abfe4dc55805a0f7b0d6e"},{"key":"kind","value":"nodejs:16"},{"key":"timeout","value":false},{"key":"limits","value":{"concurrency":1,"logs":10,"memory":256,"timeout":60000}}],"duration":3,"end":1664873207438,"logs":[],"name":"example-function","namespace":"dc6f8fa6-3ff5-4db6-8fb3-a6fc538c672b","publish":false,"response":{"result":{"message":"Hello | |
| World"},"size":25,"status":"success","success":true},"start":1664873207435,"subject":"moorh@uk.ibm.com","version":"0.0.1"} | |
| variable: message.body | |
| outputs: | |
| output: | |
| schema: | |
| type: object | |
| variable: message.body | |
| actions: | |
| - set: output | |
| from: input.response.result | |
| finally: [] | |
| activity-log: | |
| enabled: true | |
| success-content: activity | |
| error-content: payload | |
| paths: | |
| /: | |
| get: | |
| responses: | |
| '200': | |
| description: success | |
| schema: | |
| type: string | |
| consumes: [] | |
| produces: [] | |
| put: | |
| responses: | |
| '200': | |
| description: success | |
| schema: | |
| type: string | |
| consumes: [] | |
| produces: [] | |
| post: | |
| responses: | |
| '200': | |
| description: success | |
| schema: | |
| type: string | |
| consumes: [] | |
| produces: [] | |
| delete: | |
| responses: | |
| '200': | |
| description: success | |
| schema: | |
| type: string | |
| consumes: [] | |
| produces: [] | |
| head: | |
| responses: | |
| '200': | |
| description: success | |
| schema: | |
| type: string | |
| consumes: [] | |
| produces: [] | |
| patch: | |
| responses: | |
| '200': | |
| description: success | |
| schema: | |
| type: string | |
| consumes: [] | |
| produces: [] | |
| securityDefinitions: | |
| clientID: | |
| type: apiKey | |
| in: header | |
| name: X-IBM-Client-Id | |
| security: | |
| - clientID: [] | |
| schemes: | |
| - https |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment