ncloud-sdk
์ค์น
Python
Forpip
์ค์น๋ 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()
๋ฅผ ์ฌ์ฉํ๋ฉด ์๋ ์์๋ก ์ธ์ฆํค๋ฅผ ์ฐพ์ต๋๋ค:
- Environment: NCLOUD_ACCESS_KEY_ID (๋๋ NCLOUD_ACCESS_KEY), NCLOUD_SECRET_KEY (๋๋ NCLOUD_SECRET_ACCESS_KEY) ํ๊ฒฝ๋ณ์ ์ ๋ณด๋ฅผ ์ฐพ์ต๋๋ค.
- Config File: configure ํ์ผ์์ ์ธ์ฆํค๋ฅผ ์ฐพ์ต๋๋ค. Mac/Linux ์ ๊ฒฝ์ฐ ~/.ncloud/configure ์, Windows ์ ๊ฒฝ์ฐ C:\Users\USERNAME\.ncloud\configure ์ ์ธ์ฆํค ์ ๋ณด๋ฅผ ์ ์ฅํฉ๋๋ค.
- 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.