ncloud-sdk


Keywords
ncloud-sdk, ncloud
License
MIT
Install
pip install ncloud-sdk==1.1.2

Documentation

ncloud-sdk

์„ค์น˜

For Python

pip

์„ค์น˜๋Š” pip๋ฅผ ์ด์šฉํ•ด์„œ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋กœ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

pip install ncloud-sdk --user

Requirements.

Python 2.7 and 3.4+

์‹œ์ž‘ํ•˜๊ธฐ

ncloud-sdk ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋จผ์ € ์ธ์ฆํ‚ค๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  • ์ธ์ฆํ‚ค๋Š” ํฌํ„ธ์˜ ๋งˆ์ดํŽ˜์ด์ง€ > ๊ณ„์ •๊ด€๋ฆฌ > ์ธ์ฆํ‚ค ๊ด€๋ฆฌ ๋ฉ”๋‰ด์—์„œ "์‹ ๊ทœ API ์ธ์ฆํ‚ค ์ƒ์„ฑ"์„ ํ†ตํ•ด์„œ Access Key ID, Secret Key๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
  • ์ด๋ฏธ ์ƒ์„ฑ๋œ ์ธ์ฆํ‚ค๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ ํฌํ„ธ์˜ ๋งˆ์ดํŽ˜์ด์ง€ > ๊ณ„์ •๊ด€๋ฆฌ > ์ธ์ฆํ‚ค ๊ด€๋ฆฌ ๋ฉ”๋‰ด์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • sub account์˜ ๊ฒฝ์šฐ, Console์˜ Sub Account > Sub Accounts > ์„œ๋ธŒ ๊ณ„์ • ์ƒ์„ธ ๋ฉ”๋‰ด์—์„œ "API Key"ํƒญ์—์„œ ์ƒ์„ฑํ•œ Access Key ID, Secret Key๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

์ƒ์„ฑ๋œ ์ธ์ฆํ‚ค ์ •๋ณด๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

  • Mac/Linux์˜ ๊ฒฝ์šฐ ~/.ncloud/configure์—, Windows์˜ ๊ฒฝ์šฐ C:\Users\USERNAME\.ncloud\configure์— ์ธ์ฆํ‚ค ์ •๋ณด๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.
  • configure ํŒŒ์ผ์€ NCLOUD CLI ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ƒ์„ฑํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
  • configure example
ncloud_access_key_id = C9zxQyBQVqcRNQmcAXKn
ncloud_secret_access_key = NDgSdssXg4RiMMN1f5dqIe775GJXzSe8hWpd2X3g

Example

server

import ncloud_server
from ncloud_server.api.v2_api import V2Api
from ncloud_server.rest import ApiException
import ncloud_apikey

configuration = ncloud_server.Configuration()

apikeys = ncloud_apikey.ncloud_key.NcloudKey().keys()
configuration.access_key = apikeys['access_key']
configuration.secret_key = apikeys['secret_key']

api = V2Api(ncloud_server.ApiClient(configuration))

get_login_key_list_request = ncloud_server.GetLoginKeyListRequest()
try:
    api_response = api.get_login_key_list(get_login_key_list_request)
    print(api_response)
except ApiException as e:
    print("Exception when calling V2Api->get_login_key_list: %s\n" % e)

cdn

import ncloud_cdn
from ncloud_cdn.api.v2_api import V2Api
from ncloud_cdn.rest import ApiException
import ncloud_apikey

configuration = ncloud_cdn.Configuration()

apikeys = ncloud_apikey.ncloud_key.NcloudKey().keys()
configuration.access_key = apikeys['access_key']
configuration.secret_key = apikeys['secret_key']

api = V2Api(ncloud_cdn.ApiClient(configuration))

get_cdn_plus_instance_list_request = ncloud_cdn.GetCdnPlusInstanceListRequest()
try:
    api_response = api.get_cdn_plus_instance_list(get_cdn_plus_instance_list_request)
    print(api_response)
except ApiException as e:
    print("Exception when calling V2Api->get_cdn_plus_instance_list: %s\n" % e)

