├── .gitignore ├── CHANGELOG.md ├── README.md ├── gulpfile.js ├── package.json ├── src ├── client.js ├── deployment.js ├── index.js ├── integration-response.js ├── integration.js ├── method-response.js ├── method.js ├── model.js ├── resource.js └── restapi.js └── test └── client-test.js /.gitignore: -------------------------------------------------------------------------------- 1 | /lib 2 | /node_modules 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v0.1.4 2 | - Follow the change of response body `_embedded` format (#6) 3 | 4 | ## v0.1.3 5 | - Add Client#listDeployments 6 | 7 | ## v0.1.2 8 | - Add more parameters to Client#putMethodResponse (#1) 9 | 10 | ## v0.1.1 11 | - Add Client#getMethod 12 | - Add Client#getRestapi 13 | 14 | ## v0.1.0 15 | - Add Client#createDeployment 16 | - Add Client#putMethodResponse 17 | - Add Client#putIntegrationResponse 18 | 19 | ## v0.0.5 20 | - Add Client#putIntegration 21 | 22 | ## v0.0.4 23 | - Add Client#createResources 24 | - Add Client#deleteRestapi 25 | - Add Client#getRootResources 26 | - Add Client#putMethod 27 | 28 | ## v0.0.3 29 | - Rebuild lib dir 30 | 31 | ## v0.0.2 32 | - Add Client#deleteModel 33 | - Update stackable-fetcher version 34 | 35 | ## v0.0.1 36 | - 1st release 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # amazon-api-gateway-client 2 | A client library for Amazon API Gateway. 3 | 4 | ## Install 5 | ``` 6 | npm install amazon-api-gateway-client 7 | ``` 8 | 9 | ## Usage 10 | ```js 11 | var Client = require('amazon-api-gateway-client').Client; 12 | 13 | var client = new Client({ 14 | accessKeyId: '...', 15 | region: '...', 16 | secretAccessKey: '...' 17 | }); 18 | 19 | client.createRestapi({ name: 'MyRestapi' }).then(function (restapi) { 20 | // ... 21 | }); 22 | 23 | client.listRestapis().then(function (restapis) { 24 | // ... 25 | }); 26 | ``` 27 | 28 | ## Development 29 | ``` 30 | npm install 31 | npm run 32 | ``` 33 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var babel = require('gulp-babel'); 2 | var gulp = require('gulp'); 3 | var mocha = require('gulp-mocha'); 4 | var register = require('babel/register'); 5 | 6 | gulp.task('build', function () { 7 | return gulp.src('src/**/*.js') 8 | .pipe(babel()) 9 | .pipe(gulp.dest('lib')); 10 | }); 11 | 12 | gulp.task('test', function () { 13 | return gulp.src('test/**/*.js') 14 | .pipe( 15 | mocha({ 16 | compilers: { 17 | js: register 18 | } 19 | }) 20 | ); 21 | }); 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "MIT", 3 | "main": "lib/index.js", 4 | "name": "amazon-api-gateway-client", 5 | "repository": "r7kamura/amazon-api-gateway-client", 6 | "scripts": { 7 | "build": "gulp build", 8 | "test": "gulp test" 9 | }, 10 | "files": [ 11 | "lib" 12 | ], 13 | "version": "0.1.4", 14 | "devDependencies": { 15 | "babel": "^5.8.19", 16 | "gulp-babel": "^5.2.0", 17 | "gulp-mocha": "^2.1.3", 18 | "mocha": "^2.2.5" 19 | }, 20 | "dependencies": { 21 | "stackable-fetcher": "^0.3.0", 22 | "stackable-fetcher-aws-signer-v4": "0.0.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/client.js: -------------------------------------------------------------------------------- 1 | import AwsSignerV4 from 'stackable-fetcher-aws-signer-v4' 2 | import { Fetcher, JsonRequestEncoder, JsonResponseDecoder, RejectLogger } from 'stackable-fetcher' 3 | import Deployment from './deployment' 4 | import Integration from './integration' 5 | import IntegrationResponse from './integration-response' 6 | import Method from './method' 7 | import MethodResponse from './method-response' 8 | import Model from './model' 9 | import path from 'path' 10 | import Resource from './resource' 11 | import Restapi from './restapi' 12 | 13 | /** 14 | * @class Client 15 | */ 16 | export default class Client { 17 | /** 18 | * @param {String} accessKeyId 19 | * @param {Fetcher} fetcher 20 | * @param {String} region 21 | * @param {String} secretAccessKey 22 | */ 23 | constructor({ accessKeyId, fetcher, region, secretAccessKey }) { 24 | this.accessKeyId = accessKeyId; 25 | this._fetcher = fetcher; 26 | this.region = region; 27 | this.secretAccessKey = secretAccessKey; 28 | } 29 | 30 | /** 31 | * @param {Boolean=} cacheClusterEnabled 32 | * @param {Integer=} cacheClusterSize 33 | * @param {String=} description 34 | * @param {String} restapiId 35 | * @param {String} stageDescription 36 | * @param {String} stageName 37 | * @return {Promise} 38 | */ 39 | createDeployment({ cacheClusterEnabled, cacheClusterSize, description, restapiId, stageDescription, stageName }) { 40 | return this.getFetcher().post( 41 | `${this._getBaseUrl()}/restapis/${restapiId}/deployments`, 42 | { 43 | cacheClusterEnabled: cacheClusterEnabled, 44 | cacheClusterSize: cacheClusterSize, 45 | description: description, 46 | stageDescription: stageDescription, 47 | stageName: stageName 48 | } 49 | ).then(body => new Deployment(body)); 50 | } 51 | 52 | /** 53 | * @param {String} parentId 54 | * @param {String} pathPart 55 | * @param {String} restapiId 56 | * @return {Promise} 57 | */ 58 | createResource({ parentId, pathPart, restapiId }) { 59 | return this.getFetcher().post( 60 | `${this._getBaseUrl()}/restapis/${restapiId}/resources/${parentId}`, 61 | { pathPart: pathPart } 62 | ).then(body => new Resource(body)); 63 | } 64 | 65 | /** 66 | * @param {Array.} paths 67 | * @param {String} restapiId 68 | * @return {Promise} 69 | */ 70 | createResources({ paths, restapiId }) { 71 | return this.getRootResource({ restapiId: restapiId }).then((rootResource) => { 72 | return this._createResourcesByPaths({ 73 | paths: paths, 74 | restapiId: restapiId, 75 | rootResource: rootResource 76 | }); 77 | }); 78 | } 79 | 80 | /** 81 | * @param {String} name 82 | * @return {Promise} 83 | */ 84 | createRestapi({ name }) { 85 | return this.getFetcher().post( 86 | `${this._getBaseUrl()}/restapis`, 87 | { name: name } 88 | ).then(body => new Restapi(body)); 89 | } 90 | 91 | /** 92 | * @param {String} modelName 93 | * @param {String} restapiId 94 | * @return {Promise} 95 | */ 96 | deleteModel({ modelName, restapiId }) { 97 | return this.getFetcher().delete( 98 | `${this._getBaseUrl()}/restapis/${restapiId}/models/${modelName}` 99 | ).then(response => null); 100 | } 101 | 102 | /** 103 | * @param {String} restapiId 104 | * @return {Promise} 105 | */ 106 | deleteRestapi({ restapiId }) { 107 | return this.getFetcher().delete( 108 | `${this._getBaseUrl()}/restapis/${restapiId}` 109 | ).then(response => null); 110 | } 111 | 112 | /** 113 | * @todo Use Array.prototype.find polyfill instead of forEach 114 | * @param {String} path 115 | * @param {String} restapiId 116 | * @return {Promise} 117 | */ 118 | findResourceByPath({ path, restapiId }) { 119 | return this.listResources({ 120 | restapiId: restapiId 121 | }).then((resources) => { 122 | let matchedResource; 123 | resources.forEach((resource) => { 124 | if (resource.source.path === path) { 125 | matchedResource = resource; 126 | } 127 | }); 128 | return matchedResource; 129 | }); 130 | } 131 | 132 | /** 133 | * @return {Fetcher} 134 | */ 135 | getFetcher() { 136 | if (!this._fetcher) { 137 | this._fetcher = this._buildFetcher(); 138 | } 139 | return this._fetcher; 140 | } 141 | 142 | /** 143 | * @param {String} httpMethod 144 | * @param {String} resourceId 145 | * @param {String} restapiId 146 | * @return {Promise} 147 | */ 148 | getMethod({ httpMethod, resourceId, restapiId }) { 149 | return this.getFetcher().get( 150 | `${this._getBaseUrl()}/restapis/${restapiId}/resources/${resourceId}/methods/${httpMethod}` 151 | ).then(source => new Method(source)); 152 | } 153 | 154 | /** 155 | * @param {String} restapiId 156 | * @return {Promise} 157 | */ 158 | getRestapi({ restapiId }) { 159 | return this.getFetcher().get( 160 | `${this._getBaseUrl()}/restapis/${restapiId}` 161 | ).then(source => new Restapi(source)); 162 | } 163 | 164 | /** 165 | * @param {String} restapiId 166 | * @return {Promise} 167 | */ 168 | getRootResource({ restapiId }) { 169 | return this.findResourceByPath({ path: '/', restapiId: restapiId }); 170 | } 171 | 172 | /** 173 | * @param {String} restapiId 174 | * @return {Promise} 175 | */ 176 | listDeployments({ restapiId }) { 177 | return this.getFetcher().get( 178 | `${this._getBaseUrl()}/restapis/${restapiId}/deployments` 179 | ).then(body => body._embedded.item.map(source => new Deployment(source))); 180 | } 181 | 182 | /** 183 | * @param {String} restapiId 184 | * @return {Promise} 185 | */ 186 | listResources({ restapiId }) { 187 | return this.getFetcher().get( 188 | `${this._getBaseUrl()}/restapis/${restapiId}/resources` 189 | ).then(body => body._embedded.item.map(source => new Resource(source))); 190 | } 191 | 192 | /** 193 | * @return {Promise} 194 | */ 195 | listRestapis() { 196 | return this.getFetcher().get( 197 | `${this._getBaseUrl()}/restapis` 198 | ).then(body => body._embedded.item.map(source => new Restapi(source))); 199 | } 200 | 201 | /** 202 | * @param {Array.=} cacheKeyParameters 203 | * @param {String=} cacheNamespace 204 | * @param {Boolean=} credentials 205 | * @param {String} httpMethod 206 | * @param {String=} integrationHttpMethod 207 | * @param {Object=} requestParameters 208 | * @param {Object=} requestTemplates 209 | * @param {String} resourceId 210 | * @param {String} restapiId 211 | * @param {String} type 212 | * @param {String=} uri 213 | * @return {Promise} 214 | */ 215 | putIntegration({ cacheKeyParameters, cacheNamespace, credentials, httpMethod, integrationHttpMethod, requestParameters, requestTemplates, resourceId, restapiId, type, uri }) { 216 | return this.getFetcher().put( 217 | `${this._getBaseUrl()}/restapis/${restapiId}/resources/${resourceId}/methods/${httpMethod}/integration`, 218 | { 219 | cacheKeyParameters: cacheKeyParameters, 220 | cacheNamespace: cacheNamespace, 221 | credentials: credentials, 222 | httpMethod: integrationHttpMethod, 223 | requestParameters: requestParameters, 224 | requestTemplates: requestTemplates, 225 | type: type, 226 | uri: uri, 227 | } 228 | ).then(body => new Integration(body)); 229 | } 230 | 231 | /** 232 | * @param {String} httpMethod 233 | * @param {String} resourceId 234 | * @param {Object=} responseParameters 235 | * @param {Object=} responseTemplates 236 | * @param {String} restapiId 237 | * @param {Object=} selectionPattern 238 | * @param {Integer} statusCode 239 | * @return {Promise} 240 | */ 241 | putIntegrationResponse({ httpMethod, resourceId, responseParameters, responseTemplates, restapiId, selectionPattern, statusCode }) { 242 | return this.getFetcher().put( 243 | `${this._getBaseUrl()}/restapis/${restapiId}/resources/${resourceId}/methods/${httpMethod}/integration/responses/${statusCode}`, 244 | { 245 | selectionPattern: selectionPattern, 246 | responseParameters: responseParameters, 247 | responseTemplates: responseTemplates 248 | } 249 | ).then(body => new IntegrationResponse(body)); 250 | } 251 | 252 | /** 253 | * @param {Boolean=} apiKeyRequired 254 | * @param {String=} authorizationType 255 | * @param {String} httpMethod 256 | * @param {Object=} requestModels 257 | * @param {Object=} requestParameters 258 | * @param {String} resourceId 259 | * @param {String} restapiId 260 | * @return {Promise} 261 | */ 262 | putMethod({ apiKeyRequired, authorizationType, httpMethod, requestModels, requestParameters, resourceId, restapiId }) { 263 | return this.getFetcher().put( 264 | `${this._getBaseUrl()}/restapis/${restapiId}/resources/${resourceId}/methods/${httpMethod}`, 265 | { 266 | apiKeyRequired: apiKeyRequired || false, 267 | authorizationType: authorizationType || 'NONE', 268 | requestModels: requestModels || {}, 269 | requestParameters: requestParameters || {} 270 | } 271 | ).then(body => new Method(body)); 272 | } 273 | 274 | /** 275 | * @param {String} httpMethod 276 | * @param {String} resourceId 277 | * @param {Object=} responseModels 278 | * @param {Object=} responseParameters 279 | * @param {String} restapiId 280 | * @param {Integer} statusCode 281 | * @return {Promise} 282 | */ 283 | putMethodResponse({ httpMethod, resourceId, responseModels, responseParameters, restapiId, statusCode }) { 284 | return this.getFetcher().put( 285 | `${this._getBaseUrl()}/restapis/${restapiId}/resources/${resourceId}/methods/${httpMethod}/responses/${statusCode}`, 286 | { 287 | responseModels: responseModels || {}, 288 | responseParameters: responseParameters || {} 289 | } 290 | ).then(body => new MethodResponse(body)); 291 | } 292 | 293 | /** 294 | * @param {Function} middleware 295 | * @param {Object=} options 296 | * @return {Client} 297 | */ 298 | use(middleware, options) { 299 | return new this.constructor({ 300 | accessKeyId: this.accessKeyId, 301 | fetcher: this.getFetcher().use(middleware, options), 302 | region: this.region, 303 | secretAccessKey: this.secretAccessKey 304 | }); 305 | } 306 | 307 | /** 308 | * @return {Fetcher} 309 | */ 310 | _buildFetcher() { 311 | return new Fetcher() 312 | .use(RejectLogger) 313 | .use(JsonRequestEncoder) 314 | .use( 315 | AwsSignerV4, 316 | { 317 | accessKeyId: this.accessKeyId, 318 | region: this.region, 319 | secretAccessKey: this.secretAccessKey 320 | } 321 | ) 322 | .use(JsonResponseDecoder); 323 | } 324 | 325 | /** 326 | * @param {Resource} parentResource 327 | * @param {Array.} pathParts 328 | * @param {String} restapiId 329 | * @return {Promise} 330 | */ 331 | _createChildResources({ parentResource, pathParts, restapiId }) { 332 | if (pathParts.length > 0) { 333 | return this.findResourceByPath({ 334 | path: path.join(parentResource.source.path, pathParts[0]), 335 | restapiId: restapiId 336 | }).then((resource) => { 337 | return resource || this.createResource({ 338 | parentId: parentResource.source.id, 339 | pathPart: pathParts[0], 340 | restapiId: restapiId 341 | }); 342 | }).then((resource) => { 343 | return this._createChildResources({ 344 | parentResource: resource, 345 | pathParts: pathParts.slice(1), 346 | restapiId: restapiId 347 | }); 348 | }); 349 | } else { 350 | return Promise.resolve(); 351 | } 352 | } 353 | 354 | /** 355 | * @param {Array.} paths 356 | * @param {String} restapiId 357 | * @param {Resource} rootResource 358 | * @return {Promise} 359 | */ 360 | _createResourcesByPaths({ paths, restapiId, rootResource }) { 361 | if (paths.length > 0) { 362 | return this._createChildResources({ 363 | parentResource: rootResource, 364 | pathParts: paths[0].split('/').slice(1), 365 | restapiId: restapiId 366 | }).then(() => { 367 | return this._createResourcesByPaths({ 368 | paths: paths.slice(1), 369 | restapiId: restapiId, 370 | rootResource: rootResource 371 | }); 372 | }); 373 | } else { 374 | return Promise.resolve(); 375 | } 376 | } 377 | 378 | /** 379 | * @return {String} 380 | */ 381 | _getBaseUrl() { 382 | return `https://apigateway.${this.region}.amazonaws.com`; 383 | } 384 | } 385 | -------------------------------------------------------------------------------- /src/deployment.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class Deployment { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import Client from './client' 2 | 3 | export default { Client: Client } 4 | -------------------------------------------------------------------------------- /src/integration-response.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class IntegrationResponse { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/integration.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class Integration { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/method-response.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class MethodResponse { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/method.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class Method { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/model.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class Model { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/resource.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class Resource { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/restapi.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | */ 4 | export default class Restapi { 5 | /** 6 | * @param {Object} source 7 | */ 8 | constructor(source) { 9 | this.source = source; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/client-test.js: -------------------------------------------------------------------------------- 1 | import { Client } from '../src/index.js' 2 | import { Mock } from 'stackable-fetcher' 3 | 4 | describe('Client', () => { 5 | const client = new Client({ 6 | accessKeyId: 'accessKeyId', 7 | region: 'region', 8 | secretAccessKey: 'secretAccessKey', 9 | }); 10 | 11 | describe('#createDeployment', () => { 12 | it('does not raise any error', (done) => { 13 | client.use( 14 | Mock, 15 | { 16 | body: JSON.stringify({}), 17 | headers: { 18 | 'Content-Type': 'application/json' 19 | } 20 | } 21 | ).createDeployment({ 22 | restapiId: 'restapiId', 23 | stageName: 'production' 24 | }).then((resource) => { 25 | done(); 26 | }); 27 | }); 28 | }); 29 | 30 | describe('#createResource', () => { 31 | it('does not raise any error', (done) => { 32 | client.use( 33 | Mock, 34 | { 35 | body: JSON.stringify({}), 36 | headers: { 37 | 'Content-Type': 'application/json' 38 | } 39 | } 40 | ).createResource({ 41 | parentId: 'parentId', 42 | pathPart: 'pathPart', 43 | restapiId: 'restapiId' 44 | }).then((resource) => { 45 | done(); 46 | }); 47 | }); 48 | }); 49 | 50 | describe('#createRestapi', () => { 51 | it('does not raise any error', (done) => { 52 | client.use( 53 | Mock, 54 | { 55 | body: JSON.stringify({}), 56 | headers: { 57 | 'Content-Type': 'application/json' 58 | } 59 | } 60 | ).createRestapi({ 61 | name: 'name' 62 | }).then((restapi) => { 63 | done(); 64 | }); 65 | }); 66 | }); 67 | 68 | describe('#deleteModel', () => { 69 | it('does not raise any error', (done) => { 70 | client.use( 71 | Mock, 72 | { 73 | body: JSON.stringify({}), 74 | headers: { 75 | 'Content-Type': 'application/json' 76 | } 77 | } 78 | ).deleteModel({ 79 | modelName: 'modelName', 80 | restapiId: 'restapiId' 81 | }).then(() => { 82 | done(); 83 | }); 84 | }); 85 | }); 86 | 87 | describe('#deleteRestapi', () => { 88 | it('does not raise any error', (done) => { 89 | client.use( 90 | Mock, 91 | { 92 | body: JSON.stringify({}), 93 | headers: { 94 | 'Content-Type': 'application/json' 95 | } 96 | } 97 | ).deleteRestapi({ 98 | restapiId: 'restapiId' 99 | }).then(() => { 100 | done(); 101 | }); 102 | }); 103 | }); 104 | 105 | describe('#getMethod', () => { 106 | it('does not raise any error', (done) => { 107 | client.use( 108 | Mock, 109 | { 110 | body: JSON.stringify({}), 111 | headers: { 112 | 'Content-Type': 'application/json' 113 | } 114 | } 115 | ).getMethod({ 116 | httpMethod: 'GET', 117 | resourceId: 'resourceId', 118 | restapiId: 'restapiId' 119 | }).then(() => { 120 | done(); 121 | }); 122 | }); 123 | }); 124 | 125 | describe('#getRestapi', () => { 126 | it('does not raise any error', (done) => { 127 | client.use( 128 | Mock, 129 | { 130 | body: JSON.stringify({}), 131 | headers: { 132 | 'Content-Type': 'application/json' 133 | } 134 | } 135 | ).getRestapi({ 136 | restapiId: 'restapiId' 137 | }).then(() => { 138 | done(); 139 | }); 140 | }); 141 | }); 142 | 143 | describe('#getRootResource', () => { 144 | it('does not raise any error', (done) => { 145 | client.use( 146 | Mock, 147 | { 148 | body: JSON.stringify({ item: [] }), 149 | headers: { 150 | 'Content-Type': 'application/json' 151 | } 152 | } 153 | ).getRootResource({ 154 | restapiId: 'restapiId' 155 | }).then(() => { 156 | done(); 157 | }); 158 | }); 159 | }); 160 | 161 | describe('#listResources', function() { 162 | it('does not raise any error', (done) => { 163 | client.use( 164 | Mock, 165 | { 166 | body: JSON.stringify({ item: [] }), 167 | headers: { 168 | 'Content-Type': 'application/json' 169 | } 170 | } 171 | ).listResources({ 172 | restapiId: 'restapiId' 173 | }).then((error) => { 174 | done(); 175 | }); 176 | }); 177 | }); 178 | 179 | describe('#listRestapis', () => { 180 | it('does not raise any error', (done) => { 181 | client.use( 182 | Mock, 183 | { 184 | body: JSON.stringify({ item: [] }), 185 | headers: { 186 | 'Content-Type': 'application/json' 187 | } 188 | } 189 | ).listRestapis().then((restapis) => { 190 | done(); 191 | }); 192 | }); 193 | }); 194 | 195 | describe('#putIntegration', () => { 196 | it('does not raise any error', (done) => { 197 | client.use( 198 | Mock, 199 | { 200 | body: JSON.stringify({}), 201 | headers: { 202 | 'Content-Type': 'application/json' 203 | } 204 | } 205 | ).putMethod({ 206 | httpMethod: 'GET', 207 | integrationHttpMethod: 'GET', 208 | resourceId: 'resourceId', 209 | restapiId: 'restapiId', 210 | type: 'HTTP', 211 | url: 'http://example.com' 212 | }).then((method) => { 213 | done(); 214 | }); 215 | }); 216 | }); 217 | 218 | describe('#putIntegrationResponse', () => { 219 | it('does not raise any error', (done) => { 220 | client.use( 221 | Mock, 222 | { 223 | body: JSON.stringify({}), 224 | headers: { 225 | 'Content-Type': 'application/json' 226 | } 227 | } 228 | ).putIntegrationResponse({ 229 | httpMethod: 'GET', 230 | resourceId: 'resourceId', 231 | restapiId: 'restapiId', 232 | statusCode: 200 233 | }).then((method) => { 234 | done(); 235 | }); 236 | }); 237 | }); 238 | 239 | describe('#putMethod', () => { 240 | it('does not raise any error', (done) => { 241 | client.use( 242 | Mock, 243 | { 244 | body: JSON.stringify({}), 245 | headers: { 246 | 'Content-Type': 'application/json' 247 | } 248 | } 249 | ).putMethod({ 250 | httpMethod: 'GET', 251 | resourceId: 'resourceId', 252 | restapiId: 'restapiId' 253 | }).then((method) => { 254 | done(); 255 | }); 256 | }); 257 | }); 258 | 259 | describe('#putMethodResponse', () => { 260 | it('does not raise any error', (done) => { 261 | client.use( 262 | Mock, 263 | { 264 | body: JSON.stringify({}), 265 | headers: { 266 | 'Content-Type': 'application/json' 267 | } 268 | } 269 | ).putMethod({ 270 | httpMethod: 'GET', 271 | resourceId: 'resourceId', 272 | restapiId: 'restapiId', 273 | statusCode: 200 274 | }).then((method) => { 275 | done(); 276 | }); 277 | }); 278 | }); 279 | }); 280 | --------------------------------------------------------------------------------