MENU
      stopJob

        stopJob


        기사 요약

        Classic/VPC 환경에서 이용 가능합니다.

        네이버 클라우드 플랫폼 콘솔에서 사용자가 등록한 진단을 진행 중에 중지합니다.

        요청

        요청 형식을 설명합니다. 요청 형식은 다음과 같습니다.

        메서드URI
        PATCH/{instanceId}/stop

        요청 헤더

        Web Security Checker에서 공통으로 사용하는 헤더에 대한 자세한 내용은 Web Security Checker 요청 헤더를 참조해 주십시오.

        요청 경로 파라미터

        파라미터에 대한 설명은 다음과 같습니다.

        필드타입필수 여부설명
        InstanceIdIntegerRequired진단 식별 번호

        요청 예시

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

        curl --location --request PATCH 'https://wsc.apigw.ntruss.com/api/v1/jobs/{instanceId}/stop'
        --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'
        Curl

        응답

        응답 형식을 설명합니다.

        응답 상태 코드

        Web Security Checker API에서 공통으로 사용하는 오류 코드에 대한 자세한 내용은 Web Security Checker 공통 오류 코드를 참조해 주십시오.

        응답 예시

        응답 예시는 다음과 같습니다.

        • 진단 중지 작업 완료
        {
            "returnCode": "0",
            "returnDesc": "Request Success",
            "returnMessage": "Success",
            "resources": null
        }
        JSON
        • 진단 중지 작업 오류: 잘못된 InstanceId를 입력한 경우
        {
            "error": {
                "errorCode": 901,
                "message": "API Call Fail"
            }
        }
        JSON

        샘플 코드

        진단 진행 중 작업을 중지하려면 진단 검색 API와 진단 중지 API가 필요합니다. 진단 검색 API를 통해서 진단 진행 상태의 진단 중 작업 중지할 진단의 instanceNo의 값을 추출하고 이 값을 이용하여 중지 API를 요청해야 합니다.
        진단 검색 및 instanceNo 확인 방법 및 해당 API의 샘플 코드에 대한 자세한 내용은 getJobs 또는 searchJobs을 참조해 주십시오.

        진단 검색 API(jobSearch)로 검색한 샘플 코드는 다음과 같습니다.

        • 검색 유형: url
        • 키워드: target-domain.com
        # 요청 예시
        $ python jobSearch.py "url target-domain.com"
        
        # 응답 예시
        {
            "returnCode": "0",
            "returnDesc": "Request Success",
            "returnMessage": "Success",
            "resources": {
                "total_cnt": 1,
                "total_page_cnt": 1,
                "current_start_page": 1,
                "current_end_page": 1,
                "record_data": [
                    {
                        "instanceNo": "1234567890",
                        "start_date": "2024-07-10 13:42:38",
                        "end_date": "",
                        "status": "URL 수집중",
                        "progress": null,
                        "start_url": "http://target-domain.com",
                        "crawl_cnt": "",
                        "scan_cnt": "",
                        "memo": "",
                        "result_button": "terminate",
                        "result_desc": "",
                        "rescan_button": "",
                        "slave_data": null
                    }
                ]
            }
        }
        Bash

        make_signature 함수로 시그니처를 생성하여 요청 헤드를 생성한 후 입력한 요청 파라미터에 따라 진단하기 전에 취소하여 응답 코드가 200인 경우 결과를 출력하는 샘플 코드는 다음과 같습니다.

        import sys
        import os
        import hashlib
        import hmac
        import base64
        import requests
        import time
        import json
        from pprint import pprint
        
        def make_signature(method, uri, timestamp):
        
            access_key = "{accessKey}"  # access key id (from portal or sub account)
            secret_key = "{secretKey}"  # secret key (from portal or sub account)
            secret_key = bytes(secret_key, 'UTF-8')
        
            method = method
            uri = uri
        
            message = method + " " + uri + "\n" + timestamp + "\n" + access_key
            message = bytes(message, 'UTF-8')
            signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
            return signingKey
        
        method = 'PATCH'
        instanceId = "{instanceId}" # instance id (from api)
        uri = f'/api/v1/jobs/{instanceId}/stop'
        timestamp = str(int(time.time() * 1000))
        
        signature = make_signature(method, uri, timestamp)
        
        headers = {
            'x-ncp-apigw-signature-v2': signature.decode('utf-8'),
            'x-ncp-apigw-timestamp': timestamp,
            'x-ncp-iam-access-key': '{accessKey}', # access key id (from portal or sub account)
            'Content-Type': 'application/json'
        }
        
        response = requests.request(
            method,
            f"https://wsc.apigw.ntruss.com{uri}",
            headers=headers
        )
        
        if response.status_code == 200:
            pprint(json.loads(response.text))
        else:
            pprint(json.loads(response.text))
        Python
        참고

        샘플 코드는 Python3를 기반으로 작성했습니다. Java, Node.js 등 다른 언어로 작성한 샘플 코드는 API Gateway 사용 가이드의 API 호출을 참조해 주십시오.


        이 문서가 도움이 되었습니까?

        Changing your password will log you out immediately. Use the new password to log back in.
        First name must have atleast 2 characters. Numbers and special characters are not allowed.
        Last name must have atleast 1 characters. Numbers and special characters are not allowed.
        Enter a valid email
        Enter a valid password
        Your profile has been successfully updated.