메서드 추가

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~300자
mockEndPoint String Conditional API Gateway에서 설정한 값을 반환하는 엔드포인트 타입
  • mockEndPoint, ncpEndPoint, httpEndPoint 중 하나를 선택
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 네이버 클라우드 플랫폼의 서비스를 이용해 값을 반환하는 엔드포인트 타입
  • mockEndPoint, ncpEndPoint, httpEndPoint 중 하나를 선택
ncpEndPoint.service String Conditional 응답 반환에 사용할 네이버 클라우드 플랫폼의 서비스
  • Cloud Functions 서비스 이용 가능
  • ncpEndPoint 타입 선택 시 필수 입력
ncpEndPoint.region String Conditional Cloud Functions 서비스의 지원 리전 코드
  • KR
  • 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) 엔드포인트의 호출 결과를 반환하는 엔드포인트 타입
  • mockEndPoint, ncpEndPoint, httpEndPoint 중 하나를 선택
httpEndPoint.method String Conditional 백엔드 서버로 요청할 메서드 타입
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
  • httpEndPoint 타입 선택 시 필수 입력
httpEndPoint.stream Boolean Conditional Stream 기능 사용 여부
  • true | false
    • true: Stream 기능 사용. 파일 업로드 성격의 요청인 경우 사용. 응답 시간은 5분, 요청 크기는 최대 100 MB로 제한.
    • false: Stream 기능 사용 안 함. 응답 시간은 30초, 요청 크기는 최대 10 MB로 제한.
  • 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 | AUTHORIZER
    • NONE: 인증 미사용
    • IAM: 네이버 클라우드 플랫폼에서 제공하는 IAM 인증 사용
    • AUTHORIZER: 미리 생성한 Authorizer 사용
authentication.authorizerId String Conditional 인증 방법으로 Authorizer 이용 시 사용할 Authorizer의 ID

요청 예시

요청 예시는 다음과 같습니다.

curl --location --request POST 'https://apigateway.apigw.gov-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"
    }
  ]
}