メソッドの追加

Prev Next

Classic/VPC環境で利用できます。

作成した APIリソースにメソッドを設定して追加します。

リクエスト

リクエスト形式を説明します。リクエスト形式は次の通りです。

メソッド URI
POST /products/{product-id}/apis/{api-id}/resources/{resource-id}/methods

リクエストヘッダ

API Gatewayで共通して使用されるヘッダの詳細は、API Gatewayのリクエストヘッダをご参照ください。

リクエストパスパラメータ

パラメータの説明は次の通りです。

フィールド タイプ 必須の有無 説明
product-id String Required APIが属する Product ID
api-id String Required メソッド追加対象 APIの ID
resource-id String Required APIの対象リソースの ID

リクエスト構文

リクエスト構文は次の通りです。

{
  "methodName" : "ANY",
  "methodDescription" : "methodDescription",
  "mockEndPoint" : {
    "httpStatus" : 0,
    "response" : "response",
    "headers" : {
      "key" : "value"
    }
  },
  "ncpEndPoint" : {
    "service" : "service",
    "region" : "KR",
    "actionId" : "actionId",
    "actionName" : "actionName",
    "stream" : true,
    "method" : "ANY",
    "url" : "url"
  },
  "httpEndPoint" : {
    "method" : "ANY",
    "stream" : true,
    "url" : "url"
  },
  "requiredApiKey" : {
    "required" : true
  },
  "validation" : {
    "type" : "NONE",
    "headers" : [ "headers" ],
    "queryStrings" : [ "queryStrings" ]
  },
  "authentication" : {
    "platform" : "NONE",
    "authorizerId" : "authorizerId"
  }
}

リクエストボディ

リクエストボディの説明は次の通りです。

フィールド タイプ 必須の有無 説明
methodName String Required メソッドタイプ
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
methodDescription String Optional メソッドの説明
  • 0~2000文字
mockEndPoint String Conditional API Gatewayで設定した値を返すエンドポイントタイプ
  • mockEndPointncpEndPointhttpEndPointのいずれかを選択
mockEndPoint.httpStatus Integer Conditional レスポンスステータスコード
  • mockEndPointタイプ選択時、必ず入力
  • HTTPの Response Status Codeに対応する値
mockEndPoint.response String Optional レスポンスに表示するデータ
  • 0~1500文字
mockEndPoint.headers Map<String, String> Optional レスポンスに含めるヘッダ
  • ヘッダ Key, Valueの形式
ncpEndPoint String Conditional NAVERクラウドプラットフォームのサービスを使用して値を返すエンドポイントタイプ
  • mockEndPointncpEndPointhttpEndPointのいずれかを選択
ncpEndPoint.service String Conditional レスポンスの返しに使用する NAVERクラウドプラットフォームのサービス
  • Cloud Functionsサービスを利用可能
  • ncpEndPointタイプ選択時、必ず入力
ncpEndPoint.region String Conditional Cloud Functionsサービスのサポートリージョンコード
  • KR | JPN | SGN
  • ncpEndPointタイプ選択時、必ず入力
ncpEndPoint.actionId String Conditional Cloud Functionsサービスのアクション ID
  • ncpEndPointタイプ選択時、必ず入力
ncpEndPoint.actionName String Conditional Cloud Functionsサービスのアクション名
  • ncpEndPointタイプ選択時、必ず入力
ncpEndPoint.stream Boolean Conditional Stream機能を使用するかどうか
  • true | false
    • true: Stream機能を使用
    • false: Stream機能を使用しない
  • ncpEndPointタイプ選択時、必ず入力
ncpEndPoint.method String Optional Cloud Functionsサービスにリクエストするメソッドタイプ
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
ncpEndPoint.url String Conditional Cloud Functionsサービスの URLパス
  • ncpEndPointタイプ選択時、必ず入力
httpEndPoint String Conditional HTTP(S)エンドポイントの呼び出し結果を返すエンドポイントタイプ
  • mockEndPointncpEndPointhttpEndPointのいずれかを選択
httpEndPoint.method String Conditional バックエンドサーバにリクエストするメソッドタイプ
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
  • httpEndPointタイプの選択時、必ず入力
httpEndPoint.stream Boolean Conditional Stream機能を使用するかどうか
  • true | false
    • true: Stream機能を使用。ファイルアップロードのようなリクエストの場合、使用。レスポンス時間は5分、リクエストサイズは最大100MBに制限。
    • false: Stream機能を使用しない。レスポンス時間は30秒、リクエストサイズは最大10MBに制限。
  • httpEndPointタイプの選択時、必ず入力