Server Role

  • Server Role์€ ์„œ๋ธŒ๊ณ„์ •๊ณผ ์œ ์‚ฌํ•œ ์ˆ˜์ค€์˜ ๊ถŒํ•œ์„ Server์— ๋ถ€์—ฌํ•˜๋Š” ์„œ๋น„์Šค๋กœ VPC Server์— ์ ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. Role์ด ์„ค์ •๋œ Server ๋‚ด์—์„œ Ncloud SDK ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด metadata api๋ฅผ ํ†ตํ•ด ์ž„์‹œ ์ž๊ฒฉ ์ฆ๋ช…์„ ๋ฐ›์•„์™€์„œ API์ธ์ฆํ‚ค๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
  • Server Role์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ncloud-sdk-js ncloud.init ๋ฅผ ํ˜ธ์ถœํ•ด์„œ ์ธ์ฆํ‚ค๋ฅผ ๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. Server Role ์ธ์ฆํ‚ค ์ ์šฉ ๋ฐฉ๋ฒ•์€ Example ์„ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
  • Console์˜ Sub Account > Roles ๋ฉ”๋‰ด์—์„œ Server Role์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Server Example

# coding: utf-8
import ncloud_server
from ncloud_server.api.v2_api import V2Api
from ncloud_server.rest import ApiException
from ncloud_apikey.credentials import CredentialsResolver

configuration = ncloud_server.Configuration()

credentials = CredentialsResolver().load_credentials()
configuration.access_key = credentials.access_key
configuration.secret_key = credentials.secret_key

api = V2Api(ncloud_server.ApiClient(configuration))

get_login_key_list_request = ncloud_server.GetLoginKeyListRequest()
try:
    api_response = api.get_login_key_list(get_login_key_list_request)
    print(api_response)
except ApiException as e:
    print("Exception when calling V2Api->get_login_key_list: %s\n" % e)

CredentialsResolver().load_credentials()๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์•„๋ž˜ ์ˆœ์„œ๋กœ ์ธ์ฆํ‚ค๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค:

  1. Environment: NCLOUD_ACCESS_KEY_ID (๋˜๋Š” NCLOUD_ACCESS_KEY), NCLOUD_SECRET_KEY (๋˜๋Š” NCLOUD_SECRET_ACCESS_KEY) ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์ •๋ณด๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค.
  2. Config File: configure ํŒŒ์ผ์—์„œ ์ธ์ฆํ‚ค๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. Mac/Linux ์˜ ๊ฒฝ์šฐ ~/.ncloud/configure ์—, Windows ์˜ ๊ฒฝ์šฐ C:\Users\USERNAME\.ncloud\configure ์— ์ธ์ฆํ‚ค ์ •๋ณด๋ฅผ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.
  3. Server Role: Server Role์ด ์„ค์ •๋œ VPC Server์—์„œ metadata api ๋ฅผ ํ†ตํ•ด ์ž„์‹œ ์ธ์ฆํ‚ค๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. ์ž„์‹œ ์ธ์ฆํ‚ค๋Š” Role์— ๋ถ€์—ฌ๋œ ๊ถŒํ•œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Documentation for individual modules

Services Documentation Install Command
Server Server pip install ncloud-server
Loadbalancer Loadbalancer pip install ncloud-loadbalancer
Autoscaling Autoscaling pip install ncloud-autoscaling
Monitoring Monitoring pip install ncloud-monitoring
CDN CDN pip install ncloud-cdn
CloudDB CloudDB pip install ncloud-clouddb
Server(VPC) Server(VPC) pip install ncloud-vserver
VPC VPC pip install ncloud-vpc
Nas(VPC) Nas(VPC) pip install ncloud-vnas
Autoscaling(VPC) Autoscaling(VPC) pip install ncloud-vautoscaling
Loadbalancer(VPC) Loadbalancer(VPC) pip install ncloud-vloadbalancer

License

Copyright (c) 2021 NAVER Cloud Corp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.