Cloud/Naver Cloud Platform

[NCP] Cloud Insight Plugin_process GET Python 파일 공유

dalgong 2023. 6. 13. 20:57
반응형

안녕하세요.

오늘은 지난 번 POST 파일 공유에 이은 GET 파일을 공유하고자합니다.

Cloud Insight와 Plugin_ 관련 설명은 지난 포스트에 있으니 참고 부탁드립니다.

 

PLUGIN_PROCESS GET Python 파일 공유


import sys
import os
import hashlib
import hmac
import base64
import requests
import time


timestamp = int(time.time() * 1000)
timestamp = str(timestamp)

api_server = "https://cw.apigw.ntruss.com"
api_url = "/cw_server/real/api/plugin/process"

access_key = "API ACCESSKEY"	*""안에 ACCESSKEY만 넣으면 됨
secret_key = "API SECRETKEY"	*""안에 SECRETKEY만 넣으면 됨


def	make_signature():
    global access_key
    global secret_key
    global timestamp
    global api_server
    global api_url
    secret_key = bytes(secret_key, 'UTF-8')
    method = "GET"


    message = method + " " + api_url + "\n" + timestamp + "\n" + access_key
    message = bytes(message, 'UTF-8')
    signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
    return signingKey

http_header = {

"Content-Type": "application/json",
"x-ncp-apigw-timestamp": timestamp, 
"x-ncp-iam-access-key": access_key,
"x-ncp-apigw-signature-v2": make_signature(),
"x-ncp-dmn_cd" : "PUB",
"x-ncp-region_code" : "KR"
}

#Payload:
#{
#    "configList": [
#      "*httpd*" 
#    ],
#    "instanceNo": "12345678",
#    "type": "VPCServer"
#}

response = requests.get(api_server + api_url, headers=http_header)

print (response.text)

 

 

[NCP] Cloud Insight Plugin_process POST Python 파일 공유

NCP Cloud Insight Plugin_* 사용 방법 NCP Cloud Insight는 NCP의 모니터링 기능입니다. Cloud Insight의 대부분 기능은 서버 관리 및 설정에서 상세 모니터링 설정 변경을 신청하면 사용이 가능합니다. 하지만

itdalgong.tistory.com

 

반응형