httpEndPoint.url String Conditional バックエンドサーバにリクエストする URLパス
  • ドメインを除く
  • リソースパス変数とリクエストパラメータで定義したクエリ文字列とヘッダを使用できる。使用時は「{}」を使用して定義。
  • 1~1500文字
  • httpEndPointタイプの選択時、必ず入力
requiredApiKey String Required API keyの使用情報
requiredApiKey.required Boolean Required API keyを使用するかどうか
  • true | false
    • true: API keyを使用する
    • false: API keyを使用しない。Productサブスクリプション方法と Usage Planが適用されない。
validation String Required 有効性検査情報
validation.type String Required 有効性検査の範囲
  • NONE | QUERYSTRING_HEADERS
    • NONE: 有効性検査を実行しない
    • QUERYSTRING_HEADERS: クエリ文字列とヘッダの有効性検査を実行
validation.headers List<String> Conditional 有効性検査対象の必須ヘッダリスト
  • QUERYSTRING_HEADERS選択時に入力
validation.queryStrings List<String> Conditional 有効性検査対象の必須クエリ文字列リスト
  • QUERYSTRING_HEADERS選択時に入力
authentication String Required 認証情報
authentication.platform String Required 認証方法の設定
  • NONE | IAM | IAM_AUTHORIZATION | AUTHORIZER
    • NONE: 認証を使用しない
    • IAM: NAVERクラウドプラットフォームが提供する IAM認証を使用
    • IAM_AUTHORIZATION: NAVERクラウドプラットフォームが提供する IAM認証/許可を使用
    • AUTHORIZER: 事前に作成した Authorizerを使用
authentication.authorizerId String Conditional 認証方法として Authorizerを使用するときに使用する Authorizerの ID

リクエスト例

リクエストのサンプルコードは次の通りです。

curl --location --request POST 'https://apigateway.apigw.ntruss.com/api/v1/products/********o9/apis/cvcohvd2xj/resources/p1hiuvmwv3/methods' \
--header 'x-ncp-apigw-timestamp: {Timestamp}' \
--header 'x-ncp-iam-access-key: {Access Key}' \
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
--header 'Content-Type: application/json' \
--data '{
  "methodName": "GET",
  "httpEndPoint": {
    "stream": true,
    "method": "ANY",
    "url": "/sample22"
  },
  "validation": {
    "type": "NONE",
    "queryStrings": [
      "string"
    ],
    "headers": [
      "string"
    ]
  },
  "authentication": {
    "platform": "NONE"
  },
  "requiredApiKey": {
    "required": true
  },
  "methodDescription": "string"
}'

レスポンス

レスポンス形式を説明します。

レスポンス構文

レスポンス構文は次の通りです。

{
  "methods" : [ {
    "methodDescription" : "methodDescription",
    "resourceId" : "resourceId",
    "useBodyWhenFormData" : true,
    "modifier" : "modifier",
    "resourcePath" : "resourcePath",
    "methodName" : "ANY",
    "ncpEndPoint" : {
      "method" : "ANY",
      "stream" : true,
      "service" : "service",
      "actionId" : "actionId",
      "region" : "KR",
      "url" : "url",
      "actionName" : "actionName"
    },
    "requiredApiKey" : {
      "required" : true
    },
    "mockEndPoint" : {
      "headers" : {
        "key" : "headers"
      },
      "response" : "response",
      "httpStatus" : 0
    },
    "produces" : "produces",
    "tenantId" : "tenantId",
    "consumers" : "consumers",
    "apiId" : "apiId",
    "validation" : {
      "headers" : [ "headers" ],
      "queryStrings" : [ "queryStrings" ],
      "type" : "NONE"
    },
    "authentication" : {
      "authorizerId" : "authorizerId",
      "platform" : "NONE"
    },
    "httpEndPoint" : {
      "method" : "ANY",
      "stream" : true,
      "url" : "url"
    }
  } ]
}

レスポンスステータスコード

API Gatewayで共通して使用されるレスポンスステータスコードの詳細は、API Gatewayのレスポンスステータスコードをご参照ください。

レスポンス例

レスポンスのサンプルコードは次の通りです。

{
  "methods": [
    {
      "apiId": "cvcohvd2xj",
      "resourceId": "p1hiuvmwv3",
      "methodDescription": "string",
      "methodName": "GET",
      "useBodyWhenFormData": false,
      "validation": {
        "type": "NONE",
        "queryStrings": [
          "string"
        ],
        "headers": [
          "string"
        ]
      },
      "authentication": {
        "platform": "NONE"
      },
      "requiredApiKey": {
        "required": true
      },
      "httpEndPoint": {
        "stream": true,
        "method": "GET",
        "url": "/sample22"
      },
      "tenantId": "********65ec41039ce6668c2058b8a9",
      "modifier": "********-7fcd-11ec-a6ba-246e9659184c"
    }
  ]
}