Python
api
Bluemix
SoftLayer
BluemixInfrastructure

Bluemix Infrastructure API(Brandサービス)

Brand(SoftLayer_Brand)サービス(Brand系)

Brandデータ型(dict型)
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Brand

概要
The SoftLayer_Brand data type contains brand information relating to the single SoftLayer customer account.
SoftLayer customers are unable to change their brand information in the portal or the API.

Brandサービス
https://sldn.softlayer.com/reference/services/softlayer_brand

概要
Every SoftLayer customer account is associated to a brand
SoftLayer customers are unable to change their brand information in the portal or the API.

(1) SoftLayer_Brandの情報を取得(getObjectメゾッド)
http://sldn.softlayer.com/reference/services/softlayer_brand/getobject

概要

ヘッダー
Optional Headers: SoftLayer_ObjectMask
Required Headers: authenticate

戻り値
SoftLayer_Brand
http://sldn.softlayer.com/reference/datatypes/softlayer_brand

コード

import SoftLayer

from pprint import pprint

username = 'xxxxxxxx'
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

client = SoftLayer.Client(username=username, api_key=key)

for i in range(1, 10):
  try:
    pprint(client['Brand'].getObject(id=i))
  except SoftLayer.SoftLayerAPIError as e:
    print('Unable to find object with id of ''%d''.' % i)

実行結果(2017/11)

{'catalogId': 14,
 'id': 1,
 'keyName': 'SOFTLAYER_HOLDINGS',
 'longName': 'Softlayer Holdings',
 'name': 'SoftLayer Holdings'}
{'catalogId': 14,
 'id': 2,
 'keyName': 'SOFTLAYER_US',
 'longName': 'SoftLayer Technologies, Inc.',
 'name': 'SoftLayer USA'}
{'catalogId': 14,
 'id': 3,
 'keyName': 'SOFTLAYER_ASIA',
 'longName': 'SoftLayer Technologies, Asia Private Limited',
 'name': 'SoftLayer Asia'}
{'catalogId': 34,
 'id': 4,
 'keyName': 'ATT',
 'longName': 'AT&T',
 'name': 'AT&T'}
Unable to find object with id of 5.
Unable to find object with id of 6.
Unable to find object with id of 7.
Unable to find object with id of 8.
Unable to find object with id of 9.

コメント版

# 前提 sudo pip install softlayerなどでsoftlayerモジュールをインストール済み

# SoftLayer API Overview 
# https://sldn.softlayer.com/article/SoftLayer-API-Overview

# SoftLayer API Python Client Documentation 
# https://media.readthedocs.org/pdf/softlayer-python/v3.0.1/softlayer-python.pdf

import SoftLayer

# list型データを整列して表示するために使用
from pprint import pprint

# ポータルにて「アカウント > ユーザ > ユーザー・プロファイルの編集」でAPIアクセス情報を確認し入力
username = 'xxxxxxxx'
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# 認証情報を渡すことで他のメゾッドで要求されるauthenticate引数を省略可能
client = SoftLayer.Client(username=username, api_key=key)

for i in range(1, 10):
  try:
    pprint(client['Brand'].getObject(id=i))
  except SoftLayer.SoftLayerAPIError as e:
    print('Unable to find object with id of ''%d''.' % i)

(2) ブランドの製品カタログを取得(getCatalogメゾッド)
https://sldn.softlayer.com/reference/services/SoftLayer_Brand/getCatalog

概要
Retrieve the Product Catalog for the Brand

ヘッダー
Optional Headers: SoftLayer_ObjectMask
Required Headers: authenticate

戻り値
SoftLayer_Product_Catalog
https://sldn.softlayer.com/reference/datatypes/softlayer_product_catalog

コード

import SoftLayer

from pprint import pprint

username = 'xxxxxxxx'
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

client = SoftLayer.Client(username=username, api_key=key)

for i in range(1, 2):
  try:
    pprint(client['Brand'].getCatalog(id=i))
  except SoftLayer.SoftLayerAPIError as e:
    print('Unable to find object with id of ''%d''.' % i)

実行結果(2017/11/11)

{'brands': [{'catalogId': 14,
             'id': 21,
             'keyName': 'SOFTLAYER_EU',
             'longName': 'SoftLayer Dutch Holdings B.V.',
             'name': 'SoftLayer EU'},
            {'catalogId': 14,
             'id': 74805,
             'keyName': 'SOFTLAYER_EU_DC_RESTRICTED',
             'longName': 'SoftLayer EU DC Restricted',
             'name': 'SoftLayer EU DC Restricted'}]}

コメント版

前提 sudo pip install softlayerなどでsoftlayerモジュールをインストール済み

# SoftLayer API Overview 
# https://sldn.softlayer.com/article/SoftLayer-API-Overview

# SoftLayer API Python Client Documentation 
# https://media.readthedocs.org/pdf/softlayer-python/v3.0.1/softlayer-python.pdf

import SoftLayer

# list型データを整列して表示するために使用
from pprint import pprint

# ポータルにて「アカウント > ユーザ > ユーザー・プロファイルの編集」でAPIアクセス情報を確認し入力
# username = 'xxxxxxxx'
# key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# 認証情報を渡すことで他のメゾッドで要求されるauthenticate引数を省略可能
client = SoftLayer.Client(username=username, api_key=key)

for i in range(1, 2):
  try:
    pprint(client['Brand'].getCatalog(id=i))
  except SoftLayer.SoftLayerAPIError as e:
    print('Unable to find object with id of ''%d''.' % i)
  ##finally:
    ##print("loop %d" % i)

アカウント登録(1ヶ月間無料トライアル付き: 要クレジット登録)
https://ibm.biz/Bdji5q